Changeset 548 in tmcsimulator for trunk/webapps/einotebook/script/scrollframe.js


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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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} 
Note: See TracChangeset for help on using the changeset viewer.