Changeset 168 for Dev/trunk


Ignore:
Timestamp:
11/29/11 17:26:07 (13 years ago)
Author:
fpvanagthoven
Message:
  • moveStep() [js] werkt weer, editor is nu op delete/clear na helemaal functioneel
  • Zit nog steeds een creator bug in savesession.php en selectSession.php
  • getInfo.php is nu aangepast om voor meerdere objecttypes te werken en relevante informatie terug te geven, geformatteerd als table. De styling hiervan moet wel nog beter geregeld worden.
Location:
Dev/trunk
Files:
10 edited

Legend:

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

    r167 r168  
    1717        echo '<div id="logo"><a href="index.php">Research Tool</a>';
    1818        if (isset($_SESSION['username'])) {
    19             echo '<a href="index.php" onClick="savePipeline(true);" style="font-size: 12pt;">Log out</a>';
     19            echo '<a href="index.php" onClick="savePipeline(true);" style="display:block; font-size: 12px;">Log out</a>';
    2020        }
    2121        echo '</div>';
  • Dev/trunk/classes/PipelineInfoPanel.php

    r167 r168  
    2121                    Title
    2222                </div>
    23                 <div id="infoContent">
    24                     Info goes here
     23                <div id="infoPanelContent">
     24                   
    2525                </div>
    2626            </fieldset>
  • Dev/trunk/classes/Toolbox.php

    r167 r168  
    1818        <form name="toolbox" action="pipelineEditor.php" method="POST">
    1919            <fieldset id="toolbox">
    20                 <div class="fieldsetTitle">Toolbox</div><br /><br />
     20                <div class="fieldsetTitle">Toolbox</div>
    2121                <p>Add new: </p>
    2222                <div class="creationButton" onClick="SubmitToolbox('Survey');"><img src="images/icons/survey.png" class="buttonIcon"/><p>Survey</p></div>
  • Dev/trunk/classes/pipelineSequencer.php

    r167 r168  
    5151                    <input type="button" id="moveSelectedL" value="< Move" class="surveyButton"  onClick="moveStep(-1);" />
    5252                    <input type="button" id="moveSelectedR" value="Move >" class="surveyButton"  onClick="moveStep(1);" />
    53                     <input type="button" id="editSelected" value="Edit step" class="surveyButton" />
     53                    <input type="button" id="editSelected" value="Edit step" class="surveyButton" onClick="editStep();" />
    5454                    <input type="submit" id="deleteSelected" name="deleteSelected" value="Delete step" class="surveyButton" />
    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?
    57                     <input type="button" id="t_saveSession" name="t_saveSession" onClick="savePipeline(true);" value="t_Save_session!" />
    58                     <input type="button" id="t_setOOD" name="t_setOOD" onClick="t_setOutOfDate();" value="t_Set_OOD" />
    59                     <input type="button" id="t_updateSeq" name="t_updateSeq" onClick="updateSequencer();" value="t_Update_Seq" />
     57                    <input type="button" value="debug_save" onClick="savePipeline(true);" />
    6058                </div>
    6159                <div id="hiddenInputs">
     
    7270    }
    7371
    74     public function DrawSteps() {
    75         // Use AJAX to draw visual representations of step objects in a pipeline
    76         // <TODO> Implement parameters such as screen size in the drawing of objects </TODO>
    77         ?>
    78         <script type="text/javascript">
    79             drawSteps();
    80         </script>
    81 
    82 
    83         <?php
    84     }
     72   
    8573
    8674    public function Javascript() {
     
    9078        <script type="text/javascript">
    9179            $(document).ready(function() {
    92                 updateSequencer();
     80                updateSequencer(true);      // true means it is the first refresh of the page.
    9381            });
    9482        </script>
  • Dev/trunk/css/awesome.css

    r167 r168  
    108108    font-weight: bold;
    109109    text-align: center;
    110     line-height: 2em;
     110    padding-top: 15px;
     111    /*line-height: 2em;*/
    111112    text-shadow: #555 0px 0px .2em;
    112113    height: 189px;
     
    653654    text-align: right;
    654655    margin-bottom: -0.5em;
    655     float: left;
     656    float: right;
    656657}
    657658
     
    799800    font-size: 1.25em;
    800801    color: #FFF;
    801     float: left;
    802     display: block;
    803 }
     802    /*float: left;*/
     803    display: block;
     804    clear: right;
     805}
     806
     807fieldset p {
     808    display: block;
     809}
  • Dev/trunk/getInfo.php

    r152 r168  
    33require 'classes/master.php'; //should be at top of every page
    44
    5 /*
    6  * Add extra POST variable in functions using this php return, describing object type.
    7  * This makes it easier to decide what properties to echo and also to query the database.
    8  * (Prevents repetitive session->query->question->application->user->respondent->etc queries!)
    9  */
    10 
    11 if (isset($_POST['uid'])) {
    12     if (!empty($_POST['uid'])) {
     5if (isset($_POST['uid']) && isset($_POST['type'])) {
     6    if (!empty($_POST['uid']) && !empty($_POST['type'])) {
    137        $uid = $_POST['uid'];
     8        $type = $_POST['type'];
    149    } else {
    15         //$errors[] = "No uid passed!";
     10//$errors[] = "No uid passed!";
     11        return;
    1612    }
    1713} else {
    18     //$errors[] = "Wrong call, no uid property in POST data!";
     14//$errors[] = "Wrong call, no uid property in POST data!";
     15    return;
    1916}
    2017
    2118$dbi = new DatabaseInterface();
    2219
    23 // For the moment only supports sessions as object to get information for!
    24 $results = $dbi->get("Session", array("uid" => $uid));
     20$results = $dbi->get($type, array("uid" => $uid));
    2521
    26 if (count($results) > 0) {
     22if (count($results) > 0) {      // check if DB object exists and assign it to variable
    2723    if ($results[0] != null) {
    28         $returnString = "";
     24        $returnString = "<table border='0'>";
     25        $result = $results[0];
     26    } else
     27        return;
     28} else
     29    return;
    2930
    30         $result = $results[0];
    31         $returnString = $returnString . "Title: $result->title. <br />";
    32         $length = count($result->pipeline);
    33         $returnString = $returnString .  "Number of steps: $length <br />";
    34         $returnString = $returnString . "UID: $uid";
    35     } else {
    36         $returnString = "Null error!";
    37     }
    38 } else {
    39     $returnString = "Non-existing uid!";
     31switch ($type) {
     32    case "Session":
     33        $returnString .= "<tr> <td>Name</td> <td>$result->title</td> </tr>";
     34        $returnString .= "<tr><td>Created</td><td>" . $result->datetime->format("H:i:s, d-m-Y") . " by " . $result->creator[0]->name . "</td></tr>";
     35        $cS = 0; $cD = 0; $cA = 0;
     36        foreach ($result->pipeline as $step) {
     37            switch (get_class($step)){
     38                case "Survey":
     39                    $cS++;
     40                    break;
     41                case "Application":
     42                    $cA++;
     43                    break;
     44                case "Dashboard":
     45                    $cD++;
     46                    break;
     47                default:
     48                    //derp?
     49                    break;
     50            }
     51        }
     52        $returnString .= "<tr><td>Number of steps</td><td><ul style='list-style-type: none;'><li style='margin-left: -40px;'>$cS Surveys<li style='margin-left: -40px;'>$cA Applications<li style='margin-left: -40px;'>$cD Dashboards</ul></td></tr>";
     53        break;
     54    case "Survey":
     55        $returnString .= "<tr> <td>Name</td><td>$result->title</td> </tr>";
     56        $returnString .= "<tr> <td>Creator</td> <td>LOLOL ME!!!</td> </tr>";
     57        $qCount = 0;
     58        foreach ($result->questions as $q) {
     59            $qCount++;
     60        }
     61        $returnString .= "<tr> <td>Questions</td> <td>$qCount</td> </tr>";
     62        $returnString .= "<tr> <td>Description</td> <td>$result->description</td> </tr>";
     63       
     64        break;
     65    case "Application":
     66        $returnString .= "<tr> <td>Name</td> <td>$result->title</td> </tr>";
     67        $returnString .= "<tr> <td>Location</td> <td>C:/folder_of_awesomeness/epicgame.exe</td> </tr>";
     68        $returnString .= "<tr> <td>Description</td> <td>$result->description</td> </tr>";
     69        break;
     70    case "Dashboard":
     71        break;
     72    case "Respondent":
     73        break;
     74    case "Question":
     75        break;
     76    case "Answer":
     77        break;
     78    default:
     79        break;
    4080}
    4181
     82$returnString .= "</table>";
    4283echo $returnString;
    4384?>
  • Dev/trunk/js/sequencerScripts.js

    r167 r168  
    33 * and open the template in the editor.
    44 */
     5var timeDiff  =  {
     6    setStartTime:function (){
     7        d = new Date();
     8        time  = d.getTime();
     9    },
     10
     11    getDiff:function (){
     12        d = new Date();
     13        return (d.getTime()-time);
     14    }
     15}
     16
     17
     18
     19
    520
    621function IsItemSelected(check, target) {
     
    3651    var pipelineType = document.getElementById("pipelineTypeField");
    3752    var pipelineUpdated = document.getElementById("pipelineUpdatedField");
     53    document.getElementById("numSteps").value++;
    3854   
    3955    newAjaxRequest(c, u, function(result){
     
    7086
    7187function selectStep(uid) {
     88    /*
     89   
    7290    var nodes = document.getElementById("seqContentWrapper").childNodes;
    7391    for (var i = 0; i < nodes.length; i++) {     //loop through childNodes. Skip first node (whitespace)
     
    86104        }
    87105    }
    88    
    89     // Update selected step field with uid of currently selected step.
     106    */
     107    // Hier is een snellere manier voor!
     108    var element = document.getElementById(uid);
     109    var prevElement = document.getElementById(document.getElementById("selectedStepField").value);
     110   
     111    if (!element || !hasClass(element, "displayStep")) {
     112        return;
     113    }
     114    // misschien nog checks inbouwen of het echt wel een element is?
    90115    var selectedStepField = document.getElementById("selectedStepField");
    91     selectedStepField.value = uid;
    92    
     116    if (!hasClass(element, "selected")) {
     117        if (prevElement) {
     118            removeClass(prevElement, "selected");
     119        }
     120        addClass(element, "selected");
     121        selectedStepField.value = uid;
     122       
     123        var pl = stringToArray(document.getElementById("pipelineStringField").value, ",");
     124        var plType = stringToArray(document.getElementById("pipelineTypeField").value, ",");
     125        var type = plType[pl.indexOf(uid)];
     126        ajaxInfoRequest(uid, document.getElementById("infoPanelContent"), type);
     127       
     128       
     129    }
     130    else {
     131        deselectStep(uid);
     132    }
     133   
     134   
     135// Update selected step field with uid of currently selected step.
     136   
     137   
     138}
     139
     140function deselectStep(uid) {
     141    var field = document.getElementById("selectedStepField");
     142    field.value = "";
     143    var element = document.getElementById(uid);
     144    removeClass(element, "selected");
     145    document.getElementById("infoPanelContent").innerHTML = "";
    93146}
    94147                                                                           
     
    148201}
    149202
    150 function ajaxInfoRequest(id, el) {
    151     var uid = id;
     203function ajaxInfoRequest(uid, el, type) {
    152204    var c = "uid="+uid;
     205    c += "&type="+type;
    153206    var u = "getInfo.php";
    154207    newAjaxRequest(c, u, function(result) {
     
    169222}
    170223
    171 function drawSteps() {
    172    
    173 }
    174 
    175 function updateSequencer() {
     224
     225function updateSequencer(firstLoad) {
     226    // Load hidden field values
    176227    var plString = document.getElementById("pipelineStringField").value;
    177228    var plTypeString = document.getElementById("pipelineTypeField").value;
    178229    var plUpdatedString = document.getElementById("pipelineUpdatedField").value;
    179    
    180    
    181     var pl = stringToArray(plString, ",");   
    182     var plType = stringToArray(plTypeString, ",");   
    183     var plUpdated = stringToArray(plUpdatedString, ",");
    184    
    185     var count = pl.length;
    186    
    187     document.getElementById("numSteps").value = count;
    188    
    189     for (var i = 0; i < pl.length; i++) {   // loop through pipeline contents
    190         if (plUpdated[i] == "0") {   // if the element is not up to date
    191             // first remove the step representation from the sequencer
     230    var count = document.getElementById("numSteps").value;
     231   
     232    if (count < 1) {
     233        return;
     234    }
     235    // If this is on page-load time
     236    if (firstLoad == true) {
     237        requestString = plString.slice(0, -1);
     238        requestString = requestString.replace(/,/g, ",divider,");
     239        newAjaxRequest("uids="+requestString, "returnStep.php", function(result) {
    192240            var seqContent = document.getElementById("seqContentWrapper");
    193             var element = document.getElementById(pl[i]);
    194             if (element == null) {
    195                 element = document.createElement("div");
    196                 element.name = "placeholder";
    197                 seqContent.appendChild(element);
     241            seqContent.innerHTML = result.responseText;
     242        }, true);
     243       
     244        plUpdatedString = "";
     245        for (var i = 0; i < plString.split(",").length-1; i++) {
     246            plUpdatedString += "1,";
     247        }
     248       
     249        document.getElementById("pipelineUpdatedField").value = plUpdatedString;
     250    }
     251    else {      // if not
     252        var pl = stringToArray(plString, ",");   
     253        var plType = stringToArray(plTypeString, ",");   
     254        var plUpdated = stringToArray(plUpdatedString, ",");
     255   
     256        var count = pl.length;
     257   
     258        document.getElementById("numSteps").value = count;
     259        var seqContent = document.getElementById("seqContentWrapper");
     260        if (seqContent.childNodes.length > (2*count)-1) {
     261            seqContent.removeChild(seqContent.childNodes[0]);
     262           
     263        }
     264       
     265       
     266        for (var i = 0; i < pl.length; i++) {   // loop through pipeline contents
     267            if (plUpdated[i] == "0") {   // if the element is not up to date
     268                // first remove the step representation from the sequencer
     269                //timeDiff.setStartTime();
     270               
     271           
     272                // IMPROVISE !!!!!!!!!!
     273                var elementByIndex = seqContent.childNodes[2*i];    // works with moved steps
     274                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.
     275                var element = elementByIndex;
     276           
     277           
     278                // END IMPROVISE !!!!!!!!!!!!
     279                if (element == null) {
     280                    element = document.createElement("div");
     281                    element.name = "placeholder";
     282                    seqContent.appendChild(element);
     283                }
     284                if (element.nextSibling) {
     285                    var nextElement = element.nextSibling;
     286                }
     287                else {
     288                    var nextElement = document.createElement("div");
     289                    nextElement.name = "placeholderNext";
     290                    seqContent.appendChild(nextElement);
     291                }
     292           
     293                // now request a new step representation and insert it after previousElement
     294                var holderDiv = document.createElement("div");
     295                var requestString = "uids="+pl[i];
     296           
     297                if (plType[i]) {
     298                    requestString += "&types="+plType[i];
     299                }
     300                // globally declare newDiv so it can be passed to the updateDividers function
     301                var newDiv;
     302           
     303                newAjaxRequest(requestString, "returnStep.php", function(result) {
     304                    holderDiv.innerHTML = result.responseText;
     305                    newDiv = holderDiv.childNodes[1];           
     306                    seqContent.replaceChild(newDiv, element);
     307                    if (nextElement.name == "placeholderNext") {
     308                        seqContent.removeChild(nextElement);
     309                    }
     310                    plUpdated[i] = "1";
     311                }, false);
     312           
     313                       
     314                // ALTERNATIVE METHOD TO REPLACECHILD!!!
     315                //seqContent.removeChild(element);
     316                //seqContent.insertBefore(newDiv, nextElement);
     317           
     318                // Now check if dividers are necessary.
     319           
     320                //alert("INSERT CODE FOR UPDATEDIVIDERS HERE!");
     321                //alert(timeDiff.getDiff());
     322                updateDividers(newDiv);
    198323            }
    199             if (element.nextSibling) {
    200                 var nextElement = element.nextSibling;
    201             }
    202             else {
    203                 var nextElement = document.createElement("div");
    204                 nextElement.name = "placeholderNext";
    205                 seqContent.appendChild(nextElement);
    206             }
    207            
    208             // now request a new step representation and insert it after previousElement
    209             var holderDiv = document.createElement("div");
    210             var requestString = "uids="+pl[i];
    211            
    212             if (plType[i]) {
    213                 requestString += "&types="+plType[i];
    214             }
    215             // globally declare newDiv so it can be passed to the updateDividers function
    216             var newDiv;
    217            
    218             newAjaxRequest(requestString, "returnStep.php", function(result) {
    219                 holderDiv.innerHTML = result.responseText;
    220                 newDiv = holderDiv.childNodes[1];           
    221                 seqContent.replaceChild(newDiv, element);
    222                 if (nextElement.name == "placeholderNext") {
    223                     seqContent.removeChild(nextElement);
    224                 }
    225                 plUpdated[i] = "1";
    226             }, false);
    227            
    228                        
    229             // ALTERNATIVE METHOD TO REPLACECHILD!!!
    230             //seqContent.removeChild(element);
    231             //seqContent.insertBefore(newDiv, nextElement);
    232            
    233             // Now check if dividers are necessary.
    234            
    235             //alert("INSERT CODE FOR UPDATEDIVIDERS HERE!");
    236             updateDividers(newDiv);
    237         }
    238     }
    239    
    240     // afterwards, convert the arrays back to strings and set to appropriate fields
    241     var newUpdatedString = arrayToString(plUpdated, ",");
    242     document.getElementById("pipelineUpdatedField").value = newUpdatedString;
    243    
     324        }
     325   
     326        // afterwards, convert the arrays back to strings and set to appropriate fields
     327        var newUpdatedString = arrayToString(plUpdated, ",");
     328        document.getElementById("pipelineUpdatedField").value = newUpdatedString;
     329    }
    244330}
    245331
     
    366452    // eerst saven, dan de object type zoeken in de typelist, dan redirecten naar de goede pagina
    367453    savePipeline(false);
    368     debugger;
     454   
    369455    var pipeline = document.getElementById("pipelineStringField").value;
    370456    var pipelineTypes = document.getElementById("pipelineTypeField").value;
     
    375461   
    376462    var postForm = document.createElement("form");
    377     postForm.action = stepType.toLowerCase()+"Editor.php";
     463    postForm.action = stepType.toLowerCase()+"Editor.php";      //redirect to "type"editor.php
    378464    postForm.method = "POST";
    379465    var objectUid = document.createElement("input");
     
    388474function moveStep (direction) {
    389475    // misschien maar eens een loadhiddenfields functie maken voor deze meuk?
    390     debugger;
     476   
    391477    var selectedStep = document.getElementById("selectedStepField").value;
    392478   
     
    402488   
    403489    var id = pipeline.indexOf(selectedStep);
    404     // Dit werkt niet, hij replaced dingen de verkeerde kant op. Lelijke versie met placeholder variables maar weer doen?
    405     pipeline[id] = pipeline.splice(pipeline[id+direction], 1, pipeline[id])[0];
    406     pipelineTypes[id] = pipelineTypes.splice(pipelineTypes[id+direction], 1, pipelineTypes[id])[0];
     490    if ((id == 0 && direction == -1) || (id == pipeline.length-1 && direction == 1)){
     491        alert("Cannot move out of bounds!");
     492        return;
     493    }
     494    var tempString = pipeline[id], tempType = pipelineTypes[id];
     495   
     496    pipeline[id] = pipeline[id+direction];
     497    pipelineTypes[id] = pipelineTypes[id+direction];
     498    pipeline[id+direction] = tempString;
     499    pipelineTypes[id+direction] = tempType;
    407500    updated[id] = "0";
    408501    updated[id+direction] = "0";
     
    417510    updateSequencer();
    418511   
    419    
    420    
    421 }
     512    // Then reselect the previously selected step
     513    addClass(document.getElementById(selectedStep), "selected");
     514}
  • Dev/trunk/returnStep.php

    r165 r168  
    4040    }
    4141} else {
    42     foreach ($uids as $uid) {
    43         $response .= processUid($uid);
     42    for ($i = 0; $i < count($uids); $i++) {
     43        $response .= processUid($uids[$i]);
    4444    }
    4545}
  • Dev/trunk/savesession.php

    r167 r168  
    3636
    3737        $dbi->set($session);
    38         echo "true";
     38        var_dump($session);
    3939    }
    4040}
  • Dev/trunk/selectSession.php

    r166 r168  
    7676                <fieldset name="selectionMenu">
    7777                    <!-- onchange van volgende select linkt deze aan de ajax-based info panel, script staat in sequencerScripts.js -->
    78                     <select name="sessionUID" style="float: left;" onChange="ajaxInfoRequest(this.value, document.getElementById('sessionDescription'));">
     78                    <select name="sessionUID" style="float: left;" onChange="ajaxInfoRequest(this.value, document.getElementById('infoPanelContent'), 'Session');">
    7979                        <option value="" disabled="true" selected>Please select a session</option>
    8080            <?php
     
    105105                </fieldset>
    106106                <fieldset id="sessionDescription">
    107                     Info goes here:
     107                    <div class="fieldsetTitle">
     108                        Info
     109                    </div>
     110                    <div id="infoPanelContent">
     111                    </div>
    108112                </fieldset>
    109113            </form>
Note: See TracChangeset for help on using the changeset viewer.