Changeset 154 for Dev/trunk/js/sequencerScripts.js
- Timestamp:
- 11/15/11 16:25:01 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Dev/trunk/js/sequencerScripts.js
r153 r154 32 32 33 33 function 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|$)')); 35 36 } 36 37 … … 50 51 51 52 function 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 } 61 64 } 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 66 70 } 67 71 … … 123 127 } 124 128 129 125 130 /* 126 131 * ajaxStepRequest gets the markup for displaying a step in the sequencer from returnStep.php … … 128 133 */ 129 134 130 function ajaxStepRequest(UID ) {131 var c = "uid ="+UID;135 function ajaxStepRequest(UIDS) { 136 var c = "uids="+UIDS; 132 137 var u = "returnStep.php"; 133 138 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; 137 140 }); 138 141 } … … 156 159 var content = document.getElementById("seqContent"); 157 160 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); 171 163 } 172 164 … … 174 166 175 167 } 176 177
Note: See TracChangeset
for help on using the changeset viewer.