nickjillings@1404
|
1 <!DOCTYPE html>
|
nickjillings@1404
|
2 <html lang="en">
|
nickjillings@1404
|
3 <head>
|
nickjillings@1404
|
4 <meta charset="utf-8">
|
nickjillings@1404
|
5
|
nickjillings@1404
|
6 <!-- Always force latest IE rendering engine (even in intranet) & Chrome Frame
|
nickjillings@1404
|
7 Remove this if you use the .htaccess -->
|
nickjillings@1404
|
8 <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
nickjillings@1404
|
9
|
nickjillings@1404
|
10 <title>Analysis</title>
|
nickjillings@1404
|
11 <meta name="description" content="Show results from subjective evaluation">
|
nickjillings@1404
|
12 <meta name="author" content="Brecht De Man">
|
nickjillings@1404
|
13
|
nickjillings@1404
|
14 <script type="text/javascript" src="https://www.google.com/jsapi"></script>
|
nickjillings@1404
|
15 <script type="text/javascript">
|
nickjillings@1404
|
16 // To aid 'one-page set-up' all scripts and CSS must be included directly in this file!
|
nickjillings@1404
|
17
|
nickjillings@1404
|
18 //google.load("visualization", "1", {packages:["corechart"]});
|
nickjillings@1404
|
19
|
nickjillings@1404
|
20 /*************
|
nickjillings@1404
|
21 * SETUP *
|
nickjillings@1404
|
22 *************/
|
nickjillings@1404
|
23 // folder where to find the XML files
|
nickjillings@1404
|
24 xmlFileFolder = "analysis_test";
|
nickjillings@1404
|
25 // array of XML files
|
nickjillings@1404
|
26 var xmlFiles = ['McG-A-2013-09.xml', 'McG-A-2014-03.xml', 'McG-A-2014-12.xml', 'McG-B-2013-09.xml',
|
nickjillings@1404
|
27 'McG-B-2014-03.xml', 'McG-B-2014-12.xml', 'McG-C-2013-09.xml', 'McG-C-2014-03.xml', 'McG-C-2014-12.xml',
|
nickjillings@1404
|
28 'McG-D-2013-09.xml', 'McG-D-2014-03.xml', 'McG-D-2014-12.xml', 'McG-E-2013-09.xml', 'McG-E-2014-03.xml',
|
nickjillings@1404
|
29 'McG-E-2014-12.xml', 'McG-F-2013-09.xml', 'McG-F-2014-03.xml', 'McG-F-2014-12.xml', 'McG-G-2014-03.xml',
|
nickjillings@1404
|
30 'McG-G-2014-12.xml', 'McG-H-2013-09.xml', 'McG-H-2014-03.xml', 'McG-H-2014-12.xml', 'McG-I-2013-09.xml',
|
nickjillings@1404
|
31 'McG-I-2014-03.xml', 'McG-J-2013-09.xml', 'McG-J-2014-03.xml', 'McG-K-2013-09.xml', 'McG-K-2014-03.xml',
|
nickjillings@1404
|
32 'McG-L-2013-09.xml', 'McG-L-2014-03.xml', 'McG-M-2013-09.xml', 'McG-M-2014-03.xml', 'McG-N-2013-09.xml',
|
nickjillings@1404
|
33 'McG-N-2014-03.xml', 'McG-O-2013-09.xml', 'McG-O-2014-03.xml', 'McG-P-2013-09.xml', 'McG-P-2014-03.xml',
|
nickjillings@1404
|
34 'McG-pro1-2013-09.xml', 'McG-pro1-2014-03.xml', 'McG-pro1-2014-12.xml', 'McG-pro2-2013-09.xml',
|
nickjillings@1404
|
35 'McG-pro2-2014-03.xml', 'McG-pro2-2014-12.xml', 'McG-Q-2014-12.xml', 'McG-R-2014-12.xml',
|
nickjillings@1404
|
36 'McG-S-2014-12.xml', 'McG-subA-2013-09.xml', 'McG-subA-2014-03.xml', 'McG-subB-2014-03.xml',
|
nickjillings@1404
|
37 'McG-subB-2014-12.xml', 'McG-subC-2013-09.xml', 'McG-subC-2014-03.xml', 'McG-subC-2014-12.xml',
|
nickjillings@1404
|
38 'McG-subD-2013-09.xml', 'McG-subD-2014-12.xml', 'McG-subE-2014-12.xml', 'McG-subG-2014-12.xml',
|
nickjillings@1404
|
39 'McG-subH-2013-09.xml', 'McG-T-2014-12.xml', 'McG-U-2014-12.xml', 'McG-V-2014-12.xml',
|
nickjillings@1404
|
40 'McG-W-2014-12.xml', 'McG-X-2014-12.xml', 'MG1-2013-09.xml', 'MG2-2013-09.xml', 'MG3-2013-09.xml',
|
nickjillings@1404
|
41 'MG4-2013-09.xml', 'MG5-2013-09.xml', 'MG6-2013-09.xml', 'MG7-2013-09.xml', 'MG8-2013-09.xml',
|
nickjillings@1404
|
42 'MG9-2013-09.xml', 'QM-1-1.xml', 'QM-1-2.xml', 'QM-10-1.xml', 'QM-11-1.xml', 'QM-11-2.xml', 'QM-12-1.xml', 'QM-12-2.xml',
|
nickjillings@1404
|
43 'QM-13-1.xml', 'QM-14-1.xml', 'QM-15-1.xml', 'QM-16-1.xml', 'QM-17-1.xml', 'QM-18-1.xml', 'QM-18-2.xml',
|
nickjillings@1404
|
44 'QM-18-3.xml', 'QM-19-1.xml', 'QM-2-1.xml', 'QM-2-2.xml', 'QM-2-3.xml', 'QM-20-1.xml', 'QM-20-2.xml',
|
nickjillings@1404
|
45 'QM-20-3.xml', 'QM-21-1.xml', 'QM-21-2.xml', 'QM-3-1.xml', 'QM-3-2.xml', 'QM-3-3.xml', 'QM-4-1.xml', 'QM-5-1.xml',
|
nickjillings@1404
|
46 'QM-5-2.xml', 'QM-6-1.xml', 'QM-6-2.xml', 'QM-7-1.xml', 'QM-7-2.xml', 'QM-8-1.xml', 'QM-9-1.xml',
|
nickjillings@1404
|
47 'PXL-L1.xml','PXL-L2.xml','PXL-L3.xml','PXL-L4.xml','PXL-L5.xml','PXL-S1.xml','PXL-S2.xml','PXL-S3.xml',
|
nickjillings@1404
|
48 'PXL-S4.xml','PXL-S5.xml','PXL-S6.xml','PXL-S7.xml','PXL-pro.xml','DU-A1.xml','DU-A2.xml','DU-B1.xml',
|
nickjillings@1404
|
49 'DU-B2.xml','DU-C1.xml','DU-C2.xml','DU-D1.xml','DU-D2.xml','DU-E1.xml','DU-F1.xml','DU-F2.xml','DU-G1.xml',
|
nickjillings@1404
|
50 'DU-G2.xml','DU-H1.xml','DU-H2.xml','DU-I2.xml','DU-J2.xml','DU-K1.xml','DU-K2.xml','DU-L1.xml','DU-L2.xml',
|
nickjillings@1404
|
51 'DU-M1.xml','DU-M2.xml','DU-N1.xml','DU-O1.xml','DU-O2.xml','DU-P1.xml','DU-P2.xml','DU-Q1.xml','DU-Q2.xml',
|
nickjillings@1404
|
52 'DU-R1.xml','DU-R2.xml','DU-S1.xml','DU-S2.xml','DU-T1.xml','DU-T2.xml','DU-U1.xml','DU-U2.xml','DU-U3.xml'];
|
nickjillings@1404
|
53 //['QM-1-1.xml','QM-2-1.xml','QM-2-2.xml','QM-2-3.xml','QM-3-1.xml','QM-3-2.xml','QM-4-1.xml','QM-5-1.xml','QM-5-2.xml','QM-6-1.xml','QM-6-2.xml','QM-7-1.xml','QM-7-2.xml','QM-8-1.xml','QM-9-1.xml','QM-10-1.xml','QM-11-1.xml','QM-12-1.xml','QM-12-2.xml','QM-13-1.xml','QM-14-1.xml','QM-15-1.xml','QM-16-1.xml','QM-17-1.xml','QM-18-1.xml','QM-18-2.xml','QM-18-3.xml','QM-19-1.xml','QM-20-1.xml','QM-20-2.xml','QM-20-3.xml','QM-21-1.xml','QM-21-2.xml'];
|
nickjillings@1404
|
54 //['McG-A-2014-03.xml','McG-B-2014-03.xml','McG-C-2014-03.xml','McG-D-2014-03.xml','McG-E-2014-03.xml','McG-F-2014-03.xml','McG-G-2014-03.xml','McG-H-2014-03.xml'];
|
nickjillings@1404
|
55
|
nickjillings@1404
|
56 //TODO: make retrieval of file names automatic / drag files on here
|
nickjillings@1404
|
57
|
nickjillings@1404
|
58 /****************
|
nickjillings@1404
|
59 * VARIABLES *
|
nickjillings@1404
|
60 ****************/
|
nickjillings@1404
|
61
|
nickjillings@1404
|
62 // Counters
|
nickjillings@1404
|
63 // How many files, audioholders, audioelementes and statements annotated (don't count current one)
|
nickjillings@1404
|
64 var numberOfFiles = -1;
|
nickjillings@1404
|
65 var numberOfaudioholders = -1;
|
nickjillings@1404
|
66 var numberOfaudioelementes = -1;
|
nickjillings@1404
|
67 var numberOfStatements = -1;
|
nickjillings@1404
|
68 var numberOfSkippedComments = 0;
|
nickjillings@1404
|
69
|
nickjillings@1404
|
70 // Object arrays
|
nickjillings@1404
|
71 var fileNameArray = [];
|
nickjillings@1404
|
72 var subjectArray = [];
|
nickjillings@1404
|
73 var audioholderArray = [];
|
nickjillings@1404
|
74 var audioelementArray = [];
|
nickjillings@1404
|
75
|
nickjillings@1404
|
76 // End of (file, audioholder, audioelement) flags
|
nickjillings@1404
|
77 var newFile = true;
|
nickjillings@1404
|
78 var newAudioHolder = true;
|
nickjillings@1404
|
79 var newAudioElement = true;
|
nickjillings@1404
|
80
|
nickjillings@1404
|
81 var fileCounter = 0; // file index
|
nickjillings@1404
|
82 var audioholderCounter=0; // audioholder index (current XML file)
|
nickjillings@1404
|
83 var audioelementCounter=0; // audioelement index (current audioholder)
|
nickjillings@1404
|
84 var statementNumber=0; // total number of statements
|
nickjillings@1404
|
85
|
nickjillings@1404
|
86 var root; // root of XML file
|
nickjillings@1404
|
87 var commentInFull = ''; // full comment
|
nickjillings@1404
|
88
|
nickjillings@1404
|
89 var playAudio = true; // whether corresponding audio should be played back
|
nickjillings@1404
|
90
|
nickjillings@1404
|
91 // // Measuring time
|
nickjillings@1404
|
92 // var lastTimeMeasured = -1; //
|
nickjillings@1404
|
93 // var durationLastAnnotation = -1; // duration of last annotation
|
nickjillings@1404
|
94 // var timeArray = [];
|
nickjillings@1404
|
95 // var MIN_TIME = 1.0; // minimum time counted as significant
|
nickjillings@1404
|
96 // var measurementPaused = false; // whether time measurement is paused
|
nickjillings@1404
|
97 // var timeInBuffer = 0; //
|
nickjillings@1404
|
98
|
nickjillings@1404
|
99 var topLevel;
|
nickjillings@1404
|
100 window.onload = function() {
|
nickjillings@1404
|
101 // Initialise page
|
nickjillings@1404
|
102 topLevel = document.getElementById('topLevelBody');
|
nickjillings@1404
|
103 var setup = document.createElement('div');
|
nickjillings@1404
|
104 setup.id = 'setupTagDiv';
|
nickjillings@1404
|
105 loadAllFiles();
|
nickjillings@1404
|
106 printSurveyData()
|
nickjillings@1404
|
107 //makePlots();
|
nickjillings@1404
|
108 // measure time at this point:
|
nickjillings@1404
|
109 lastTimeMeasured = new Date().getTime(); // in milliseconds
|
nickjillings@1404
|
110 };
|
nickjillings@1404
|
111
|
nickjillings@1404
|
112 // Assert function
|
nickjillings@1404
|
113 function assert(condition, message) {
|
nickjillings@1404
|
114 if (!condition) {
|
nickjillings@1404
|
115 message = message || "Assertion failed";
|
nickjillings@1404
|
116 if (typeof Error !== "undefined") {
|
nickjillings@1404
|
117 throw new Error(message);
|
nickjillings@1404
|
118 }
|
nickjillings@1404
|
119 throw message; // Fallback
|
nickjillings@1404
|
120 }
|
nickjillings@1404
|
121 }
|
nickjillings@1404
|
122
|
nickjillings@1404
|
123 function median(values) { // TODO: replace code by '50th percentile' - should be the same?
|
nickjillings@1404
|
124 values.sort( function(a,b) {return a - b;} );
|
nickjillings@1404
|
125 var half = Math.floor(values.length/2);
|
nickjillings@1404
|
126 if(values.length % 2)
|
nickjillings@1404
|
127 return values[half];
|
nickjillings@1404
|
128 else
|
nickjillings@1404
|
129 return (values[half-1] + values[half]) / 2.0;
|
nickjillings@1404
|
130 }
|
nickjillings@1404
|
131
|
nickjillings@1404
|
132 function percentile(values, n) {
|
nickjillings@1404
|
133 values.sort( function(a,b) {return a - b;} );
|
nickjillings@1404
|
134 // get ordinal rank
|
nickjillings@1404
|
135 var rank = Math.min(Math.floor(values.length*n/100), values.length-1);
|
nickjillings@1404
|
136 return values[rank];
|
nickjillings@1404
|
137 }
|
nickjillings@1404
|
138
|
nickjillings@1404
|
139 /***********************
|
nickjillings@1404
|
140 * TIME MEASUREMENT *
|
nickjillings@1404
|
141 ************************/
|
nickjillings@1404
|
142
|
nickjillings@1404
|
143 // measure time since last time this function was called
|
nickjillings@1404
|
144 function timeSinceLastCall() {
|
nickjillings@1404
|
145 // current time
|
nickjillings@1404
|
146 var currentTime = new Date().getTime();
|
nickjillings@1404
|
147 // calculate time difference
|
nickjillings@1404
|
148 var timeDifference = currentTime - lastTimeMeasured + timeInBuffer;
|
nickjillings@1404
|
149 // clear buffer (for pausing)
|
nickjillings@1404
|
150 timeInBuffer = 0;
|
nickjillings@1404
|
151 // remember last measured time
|
nickjillings@1404
|
152 lastTimeMeasured = currentTime;
|
nickjillings@1404
|
153 return timeDifference;
|
nickjillings@1404
|
154 }
|
nickjillings@1404
|
155
|
nickjillings@1404
|
156 // pause time measurement
|
nickjillings@1404
|
157 function pauseTimeMeasurement() {
|
nickjillings@1404
|
158 // UN-PAUSE
|
nickjillings@1404
|
159 if (measurementPaused) { // already paused
|
nickjillings@1404
|
160 // button shows 'pause' again
|
nickjillings@1404
|
161 document.getElementById('pauseButton').innerHTML = 'Pause';
|
nickjillings@1404
|
162 // toggle state
|
nickjillings@1404
|
163 measurementPaused = false;
|
nickjillings@1404
|
164 // resume time measurement
|
nickjillings@1404
|
165 lastTimeMeasured = new Date().getTime(); // reset time, discard time while paused
|
nickjillings@1404
|
166 } else { // PAUSE
|
nickjillings@1404
|
167 // button shows 'resume'
|
nickjillings@1404
|
168 document.getElementById('pauseButton').innerHTML = 'Resume';
|
nickjillings@1404
|
169 // toggle state
|
nickjillings@1404
|
170 measurementPaused = true;
|
nickjillings@1404
|
171 // pause time measurement
|
nickjillings@1404
|
172 timeInBuffer = timeSinceLastCall();
|
nickjillings@1404
|
173 }
|
nickjillings@1404
|
174 }
|
nickjillings@1404
|
175
|
nickjillings@1404
|
176 // show elapsed time on interface
|
nickjillings@1404
|
177 function showTimeElapsedInSeconds() {
|
nickjillings@1404
|
178 // if paused: un-pause
|
nickjillings@1404
|
179 if (measurementPaused) {
|
nickjillings@1404
|
180 pauseTimeMeasurement();
|
nickjillings@1404
|
181 }
|
nickjillings@1404
|
182
|
nickjillings@1404
|
183 // time of last annotation
|
nickjillings@1404
|
184 var lastAnnotationTime = timeSinceLastCall()/1000;
|
nickjillings@1404
|
185 document.getElementById('timeDisplay').innerHTML = lastAnnotationTime.toFixed(2);
|
nickjillings@1404
|
186 // average time over last ... annotations
|
nickjillings@1404
|
187 var avgAnnotationTime;
|
nickjillings@1404
|
188 var numberOfElementsToAverage =
|
nickjillings@1404
|
189 document.getElementById('numberOfTimeAverages').value;
|
nickjillings@1404
|
190 if (isPositiveInteger(numberOfElementsToAverage)) {
|
nickjillings@1404
|
191 avgAnnotationTime =
|
nickjillings@1404
|
192 calculateAverageTime(lastAnnotationTime,
|
nickjillings@1404
|
193 Number(numberOfElementsToAverage));
|
nickjillings@1404
|
194 } else {
|
nickjillings@1404
|
195 // change text field content to 'ALL'
|
nickjillings@1404
|
196 document.getElementById('numberOfTimeAverages').value = 'ALL';
|
nickjillings@1404
|
197 avgAnnotationTime = calculateAverageTime(lastAnnotationTime, -1);
|
nickjillings@1404
|
198 }
|
nickjillings@1404
|
199 document.getElementById('timeAverageDisplay').innerHTML = avgAnnotationTime.toFixed(2);
|
nickjillings@1404
|
200 }
|
nickjillings@1404
|
201
|
nickjillings@1404
|
202 // auxiliary function: is string a positive integer?
|
nickjillings@1404
|
203 // http://stackoverflow.com/questions/10834796/...
|
nickjillings@1404
|
204 // validate-that-a-string-is-a-positive-integer
|
nickjillings@1404
|
205 function isPositiveInteger(str) {
|
nickjillings@1404
|
206 var n = ~~Number(str);
|
nickjillings@1404
|
207 return String(n) === str && n >= 0;
|
nickjillings@1404
|
208 }
|
nickjillings@1404
|
209
|
nickjillings@1404
|
210 // calculate average time
|
nickjillings@1404
|
211 function calculateAverageTime(newTimeMeasurementInSeconds,numberOfPoints) {
|
nickjillings@1404
|
212 // append last measurement time to time array, if significant
|
nickjillings@1404
|
213 if (newTimeMeasurementInSeconds > MIN_TIME) {
|
nickjillings@1404
|
214 timeArray.push(newTimeMeasurementInSeconds);
|
nickjillings@1404
|
215 }
|
nickjillings@1404
|
216 // average over last N elements of this array
|
nickjillings@1404
|
217 if (numberOfPoints < 0 || numberOfPoints>=timeArray.length) { // calculate average over all
|
nickjillings@1404
|
218 var sum = 0;
|
nickjillings@1404
|
219 for (var i = 0; i < timeArray.length; i++) {
|
nickjillings@1404
|
220 sum += timeArray[i];
|
nickjillings@1404
|
221 }
|
nickjillings@1404
|
222 averageOfTimes = sum/timeArray.length;
|
nickjillings@1404
|
223 } else { // calculate average over specified number of times measured last
|
nickjillings@1404
|
224 var sum = 0;
|
nickjillings@1404
|
225 for (var i = timeArray.length-numberOfPoints; i < timeArray.length; i++) {
|
nickjillings@1404
|
226 sum += timeArray[i];
|
nickjillings@1404
|
227 }
|
nickjillings@1404
|
228 averageOfTimes = sum/numberOfPoints;
|
nickjillings@1404
|
229 }
|
nickjillings@1404
|
230 return averageOfTimes;
|
nickjillings@1404
|
231 }
|
nickjillings@1404
|
232
|
nickjillings@1404
|
233
|
nickjillings@1404
|
234 /********************************
|
nickjillings@1404
|
235 * PLAYBACK OF AUDIO *
|
nickjillings@1404
|
236 ********************************/
|
nickjillings@1404
|
237
|
nickjillings@1404
|
238 //PLAYaudioelement
|
nickjillings@1404
|
239 // Keep track of whether audio should be played
|
nickjillings@1404
|
240 function playFlagChanged(){
|
nickjillings@1404
|
241 playAudio = playFlag.checked; // global variable
|
nickjillings@1404
|
242
|
nickjillings@1404
|
243 if (!playAudio){ // if audio needs to stop
|
nickjillings@1404
|
244 audio.pause(); // stop audio - if anything is playing
|
nickjillings@1404
|
245 currently_playing = ''; // back to empty string so playaudioelement knows nothing's playing
|
nickjillings@1404
|
246 }
|
nickjillings@1404
|
247 }
|
nickjillings@1404
|
248
|
nickjillings@1404
|
249 // audioholder that's currently playing
|
nickjillings@1404
|
250 var currently_playing_audioholder = ''; // at first: empty string
|
nickjillings@1404
|
251 var currently_playing_audioelement = '';
|
nickjillings@1404
|
252 var audio;
|
nickjillings@1404
|
253
|
nickjillings@1404
|
254 // Play audioelement of audioholder if available, from start or from same position
|
nickjillings@1404
|
255 function playaudioelement(audioholderName, audioelementerName){
|
nickjillings@1404
|
256 if (playAudio) { // if enabled
|
nickjillings@1404
|
257 // get corresponding file from folder
|
nickjillings@1404
|
258 var file_location = 'audio/'+audioholderName + '/' + audioelementerName + '.mp3'; // fixed path and file name format
|
nickjillings@1404
|
259
|
nickjillings@1404
|
260 // if not available, show error/warning message
|
nickjillings@1404
|
261 //TODO ...
|
nickjillings@1404
|
262
|
nickjillings@1404
|
263 // if nothing playing yet, start playing
|
nickjillings@1404
|
264 if (currently_playing_audioholder == ''){ // signal that nothing is playing
|
nickjillings@1404
|
265 //playSound(audioBuffer);
|
nickjillings@1404
|
266 audio = new Audio(file_location);
|
nickjillings@1404
|
267 audio.loop = true; // loop when end is reached
|
nickjillings@1404
|
268 audio.play();
|
nickjillings@1404
|
269 currently_playing_audioholder = audioholderName;
|
nickjillings@1404
|
270 currently_playing_audioelement = audioelementerName;
|
nickjillings@1404
|
271 } else if (currently_playing_audioholder != audioholderName) {
|
nickjillings@1404
|
272 // if different audioholder playing, stop that and start playing
|
nickjillings@1404
|
273 audio.pause(); // stop audio
|
nickjillings@1404
|
274 audio = new Audio(file_location); // load new file
|
nickjillings@1404
|
275 audio.loop = true; // loop when end is reached
|
nickjillings@1404
|
276 audio.play(); // play audio from the start
|
nickjillings@1404
|
277 currently_playing_audioholder = audioholderName;
|
nickjillings@1404
|
278 currently_playing_audioelement = audioelementerName;
|
nickjillings@1404
|
279 } else if (currently_playing_audioelement != audioelementerName) {
|
nickjillings@1404
|
280 // if same audioholder playing, start playing from where it left off
|
nickjillings@1404
|
281 skipTime = audio.currentTime; // time to skip to
|
nickjillings@1404
|
282 audio.pause(); // stop audio
|
nickjillings@1404
|
283 audio = new Audio(file_location);
|
nickjillings@1404
|
284 audio.addEventListener('loadedmetadata', function() {
|
nickjillings@1404
|
285 this.currentTime = skipTime;
|
nickjillings@1404
|
286 console.log('Loaded '+audioholderName+'-'+audioelementerName+', playing from '+skipTime);
|
nickjillings@1404
|
287 }, false); // skip to same time when audio is loaded!
|
nickjillings@1404
|
288 audio.loop = true; // loop when end is reached
|
nickjillings@1404
|
289 audio.play(); // play from that time
|
nickjillings@1404
|
290 audio.currentTime = skipTime;
|
nickjillings@1404
|
291 currently_playing_audioholder = audioholderName;
|
nickjillings@1404
|
292 currently_playing_audioelement = audioelementerName;
|
nickjillings@1404
|
293 }
|
nickjillings@1404
|
294 // if same audioelement playing: keep on playing (i.e. do nothing)
|
nickjillings@1404
|
295 }
|
nickjillings@1404
|
296 }
|
nickjillings@1404
|
297
|
nickjillings@1404
|
298 /********************
|
nickjillings@1404
|
299 * READING FILES *
|
nickjillings@1404
|
300 ********************/
|
nickjillings@1404
|
301
|
nickjillings@1404
|
302 // Read necessary data from XML file
|
nickjillings@1404
|
303 function readXML(xmlFileName){
|
nickjillings@1404
|
304 if (window.XMLHttpRequest)
|
nickjillings@1404
|
305 {// code for IE7+, Firefox, Chrome, Opera, Safari
|
nickjillings@1404
|
306 xmlhttp=new XMLHttpRequest();
|
nickjillings@1404
|
307 }
|
nickjillings@1404
|
308 else
|
nickjillings@1404
|
309 {// code for IE6, IE5
|
nickjillings@1404
|
310 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
|
nickjillings@1404
|
311 }
|
nickjillings@1404
|
312 xmlhttp.open("GET",xmlFileName,false);
|
nickjillings@1404
|
313 xmlhttp.send();
|
nickjillings@1404
|
314 return xmlhttp.responseXML;
|
nickjillings@1404
|
315 }
|
nickjillings@1404
|
316
|
nickjillings@1404
|
317 // go over all files and compute relevant statistics
|
nickjillings@1404
|
318 function loadAllFiles() {
|
nickjillings@1404
|
319 // retrieve information from XMLs
|
nickjillings@1404
|
320
|
nickjillings@1404
|
321 for (fileIndex = 0; fileIndex < xmlFiles.length; fileIndex++) {
|
nickjillings@1404
|
322 xmlFileName = xmlFileFolder+"/"+xmlFiles[fileIndex];
|
nickjillings@1404
|
323 xml = readXML(xmlFileName);
|
nickjillings@1404
|
324 if (xml != null) { // if file exists
|
nickjillings@1404
|
325 // append file name to array of file names
|
nickjillings@1404
|
326 fileNameArray.push(xmlFiles[fileIndex]);
|
nickjillings@1404
|
327
|
nickjillings@1404
|
328 // get root of XML file
|
nickjillings@1404
|
329 root = xml.getElementsByTagName('browserevaluationresult')[0];
|
nickjillings@1404
|
330
|
nickjillings@1404
|
331 // get subject ID, add to array if not already there
|
nickjillings@1404
|
332 pretest = root.getElementsByTagName('pretest')[0];
|
nickjillings@1404
|
333 subjectID = pretest.getElementsByTagName('comment')[0];
|
nickjillings@1404
|
334 if (subjectID){
|
nickjillings@1404
|
335 if (subjectID.getAttribute('id')!='sessionId') { // warning in console when not available
|
nickjillings@1404
|
336 console.log(xmlFiles[fileIndex]+': no SessionID available');
|
nickjillings@1404
|
337 }
|
nickjillings@1404
|
338 if (subjectArray.indexOf(subjectID.textContent) == -1) { // if not already in array
|
nickjillings@1404
|
339 subjectArray.push(subjectID.textContent); // append to array
|
nickjillings@1404
|
340 }
|
nickjillings@1404
|
341 }
|
nickjillings@1404
|
342
|
nickjillings@1404
|
343 // go over all audioholders, add to array if not already there
|
nickjillings@1404
|
344 audioholderNodes = root.getElementsByTagName('audioholder');
|
nickjillings@1404
|
345 // go over audioholderNodes and append audioholder name when not present yet
|
nickjillings@1404
|
346 for (audioholderIndex = 0; audioholderIndex < audioholderNodes.length; audioholderIndex++) {
|
nickjillings@1404
|
347 audioholderName = audioholderNodes[audioholderIndex].getAttribute('id');
|
nickjillings@1404
|
348 if (audioholderArray.indexOf(audioholderName) == -1) { // if not already in array
|
nickjillings@1404
|
349 audioholderArray.push(audioholderName); // append to array
|
nickjillings@1404
|
350 }
|
nickjillings@1404
|
351 // within each audioholder, go over all audioelement IDs, add to array if not already there
|
nickjillings@1404
|
352 audioelementNodes = audioholderNodes[audioholderIndex].getElementsByTagName('audioelement');
|
nickjillings@1404
|
353 for (audioelementIndex = 0; audioelementIndex < audioelementNodes.length; audioelementIndex++) {
|
nickjillings@1404
|
354 audioelementName = audioelementNodes[audioelementIndex].getAttribute('id');
|
nickjillings@1404
|
355 if (audioelementArray.indexOf(audioelementName) == -1) { // if not already in array
|
nickjillings@1404
|
356 audioelementArray.push(audioelementName); // append to array
|
nickjillings@1404
|
357 }
|
nickjillings@1404
|
358 }
|
nickjillings@1404
|
359 }
|
nickjillings@1404
|
360 // count occurrences of each audioholder
|
nickjillings@1404
|
361 // ...
|
nickjillings@1404
|
362 }
|
nickjillings@1404
|
363 else {
|
nickjillings@1404
|
364 console.log('XML file '+xmlFileName+' not found.');
|
nickjillings@1404
|
365 }
|
nickjillings@1404
|
366 }
|
nickjillings@1404
|
367
|
nickjillings@1404
|
368 // sort alphabetically
|
nickjillings@1404
|
369 fileNameArray.sort();
|
nickjillings@1404
|
370 subjectArray.sort();
|
nickjillings@1404
|
371 audioholderArray.sort();
|
nickjillings@1404
|
372 audioelementArray.sort();
|
nickjillings@1404
|
373
|
nickjillings@1404
|
374 // display all information in HTML
|
nickjillings@1404
|
375 // show XML file folder
|
nickjillings@1404
|
376 document.getElementById('xmlFileFolder_span').innerHTML = "\""+xmlFileFolder+"/\"";
|
nickjillings@1404
|
377 // show number of files
|
nickjillings@1404
|
378 document.getElementById('numberOfFiles_span').innerHTML = fileNameArray.length;
|
nickjillings@1404
|
379 // show list of subject names
|
nickjillings@1404
|
380 document.getElementById('subjectArray_span').innerHTML = subjectArray.toString();
|
nickjillings@1404
|
381 // show list of audioholders
|
nickjillings@1404
|
382 document.getElementById('audioholderArray_span').innerHTML = audioholderArray.toString();
|
nickjillings@1404
|
383 // show list of audioelementes
|
nickjillings@1404
|
384 document.getElementById('audioelementArray_span').innerHTML = audioelementArray.toString();
|
nickjillings@1404
|
385 }
|
nickjillings@1404
|
386
|
nickjillings@1404
|
387 function printSurveyData() {
|
nickjillings@1404
|
388 // print some fields from the survey for different people
|
nickjillings@1404
|
389
|
nickjillings@1404
|
390 // go over all XML files
|
nickjillings@1404
|
391 for (fileIndex = 0; fileIndex < xmlFiles.length; fileIndex++) {
|
nickjillings@1404
|
392 xmlFileName = xmlFileFolder+"/"+xmlFiles[fileIndex];
|
nickjillings@1404
|
393 xml = readXML(xmlFileName);
|
nickjillings@1404
|
394 // make a div
|
nickjillings@1404
|
395 var div = document.createElement('div');
|
nickjillings@1404
|
396 document.body.appendChild(div);
|
nickjillings@1404
|
397 div.id = 'div_survey_'+xmlFileName;
|
nickjillings@1404
|
398 div.style.width = '1100px';
|
nickjillings@1404
|
399 //div.style.height = '350px';
|
nickjillings@1404
|
400
|
nickjillings@1404
|
401 // title for that div (subject id)
|
nickjillings@1404
|
402 document.getElementById('div_survey_'+xmlFileName).innerHTML = '<h2>'+xmlFileName+'</h2>';
|
nickjillings@1404
|
403
|
nickjillings@1404
|
404 // which songs did they do
|
nickjillings@1404
|
405 if (xml != null) { // if file exists
|
nickjillings@1404
|
406 // get root of XML file
|
nickjillings@1404
|
407 root = xml.getElementsByTagName('browserevaluationresult')[0];
|
nickjillings@1404
|
408 // go over all audioholders
|
nickjillings@1404
|
409 // document.getElementById('div_survey_'+xmlFileName).innerHTML += '<strong>Audioholders: </strong>';
|
nickjillings@1404
|
410 // audioholderNodes = root.getElementsByTagName('audioholder');
|
nickjillings@1404
|
411 // for (audioholderIndex = 0; audioholderIndex < audioholderNodes.length-1; audioholderIndex++) {
|
nickjillings@1404
|
412 // document.getElementById('div_survey_'+xmlFileName).innerHTML += audioholderNodes[audioholderIndex].getAttribute('id')+', ';
|
nickjillings@1404
|
413 // }
|
nickjillings@1404
|
414 // document.getElementById('div_survey_'+xmlFileName).innerHTML += audioholderNodes[audioholderNodes.length-1].getAttribute('id');
|
nickjillings@1404
|
415
|
nickjillings@1404
|
416 // survey responses (each if available)
|
nickjillings@1404
|
417 // get posttest node for total test
|
nickjillings@1404
|
418 childNodes = root.childNodes;
|
nickjillings@1404
|
419 posttestnode = null;
|
nickjillings@1404
|
420 for (idx = 0; idx < childNodes.length; idx++){
|
nickjillings@1404
|
421 if (childNodes[childNodes.length-idx-1].tagName == 'posttest') {
|
nickjillings@1404
|
422 posttestnode = childNodes[childNodes.length-idx-1];
|
nickjillings@1404
|
423 break;
|
nickjillings@1404
|
424 }
|
nickjillings@1404
|
425 }
|
nickjillings@1404
|
426
|
nickjillings@1404
|
427 // mix experience
|
nickjillings@1404
|
428 if (posttestnode) {
|
nickjillings@1404
|
429 posttestcomments = posttestnode.getElementsByTagName('comment');
|
nickjillings@1404
|
430 for (idx=0; idx < posttestcomments.length; idx++){
|
nickjillings@1404
|
431 commentsToPrint = ['generalExperience', 'interfaceExperience'];
|
nickjillings@1404
|
432 idAttribute = posttestcomments[idx].getAttribute('id');
|
nickjillings@1404
|
433 if (commentsToPrint.indexOf(idAttribute) >= 0) { // if exists?
|
nickjillings@1404
|
434 document.getElementById('div_survey_'+xmlFileName).innerHTML += '<br><strong>'+idAttribute+': </strong>'+posttestcomments[idx].textContent;
|
nickjillings@1404
|
435 }
|
nickjillings@1404
|
436 }
|
nickjillings@1404
|
437 }
|
nickjillings@1404
|
438 }
|
nickjillings@1404
|
439 }
|
nickjillings@1404
|
440 }
|
nickjillings@1404
|
441
|
nickjillings@1404
|
442 function makePlots() { //TODO: split into different functions
|
nickjillings@1404
|
443 // TEMPORARY
|
nickjillings@1404
|
444 makeTimeline(xmlFileFolder+"/"+xmlFiles[7]);
|
nickjillings@1404
|
445
|
nickjillings@1404
|
446 // create value array
|
nickjillings@1404
|
447 var ratings = []; // 3D matrix of ratings (audioholder, audioelement, subject)
|
nickjillings@1404
|
448 for (audioholderIndex = 0; audioholderIndex < audioholderArray.length; audioholderIndex++) {
|
nickjillings@1404
|
449 ratings.push([]);
|
nickjillings@1404
|
450 for (audioelementIndex = 0; audioelementIndex < audioelementArray.length; audioelementIndex++) {
|
nickjillings@1404
|
451 ratings[audioholderIndex].push([]);
|
nickjillings@1404
|
452 }
|
nickjillings@1404
|
453 }
|
nickjillings@1404
|
454
|
nickjillings@1404
|
455 // go over all XML files
|
nickjillings@1404
|
456 for (fileIndex = 0; fileIndex < xmlFiles.length; fileIndex++) {
|
nickjillings@1404
|
457 xmlFileName = xmlFileFolder+"/"+xmlFiles[fileIndex];
|
nickjillings@1404
|
458 xml = readXML(xmlFileName);
|
nickjillings@1404
|
459 if (xml != null) { // if file exists
|
nickjillings@1404
|
460 // get root of XML file
|
nickjillings@1404
|
461 root = xml.getElementsByTagName('browserevaluationresult')[0];
|
nickjillings@1404
|
462 // go over all audioholders
|
nickjillings@1404
|
463 audioholderNodes = root.getElementsByTagName('audioholder');
|
nickjillings@1404
|
464 for (audioholderIndex = 0; audioholderIndex < audioholderNodes.length; audioholderIndex++) {
|
nickjillings@1404
|
465 audioholderName = audioholderNodes[audioholderIndex].getAttribute('id');
|
nickjillings@1404
|
466 audioelementNodes = audioholderNodes[audioholderIndex].getElementsByTagName('audioelement');
|
nickjillings@1404
|
467 // go over all audioelements
|
nickjillings@1404
|
468 for (audioelementIndex = 0; audioelementIndex < audioelementNodes.length; audioelementIndex++) {
|
nickjillings@1404
|
469 audioelementName = audioelementNodes[audioelementIndex].getAttribute('id');
|
nickjillings@1404
|
470 // get value
|
nickjillings@1404
|
471 var value = audioelementNodes[audioelementIndex].getElementsByTagName("value")[0].textContent;
|
nickjillings@1404
|
472 if (value) { // if not empty, null, undefined...
|
nickjillings@1404
|
473 ratingValue = parseFloat(value);
|
nickjillings@1404
|
474 // add to matrix at proper position
|
nickjillings@1404
|
475 aHidx = audioholderArray.indexOf(audioholderName);
|
nickjillings@1404
|
476 aEidx = audioelementArray.indexOf(audioelementName);
|
nickjillings@1404
|
477 ratings[aHidx][aEidx].push(ratingValue);
|
nickjillings@1404
|
478 }
|
nickjillings@1404
|
479 }
|
nickjillings@1404
|
480 }
|
nickjillings@1404
|
481
|
nickjillings@1404
|
482 // go over all audioholders
|
nickjillings@1404
|
483
|
nickjillings@1404
|
484 // go over all audioelements within audioholder, see if present in idMatrix, add if not
|
nickjillings@1404
|
485 // add corresponding rating to 'ratings', at position corresponding with position in idMatrix
|
nickjillings@1404
|
486 }
|
nickjillings@1404
|
487 }
|
nickjillings@1404
|
488
|
nickjillings@1404
|
489 for (audioholderIndex = 0; audioholderIndex < audioholderArray.length; audioholderIndex++) {
|
nickjillings@1404
|
490 audioholderName = audioholderArray[audioholderIndex]; // for this song
|
nickjillings@1404
|
491 tickArray = []
|
nickjillings@1404
|
492
|
nickjillings@1404
|
493 raw_data = [['SubjectID', 'Rating']];
|
nickjillings@1404
|
494 audioElIdx = 0;
|
nickjillings@1404
|
495 for (audioelementIndex = 0; audioelementIndex<ratings[audioholderIndex].length; audioelementIndex++){
|
nickjillings@1404
|
496 if (ratings[audioholderIndex][audioelementIndex].length>0) {
|
nickjillings@1404
|
497 audioElIdx++; // increase if not empty
|
nickjillings@1404
|
498 // make tick label
|
nickjillings@1404
|
499 tickArray.push({v:audioElIdx, f: audioelementArray[audioelementIndex]});
|
nickjillings@1404
|
500 }
|
nickjillings@1404
|
501 for (subject = 0; subject<ratings[audioholderIndex][audioelementIndex].length; subject++){
|
nickjillings@1404
|
502 // add subject-value pair for each subject
|
nickjillings@1404
|
503 raw_data.push([audioElIdx, ratings[audioholderIndex][audioelementIndex][subject]]);
|
nickjillings@1404
|
504 }
|
nickjillings@1404
|
505 }
|
nickjillings@1404
|
506
|
nickjillings@1404
|
507 // create plot (one per song)
|
nickjillings@1404
|
508 var data = google.visualization.arrayToDataTable(raw_data);
|
nickjillings@1404
|
509
|
nickjillings@1404
|
510 var options = {
|
nickjillings@1404
|
511 title: audioholderName,
|
nickjillings@1404
|
512 hAxis: {title: 'audioelement ID', minValue: 0, maxValue: audioElIdx+1,
|
nickjillings@1404
|
513 ticks: tickArray},
|
nickjillings@1404
|
514 vAxis: {title: 'Rating', minValue: 0, maxValue: 1},
|
nickjillings@1404
|
515 seriesType: 'scatter',
|
nickjillings@1404
|
516 legend: 'none'
|
nickjillings@1404
|
517 };
|
nickjillings@1404
|
518 var div = document.createElement('div');
|
nickjillings@1404
|
519 document.body.appendChild(div);
|
nickjillings@1404
|
520 div.id = 'div_'+audioholderName;
|
nickjillings@1404
|
521 div.style.width = '1100px';
|
nickjillings@1404
|
522 div.style.height = '350px';
|
nickjillings@1404
|
523 var chart = new google.visualization.ComboChart(document.getElementById('div_'+audioholderName));
|
nickjillings@1404
|
524 chart.draw(data, options);
|
nickjillings@1404
|
525
|
nickjillings@1404
|
526 // box plots
|
nickjillings@1404
|
527 var div = document.createElement('div');
|
nickjillings@1404
|
528 document.body.appendChild(div);
|
nickjillings@1404
|
529 div.id = 'div_box_'+audioholderName;
|
nickjillings@1404
|
530 div.style.width = '1100px';
|
nickjillings@1404
|
531 div.style.height = '350px';
|
nickjillings@1404
|
532 // Get median, percentiles, maximum and minimum; outliers.
|
nickjillings@1404
|
533 pctl25 = [];
|
nickjillings@1404
|
534 pctl75 = [];
|
nickjillings@1404
|
535 med = [];
|
nickjillings@1404
|
536 min = [];
|
nickjillings@1404
|
537 max = [];
|
nickjillings@1404
|
538 outlierArray = [];
|
nickjillings@1404
|
539 max_n_outliers = 0; // maximum number of outliers for one audioelement
|
nickjillings@1404
|
540 for (audioelementIndex = 0; audioelementIndex<ratings[audioholderIndex].length; audioelementIndex++){
|
nickjillings@1404
|
541 med.push(median(ratings[audioholderIndex][audioelementIndex])); // median
|
nickjillings@1404
|
542 pctl25.push(percentile(ratings[audioholderIndex][audioelementIndex], 25)); // 25th percentile
|
nickjillings@1404
|
543 pctl75.push(percentile(ratings[audioholderIndex][audioelementIndex], 75)); // 75th percentile
|
nickjillings@1404
|
544 IQR = pctl75[pctl75.length-1]-pctl25[pctl25.length-1];
|
nickjillings@1404
|
545 // outliers: range of values which is above pctl75+1.5*IQR or below pctl25-1.5*IQR
|
nickjillings@1404
|
546 outliers = [];
|
nickjillings@1404
|
547 rest = [];
|
nickjillings@1404
|
548 for (idx = 0; idx<ratings[audioholderIndex][audioelementIndex].length; idx++){
|
nickjillings@1404
|
549 if (ratings[audioholderIndex][audioelementIndex][idx] > pctl75[pctl75.length-1]+1.5*IQR ||
|
nickjillings@1404
|
550 ratings[audioholderIndex][audioelementIndex][idx] < pctl25[pctl25.length-1]-1.5*IQR){
|
nickjillings@1404
|
551 outliers.push(ratings[audioholderIndex][audioelementIndex][idx]);
|
nickjillings@1404
|
552 }
|
nickjillings@1404
|
553 else {
|
nickjillings@1404
|
554 rest.push(ratings[audioholderIndex][audioelementIndex][idx]);
|
nickjillings@1404
|
555 }
|
nickjillings@1404
|
556 }
|
nickjillings@1404
|
557 outlierArray.push(outliers);
|
nickjillings@1404
|
558 max_n_outliers = Math.max(max_n_outliers, outliers.length); // update max mber
|
nickjillings@1404
|
559 // max: maximum value which is not outlier
|
nickjillings@1404
|
560 max.push(Math.max.apply(null, rest));
|
nickjillings@1404
|
561 // min: minimum value which is not outlier
|
nickjillings@1404
|
562 min.push(Math.min.apply(null, rest));
|
nickjillings@1404
|
563 }
|
nickjillings@1404
|
564
|
nickjillings@1404
|
565 // Build data array
|
nickjillings@1404
|
566 boxplot_data = [['ID', 'Span', '', '', '', 'Median']];
|
nickjillings@1404
|
567 for (idx = 0; idx < max_n_outliers; idx++) {
|
nickjillings@1404
|
568 boxplot_data[0].push('Outlier');
|
nickjillings@1404
|
569 }
|
nickjillings@1404
|
570 for (audioelementIndex = 0; audioelementIndex<ratings[audioholderIndex].length; audioelementIndex++){
|
nickjillings@1404
|
571 if (ratings[audioholderIndex][audioelementIndex].length>0) { // if rating array not empty for this audioelement
|
nickjillings@1404
|
572 data_array = [
|
nickjillings@1404
|
573 audioelementArray[audioelementIndex], // name
|
nickjillings@1404
|
574 min[audioelementIndex], // minimum
|
nickjillings@1404
|
575 pctl75[audioelementIndex],
|
nickjillings@1404
|
576 pctl25[audioelementIndex],
|
nickjillings@1404
|
577 max[audioelementIndex], // maximum
|
nickjillings@1404
|
578 med[audioelementIndex]
|
nickjillings@1404
|
579 ];
|
nickjillings@1404
|
580 for (idx = 0; idx < max_n_outliers; idx++) {
|
nickjillings@1404
|
581 if (idx<outlierArray[audioelementIndex].length){
|
nickjillings@1404
|
582 data_array.push(outlierArray[audioelementIndex][idx]);
|
nickjillings@1404
|
583 }
|
nickjillings@1404
|
584 else {
|
nickjillings@1404
|
585 data_array.push(null);
|
nickjillings@1404
|
586 }
|
nickjillings@1404
|
587 }
|
nickjillings@1404
|
588 boxplot_data.push(data_array);
|
nickjillings@1404
|
589 }
|
nickjillings@1404
|
590 }
|
nickjillings@1404
|
591
|
nickjillings@1404
|
592 // Create and populate the data table.
|
nickjillings@1404
|
593 var data = google.visualization.arrayToDataTable(boxplot_data);
|
nickjillings@1404
|
594 // Create and draw the visualization.
|
nickjillings@1404
|
595 var ac = new google.visualization.ComboChart(document.getElementById('div_box_'+audioholderName));
|
nickjillings@1404
|
596 ac.draw(data, {
|
nickjillings@1404
|
597 title : audioholderName,
|
nickjillings@1404
|
598 //width: 600,
|
nickjillings@1404
|
599 //height: 400,
|
nickjillings@1404
|
600 vAxis: {title: "Rating"},
|
nickjillings@1404
|
601 hAxis: {title: "audioelement ID"},
|
nickjillings@1404
|
602 seriesType: "line",
|
nickjillings@1404
|
603 pointSize: 5,
|
nickjillings@1404
|
604 lineWidth: 0,
|
nickjillings@1404
|
605 colors: ['black'],
|
nickjillings@1404
|
606 series: { 0: {type: "candlesticks", color: 'blue'}, // box plot shape
|
nickjillings@1404
|
607 1: {type: "line", pointSize: 10, lineWidth: 0, color: 'red' } }, // median
|
nickjillings@1404
|
608 legend: 'none'
|
nickjillings@1404
|
609 });
|
nickjillings@1404
|
610 }
|
nickjillings@1404
|
611 }
|
nickjillings@1404
|
612
|
nickjillings@1404
|
613 function makeTimeline(xmlFileName){ // WIP
|
nickjillings@1404
|
614 // Based on the XML file name, take time data and plot playback and marker movements
|
nickjillings@1404
|
615
|
nickjillings@1404
|
616 // read XML file and check if exists
|
nickjillings@1404
|
617 xml = readXML(xmlFileName);
|
nickjillings@1404
|
618 if (!xml) { // if file does not exist
|
nickjillings@1404
|
619 console.log('XML file '+xml+'does not exist. ('+xmlFileName+')')
|
nickjillings@1404
|
620 return; // do nothing; exit function
|
nickjillings@1404
|
621 }
|
nickjillings@1404
|
622 // get root of XML file
|
nickjillings@1404
|
623 root = xml.getElementsByTagName('browserevaluationresult')[0];
|
nickjillings@1404
|
624
|
nickjillings@1404
|
625 audioholder_time = 0;
|
nickjillings@1404
|
626 previous_audioholder_time = 0; // time spent before current audioholder
|
nickjillings@1404
|
627 time_offset = 0; // test starts at zero
|
nickjillings@1404
|
628
|
nickjillings@1404
|
629 // go over all audioholders
|
nickjillings@1404
|
630 audioholderNodes = root.getElementsByTagName('audioholder');
|
nickjillings@1404
|
631 for (audioholderIndex = 0; audioholderIndex < audioholderNodes.length; audioholderIndex++) {
|
nickjillings@1404
|
632 audioholderName = audioholderNodes[audioholderIndex].getAttribute('id');
|
nickjillings@1404
|
633 if (!audioholderName) {
|
nickjillings@1404
|
634 console.log('audioholder name is empty; go to next one. ('+xmlFileName+')');
|
nickjillings@1404
|
635 break;
|
nickjillings@1404
|
636 }
|
nickjillings@1404
|
637
|
nickjillings@1404
|
638 // subtract total audioholder length from subsequent audioholder event times
|
nickjillings@1404
|
639 audioholder_children = audioholderNodes[audioholderIndex].childNodes;
|
nickjillings@1404
|
640 foundIt = false;
|
nickjillings@1404
|
641 console.log(audioholder_children[2].getElementsByTagName("metricResult")) // not working!
|
nickjillings@1404
|
642 for (idx = 0; idx<audioholder_children.length; idx++) { // go over children
|
nickjillings@1404
|
643
|
nickjillings@1404
|
644 if (audioholder_children[idx].getElementsByTagName('metricResult').length) {
|
nickjillings@1404
|
645 console.log(audioholder_children[idx].getElementsByTagName('metricResult')[0]);
|
nickjillings@1404
|
646 if (audioholder_children[idx].getElementsByTagName('metricResult')[0].getAttribute('id') == "testTime"){
|
nickjillings@1404
|
647 audioholder_time = parseFloat(audioholder_children[idx].getElementsByTagName('metricResult')[0].textContent);
|
nickjillings@1404
|
648 console.log(audioholder_time);
|
nickjillings@1404
|
649 foundIt = true;
|
nickjillings@1404
|
650 }
|
nickjillings@1404
|
651 }
|
nickjillings@1404
|
652 }
|
nickjillings@1404
|
653 if (!foundIt) {
|
nickjillings@1404
|
654 console.log("Skipping audioholder without total time specified from "+xmlFileName+"."); // always hitting this
|
nickjillings@1404
|
655 break;
|
nickjillings@1404
|
656 }
|
nickjillings@1404
|
657
|
nickjillings@1404
|
658 audioelementNodes = audioholderNodes[audioholderIndex].getElementsByTagName('audioelement');
|
nickjillings@1404
|
659
|
nickjillings@1404
|
660 // make div
|
nickjillings@1404
|
661
|
nickjillings@1404
|
662 // draw chart
|
nickjillings@1404
|
663
|
nickjillings@1404
|
664 // legend with audioelement names
|
nickjillings@1404
|
665 }
|
nickjillings@1404
|
666 }
|
nickjillings@1404
|
667
|
nickjillings@1404
|
668 </script>
|
nickjillings@1404
|
669
|
nickjillings@1404
|
670
|
nickjillings@1404
|
671
|
nickjillings@1404
|
672 <style>
|
nickjillings@1404
|
673 div {
|
nickjillings@1404
|
674 padding: 2px;
|
nickjillings@1404
|
675 margin-top: 2px;
|
nickjillings@1404
|
676 margin-bottom: 2px;
|
nickjillings@1404
|
677 }
|
nickjillings@1404
|
678 div.head{
|
nickjillings@1404
|
679 margin-left: 10px;
|
nickjillings@1404
|
680 border: black;
|
nickjillings@1404
|
681 border-width: 2px;
|
nickjillings@1404
|
682 border-style: solid;
|
nickjillings@1404
|
683 }
|
nickjillings@1404
|
684 div.attrib{
|
nickjillings@1404
|
685 margin-left:25px;
|
nickjillings@1404
|
686 border: black;
|
nickjillings@1404
|
687 border-width: 2px;
|
nickjillings@1404
|
688 border-style: dashed;
|
nickjillings@1404
|
689 margin-bottom: 10px;
|
nickjillings@1404
|
690 }
|
nickjillings@1404
|
691 div#headerMatter{
|
nickjillings@1404
|
692 background-color: #FFFFCC;
|
nickjillings@1404
|
693 }
|
nickjillings@1404
|
694 div#currentStatement{
|
nickjillings@1404
|
695 font-size:3.0em;
|
nickjillings@1404
|
696 font-weight: bold;
|
nickjillings@1404
|
697
|
nickjillings@1404
|
698 }
|
nickjillings@1404
|
699 div#debugDisplay {
|
nickjillings@1404
|
700 color: #CCCCCC;
|
nickjillings@1404
|
701 font-size:0.3em;
|
nickjillings@1404
|
702 }
|
nickjillings@1404
|
703 span#scoreDisplay {
|
nickjillings@1404
|
704 font-weight: bold;
|
nickjillings@1404
|
705 }
|
nickjillings@1404
|
706 div#wrapper {
|
nickjillings@1404
|
707 width: 780px;
|
nickjillings@1404
|
708 border: 1px solid black;
|
nickjillings@1404
|
709 overflow: hidden; /* add this to contain floated children */
|
nickjillings@1404
|
710 }
|
nickjillings@1404
|
711 div#instrumentSection {
|
nickjillings@1404
|
712 width: 250px;
|
nickjillings@1404
|
713 border: 1px solid red;
|
nickjillings@1404
|
714 display: inline-block;
|
nickjillings@1404
|
715 }
|
nickjillings@1404
|
716 div#featureSection {
|
nickjillings@1404
|
717 width: 250px;
|
nickjillings@1404
|
718 border: 1px solid green;
|
nickjillings@1404
|
719 display: inline-block;
|
nickjillings@1404
|
720 }
|
nickjillings@1404
|
721 div#valenceSection {
|
nickjillings@1404
|
722 width: 250px;
|
nickjillings@1404
|
723 border: 1px solid blue;
|
nickjillings@1404
|
724 display: inline-block;
|
nickjillings@1404
|
725 }
|
nickjillings@1404
|
726 button#previousComment{
|
nickjillings@1404
|
727 width: 120px;
|
nickjillings@1404
|
728 height: 150px;
|
nickjillings@1404
|
729 font-size:1.5em;
|
nickjillings@1404
|
730 }
|
nickjillings@1404
|
731 button#nextComment{
|
nickjillings@1404
|
732 width: 666px;
|
nickjillings@1404
|
733 height: 150px;
|
nickjillings@1404
|
734 font-size:1.5em;
|
nickjillings@1404
|
735 }
|
nickjillings@1404
|
736 ul
|
nickjillings@1404
|
737 {
|
nickjillings@1404
|
738 list-style-type: none; /* no bullet points */
|
nickjillings@1404
|
739 margin-left: -20px; /* less indent */
|
nickjillings@1404
|
740 margin-top: 0px;
|
nickjillings@1404
|
741 margin-bottom: 5px;
|
nickjillings@1404
|
742 }
|
nickjillings@1404
|
743 </style>
|
nickjillings@1404
|
744
|
nickjillings@1404
|
745 </head>
|
nickjillings@1404
|
746
|
nickjillings@1404
|
747 <body>
|
nickjillings@1404
|
748 <h1>Subjective evaluation results</h1>
|
nickjillings@1404
|
749
|
nickjillings@1404
|
750 <div id="debugDisplay">
|
nickjillings@1404
|
751 XML file folder: <span id="xmlFileFolder_span"></span>
|
nickjillings@1404
|
752 </div>
|
nickjillings@1404
|
753
|
nickjillings@1404
|
754 <div id="headerMatter">
|
nickjillings@1404
|
755 <div>
|
nickjillings@1404
|
756 <strong>Result XML files:</strong> <span id="numberOfFiles_span"></span>
|
nickjillings@1404
|
757 </div>
|
nickjillings@1404
|
758 <div>
|
nickjillings@1404
|
759 <strong>Audioholders in dataset:</strong> <span id="audioholderArray_span"></span>
|
nickjillings@1404
|
760 </div>
|
nickjillings@1404
|
761 <div>
|
nickjillings@1404
|
762 <strong>Subjects in dataset:</strong> <span id="subjectArray_span"></span>
|
nickjillings@1404
|
763 </div>
|
nickjillings@1404
|
764 <div>
|
nickjillings@1404
|
765 <strong>Audioelements in dataset:</strong> <span id="audioelementArray_span"></span>
|
nickjillings@1404
|
766 </div>
|
nickjillings@1404
|
767 <br>
|
nickjillings@1404
|
768 </div>
|
nickjillings@1404
|
769 <br>
|
nickjillings@1404
|
770
|
nickjillings@1404
|
771 <!-- Show time elapsed
|
nickjillings@1404
|
772 The last annotation took <strong><span id="timeDisplay">(N/A)</span></strong> seconds.
|
nickjillings@1404
|
773 <br>-->
|
nickjillings@1404
|
774
|
nickjillings@1404
|
775 </body>
|
nickjillings@1404
|
776 </html>
|