Changeset 70


Ignore:
Timestamp:
08/03/11 20:07:20 (14 years ago)
Author:
fpvanagthoven
Message:

Bugfix pipeline (js)

File:
1 edited

Legend:

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

    r69 r70  
    1717
    1818        $this->javascript();
     19        var_dump($_POST);
    1920        var_dump($session);
    20         var_dump($_POST);
     21       
    2122        ?>
    2223
     
    4647        <script type="text/javascript">
    4748            var pipelineCount = 0;
    48                                                                                                                                                                                                                                                                              
     49                                                                                                                                                                                                                                                                                                                                    
    4950            // =============================================================
    50                                                                                                                                                                                                                                                                                                    
    51             function addSurvey(surveyID) {
    52                 pipelineCount++;
    53                                                                                                                                                                        
    54                 var pipeline = document.getElementById("pipeline");
     51                                                                                                                                                                                                                                                                                                                                                           
     52            function addSurvey(surveyID) {       
    5553                var surveysList = document.getElementById("surveysList");
    56                                                                                                                                                                                                
    57                 var entry = document.createElement("option");
    58                                                                                                                                        
    59                 if (surveyID != null)
     54                           
     55                if(surveysList.selectedIndex != -1 || surveyID != null)
    6056                {
    61                     entry.setAttribute("value", surveyID);
    62                     entry.innerHTML = pipelineCount + ". " + surveysList.options.namedItem(surveyID).innerHTML;
    63                 }
    64                 else
    65                 {
    66                     entry.setAttribute("value", surveysList.options[surveysList.selectedIndex].value);
    67                                                                                                                                    
    68                     entry.innerHTML = pipelineCount + ". " + surveysList.options[surveysList.selectedIndex].innerHTML;
    69                                                                                                                                    
    70                 }
    71                 entry.style.backgroundColor = "#0090ac";
    72                 entry.name = pipelineCount + "s";
    73                 entry.entryType = "s";
    74                                                                                                                                                                                        
    75                 pipeline.appendChild(entry);
    76             }
    77                                                                                                                                                                            
     57                    var pipeline = document.getElementById("pipeline");
     58                    var entry = document.createElement("option");
     59                           
     60                    if (surveyID != null)
     61                    {
     62                        pipelineCount++;
     63                        entry.setAttribute("value", surveyID);
     64                        entry.innerHTML = pipelineCount + ". " + surveysList.options.namedItem(surveyID).innerHTML;
     65                    }
     66                    else if(surveysList.selectedIndex != -1)
     67                    {
     68                        pipelineCount++;
     69                        entry.setAttribute("value", surveysList.options[surveysList.selectedIndex].value);
     70                                                                                                                                                                                           
     71                        entry.innerHTML = pipelineCount + ". " + surveysList.options[surveysList.selectedIndex].innerHTML;
     72                                                                                                                                                                                           
     73                    }
     74                    entry.style.backgroundColor = "#0090ac";
     75                    entry.name = pipelineCount + "s";
     76                    entry.entryType = "s";
     77                                                                                                                                                                                                                                               
     78                    pipeline.appendChild(entry);
     79                }                         
     80            }
     81                                                                                                                                                                                                                                   
    7882            function addDashboard() {
    7983                pipelineCount++;
    8084                var pipeline = document.getElementById("pipeline");
    81                                                                                                                                                                                
     85                                                                                                                                                                                                                                       
    8286                var entry = document.createElement("option");
    8387                entry.setAttribute("value", "dashboard");
     
    8791                entry.name = pipelineCount + "d";
    8892                entry.entryType = "d";
    89                                                                                                                                                                                
     93                                                                                                                                                                                                                                       
    9094                pipeline.appendChild(entry);
    9195            }
    92                            
     96                                                                                   
    9397            function removeFromPipeline() {
    9498                var pipeline = document.getElementById("pipeline");
    95                 if (pipeline.selectedIndex != null)
     99                if (pipeline.selectedIndex != -1)
    96100                {
    97101                    var index = pipeline.selectedIndex;
    98102                    pipeline.remove(index);
    99                    
     103                    if (pipelineCount > 1)
     104                    {
     105                        pipeline.options[index].selected = true;
     106                    }
     107                                                                           
    100108                    for(var i = index; i < pipeline.length; i++)
    101                         {
    102                             var entry = pipeline.options[i];
    103                             entry.name = "" + (i+1) + entry.entryType;
    104                             var htmlStr = entry.innerHTML;
    105                             var dotIndex = htmlStr.indexOf('.');
    106                             entry.innerHTML = (i+1) + htmlStr.substr(dotIndex);
    107                         }
     109                    {
     110                        var entry = pipeline.options[i];
     111                        entry.name = "" + (i+1) + entry.entryType;
     112                        var htmlStr = entry.innerHTML;
     113                        var dotIndex = htmlStr.indexOf('.');
     114                        entry.innerHTML = (i+1) + htmlStr.substr(dotIndex);
     115                    }
    108116                    pipelineCount--;
    109117                }
    110118            }
    111                                                                                                                                                                                              
     119                                                                                                                                                                                                                                                    
    112120            function submitPipeline()
    113121            {
    114122                var form = document.getElementById("sessionCreationForm");
    115                                                                                                                                                                
     123                                                                                                                                                                                                                       
    116124                var pipeline = document.getElementById("pipeline").options;
    117                                                                                                                                                                        
    118                                                                                                                                                                        
     125                                                                                                                                                                                                                              
     126                                                                                                                                                                                                                               
    119127                for (var i = 0; i < pipeline.length; i++)
    120128                {
     
    123131                    pipelineElem.value = pipeline[i].value;
    124132                    pipelineElem.type = "hidden";
    125                                                                                                                                                                    
     133                                                                                                                                                                                                                           
    126134                    form.appendChild(pipelineElem);
    127135                }
    128                                                                                                                                                        
     136                                                                                                                                                                                                               
    129137                var count = document.createElement("input");
    130138                count.name = "pipelineCount";
    131139                count.value = pipelineCount;
    132140                count.type = "hidden";
    133                                                                                                                                                        
     141                                                                                                                                                                                                               
    134142                form.appendChild(count);
    135143            }
Note: See TracChangeset for help on using the changeset viewer.