Ignore:
Timestamp:
11/15/11 16:25:01 (13 years ago)
Author:
fpvanagthoven
Message:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • Dev/trunk/js/sequencerScripts.js

    r153 r154  
    3232
    3333function hasClass(ele,cls) {
    34     return ele.className.match(new RegExp('(\\s|^)'+cls+'(\\s|$)'));
     34    if (ele.className)
     35        return ele.className.match(new RegExp('(\\s|^)'+cls+'(\\s|$)'));
    3536}
    3637 
     
    5051
    5152function selectStep(uid) {
    52     document.getElementById(uid).addClass("selected");
    53     var selectedInfo = document.getElementById("selectedStepField");
    54     if (selectedInfo == null) {     // This is the first time a step is selected after a reload of the page, therefore a hidden input field is not yet present.
    55         selectedInfo = document.createElement("input")
    56         selectedInfo.setAttribute("type","hidden");
    57         selectedInfo.setAttribute("id","selectedStepField");
    58         selectedInfo.setAttribute("value",uid);
    59         var hiddenInputFields = document.getElementById("hiddenInputs");
    60         hiddenInputFields.appendChild(selectedInfo);
     53    var nodes = document.getElementById("seqContent").childNodes;
     54    for (var i = 0; i < nodes.length; i++) {     //loop through childNodes. Skip first node (whitespace)
     55        //debugger;
     56        if (hasClass(nodes[i], "displayStep")) {    //check if current childNode is a displayStep, not divider or text.
     57            if (nodes[i].id == uid) {
     58                addClass(nodes[i], "selected");
     59            }
     60            else {
     61                removeClass(nodes[i], "selected");
     62            }
     63        }
    6164    }
    62     else {      // There already exists a hidden input field with id selectedStepField, therefore we only change the value of this field.
    63         var hiddenInput = document.getElementById("selectedStepField");
    64         hiddenInput.value = uid;
    65     }
     65   
     66    // Update selected step field with uid of currently selected step.
     67    var selectedStepField = document.getElementById("selectedStepField");
     68    selectedStepField.value = uid;
     69   
    6670}
    6771                                                                           
     
    123127}
    124128
     129
    125130/*
    126131 * ajaxStepRequest gets  the markup for displaying a step in the sequencer from returnStep.php
     
    128133 */
    129134
    130 function ajaxStepRequest(UID) {
    131     var c = "uid="+UID;
     135function ajaxStepRequest(UIDS) {
     136    var c = "uids="+UIDS;
    132137    var u = "returnStep.php";
    133138    newAjaxRequest(c, u, function(result) {
    134         var newDiv = document.createElement("div");
    135         newDiv.innerHTML = result.responseText;
    136         document.getElementById("seqContent").appendChild(newDiv);
     139        document.getElementById("seqContent").innerHTML = result.responseText;
    137140    });
    138141}
     
    156159    var content = document.getElementById("seqContent");
    157160    var pipeline = document.getElementById("pipelineStringField").value;
    158     var copy = pipeline;
    159     pipeline = copy.split(",");
    160    
    161     // then do an xmlhttp request for each step to be added to the sequencer
    162     var numberOfSteps = pipeline.length;
    163     for (var i = 0; i < numberOfSteps; i++) {
    164         ajaxStepRequest(pipeline[i]);
    165         if (i < (numberOfSteps-1)) {
    166             ajaxStepRequest("divider");
    167         }
    168     }
    169    
    170                
     161    pipeline = pipeline.replace(/,/g , ",divider,");    //regex search for commas, global (repeat), to represent them with visual dividers.
     162    ajaxStepRequest(pipeline);
    171163}
    172164
     
    174166   
    175167}
    176 
    177 
Note: See TracChangeset for help on using the changeset viewer.