Changeset 169 for Dev/trunk/js
- Timestamp:
- 11/30/11 16:34:11 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Dev/trunk/js/sequencerScripts.js
r168 r169 138 138 } 139 139 140 function deleteStep() { 141 // delete an object from the session. 142 // note: does not actually remove the object from the database, only takes it out of the pipeline array. 143 144 var pl = stringToArray(document.getElementById("pipelineStringField").value, ","); 145 var plType = stringToArray(document.getElementById("pipelineTypeField").value, ","); 146 var plUpdated = stringToArray(document.getElementById("pipelineUpdatedField").value, ","); 147 var selectedStep = document.getElementById("selectedStepField").value; 148 149 // if no step has been selected, exit the function 150 if (selectedStep == undefined || selectedStep == "") { 151 return; 152 } 153 154 // find the array index of the specified object uid, then remove it from all three arrays. 155 var index = pl.indexOf(selectedStep); 156 if (index >= 0 && index < pl.length) { 157 pl.splice(index, 1); 158 plType.splice(index, 1); 159 plUpdated.splice(index, 1); 160 // set the updated status of all objects from *index* and forward to "0" (out of date) 161 // this way they will be refreshed the next time updateSequencer(); is called, adn the visual display will match the new pipeline. 162 for (var i = index-1; i < plUpdated.length; i++) { 163 if (i >= 0 ) { 164 plUpdated[i] = "0"; 165 } 166 } 167 } 168 169 document.getElementById("pipelineStringField").value = arrayToString(pl, ","); 170 document.getElementById("pipelineTypeField").value = arrayToString(plType, ","); 171 document.getElementById("pipelineUpdatedField").value = arrayToString(plUpdated, ","); 172 deselectStep(selectedStep); // Make sure the info panel is up to date as well. (Not showing anything, as it should be...) 173 document.getElementById("numSteps").value--; 174 175 updateSequencer(false); 176 177 178 179 } 180 140 181 function deselectStep(uid) { 141 182 var field = document.getElementById("selectedStepField"); … … 225 266 function updateSequencer(firstLoad) { 226 267 // Load hidden field values 268 227 269 var plString = document.getElementById("pipelineStringField").value; 228 270 var plTypeString = document.getElementById("pipelineTypeField").value; … … 231 273 232 274 if (count < 1) { 275 document.getElementById("seqContentWrapper").innerHTML = ""; 233 276 return; 234 277 } 235 278 // If this is on page-load time 236 279 if (firstLoad == true) { 280 var seqContent = document.getElementById("seqContentWrapper"); 281 seqContent.innerHTML = ""; 237 282 requestString = plString.slice(0, -1); 238 283 requestString = requestString.replace(/,/g, ",divider,"); 239 284 newAjaxRequest("uids="+requestString, "returnStep.php", function(result) { 240 var seqContent = document.getElementById("seqContentWrapper");241 285 seqContent.innerHTML = result.responseText; 242 286 }, true); … … 258 302 document.getElementById("numSteps").value = count; 259 303 var seqContent = document.getElementById("seqContentWrapper"); 260 if (seqContent.childNodes.length > (2*count)-1) { 304 // hier zit een fout. Als er een deleted step nog in de pipeline staat haalt hij de eerste valid step weg ipv een text node. 305 // twee mogelijkheden: 306 // 1: check of het text node is. 307 // 2: modulo check of het een even aantal steps is. Als alles klopt kan er onmogelijk een even aantal childNodes zijn. 308 if (seqContent.childNodes.length % 2 == 0 && seqContent.childNodes.length > 0) { 261 309 seqContent.removeChild(seqContent.childNodes[0]); 262 310 … … 320 368 //alert("INSERT CODE FOR UPDATEDIVIDERS HERE!"); 321 369 //alert(timeDiff.getDiff()); 370 371 // If seqContent contains any further entries when the last pipeline uid has been drawn, these are to be removed. 372 // This happens after the user performs a "delete step" operation and there is now one fewer step in the array than in seqContent. 373 // All steps other than the first and the last are auto-adjusted due to "out of date" flag. 374 if (i >= pl.length - 1) { 375 376 // This is a really complicated way of saying "Delete the next two elements if they exist" 377 while ((nextElement = newDiv.nextSibling) != undefined) { 378 seqContent.removeChild(nextElement); 379 } 380 381 } 382 // Do the same check for the first step in the pipeline. 383 // Is there no more elegant solution for this? For instance, check if a step should be in the pipeline in the first place, else delete it and it's following divider 384 385 322 386 updateDividers(newDiv); 323 387 }
Note: See TracChangeset
for help on using the changeset viewer.