diff test_create/test_core.js @ 2355:33d2c4fd2625

Implemented #10. Each test definition can have some text describing the test.
author Nicholas Jillings <nicholas.jillings@mail.bcu.ac.uk>
date Mon, 16 May 2016 13:41:35 +0100
parents a7e50a52a896
children de1d5100d7a1
line wrap: on
line diff
--- a/test_create/test_core.js	Mon May 16 13:32:11 2016 +0100
+++ b/test_create/test_core.js	Mon May 16 13:41:35 2016 +0100
@@ -5,6 +5,7 @@
 var specification;
 var convert;
 var attributeText;
+var page_lang = "en";
 
 // Firefox does not have an XMLDocument.prototype.getElementsByName
 // and there is no searchAll style command, this custom function will
@@ -278,6 +279,9 @@
             spnH.appendChild(span);
             this.content.appendChild(spnH);
             this.select = document.createElement("select");
+            this.content.appendChild(this.select);
+            this.description = document.createElement("p");
+            this.content.appendChild(this.description);
             this.testsXML = interfaceSpecs.getElementsByTagName('tests')[0].children;
             for (var i=0; i<this.testsXML.length; i++)
             {
@@ -286,7 +290,18 @@
                 option.textContent = this.testsXML[i].getAttribute('name');
                 this.select.appendChild(option);
             }
-            this.content.appendChild(this.select);
+            this.handleEvent = function(event) {
+                var testXML = interfaceSpecs.getElementsByTagName("tests")[0].getAllElementsByName(this.select.value)[0];
+                var descriptors = testXML.getAllElementsByTagName("description");
+                this.description.textContent = "";
+                for (var i=0; i<descriptors.length; i++) {
+                    if (descriptors[i].getAttribute("lang") == page_lang) {
+                        this.description.textContent = descriptors[i].textContent;
+                    }
+                }
+            }
+            this.select.addEventListener("change",this);
+            this.handleEvent();
             this.continue = function()
             {
                 var testXML = interfaceSpecs.getElementsByTagName("tests")[0].getAllElementsByName(this.select.value)[0];