[181] | 1 | //THIS IS THE BACKUP!!!!!!! |
---|
| 2 | |
---|
| 3 | /* |
---|
| 4 | * To change this template, choose Tools | Templates |
---|
| 5 | * and open the template in the editor. |
---|
| 6 | */ |
---|
| 7 | |
---|
| 8 | var sequencer = { // GLOBAL VAR TO STORE SEQUENCER SETTINGS! |
---|
| 9 | uid: "", // The unique id of this sequencer (not DB related!). This will help to avoid global var conflicts. Assign this randomly! |
---|
| 10 | session: { // Properties of the currently loaded session |
---|
| 11 | title: "", // Title or name |
---|
| 12 | uid: "", // Database UID of the current session |
---|
| 13 | pipeline: { // Pipeline |
---|
| 14 | uids: [], // Uids of objects in pipeline |
---|
| 15 | types: [], // Types of objects in pipeline |
---|
| 16 | upToDate: [] // Whether or not object displays are up to date |
---|
| 17 | } |
---|
| 18 | }, |
---|
| 19 | state: { // Operating state of the sequencer |
---|
| 20 | numSteps: 0, // Number of steps currently drawn in the editor (not necessarily same as number of steps in pipeline!) |
---|
| 21 | loaded: false // Whether or not the sequencer content has been updated for the first time |
---|
| 22 | }, |
---|
| 23 | settings: { // Various settings to determine the workings of the sequencer |
---|
| 24 | content: { |
---|
| 25 | width: null, |
---|
| 26 | height: null, |
---|
| 27 | orientation: "h" |
---|
| 28 | }, |
---|
| 29 | efficientUpdating: true |
---|
| 30 | } |
---|
| 31 | } |
---|
| 32 | |
---|
| 33 | |
---|
| 34 | function IsItemSelected(check, target) { |
---|
| 35 | if (check.value) { |
---|
| 36 | target.disabled = false; |
---|
| 37 | } |
---|
| 38 | else { |
---|
| 39 | target.disabled = true; |
---|
| 40 | } |
---|
| 41 | } |
---|
| 42 | |
---|
| 43 | function IsCheckEnabled(check, target) { |
---|
| 44 | if (check.checked) { |
---|
| 45 | target.disabled = false; |
---|
| 46 | this.removeClass(target, "dis"); |
---|
| 47 | |
---|
| 48 | } |
---|
| 49 | else { |
---|
| 50 | target.disabled = true; |
---|
| 51 | this.addClass(target, "dis"); |
---|
| 52 | } |
---|
| 53 | } |
---|
| 54 | |
---|
| 55 | function SubmitToolbox(type) { |
---|
| 56 | var c = "objectToCreate="+type; |
---|
| 57 | var u = "createObject.php"; |
---|
| 58 | var a = true; |
---|
| 59 | var pipeline = document.getElementById("pipelineStringField"); |
---|
| 60 | var pipelineType = document.getElementById("pipelineTypeField"); |
---|
| 61 | var pipelineUpdated = document.getElementById("pipelineUpdatedField"); |
---|
| 62 | document.getElementById("numSteps").value++; |
---|
| 63 | |
---|
| 64 | newAjaxRequest(c, u, function(result){ |
---|
| 65 | var resultUid = removeNL(result.responseText); |
---|
| 66 | //resultUid.replace("\n","").replace("\r",""); |
---|
| 67 | |
---|
| 68 | pipeline.value += resultUid+","; |
---|
| 69 | pipelineType.value += type+","; |
---|
| 70 | pipelineUpdated.value += "0,"; |
---|
| 71 | updateSequencer(); |
---|
| 72 | }, a); |
---|
| 73 | } |
---|
| 74 | |
---|
| 75 | function selectStep(uid) { |
---|
| 76 | /* |
---|
| 77 | |
---|
| 78 | var nodes = document.getElementById("seqContentWrapper").childNodes; |
---|
| 79 | for (var i = 0; i < nodes.length; i++) { //loop through childNodes. Skip first node (whitespace) |
---|
| 80 | if (hasClass(nodes[i], "displayStep")) { //check if current childNode is a displayStep, not divider or text. |
---|
| 81 | if (nodes[i].id == uid) { |
---|
| 82 | if (hasClass(nodes[i], "selected")) { |
---|
| 83 | removeClass(nodes[i], "selected"); |
---|
| 84 | } |
---|
| 85 | else { |
---|
| 86 | addClass(nodes[i], "selected"); |
---|
| 87 | } |
---|
| 88 | } |
---|
| 89 | else { |
---|
| 90 | removeClass(nodes[i], "selected"); |
---|
| 91 | } |
---|
| 92 | } |
---|
| 93 | } |
---|
| 94 | */ |
---|
| 95 | // Hier is een snellere manier voor! |
---|
| 96 | var element = document.getElementById(uid); |
---|
| 97 | var prevElement = document.getElementById(document.getElementById("selectedStepField").value); |
---|
| 98 | |
---|
| 99 | if (!element || !hasClass(element, "displayStep")) { |
---|
| 100 | return; |
---|
| 101 | } |
---|
| 102 | // misschien nog checks inbouwen of het echt wel een element is? |
---|
| 103 | var selectedStepField = document.getElementById("selectedStepField"); |
---|
| 104 | if (!hasClass(element, "selected")) { |
---|
| 105 | if (prevElement) { |
---|
| 106 | removeClass(prevElement, "selected"); |
---|
| 107 | } |
---|
| 108 | addClass(element, "selected"); |
---|
| 109 | selectedStepField.value = uid; |
---|
| 110 | |
---|
| 111 | var pl = stringToArray(document.getElementById("pipelineStringField").value, ","); |
---|
| 112 | var plType = stringToArray(document.getElementById("pipelineTypeField").value, ","); |
---|
| 113 | var type = plType[pl.indexOf(uid)]; |
---|
| 114 | ajaxInfoRequest(uid, document.getElementById("infoPanelContent"), type); |
---|
| 115 | |
---|
| 116 | |
---|
| 117 | } |
---|
| 118 | else { |
---|
| 119 | deselectStep(uid); |
---|
| 120 | } |
---|
| 121 | |
---|
| 122 | |
---|
| 123 | // Update selected step field with uid of currently selected step. |
---|
| 124 | |
---|
| 125 | |
---|
| 126 | } |
---|
| 127 | |
---|
| 128 | function deleteStep() { |
---|
| 129 | // delete an object from the session. |
---|
| 130 | // note: does not actually remove the object from the database, only takes it out of the pipeline array. |
---|
| 131 | |
---|
| 132 | var pl = stringToArray(document.getElementById("pipelineStringField").value, ","); |
---|
| 133 | var plType = stringToArray(document.getElementById("pipelineTypeField").value, ","); |
---|
| 134 | var plUpdated = stringToArray(document.getElementById("pipelineUpdatedField").value, ","); |
---|
| 135 | var selectedStep = document.getElementById("selectedStepField").value; |
---|
| 136 | |
---|
| 137 | // if no step has been selected, exit the function |
---|
| 138 | if (selectedStep == undefined || selectedStep == "") { |
---|
| 139 | return; |
---|
| 140 | } |
---|
| 141 | |
---|
| 142 | // find the array index of the specified object uid, then remove it from all three arrays. |
---|
| 143 | var index = pl.indexOf(selectedStep); |
---|
| 144 | if (index >= 0 && index < pl.length) { |
---|
| 145 | pl.splice(index, 1); |
---|
| 146 | plType.splice(index, 1); |
---|
| 147 | plUpdated.splice(index, 1); |
---|
| 148 | // set the updated status of all objects from *index* and forward to "0" (out of date) |
---|
| 149 | // this way they will be refreshed the next time updateSequencer(); is called, adn the visual display will match the new pipeline. |
---|
| 150 | for (var i = index-1; i < plUpdated.length; i++) { |
---|
| 151 | if (i >= 0 ) { |
---|
| 152 | plUpdated[i] = "0"; |
---|
| 153 | } |
---|
| 154 | } |
---|
| 155 | } |
---|
| 156 | |
---|
| 157 | document.getElementById("pipelineStringField").value = arrayToString(pl, ","); |
---|
| 158 | document.getElementById("pipelineTypeField").value = arrayToString(plType, ","); |
---|
| 159 | document.getElementById("pipelineUpdatedField").value = arrayToString(plUpdated, ","); |
---|
| 160 | deselectStep(selectedStep); // Make sure the info panel is up to date as well. (Not showing anything, as it should be...) |
---|
| 161 | document.getElementById("numSteps").value--; |
---|
| 162 | |
---|
| 163 | updateSequencer(false); |
---|
| 164 | |
---|
| 165 | |
---|
| 166 | |
---|
| 167 | } |
---|
| 168 | |
---|
| 169 | function deselectStep(uid) { |
---|
| 170 | var field = document.getElementById("selectedStepField"); |
---|
| 171 | field.value = ""; |
---|
| 172 | var element = document.getElementById(uid); |
---|
| 173 | removeClass(element, "selected"); |
---|
| 174 | document.getElementById("infoPanelContent").innerHTML = ""; |
---|
| 175 | } |
---|
| 176 | |
---|
| 177 | function ajaxStepRequest(UIDS, types) { |
---|
| 178 | var c = "uids="+UIDS; |
---|
| 179 | if (types != "") { |
---|
| 180 | c += "&types="+types; |
---|
| 181 | } |
---|
| 182 | var u = "returnStep.php"; |
---|
| 183 | newAjaxRequest(c, u, function(result) { |
---|
| 184 | document.getElementById("seqContentWrapper").innerHTML = result.responseText; |
---|
| 185 | }, true); |
---|
| 186 | } |
---|
| 187 | |
---|
| 188 | function ajaxInfoRequest(uid, el, type) { |
---|
| 189 | var c = "uid="+uid; |
---|
| 190 | c += "&type="+type; |
---|
| 191 | var u = "getInfo.php"; |
---|
| 192 | newAjaxRequest(c, u, function(result) { |
---|
| 193 | el.innerHTML = result.responseText; |
---|
| 194 | }, true); |
---|
| 195 | } |
---|
| 196 | |
---|
| 197 | function drawSteps2() { |
---|
| 198 | var content = document.getElementById("seqContentWrapper"); |
---|
| 199 | var pipeline = document.getElementById("pipelineStringField").value; |
---|
| 200 | var pipelineTypes = document.getElementById("pipelineTypeField").value; |
---|
| 201 | var numSteps = document.getElementById("numSteps").value; |
---|
| 202 | if (numSteps > 0) { |
---|
| 203 | pipeline = pipeline.replace(/,/g , ",divider,"); //regex search for commas, global (repeat), to represent them with visual dividers. |
---|
| 204 | pipelineTypes = pipelineTypes.replace(/,/g, ",divider,"); |
---|
| 205 | ajaxStepRequest(pipeline, pipelineTypes); |
---|
| 206 | } |
---|
| 207 | } |
---|
| 208 | |
---|
| 209 | function updateSequencer(firstLoad) { |
---|
| 210 | // Load hidden field values |
---|
| 211 | debugger; |
---|
| 212 | var plString = document.getElementById("pipelineStringField").value; |
---|
| 213 | var plTypeString = document.getElementById("pipelineTypeField").value; |
---|
| 214 | var plUpdatedString = document.getElementById("pipelineUpdatedField").value; |
---|
| 215 | var count = document.getElementById("numSteps").value; |
---|
| 216 | |
---|
| 217 | if (count < 1) { |
---|
| 218 | document.getElementById("seqContentWrapper").innerHTML = ""; |
---|
| 219 | return; |
---|
| 220 | } |
---|
| 221 | // If this is on page-load time |
---|
| 222 | if (firstLoad == true) { |
---|
| 223 | var seqContent = document.getElementById("seqContentWrapper"); |
---|
| 224 | seqContent.innerHTML = ""; |
---|
| 225 | requestString = plString.slice(0, -1); |
---|
| 226 | requestString = requestString.replace(/,/g, ",divider,"); |
---|
| 227 | newAjaxRequest("uids="+requestString, "returnStep.php", function(result) { |
---|
| 228 | seqContent.innerHTML = result.responseText; |
---|
| 229 | }, true); |
---|
| 230 | |
---|
| 231 | plUpdatedString = ""; |
---|
| 232 | for (var i = 0; i < plString.split(",").length-1; i++) { |
---|
| 233 | plUpdatedString += "1,"; |
---|
| 234 | } |
---|
| 235 | |
---|
| 236 | document.getElementById("pipelineUpdatedField").value = plUpdatedString; |
---|
| 237 | } |
---|
| 238 | else { // if not |
---|
| 239 | var pl = stringToArray(plString, ","); |
---|
| 240 | var plType = stringToArray(plTypeString, ","); |
---|
| 241 | var plUpdated = stringToArray(plUpdatedString, ","); |
---|
| 242 | |
---|
| 243 | var count = pl.length; |
---|
| 244 | |
---|
| 245 | document.getElementById("numSteps").value = count; |
---|
| 246 | var seqContent = document.getElementById("seqContentWrapper"); |
---|
| 247 | // 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. |
---|
| 248 | // twee mogelijkheden: |
---|
| 249 | // 1: check of het text node is. |
---|
| 250 | // 2: modulo check of het een even aantal steps is. Als alles klopt kan er onmogelijk een even aantal childNodes zijn. |
---|
| 251 | if (seqContent.childNodes.length % 2 == 0 && seqContent.childNodes.length > 0) { |
---|
| 252 | seqContent.removeChild(seqContent.childNodes[0]); |
---|
| 253 | |
---|
| 254 | } |
---|
| 255 | |
---|
| 256 | |
---|
| 257 | for (var i = 0; i < pl.length; i++) { // loop through pipeline contents |
---|
| 258 | if (plUpdated[i] == "0") { // if the element is not up to date |
---|
| 259 | // first remove the step representation from the sequencer |
---|
| 260 | //timeDiff.setStartTime(); |
---|
| 261 | |
---|
| 262 | |
---|
| 263 | // IMPROVISE !!!!!!!!!! |
---|
| 264 | var elementByIndex = seqContent.childNodes[2*i]; // works with moved steps |
---|
| 265 | var elementById = document.getElementById(pl[i]); // works with ???, not moved steps though... Keeping this in here for future bugfixing. This value is not currently used. |
---|
| 266 | var element = elementByIndex; |
---|
| 267 | |
---|
| 268 | |
---|
| 269 | // END IMPROVISE !!!!!!!!!!!! |
---|
| 270 | if (element == null) { |
---|
| 271 | element = document.createElement("div"); |
---|
| 272 | element.name = "placeholder"; |
---|
| 273 | seqContent.appendChild(element); |
---|
| 274 | } |
---|
| 275 | if (element.nextSibling) { |
---|
| 276 | var nextElement = element.nextSibling; |
---|
| 277 | } |
---|
| 278 | else { |
---|
| 279 | var nextElement = document.createElement("div"); |
---|
| 280 | nextElement.name = "placeholderNext"; |
---|
| 281 | seqContent.appendChild(nextElement); |
---|
| 282 | } |
---|
| 283 | |
---|
| 284 | // now request a new step representation and insert it after previousElement |
---|
| 285 | var holderDiv = document.createElement("div"); |
---|
| 286 | var requestString = "uids="+pl[i]; |
---|
| 287 | |
---|
| 288 | if (plType[i]) { |
---|
| 289 | requestString += "&types="+plType[i]; |
---|
| 290 | } |
---|
| 291 | // globally declare newDiv so it can be passed to the updateDividers function |
---|
| 292 | var newDiv; |
---|
| 293 | |
---|
| 294 | newAjaxRequest(requestString, "returnStep.php", function(result) { |
---|
| 295 | holderDiv.innerHTML = result.responseText; |
---|
| 296 | newDiv = holderDiv.childNodes[1]; |
---|
| 297 | seqContent.replaceChild(newDiv, element); |
---|
| 298 | if (nextElement.name == "placeholderNext") { |
---|
| 299 | seqContent.removeChild(nextElement); |
---|
| 300 | } |
---|
| 301 | plUpdated[i] = "1"; |
---|
| 302 | }, false); |
---|
| 303 | |
---|
| 304 | |
---|
| 305 | // ALTERNATIVE METHOD TO REPLACECHILD!!! |
---|
| 306 | //seqContent.removeChild(element); |
---|
| 307 | //seqContent.insertBefore(newDiv, nextElement); |
---|
| 308 | |
---|
| 309 | // Now check if dividers are necessary. |
---|
| 310 | |
---|
| 311 | //alert("INSERT CODE FOR UPDATEDIVIDERS HERE!"); |
---|
| 312 | //alert(timeDiff.getDiff()); |
---|
| 313 | |
---|
| 314 | // If seqContent contains any further entries when the last pipeline uid has been drawn, these are to be removed. |
---|
| 315 | // This happens after the user performs a "delete step" operation and there is now one fewer step in the array than in seqContent. |
---|
| 316 | // All steps other than the first and the last are auto-adjusted due to "out of date" flag. |
---|
| 317 | if (i >= pl.length - 1) { |
---|
| 318 | |
---|
| 319 | // This is a really complicated way of saying "Delete the next two elements if they exist" |
---|
| 320 | while ((nextElement = newDiv.nextSibling) != undefined) { |
---|
| 321 | seqContent.removeChild(nextElement); |
---|
| 322 | } |
---|
| 323 | |
---|
| 324 | } |
---|
| 325 | // Do the same check for the first step in the pipeline. |
---|
| 326 | // 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 |
---|
| 327 | |
---|
| 328 | |
---|
| 329 | updateDividers(newDiv); |
---|
| 330 | } |
---|
| 331 | } |
---|
| 332 | |
---|
| 333 | // afterwards, convert the arrays back to strings and set to appropriate fields |
---|
| 334 | var newUpdatedString = arrayToString(plUpdated, ","); |
---|
| 335 | document.getElementById("pipelineUpdatedField").value = newUpdatedString; |
---|
| 336 | } |
---|
| 337 | } |
---|
| 338 | |
---|
| 339 | function updateDividers (element) { |
---|
| 340 | var seqContent = document.getElementById("seqContentWrapper"); |
---|
| 341 | |
---|
| 342 | if (element.nextSibling){ |
---|
| 343 | var nextElement = element.nextSibling; |
---|
| 344 | } |
---|
| 345 | if (element.previousSibling) { |
---|
| 346 | var previousElement = element.previousSibling; |
---|
| 347 | } |
---|
| 348 | |
---|
| 349 | if (nextElement){ |
---|
| 350 | if (!hasClass(nextElement, "divider")) { |
---|
| 351 | /*var holderDiv = document.createElement("div"); |
---|
| 352 | newAjaxRequest("uids=divider&types=divider", "returnStep.php", function(result) { |
---|
| 353 | holderDiv.innerHTML = result.responseText; |
---|
| 354 | var newDivider = holderDiv.childNodes[1]; |
---|
| 355 | seqContent.insertBefore(newDivider, nextElement); |
---|
| 356 | }, false);*/ |
---|
| 357 | |
---|
| 358 | var newDivider = document.createElement("div"); |
---|
| 359 | newDivider.className = "divider"; |
---|
| 360 | // set the divider type, depending on orientation of editor |
---|
| 361 | // This currently does nothing, because editors haven't been generalized yet and there is no sequencer global var. |
---|
| 362 | // Shame on me for including this... |
---|
| 363 | if (sequencer.type) { |
---|
| 364 | if (sequencer.type.indexOf("v") != -1) { |
---|
| 365 | addClass(newDivider, "vertical"); |
---|
| 366 | } |
---|
| 367 | else if (sequencer.type.indexOf("h") != -1) { |
---|
| 368 | addClass(newDivider, "horizontal"); |
---|
| 369 | } |
---|
| 370 | else { |
---|
| 371 | // Do nothing |
---|
| 372 | } |
---|
| 373 | } |
---|
| 374 | seqContent.insertBefore(newDivider, nextElement); |
---|
| 375 | |
---|
| 376 | } |
---|
| 377 | } |
---|
| 378 | |
---|
| 379 | if (previousElement){ |
---|
| 380 | if (!hasClass(previousElement, "divider")) { |
---|
| 381 | var holderDiv = document.createElement("div"); |
---|
| 382 | newAjaxRequest("uids=divider&types=divider", "returnStep.php", function(result) { |
---|
| 383 | holderDiv.innerHTML = result.responseText; |
---|
| 384 | var newDivider = holderDiv.childNodes[1]; |
---|
| 385 | seqContent.insertBefore(newDivider, element); |
---|
| 386 | }, false); |
---|
| 387 | } |
---|
| 388 | } |
---|
| 389 | |
---|
| 390 | } |
---|
| 391 | |
---|
| 392 | function savePipeline (confirmSave) { |
---|
| 393 | if (confirmSave==true) { |
---|
| 394 | var answer = confirm("Save changes to pipeline?"); |
---|
| 395 | } |
---|
| 396 | else { |
---|
| 397 | var answer = true; |
---|
| 398 | } |
---|
| 399 | |
---|
| 400 | |
---|
| 401 | if (answer) { |
---|
| 402 | var pipeline = document.getElementById("pipelineStringField").value; |
---|
| 403 | pipeline = pipeline.slice(0, pipeline.length - 1); |
---|
| 404 | var types = document.getElementById("pipelineTypeField").value; |
---|
| 405 | types = types.slice(0, types.length - 1); |
---|
| 406 | var session = document.getElementById("sessionField").value; |
---|
| 407 | var requestString = "uids="+pipeline+"&types="+types+"&sessionUid="+session; |
---|
| 408 | console.log(requestString); |
---|
| 409 | |
---|
| 410 | |
---|
| 411 | var success; |
---|
| 412 | newAjaxRequest(requestString, "savesession.php", function(result){ |
---|
| 413 | success = result.responseText; |
---|
| 414 | }, true); |
---|
| 415 | console.log(success); |
---|
| 416 | } |
---|
| 417 | } |
---|
| 418 | |
---|
| 419 | function t_setOutOfDate() { |
---|
| 420 | // if a step is currently selected |
---|
| 421 | var uid = document.getElementById("selectedStepField").value; |
---|
| 422 | if (uid == "") { |
---|
| 423 | alert("No step selected!"); |
---|
| 424 | return; |
---|
| 425 | } |
---|
| 426 | |
---|
| 427 | // convert to arrays for looping |
---|
| 428 | var plString = document.getElementById("pipelineStringField").value; |
---|
| 429 | var plTypeString = document.getElementById("pipelineTypeField").value; |
---|
| 430 | var plUpdatedString = document.getElementById("pipelineUpdatedField").value; |
---|
| 431 | |
---|
| 432 | |
---|
| 433 | var pl = stringToArray(plString, ","); |
---|
| 434 | var plType = stringToArray(plTypeString, ","); |
---|
| 435 | var plUpdated = stringToArray(plUpdatedString, ","); |
---|
| 436 | |
---|
| 437 | // set the targeted element's tag for "Needs updating" |
---|
| 438 | plUpdated[pl.indexOf(uid)] = "0"; |
---|
| 439 | |
---|
| 440 | // then rewrite the content strings and set them to the appropriate fields |
---|
| 441 | var newUpdatedString = arrayToString(plUpdated, ","); |
---|
| 442 | document.getElementById("pipelineUpdatedField").value = newUpdatedString; |
---|
| 443 | } |
---|
| 444 | |
---|
| 445 | function editStep() { |
---|
| 446 | // eerst saven, dan de object type zoeken in de typelist, dan redirecten naar de goede pagina |
---|
| 447 | savePipeline(false); |
---|
| 448 | |
---|
| 449 | var pipeline = document.getElementById("pipelineStringField").value; |
---|
| 450 | var pipelineTypes = document.getElementById("pipelineTypeField").value; |
---|
| 451 | var selectedStep = document.getElementById("selectedStepField").value; |
---|
| 452 | pipeline = stringToArray(pipeline, ","); |
---|
| 453 | pipelineTypes = stringToArray(pipelineTypes, ","); |
---|
| 454 | var stepType = pipelineTypes[pipeline.indexOf(selectedStep)]; |
---|
| 455 | var postForm = document.createElement("form"); |
---|
| 456 | postForm.action = stepType.toLowerCase()+"Editor.php"; //redirect to "type"editor.php |
---|
| 457 | postForm.method = "POST"; |
---|
| 458 | var objectUid = document.createElement("input"); |
---|
| 459 | objectUid.type = "hidden"; |
---|
| 460 | objectUid.name = "objectUid"; |
---|
| 461 | objectUid.value = selectedStep; |
---|
| 462 | postForm.appendChild(objectUid); |
---|
| 463 | postForm.submit(); |
---|
| 464 | } |
---|
| 465 | |
---|
| 466 | function moveStep (direction) { |
---|
| 467 | // misschien maar eens een loadhiddenfields functie maken voor deze meuk? |
---|
| 468 | |
---|
| 469 | var selectedStep = document.getElementById("selectedStepField").value; |
---|
| 470 | |
---|
| 471 | if (selectedStep != undefined && selectedStep != "") { |
---|
| 472 | var pipeline = stringToArray(document.getElementById("pipelineStringField").value, ","); |
---|
| 473 | var pipelineTypes = stringToArray(document.getElementById("pipelineTypeField").value, ","); |
---|
| 474 | var updated = stringToArray(document.getElementById("pipelineUpdatedField").value, ","); |
---|
| 475 | } |
---|
| 476 | else { |
---|
| 477 | alert("No step selected! Unable to move"); |
---|
| 478 | return; |
---|
| 479 | } |
---|
| 480 | |
---|
| 481 | var id = pipeline.indexOf(selectedStep); |
---|
| 482 | if ((id == 0 && direction == -1) || (id == pipeline.length-1 && direction == 1)){ |
---|
| 483 | alert("Cannot move out of bounds!"); |
---|
| 484 | return; |
---|
| 485 | } |
---|
| 486 | var tempString = pipeline[id], tempType = pipelineTypes[id]; |
---|
| 487 | |
---|
| 488 | pipeline[id] = pipeline[id+direction]; |
---|
| 489 | pipelineTypes[id] = pipelineTypes[id+direction]; |
---|
| 490 | pipeline[id+direction] = tempString; |
---|
| 491 | pipelineTypes[id+direction] = tempType; |
---|
| 492 | updated[id] = "0"; |
---|
| 493 | updated[id+direction] = "0"; |
---|
| 494 | |
---|
| 495 | pipeline = arrayToString(pipeline, ","); |
---|
| 496 | pipelineTypes = arrayToString(pipelineTypes, ","); |
---|
| 497 | updated = arrayToString(updated, ","); |
---|
| 498 | |
---|
| 499 | document.getElementById("pipelineStringField").value = pipeline; |
---|
| 500 | document.getElementById("pipelineTypeField").value = pipelineTypes; |
---|
| 501 | document.getElementById("pipelineUpdatedField").value = updated; |
---|
| 502 | updateSequencer(); |
---|
| 503 | |
---|
| 504 | // Then reselect the previously selected step |
---|
| 505 | addClass(document.getElementById(selectedStep), "selected"); |
---|
| 506 | } |
---|
| 507 | |
---|
| 508 | |
---|
| 509 | |
---|
| 510 | |
---|
| 511 | |
---|
| 512 | |
---|
| 513 | |
---|
| 514 | |
---|
| 515 | |
---|
| 516 | |
---|
| 517 | |
---|
| 518 | |
---|
| 519 | |
---|
| 520 | |
---|
| 521 | |
---|
| 522 | |
---|
| 523 | |
---|
| 524 | |
---|
| 525 | |
---|
| 526 | |
---|
| 527 | |
---|
| 528 | |
---|
| 529 | |
---|
| 530 | |
---|
| 531 | |
---|
| 532 | |
---|
| 533 | |
---|
| 534 | |
---|
| 535 | |
---|
| 536 | |
---|
| 537 | |
---|
| 538 | |
---|
| 539 | |
---|
| 540 | |
---|
| 541 | |
---|
| 542 | |
---|
| 543 | |
---|
| 544 | |
---|
| 545 | |
---|
| 546 | |
---|
| 547 | |
---|
| 548 | |
---|
| 549 | |
---|
| 550 | |
---|
| 551 | |
---|
| 552 | |
---|
| 553 | |
---|
| 554 | |
---|
| 555 | |
---|
| 556 | |
---|
| 557 | |
---|
| 558 | |
---|
| 559 | |
---|
| 560 | |
---|
| 561 | |
---|