n@280
|
1 <!DOCTYPE html>
|
n@280
|
2 <html lang="en">
|
n@280
|
3 <head>
|
n@280
|
4 <meta charset="utf-8">
|
n@280
|
5
|
n@280
|
6 <!-- Always force latest IE rendering engine (even in intranet) & Chrome Frame
|
n@280
|
7 Remove this if you use the .htaccess -->
|
n@280
|
8 <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
n@280
|
9
|
n@280
|
10 <title>test_create_2</title>
|
n@280
|
11 <meta name="description" content="">
|
n@280
|
12 <meta name="author" content="Nicholas">
|
n@280
|
13
|
n@280
|
14 <meta name="viewport" content="width=device-width; initial-scale=1.0">
|
n@280
|
15
|
n@280
|
16 <script type="text/javascript">
|
n@280
|
17 window.onload = function() {
|
n@280
|
18 var dropBody = document.getElementById('dragFile');
|
n@280
|
19 dropBody.addEventListener('dragover', handleDragOver, false);
|
n@280
|
20 dropBody.addEventListener('dragenter',handleDragEnter,false);
|
n@280
|
21 dropBody.addEventListener('dragleave',handleDragLeave,false);
|
n@280
|
22 dropBody.addEventListener('drop', handleDrop,false);
|
n@280
|
23 };
|
n@280
|
24
|
n@280
|
25 function handleDragOver(e) {
|
n@280
|
26 e.stopPropagation();
|
n@280
|
27 e.preventDefault();
|
n@280
|
28 }
|
n@280
|
29 function handleDragEnter(e) {
|
n@280
|
30 e.stopPropagation();
|
n@280
|
31 e.preventDefault();
|
n@280
|
32 this.style.backgroundColor = '#AAFFAA';
|
n@280
|
33 }
|
n@280
|
34 function handleDragLeave(e) {
|
n@280
|
35 e.stopPropagation();
|
n@280
|
36 e.preventDefault();
|
n@280
|
37 this.style.backgroundColor = "#FFFFFF";
|
n@280
|
38 }
|
n@280
|
39 function handleDrop(e) {
|
n@280
|
40 e.stopPropagation();
|
n@280
|
41 e.preventDefault();
|
n@280
|
42
|
n@280
|
43 var file = e.dataTransfer.files[0];
|
n@280
|
44
|
n@280
|
45 // Uses HTML5 FileAPI - https://w3c.github.io/FileAPI/#filereader-interface
|
n@280
|
46 var reader = new FileReader();
|
n@280
|
47 reader.onload = function() {
|
n@280
|
48 var parse = new DOMParser();
|
n@280
|
49 var xml = parse.parseFromString(reader.result,'text/xml');
|
n@280
|
50 importXML(xml);
|
n@280
|
51 };
|
n@280
|
52 reader.readAsText(file);
|
n@280
|
53
|
n@280
|
54 }
|
n@280
|
55
|
n@280
|
56 function removeNode(event) {
|
n@280
|
57 event.srcElement.parentElement.parentElement.removeChild(event.srcElement.parentElement);
|
n@280
|
58 }
|
n@280
|
59
|
n@280
|
60 function removeNodeButton()
|
n@280
|
61 {
|
n@280
|
62 var button = document.createElement('button');
|
n@280
|
63 button.textContent = 'Remove';
|
n@280
|
64 button.onclick = function(event){removeNode(event);};
|
n@280
|
65 return button;
|
n@280
|
66 }
|
n@280
|
67
|
n@280
|
68 function attributePair(type,text,name,mandatory)
|
n@280
|
69 {
|
n@280
|
70 var node = document.createElement('div');
|
n@280
|
71 node.setAttribute('name','attribute');
|
n@280
|
72 var span = document.createElement('span');
|
n@280
|
73 span.textContent = text;
|
n@280
|
74 var input = document.createElement('input');
|
n@280
|
75 input.type = type;
|
n@280
|
76 input.setAttribute('attrib-name',name);
|
n@280
|
77 input.setAttribute('mandatory',mandatory);
|
n@280
|
78 node.appendChild(span);
|
n@280
|
79 node.appendChild(input);
|
n@280
|
80 return node;
|
n@280
|
81 }
|
n@280
|
82
|
n@280
|
83 function buttonClickedValidate()
|
n@280
|
84 {
|
n@280
|
85 var allInputs = document.getElementsByTagName('input');
|
n@280
|
86 for (var i=0; i<allInputs.length; i++)
|
n@280
|
87 {goodNode(allInputs[i]);}
|
n@280
|
88 var errList = document.getElementById('errorMessage');
|
n@280
|
89 errList.innerHTML = "";
|
n@280
|
90 validate(document.getElementById('topLevelBody'));
|
n@280
|
91 var submit = document.getElementById('createXML');
|
n@280
|
92 if (errList.innerHTML == "")
|
n@280
|
93 {submit.disabled = false;}
|
n@280
|
94 else {submit.disabled = true;}
|
n@280
|
95 }
|
n@280
|
96
|
n@280
|
97 function validate(node)
|
n@280
|
98 {
|
n@280
|
99 var name = node.getAttribute('name');
|
n@280
|
100 if (name != 'attribute' && name != 'element') {
|
n@280
|
101 var child = node.children;
|
n@280
|
102 for (var i=0; i<node.childElementCount; i++)
|
n@280
|
103 {
|
n@280
|
104 if (child[i].nodeName == "DIV")
|
n@280
|
105 {
|
n@280
|
106 validate(child[i]);
|
n@280
|
107 }
|
n@280
|
108 }
|
n@280
|
109 } else if (name == 'attribute')
|
n@280
|
110 {
|
n@280
|
111 var child = node.children;
|
n@280
|
112 for (var i=0; i<node.childElementCount; i++)
|
n@280
|
113 {
|
n@280
|
114 if (child[i].nodeName == "INPUT")
|
n@280
|
115 {
|
n@280
|
116 var mandatory = child[i].getAttribute('mandatory');
|
n@280
|
117 if (mandatory == 'true') {mandatory = true;}
|
n@280
|
118 else {mandatory = false;}
|
n@280
|
119 if (child[i].type =='text' || child[i].type =='number')
|
n@280
|
120 {
|
n@280
|
121 if (child[i].value.length == 0)
|
n@280
|
122 {
|
n@280
|
123 if (mandatory == true) {errorNode(child[i]);}
|
n@280
|
124 else {warningNode(child[i]);}
|
n@280
|
125 } else {goodNode(child[i]);}
|
n@280
|
126 }
|
n@280
|
127 }
|
n@280
|
128 }
|
n@280
|
129 } else if (name == 'element')
|
n@280
|
130 {
|
n@280
|
131 var child = node.children;
|
n@280
|
132 for (var i=0; i<node.childElementCount; i++)
|
n@280
|
133 {
|
n@280
|
134 if (child[i].nodeName == "INPUT")
|
n@280
|
135 {
|
n@280
|
136 if (child[i].value.length == 0){warningNode(child[i]);}
|
n@280
|
137 else {goodNode(child[i]);}
|
n@280
|
138 }
|
n@280
|
139 }
|
n@280
|
140 }
|
n@280
|
141 }
|
n@280
|
142
|
n@280
|
143 function buttonClickedSubmit()
|
n@280
|
144 {
|
n@280
|
145 var xml = document.createElement('BrowserEvalProjectDocument');
|
n@280
|
146 var dom = document.getElementById('topLevelBody');
|
n@280
|
147 xml = extractXML(xml,dom);
|
n@280
|
148 var drop = document.getElementById('errorMessage');
|
n@280
|
149 createProjectSave(xml,drop);
|
n@280
|
150 }
|
n@280
|
151
|
n@280
|
152 function createProjectSave(xmlDoc, injectPoint) {
|
n@280
|
153 var parent = document.createElement("div");
|
n@280
|
154 parent.appendChild(xmlDoc);
|
n@280
|
155 var file = [parent.innerHTML];
|
n@280
|
156 var bb = new Blob(file,{type : 'application/xml'});
|
n@280
|
157 var dnlk = window.URL.createObjectURL(bb);
|
n@280
|
158 var a = document.createElement("a");
|
n@280
|
159 a.hidden = '';
|
n@280
|
160 a.href = dnlk;
|
n@280
|
161 a.download = "save.xml";
|
n@280
|
162 a.textContent = "Save File";
|
n@280
|
163 injectPoint.appendChild(a);
|
n@280
|
164 }
|
n@280
|
165
|
n@280
|
166 function extractXML(xml,node)
|
n@280
|
167 {
|
n@280
|
168 if(node.getAttribute('class')=='attrib')
|
n@280
|
169 {
|
n@280
|
170 var children = node.children;
|
n@280
|
171 for (var i=0; i<children.length; i++)
|
n@280
|
172 {
|
n@280
|
173 if (children[i].getAttribute('name')=='attribute')
|
n@280
|
174 {
|
n@280
|
175 var input = children[i].children[1];
|
n@280
|
176 if (input.type == 'checkbox')
|
n@280
|
177 {
|
n@280
|
178 xml.setAttribute(input.getAttribute('attrib-name'),input.checked);
|
n@280
|
179 } else {
|
n@280
|
180 xml.setAttribute(input.getAttribute('attrib-name'),input.value);
|
n@280
|
181 }
|
n@280
|
182 } else if (children[i].getAttribute('name') == 'element')
|
n@280
|
183 {
|
n@280
|
184 var input = children[i].children[1];
|
n@280
|
185 xml.textContent = input.value;
|
n@280
|
186 }
|
n@280
|
187 }
|
n@280
|
188 return xml;
|
n@280
|
189 } else if (node.getAttribute('node-name') != undefined)
|
n@280
|
190 {
|
n@280
|
191 var xmlDom = document.createElement(node.getAttribute('node-name'));
|
n@280
|
192 xml.appendChild(xmlDom);
|
n@280
|
193 var children = node.children;
|
n@280
|
194 for (var i=0; i<children.length; i++)
|
n@280
|
195 {
|
n@280
|
196 if (children[i].nodeName == "DIV")
|
n@280
|
197 {
|
n@280
|
198 xmlDom = extractXML(xmlDom,children[i]);
|
n@280
|
199 }
|
n@280
|
200 }
|
n@280
|
201 } else {
|
n@280
|
202 var children = node.children;
|
n@280
|
203 for (var i=0; i<children.length; i++)
|
n@280
|
204 {
|
n@280
|
205 if (children[i].nodeName == "DIV")
|
n@280
|
206 {
|
n@280
|
207 xml = extractXML(xml,children[i]);
|
n@280
|
208 }
|
n@280
|
209 }
|
n@280
|
210 }
|
n@280
|
211 return xml;
|
n@280
|
212 }
|
n@280
|
213
|
n@280
|
214 function goodNode(node)
|
n@280
|
215 {node.style.backgroundColor="#FFFFFF";}
|
n@280
|
216
|
n@280
|
217 function warningNode(node)
|
n@280
|
218 {node.style.backgroundColor="#FFFF88";}
|
n@280
|
219
|
n@280
|
220 function errorNode(node)
|
n@280
|
221 {
|
n@280
|
222 var errLog = document.getElementById('errorMessage');
|
n@280
|
223 var div = document.createElement('div');
|
n@280
|
224 var span = document.createElement('span');
|
n@280
|
225 span.textContent = 'Invalid Data: ';
|
n@280
|
226 var list = [node.getAttribute('attrib-name')];
|
n@280
|
227 var pNode = node;
|
n@280
|
228 while (pNode.id != 'topLevelBody')
|
n@280
|
229 {
|
n@280
|
230 if (pNode.getAttribute('node-name') != undefined)
|
n@280
|
231 {list.push(pNode.getAttribute('node-name'));}
|
n@280
|
232 pNode = pNode.parentElement;
|
n@280
|
233 }
|
n@280
|
234 for (var i=list.length-1; i>=0; i--)
|
n@280
|
235 {
|
n@280
|
236 span.textContent = span.textContent +' ->'+ list[i];
|
n@280
|
237 }
|
n@280
|
238 div.appendChild(span);
|
n@280
|
239 errLog.appendChild(div);
|
n@280
|
240 errLog.style.visibility = 'visible';
|
n@280
|
241 node.style.backgroundColor="#FF0000";
|
n@280
|
242 }
|
n@280
|
243
|
n@280
|
244 function importXML(xml)
|
n@280
|
245 {
|
n@280
|
246 xml = xml.children[0];
|
n@280
|
247 var setup = xml.getElementsByTagName('setup')[0];
|
n@280
|
248 var DOM = document.getElementById('setup');
|
n@280
|
249 // Insert any setup node attributes
|
n@280
|
250 setAttributes(DOM,setup);
|
n@280
|
251
|
n@280
|
252 for (var i=0; i<setup.childElementCount; i++)
|
n@280
|
253 {
|
n@280
|
254 var node = DOM.getElementsByClassName(setup.children[i].nodeName);
|
n@280
|
255 if (node.length != 0)
|
n@280
|
256 {
|
n@280
|
257 node = node[0];
|
n@280
|
258 setAttributes(node,setup.children[i]);
|
n@280
|
259 buildNode(node,setup.children[i]);
|
n@280
|
260 }
|
n@280
|
261 }
|
n@280
|
262
|
n@280
|
263 var holders = xml.getElementsByTagName('audioHolder');
|
n@280
|
264 for (var i=0; i<holders.length; i++)
|
n@280
|
265 {
|
n@280
|
266 var node = addAudioHolder();
|
n@280
|
267 document.getElementById('topLevelBody').appendChild(node);
|
n@280
|
268 setAttributes(node,holders[i]);
|
n@280
|
269 buildNode(node,holders[i]);
|
n@280
|
270 }
|
n@280
|
271 }
|
n@280
|
272
|
n@280
|
273 function setAttributes(node,xml)
|
n@280
|
274 {
|
n@280
|
275 var attribs = node.getElementsByClassName('attrib');
|
n@280
|
276 if (attribs.length != 0){
|
n@280
|
277 attribs = attribs[0];
|
n@280
|
278 for (var i=0; i < attribs.children.length; i++)
|
n@280
|
279 {
|
n@280
|
280 if(attribs.children[i].getAttribute('name')=='attribute'){
|
n@280
|
281 var input = attribs.children[i].children[1];
|
n@280
|
282 var value = xml.attributes.getNamedItem(input.getAttribute('attrib-name'));
|
n@280
|
283 if (value != undefined) {value = value.value;}
|
n@280
|
284 if (input.type == 'checkbox')
|
n@280
|
285 {input.checked = value;}
|
n@280
|
286 else
|
n@280
|
287 {input.value = value;}
|
n@280
|
288 } else if(attribs.children[i].getAttribute('name')=='element'){
|
n@280
|
289 var input = attribs.children[i].children[1];
|
n@280
|
290 input.value = xml.textContent;
|
n@280
|
291 }
|
n@280
|
292 }
|
n@280
|
293 }
|
n@280
|
294 }
|
n@280
|
295
|
n@280
|
296 function buildNode(parent,xml)
|
n@280
|
297 {
|
n@280
|
298 for (var i=0; i<xml.childElementCount; i++)
|
n@280
|
299 {
|
n@280
|
300 var child = xml.children[i];
|
n@280
|
301 var name = child.nodeName;
|
n@280
|
302 var node = null;
|
n@280
|
303 if (name == 'statement'){node = addPPStatement();}
|
n@280
|
304 else if (name == 'question' || name == 'number'){node = addPPQuestion();}
|
n@280
|
305 else if (name == 'checkbox'){node = addPPCheckbox();}
|
n@280
|
306 else if (name == 'radio'){node = addPPRadio();}
|
n@280
|
307 else if (name == 'metricEnable'){node = addMetricEnable();}
|
n@280
|
308 else if (name == 'check'){node = addInterfaceCheck();}
|
n@280
|
309 else if (name == 'option'){node = addInterfaceOption();}
|
n@280
|
310 else if (name == 'scale'){node = addScaleMarker();}
|
n@280
|
311 else if (name == 'audioHolder'){node = addAudioHolder();}
|
n@280
|
312 else if (name == 'audioElements'){node = addAudioElement();}
|
n@280
|
313 else if (name == 'commentQuestion'){node = addExtraComment();}
|
n@280
|
314 else if (name == 'interface'){node = parent.getElementsByClassName('interface')[0];}
|
n@280
|
315 else if (name == 'preTest' || name == 'PreTest')
|
n@280
|
316 {
|
n@280
|
317 node = parent.getElementsByClassName('preTest')[0];
|
n@280
|
318 }
|
n@280
|
319 else if (name == 'postTest' || name == 'PostTest')
|
n@280
|
320 {
|
n@280
|
321 node = parent.getElementsByClassName('postTest')[0];
|
n@280
|
322 }
|
n@280
|
323 else if (name == 'title' || name == 'commentBoxPrefix')
|
n@280
|
324 {
|
n@280
|
325 node = parent.getElementsByClassName(name)[0];
|
n@280
|
326 }
|
n@280
|
327 if (node != null) {
|
n@280
|
328 if (name == 'radio' || name == 'checkbox')
|
n@280
|
329 {
|
n@280
|
330 buildRadio(node,xml.children[i]);
|
n@280
|
331 parent.appendChild(node);
|
n@280
|
332 } else
|
n@280
|
333 {
|
n@280
|
334 setAttributes(node,child);
|
n@280
|
335 parent.appendChild(node);
|
n@280
|
336 buildNode(node,child);
|
n@280
|
337 }
|
n@280
|
338 } else {
|
n@280
|
339 var node = createHead(name,name,'h3');
|
n@280
|
340
|
n@280
|
341 var attrib = document.createElement('div');
|
n@280
|
342 attrib.className = 'attrib';
|
n@280
|
343 for (var j=0; j<child.attributes.length; j++)
|
n@280
|
344 {
|
n@280
|
345 attrib.appendChild(attributePair('text',child.attributes[j].name,child.attributes[j].name,false));
|
n@280
|
346 }
|
n@280
|
347
|
n@280
|
348 node.appendChild(attrib);
|
n@280
|
349 parent.appendChild(node);
|
n@280
|
350 setAttributes(node,child);
|
n@280
|
351 /*
|
n@280
|
352 buildNode(node,child);
|
n@280
|
353 */
|
n@280
|
354 }
|
n@280
|
355 }
|
n@280
|
356 }
|
n@280
|
357
|
n@280
|
358 function buildRadio(node,xml)
|
n@280
|
359 {
|
n@280
|
360 setAttributes(node,xml);
|
n@280
|
361 setAttributes(node.getElementsByClassName('statement')[0],xml.getElementsByTagName('statement')[0]);
|
n@280
|
362 var options = xml.getElementsByTagName('option');
|
n@280
|
363 var addOptionButton = node.getElementsByTagName('button')[2];
|
n@280
|
364 for (var i=0; i<options.length; i++)
|
n@280
|
365 {
|
n@280
|
366 addOptionButton.click();
|
n@280
|
367 setAttributes(node.getElementsByClassName('option')[i],options[i]);
|
n@280
|
368 }
|
n@280
|
369 }
|
n@280
|
370
|
n@280
|
371 function createHead(name,title,size)
|
n@280
|
372 {
|
n@280
|
373 var node = document.createElement('div');
|
n@280
|
374 node.setAttribute('class','head '+name);
|
n@280
|
375 node.setAttribute('node-name',name);
|
n@280
|
376 if (size == undefined)
|
n@280
|
377 {var node_T = document.createElement('h3');}
|
n@280
|
378 else{var node_T = document.createElement(size);}
|
n@280
|
379 node_T.textContent = title;
|
n@280
|
380 node.appendChild(node_T);
|
n@280
|
381 node.appendChild(removeNodeButton());
|
n@280
|
382 return node;
|
n@280
|
383 }
|
n@280
|
384
|
n@280
|
385 function addPretestNode()
|
n@280
|
386 {
|
n@280
|
387 var node = createHead('preTest', 'Pre Test','h3');
|
n@280
|
388 var addStatement = document.createElement('button');
|
n@280
|
389 addStatement.textContent = 'Add Statement';
|
n@280
|
390 addStatement.onclick = function(){event.srcElement.parentElement.appendChild(addPPStatement());};
|
n@280
|
391 node.appendChild(addStatement);
|
n@280
|
392 var addQuestion = document.createElement('button');
|
n@280
|
393 addQuestion.textContent = 'Add Question';
|
n@280
|
394 addQuestion.onclick = function(){event.srcElement.parentElement.appendChild(addPPQuestion());};
|
n@280
|
395 node.appendChild(addQuestion);
|
n@280
|
396 var addCheckbox = document.createElement('button');
|
n@280
|
397 addCheckbox.textContent = 'Add Checkbox';
|
n@280
|
398 addCheckbox.onclick = function(){event.srcElement.parentElement.appendChild(addPPCheckbox());};
|
n@280
|
399 node.appendChild(addCheckbox);
|
n@280
|
400 var addRadio = document.createElement('button');
|
n@280
|
401 addRadio.textContent = 'Add Checkbox';
|
n@280
|
402 addRadio.onclick = function(){event.srcElement.parentElement.appendChild(addPPRadio());};
|
n@280
|
403 node.appendChild(addRadio);
|
n@280
|
404 return node;
|
n@280
|
405 };
|
n@280
|
406
|
n@280
|
407 function addPosttestNode()
|
n@280
|
408 {
|
n@280
|
409 var node = createHead('postTest', 'Post Test','h3');
|
n@280
|
410 var addStatement = document.createElement('button');
|
n@280
|
411 addStatement.textContent = 'Add Statement';
|
n@280
|
412 addStatement.onclick = function(){event.srcElement.parentElement.appendChild(addPPStatement());};
|
n@280
|
413 node.appendChild(addStatement);
|
n@280
|
414 var addQuestion = document.createElement('button');
|
n@280
|
415 addQuestion.textContent = 'Add Question';
|
n@280
|
416 addQuestion.onclick = function(){event.srcElement.parentElement.appendChild(addPPQuestion());};
|
n@280
|
417 node.appendChild(addQuestion);
|
n@280
|
418 var addCheckbox = document.createElement('button');
|
n@280
|
419 addCheckbox.textContent = 'Add Checkbox';
|
n@280
|
420 addCheckbox.onclick = function(){event.srcElement.parentElement.appendChild(addPPCheckbox());};
|
n@280
|
421 node.appendChild(addCheckbox);
|
n@280
|
422 var addRadio = document.createElement('button');
|
n@280
|
423 addRadio.textContent = 'Add Checkbox';
|
n@280
|
424 addRadio.onclick = function(){event.srcElement.parentElement.appendChild(addPPRadio());};
|
n@280
|
425 node.appendChild(addRadio);
|
n@280
|
426 return node;
|
n@280
|
427 };
|
n@280
|
428
|
n@280
|
429 function addPPStatement()
|
n@280
|
430 {
|
n@280
|
431 var node = createHead('statement', 'Statement','h4');
|
n@280
|
432 var attrib = document.createElement('div');
|
n@280
|
433 attrib.className = "attrib";
|
n@280
|
434 var element = document.createElement('div');
|
n@280
|
435 element.setAttribute('name','element');
|
n@280
|
436 var span = document.createElement('span');
|
n@280
|
437 span.textContent = "Enter statement: ";
|
n@280
|
438 element.appendChild(span);
|
n@280
|
439 var input = document.createElement('input');
|
n@280
|
440 input.type = "text";
|
n@280
|
441 input.style.width = "500px";
|
n@280
|
442 element.appendChild(input);
|
n@280
|
443 attrib.appendChild(element);
|
n@280
|
444 node.appendChild(attrib);
|
n@280
|
445 return node;
|
n@280
|
446 };
|
n@280
|
447 function addPPQuestion()
|
n@280
|
448 {
|
n@280
|
449 var node = createHead('question', 'Question','h4');
|
n@280
|
450 var attrib = document.createElement('div');
|
n@280
|
451 attrib.className = "attrib";
|
n@280
|
452 attrib.appendChild(attributePair('text','ID: ','id',true));
|
n@280
|
453 attrib.appendChild(attributePair('checkbox','Mandatory: ','mandatory',false));
|
n@280
|
454 attrib.appendChild(attributePair('text','Box size: ','boxsize',false));
|
n@280
|
455 var element = document.createElement('div');
|
n@280
|
456 element.setAttribute('name','element');
|
n@280
|
457 var span = document.createElement('span');
|
n@280
|
458 span.textContent = "Enter Question: ";
|
n@280
|
459 element.appendChild(span);
|
n@280
|
460 var input = document.createElement('input');
|
n@280
|
461 input.type = "text";
|
n@280
|
462 input.style.width = "500px";
|
n@280
|
463 element.appendChild(input);
|
n@280
|
464 attrib.appendChild(element);
|
n@280
|
465 node.appendChild(attrib);
|
n@280
|
466 return node;
|
n@280
|
467 };
|
n@280
|
468 function addPPCheckbox()
|
n@280
|
469 {
|
n@280
|
470 var node = createHead('checkbox', 'Checkbox','h4');
|
n@280
|
471 var attrib = document.createElement('div');
|
n@280
|
472 attrib.className = "attrib";
|
n@280
|
473 attrib.appendChild(attributePair('text','ID: ','id',true));
|
n@280
|
474 attrib.appendChild(attributePair('checkbox','Mandatory: ','mandatory',false));
|
n@280
|
475 node.appendChild(attrib);
|
n@280
|
476 node.appendChild(addPPStatement());
|
n@280
|
477 var addOption = document.createElement('button');
|
n@280
|
478 addOption.textContent = 'Add Checkbox';
|
n@280
|
479 addOption.onclick = function() {
|
n@280
|
480 var node = createHead('option', 'Option','h4');
|
n@280
|
481 var attrib = document.createElement('div');
|
n@280
|
482 attrib.className = "attrib";
|
n@280
|
483 attrib.appendChild(attributePair('text','ID: ','id',true));
|
n@280
|
484 var element = document.createElement('div');
|
n@280
|
485 element.setAttribute('name','element');
|
n@280
|
486 var span = document.createElement('span');
|
n@280
|
487 span.textContent = "Enter Text: ";
|
n@280
|
488 var input = document.createElement('input');
|
n@280
|
489 input.type = 'text';
|
n@280
|
490 element.appendChild(span);
|
n@280
|
491 element.appendChild(input);
|
n@280
|
492 attrib.appendChild(element);
|
n@280
|
493 node.appendChild(attrib);
|
n@280
|
494 event.srcElement.parentElement.appendChild(node);
|
n@280
|
495 };
|
n@280
|
496 node.appendChild(addOption);
|
n@280
|
497 return node;
|
n@280
|
498 };
|
n@280
|
499
|
n@280
|
500 function addPPRadio()
|
n@280
|
501 {
|
n@280
|
502 var node = createHead('radio', 'Radio','h4');
|
n@280
|
503 var attrib = document.createElement('div');
|
n@280
|
504 attrib.className = "attrib";
|
n@280
|
505 attrib.appendChild(attributePair('text','ID: ','id',true));
|
n@280
|
506 attrib.appendChild(attributePair('checkbox','Mandatory: ','mandatory',false));
|
n@280
|
507 node.appendChild(attrib);
|
n@280
|
508 node.appendChild(addPPStatement());
|
n@280
|
509 var addOption = document.createElement('button');
|
n@280
|
510 addOption.textContent = 'Add Radio';
|
n@280
|
511 addOption.onclick = function() {
|
n@280
|
512 var node = createHead('option', 'Option','h4');
|
n@280
|
513 var attrib = document.createElement('div');
|
n@280
|
514 attrib.className = "attrib";
|
n@280
|
515 attrib.appendChild(attributePair('text','Name: ','name',true));
|
n@280
|
516 var element = document.createElement('div');
|
n@280
|
517 element.setAttribute('name','element');
|
n@280
|
518 var span = document.createElement('span');
|
n@280
|
519 span.textContent = "Enter Text: ";
|
n@280
|
520 var input = document.createElement('input');
|
n@280
|
521 input.type = 'text';
|
n@280
|
522 element.appendChild(span);
|
n@280
|
523 element.appendChild(input);
|
n@280
|
524 attrib.appendChild(element);
|
n@280
|
525 node.appendChild(attrib);
|
n@280
|
526 event.srcElement.parentElement.appendChild(node);
|
n@280
|
527 };
|
n@280
|
528 node.appendChild(addOption);
|
n@280
|
529 return node;
|
n@280
|
530 };
|
n@280
|
531
|
n@280
|
532 function addMetricEnable()
|
n@280
|
533 {
|
n@280
|
534 var node = createHead('metricEnable', '','h4');
|
n@280
|
535 var attrib = document.createElement('div');
|
n@280
|
536 attrib.className = "attrib";
|
n@280
|
537 var element = document.createElement('div');
|
n@280
|
538 element.setAttribute('name','element');
|
n@280
|
539 var span = document.createElement('span');
|
n@280
|
540 span.textContent = "Enter Metric Name: ";
|
n@280
|
541 element.appendChild(span);
|
n@280
|
542 var input = document.createElement('input');
|
n@280
|
543 input.type = "text";
|
n@280
|
544 input.style.width = "500px";
|
n@280
|
545 element.appendChild(input);
|
n@280
|
546 attrib.appendChild(element);
|
n@280
|
547 node.appendChild(attrib);
|
n@280
|
548 return node;
|
n@280
|
549 };
|
n@280
|
550
|
n@280
|
551 function addInterfaceCheck()
|
n@280
|
552 {
|
n@280
|
553 var node = createHead('check', 'Check','h4');
|
n@280
|
554 var attrib = document.createElement('div');
|
n@280
|
555 attrib.className = "attrib";
|
n@280
|
556 attrib.appendChild(attributePair('text','Name','name',true));
|
n@280
|
557 node.appendChild(attrib);
|
n@280
|
558 return node;
|
n@280
|
559 }
|
n@280
|
560 function addInterfaceOption()
|
n@280
|
561 {
|
n@280
|
562 var node = createHead('option', 'Option','h4');
|
n@280
|
563 var attrib = document.createElement('div');
|
n@280
|
564 attrib.className = "attrib";
|
n@280
|
565 attrib.appendChild(attributePair('text','Name','name',true));
|
n@280
|
566 node.appendChild(attrib);
|
n@280
|
567 return node;
|
n@280
|
568 }
|
n@280
|
569
|
n@280
|
570
|
n@280
|
571 function addAudioHolder()
|
n@280
|
572 {
|
n@280
|
573 var node = createHead('audioHolder','Audio Holder / Test Page','h2');
|
n@280
|
574 var attrib = document.createElement('div');
|
n@280
|
575 attrib.className = "attrib";
|
n@280
|
576 node.appendChild(attrib);
|
n@280
|
577
|
n@280
|
578 attrib.appendChild(attributePair('text','ID: ','id',true));
|
n@280
|
579 attrib.appendChild(attributePair('url','Host URL: ','hostURL',false));
|
n@280
|
580 attrib.appendChild(attributePair('number','Sample Rate: ','sampleRate',false));
|
n@280
|
581 attrib.appendChild(attributePair('checkbox','Randomise Fragment Order: ','randomiseOrder',false));
|
n@280
|
582 attrib.appendChild(attributePair('number','Repeat Count: ','repeatCount',false));
|
n@280
|
583 attrib.appendChild(attributePair('checkbox','Loop Fragments: ','loop',false));
|
n@280
|
584 attrib.appendChild(attributePair('checkbox','Fragment Comment Boxes: ','enableComments',false));
|
n@280
|
585
|
n@280
|
586 node.appendChild(addPretestNode());
|
n@280
|
587
|
n@280
|
588 node.appendChild(addPosttestNode());
|
n@280
|
589
|
n@280
|
590 var interfaceNode = createHead('interface','Interface','h3');
|
n@280
|
591 var addOption = document.createElement('button');
|
n@280
|
592 addOption.textContent = 'Add Option';
|
n@280
|
593 addOption.onclick = function(){event.srcElement.parentElement.appendChild(addInterfaceOption());};
|
n@280
|
594 interfaceNode.appendChild(addOption);
|
n@280
|
595 var scale = document.createElement('button');
|
n@280
|
596 scale.textContent = 'Add scale';
|
n@280
|
597 scale.onclick = function(){event.srcElement.parentElement.appendChild(addScaleMarker());};
|
n@280
|
598 interfaceNode.appendChild(scale);
|
n@280
|
599
|
n@280
|
600 var PageTitle = createHead('title','Page Title','h4');
|
n@280
|
601 var attrib = document.createElement('div');
|
n@280
|
602 attrib.className='attrib';
|
n@280
|
603 var element = document.createElement('div');
|
n@280
|
604 element.setAttribute('name','element');
|
n@280
|
605 var span = document.createElement('span');
|
n@280
|
606 span.textContent = 'Page Title: ';
|
n@280
|
607 element.appendChild(span);
|
n@280
|
608 var input = document.createElement('input');
|
n@280
|
609 input.type = 'text';
|
n@280
|
610 input.style.width = "500px";
|
n@280
|
611 element.appendChild(input);
|
n@280
|
612 attrib.appendChild(element);
|
n@280
|
613 PageTitle.appendChild(attrib);
|
n@280
|
614 interfaceNode.appendChild(PageTitle);
|
n@280
|
615
|
n@280
|
616 var commentBoxPrefix = createHead('commentBoxPrefix','Comment Box Prefix','h4');
|
n@280
|
617 var attrib = document.createElement('div');
|
n@280
|
618 attrib.className='attrib';
|
n@280
|
619 var element = document.createElement('div');
|
n@280
|
620 element.setAttribute('name','element');
|
n@280
|
621 var span = document.createElement('span');
|
n@280
|
622 span.textContent = 'Prefix: ';
|
n@280
|
623 element.appendChild(span);
|
n@280
|
624 var input = document.createElement('input');
|
n@280
|
625 input.type = 'text';
|
n@280
|
626 input.style.width = "500px";
|
n@280
|
627 element.appendChild(input);
|
n@280
|
628 attrib.appendChild(element);
|
n@280
|
629 commentBoxPrefix.appendChild(attrib);
|
n@280
|
630 interfaceNode.appendChild(commentBoxPrefix);
|
n@280
|
631
|
n@280
|
632 node.appendChild(interfaceNode);
|
n@280
|
633
|
n@280
|
634 var addElement = document.createElement('button');
|
n@280
|
635 addElement.textContent = 'Add Audio Element';
|
n@280
|
636 addElement.onclick = function(){event.srcElement.parentElement.appendChild(addAudioElement());};
|
n@280
|
637 node.appendChild(addElement);
|
n@280
|
638
|
n@280
|
639 var addCQ = document.createElement('button');
|
n@280
|
640 addCQ.textContent = 'Add Comment Box';
|
n@280
|
641 addCQ.onclick = function(){event.srcElement.parentElement.appendChild(addExtraComment());};
|
n@280
|
642 node.appendChild(addCQ);
|
n@280
|
643
|
n@280
|
644 return node;
|
n@280
|
645 };
|
n@280
|
646
|
n@280
|
647 function addScaleMarker(){
|
n@280
|
648 var node = createHead('scale','Scale','h4');
|
n@280
|
649 var attrib = document.createElement('div');
|
n@280
|
650 attrib.className = "attrib";
|
n@280
|
651 node.appendChild(attrib);
|
n@280
|
652 attrib.appendChild(attributePair('number','Position','position',true));
|
n@280
|
653 var element = document.createElement('div');
|
n@280
|
654 element.setAttribute('name','element');
|
n@280
|
655 var span = document.createElement('span');
|
n@280
|
656 span.textContent = 'Marker Text (Optional): ';
|
n@280
|
657 element.appendChild(span);
|
n@280
|
658 var input = document.createElement('input');
|
n@280
|
659 input.type = 'text';
|
n@280
|
660 element.appendChild(input);
|
n@280
|
661 attrib.appendChild(element);
|
n@280
|
662 return node;
|
n@280
|
663 };
|
n@280
|
664
|
n@280
|
665 function addAudioElement()
|
n@280
|
666 {
|
n@280
|
667 var node = createHead('audioElements','Audio Element');
|
n@280
|
668 var attrib = document.createElement('div');
|
n@280
|
669 attrib.className = "attrib";
|
n@280
|
670 node.appendChild(attrib);
|
n@280
|
671
|
n@280
|
672 attrib.appendChild(attributePair('text','ID: ','id',true));
|
n@280
|
673 attrib.appendChild(attributePair('text','URL: ','url',true));
|
n@280
|
674 attrib.appendChild(attributePair('text','Type: ','type',false));
|
n@280
|
675
|
n@280
|
676 return node;
|
n@280
|
677 };
|
n@280
|
678
|
n@280
|
679 function addExtraComment()
|
n@280
|
680 {
|
n@280
|
681 var node = createHead('CommentQuestion','Comment');
|
n@280
|
682 var attrib = document.createElement('div');
|
n@280
|
683 attrib.className = "attrib";
|
n@280
|
684 node.appendChild(attrib);
|
n@280
|
685 attrib.appendChild(attributePair('text','ID: ','id',true));
|
n@280
|
686
|
n@280
|
687 var element = document.createElement('div');
|
n@280
|
688 element.setAttribute('name','element');
|
n@280
|
689 var span = document.createElement('span');
|
n@280
|
690 span.textContent = 'Question: ';
|
n@280
|
691 element.appendChild(span);
|
n@280
|
692 var input = document.createElement('input');
|
n@280
|
693 input.type = 'text';
|
n@280
|
694 input.style.width = "500px";
|
n@280
|
695 element.appendChild(input);
|
n@280
|
696 attrib.appendChild(element);
|
n@280
|
697 return node;
|
n@280
|
698 }
|
n@280
|
699 </script>
|
n@280
|
700
|
n@280
|
701 <style>
|
n@280
|
702 h4 {margin: 0px;}
|
n@280
|
703 div {
|
n@280
|
704 padding: 2px;
|
n@280
|
705 margin-top: 2px;
|
n@280
|
706 margin-bottom: 2px;
|
n@280
|
707 }
|
n@280
|
708 div.head{
|
n@280
|
709 margin-left: 10px;
|
n@280
|
710 border: black;
|
n@280
|
711 border-width: 2px;
|
n@280
|
712 border-style: solid;
|
n@280
|
713 }
|
n@280
|
714 div.attrib{
|
n@280
|
715 margin-left:25px;
|
n@280
|
716 border: black;
|
n@280
|
717 border-width: 2px;
|
n@280
|
718 border-style: dashed;
|
n@280
|
719 margin-bottom: 10px;
|
n@280
|
720 display: table;
|
n@280
|
721 background-color: rgb(200,255,255);
|
n@280
|
722 }
|
n@280
|
723 div.attrib div {
|
n@280
|
724 width: auto;
|
n@280
|
725 position: relative;
|
n@280
|
726 display: table-cell;
|
n@280
|
727 }
|
n@280
|
728 div#dragFile{
|
n@280
|
729 height:100px;
|
n@280
|
730 border-width: 2px;
|
n@280
|
731 border-style: dashed;
|
n@280
|
732 margin-bottom: 10px;
|
n@280
|
733 }
|
n@280
|
734 </style>
|
n@280
|
735 </head>
|
n@280
|
736
|
n@280
|
737 <body>
|
n@280
|
738 <h1>Create Test Setup XML</h1>
|
n@280
|
739 <div id="dragFile">
|
n@280
|
740 <span>Drag and Drop an XML specification file here to auto-load.</span>
|
n@280
|
741 </div>
|
n@280
|
742 <button id="validateXML" onclick="buttonClickedValidate();">Validate</button>
|
n@280
|
743 <button id="createXML" onclick="buttonClickedSubmit();" disabled>Submit</button>
|
n@280
|
744 <div id="errorMessage" visibility="hidden"></div>
|
n@280
|
745 <div id="topLevelBody" align="left">
|
n@280
|
746 <div id='setup' class="head setup" node-name='setup'>
|
n@280
|
747 <h2>Setup Node</h2>
|
n@280
|
748 <div class="attrib">
|
n@280
|
749 <div name="attribute">
|
n@280
|
750 <span>Interface: </span>
|
n@280
|
751 <input type="text" attrib-name='interface' mandatory='true'/>
|
n@280
|
752 </div>
|
n@280
|
753 <div name="attribute">
|
n@280
|
754 <span>Project Return: </span>
|
n@280
|
755 <input type="url" attrib-name='projectReturn'/>
|
n@280
|
756 </div>
|
n@280
|
757 <div name="attribute">
|
n@280
|
758 <span>Randomise Page Order: </span>
|
n@280
|
759 <input type="checkbox" attrib-name='randomiseOrder'/>
|
n@280
|
760 </div>
|
n@280
|
761 <div name="attribute">
|
n@280
|
762 <span>Collect Metrics: </span>
|
n@280
|
763 <input type="checkbox" attrib-name='collectMetrics'/>
|
n@280
|
764 </div>
|
n@280
|
765 </div>
|
n@280
|
766 <div class="head PreTest" node-name="preTest">
|
n@280
|
767 <h3>Pre Test</h3>
|
n@280
|
768 <button onclick="event.srcElement.parentElement.appendChild(addPPStatement());">Add Statement</button>
|
n@280
|
769 <button onclick="event.srcElement.parentElement.appendChild(addPPQuestion());">Add Question</button>
|
n@280
|
770 <button onclick="event.srcElement.parentElement.appendChild(addPPCheckbox());">Add Checkbox</button>
|
n@280
|
771 <button onclick="event.srcElement.parentElement.appendChild(addPPRadio());">Add Radio</button>
|
n@280
|
772 </div>
|
n@280
|
773 <div class="head PostTest" node-name="postTest">
|
n@280
|
774 <h3>Post Test</h3>
|
n@280
|
775 <button onclick="event.srcElement.parentElement.appendChild(addPPStatement());">Add Statement</button>
|
n@280
|
776 <button onclick="event.srcElement.parentElement.appendChild(addPPQuestion());">Add Question</button>
|
n@280
|
777 <button onclick="event.srcElement.parentElement.appendChild(addPPCheckbox());">Add Checkbox</button>
|
n@280
|
778 <button onclick="event.srcElement.parentElement.appendChild(addPPRadio());">Add Radio</button>
|
n@280
|
779 </div>
|
n@280
|
780 <div class="head Metric" node-name="metrics">
|
n@280
|
781 <h3>Metrics</h3>
|
n@280
|
782 <button onclick="event.srcElement.parentElement.appendChild(addMetricEnable());">Add Metric Enable</button>
|
n@280
|
783 </div>
|
n@280
|
784 <div class="head interface" node-name="interface">
|
n@280
|
785 <h3>Interface</h3>
|
n@280
|
786 <button onclick="event.srcElement.parentElement.appendChild(addInterfaceCheck());">Add Check</button>
|
n@280
|
787 <button onclick="event.srcElement.parentElement.appendChild(addInterfaceOption());">Add Option</button>
|
n@280
|
788 </div>
|
n@280
|
789 </div>
|
n@280
|
790 <button onclick="event.srcElement.parentElement.appendChild(addAudioHolder());">Add Audio Holder</button>
|
n@280
|
791 </div>
|
n@280
|
792 </body>
|
n@280
|
793 </html>
|