Changeset 548 in tmcsimulator for trunk/webapps/einotebook/script


Ignore:
Timestamp:
12/25/2019 09:44:50 AM (6 years ago)
Author:
jdalbey
Message:

Evaluation.js restore radio buttons and simplify recordRating(). Add submit button to scrollframe and add collectRatings function to retrieve any rating that have been set.

Location:
trunk/webapps/einotebook/script
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/webapps/einotebook/script/index.html

    r468 r548  
    1313  <body> 
    1414    
     15 
    1516    <button class="jumpToCurrentEvent"  
    1617            onclick="jumpToLastExecutedEvent()">Jump to Current Event</button> 
    17       
     18     
    1819    <iframe id='view' src='scrollframe.html' frameborder='0' scrolling='yes' 
    1920            width='100%'></iframe> 
     21 
     22      </form> 
     23    
    2024  </body> 
    2125</html> 
  • trunk/webapps/einotebook/script/scrollframe.js

    r468 r548  
    1111        events = theEvents; 
    1212} 
     13 
     14function collectRatings()  
     15{ 
     16    // Consider each event in the incident script 
     17    for (var evtidx = 0; evtidx < events.length; evtidx++) 
     18    { 
     19        // Does this event have any evaluations? 
     20        if (events[evtidx].evaluations.evaluations.length > 0) 
     21        { 
     22            // Examine each evaluation contained in this event 
     23            for (var rating=0; rating<events[evtidx].evaluations.evaluations.length; rating++ ) 
     24            { 
     25                // Extract the rating assigned to this item 
     26                var item = events[evtidx].evaluations.evaluations[rating]; 
     27                // If it not the default value we want to save it 
     28                if (item.rating > 0) 
     29                { 
     30                    console.log("collecting event"+evtidx + " at " + events[evtidx].time.format() +" "+item.type + " " + item.rating) 
     31                } 
     32            } 
     33        } 
     34    } 
     35} 
     36 
     37/* This is an alternative way to collect the ratings values by reading them directly from the radio buttons  
     38function collectRadios() 
     39{ 
     40    var radios = document.getElementsByTagName('input'); 
     41    var count = 0; 
     42    for (var j=0; j<radios.length; j++) 
     43    { 
     44        if (radios[j].type == 'radio')  
     45        { 
     46            count++; 
     47            if (radios[j].checked)  
     48            { 
     49                console.log(radios[j].name + " checked " + radios[j].value)                         
     50            } 
     51        } 
     52    } 
     53    alert("counted " + count + " radios"); 
     54} 
     55*/ 
     56 
     57// TODO 
     58function submitRatings() 
     59{ 
     60        // Using POST to send the data  
     61        var xhr = new XMLHttpRequest(); 
     62        xhr.open("POST", "../../cgi-bin/saveRatings.py", true); 
     63        xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8'); 
     64        // send the collected data 
     65        xhr.send("msg="+outString); 
     66} 
  • trunk/webapps/einotebook/script/simscript.js

    r468 r548  
    7070        } 
    7171         
     72    // Add a submit button to the very bottom  
     73    html += "<button style=\"float: right\" onclick=\"collectRatings();\">Submit Ratings</button>" 
    7274        // display events in iframe 
    7375        getDocumentFromFrame('view').body.innerHTML = html;      
     
    7678        resizeIframe(); 
    7779        window.onresize = resizeIframe; 
    78     // This line is causing an error 
    79         //window.frames['view'].setEvents(Script.events); 
    80          
     80    // Pass the events to the scroll frame window 
     81        document.getElementById("view").contentWindow.setEvents(Script.events); 
     82     
    8183        Script.events.win.scrollTo(0, readCookie('scriptScrollY')); 
    8284         
Note: See TracChangeset for help on using the changeset viewer.