source: tmcsimulator/trunk/webapps/einotebook/script/scrollframe.js @ 548

Revision 548, 2.0 KB checked in by jdalbey, 6 years ago (diff)

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.

  • Property svn:executable set to *
Line 
1/************* WARNING: THIS IS A GLOBAL VARIABLE. ********************/
2// Reference to the 'events' array in Events.js
3var events;
4
5/**
6 * Sets the events.
7 * @param theEvents Reference to the 'events' array in Events.js.
8 */
9function setEvents(theEvents)
10{
11        events = theEvents;
12}
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 TracBrowser for help on using the repository browser.