Changeset 169 for Dev/trunk


Ignore:
Timestamp:
11/30/11 16:34:11 (13 years ago)
Author:
fpvanagthoven
Message:

Enkele bugfixes in sequencerScripts.js

  • updateSequencer werkt nu ook als er meer objecten in seqContent staan dan de bedoeling is (bijvoorbeeld na een deleteStep)
  • updateSequencer "remove text node" operatie aangepast om alleen te triggeren als er een even aantal childNodes in seqContent zitten. Bij goede werking kan dit nooit. Voorheen verwijderde hij ook goeie div's als die toevallig de eerste childNode waren.

->>>>>Toekomstige aanpassing: checken of seqContent.childNodes[0] ook daadwerkelijk een text node is. Internet deed het niet toen ik deze code schreef, dus kon hier de syntax niet voor opzoeken.
deleteStep toegevoegd.

Met andere woorden: alle functies van de sequencer werken nu!

Location:
Dev/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • Dev/trunk/classes/pipelineSequencer.php

    r168 r169  
    5252                    <input type="button" id="moveSelectedR" value="Move >" class="surveyButton"  onClick="moveStep(1);" />
    5353                    <input type="button" id="editSelected" value="Edit step" class="surveyButton" onClick="editStep();" />
    54                     <input type="submit" id="deleteSelected" name="deleteSelected" value="Delete step" class="surveyButton" />
     54                    <input type="button" id="deleteSelected" value="Delete step" class="surveyButton" onClick="deleteStep();" />
    5555                    <input type="submit" id ="clearPipeline" name="clearPipeline" value="Clear pipeline" class="surveyButton dis" disabled="true"/>
    5656                    <input type="checkbox" id="confirmClear" name="confirmClear" onChange="IsCheckEnabled(this, document.getElementById('clearPipeline'));" />Really clear?
  • Dev/trunk/js/sequencerScripts.js

    r168 r169  
    138138}
    139139
     140function 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
    140181function deselectStep(uid) {
    141182    var field = document.getElementById("selectedStepField");
     
    225266function updateSequencer(firstLoad) {
    226267    // Load hidden field values
     268   
    227269    var plString = document.getElementById("pipelineStringField").value;
    228270    var plTypeString = document.getElementById("pipelineTypeField").value;
     
    231273   
    232274    if (count < 1) {
     275        document.getElementById("seqContentWrapper").innerHTML = "";
    233276        return;
    234277    }
    235278    // If this is on page-load time
    236279    if (firstLoad == true) {
     280        var seqContent = document.getElementById("seqContentWrapper");
     281        seqContent.innerHTML = "";
    237282        requestString = plString.slice(0, -1);
    238283        requestString = requestString.replace(/,/g, ",divider,");
    239284        newAjaxRequest("uids="+requestString, "returnStep.php", function(result) {
    240             var seqContent = document.getElementById("seqContentWrapper");
    241285            seqContent.innerHTML = result.responseText;
    242286        }, true);
     
    258302        document.getElementById("numSteps").value = count;
    259303        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) {
    261309            seqContent.removeChild(seqContent.childNodes[0]);
    262310           
     
    320368                //alert("INSERT CODE FOR UPDATEDIVIDERS HERE!");
    321369                //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               
    322386                updateDividers(newDiv);
    323387            }
Note: See TracChangeset for help on using the changeset viewer.