Changeset 164 for Dev/trunk/js/sequencerScripts.js
- Timestamp:
- 11/22/11 16:42:37 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Dev/trunk/js/sequencerScripts.js
r154 r164 56 56 if (hasClass(nodes[i], "displayStep")) { //check if current childNode is a displayStep, not divider or text. 57 57 if (nodes[i].id == uid) { 58 addClass(nodes[i], "selected"); 58 if (hasClass(nodes[i], "selected")) { 59 removeClass(nodes[i], "selected"); 60 } 61 else { 62 addClass(nodes[i], "selected"); 63 } 59 64 } 60 65 else { … … 88 93 */ 89 94 90 function newAjaxRequest(c, u, cb ) {95 function newAjaxRequest(c, u, cb, async) { 91 96 92 97 var xml; … … 101 106 // subscribe the callback function to a response event 102 107 xml.onreadystatechange = function() { 108 xml.responseText = "Processing..."; 103 109 if (xml.readyState == 4 && xml.status == 200) { 104 //alert("Received!");105 110 cb(xml); 106 111 } 107 112 }; 108 113 // initialize XMLRequest 109 xml.open("POST", u, true);114 xml.open("POST", u, async); 110 115 xml.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); 111 116 var contentString = ""; … … 138 143 newAjaxRequest(c, u, function(result) { 139 144 document.getElementById("seqContent").innerHTML = result.responseText; 140 } );145 }, true); 141 146 } 142 147 … … 147 152 newAjaxRequest(c, u, function(result) { 148 153 el.innerHTML = result.responseText; 149 }); 150 } 151 152 153 154 155 156 154 }, true); 155 } 157 156 158 157 function drawSteps() { … … 163 162 } 164 163 165 function updatePipelineHidden (pipelineString) { 166 167 } 164 function updateSequencer() { 165 var plString = document.getElementById("pipelineStringField").value; 166 var plTypeString = document.getElementById("pipelineTypeField").value; 167 var plUpdatedString = document.getElementById("pipelineUpdatedField").value; 168 169 var pl = plString.split(","); 170 var plType = plTypeString.split(","); 171 var plUpdated = plUpdatedString.split(","); 172 //console.log(plUpdated); 173 174 175 for (var i = 0; i < pl.length; i++) { // loop through pipeline contents 176 if (plUpdated[i] == "0") { // if the element is not up to date 177 // first remove the step representation from the sequencer 178 var seqContent = document.getElementById("seqContent"); 179 var element = document.getElementById(pl[i]); 180 var nextElement = element.nextSibling; 181 182 // now request a new step representation and insert it after previousElement 183 var holderDiv = document.createElement("div"); 184 var requestString = "uids="+pl[i]; 185 var resultText; 186 newAjaxRequest(requestString, "returnStep.php", function(result) { 187 holderDiv.innerHTML = result.responseText; 188 }, false); 189 190 //debugger; 191 while (holderDiv.childNodes.length == 1) { 192 // wait for response 193 } 194 var newDiv = holderDiv.childNodes[1]; 195 seqContent.replaceChild(newDiv, element); 196 plUpdated[i] = "1"; 197 // ALTERNATIVE METHOD TO REPLACECHILD!!! 198 //seqContent.removeChild(element); 199 //seqContent.insertBefore(newDiv, nextElement); 200 201 202 } 203 else { 204 205 } 206 } 207 208 // afterwards, convert the arrays back to strings 209 var newUpdatedString = ""; 210 211 for (var i = 0; i < plUpdated.length; i++) { 212 newUpdatedString += plUpdated[i]+","; 213 } 214 215 if (newUpdatedString.substring(newUpdatedString.length - 1) == ",") { // remove comma at the end of string! 216 newUpdatedString = newUpdatedString.substring(0, newUpdatedString.length-1); 217 218 } 219 document.getElementById("pipelineUpdatedField").value = newUpdatedString; 220 221 } 222 223 function savePipeline() { 224 var answer = confirm("Save changes to pipeline?"); 225 if (answer) { 226 newAjaxRequest("", "savesession.php", function(){}, false); 227 alert("Saved!"); 228 } 229 } 230 231 function t_setOutOfDate() { 232 // if a step is currently selected 233 var uid = document.getElementById("selectedStepField").value; 234 if (uid == "") { 235 alert("No step selected!"); 236 return; 237 } 238 239 // convert to arrays for looping 240 var plString = document.getElementById("pipelineStringField").value; 241 var plTypeString = document.getElementById("pipelineTypeField").value; 242 var plUpdatedString = document.getElementById("pipelineUpdatedField").value; 243 244 var pl = plString.split(","); 245 var plType = plTypeString.split(","); 246 var plUpdated = plUpdatedString.split(","); 247 248 249 250 // set the targeted element's tag for "Needs updating" 251 for (var i = 0; i < pl.length; i++) { 252 if (pl[i] == uid) { 253 plUpdated[i] = 0; 254 } 255 } 256 257 // then rewrite the content strings and set them to the appropriate fields 258 259 var newUpdatedString = ""; 260 for (var i = 0; i < pl.length; i++) { 261 newUpdatedString += plUpdated[i]+","; 262 } 263 alert(newUpdatedString+": OLD"); 264 if (newUpdatedString.substring(newUpdatedString.length-1) == ",") { 265 newUpdatedString = newUpdatedString.substring(0, newUpdatedString.length-1); 266 } 267 alert(newUpdatedString+": NEW!"); 268 269 document.getElementById("pipelineUpdatedField").value = newUpdatedString; 270 //alert("OOD set"); 271 }
Note: See TracChangeset
for help on using the changeset viewer.