Mercurial > hg > webaudioevaluationtool
comparison test_create/test_create.html @ 838:0920172d9478
test_create.html: Modifying items on page updates the specification nodes.
author | Nicholas Jillings <n.g.r.jillings@se14.qmul.ac.uk> |
---|---|
date | Thu, 03 Dec 2015 15:11:06 +0000 |
parents | 1db3dd91fb26 |
children | 07b89feada77 |
comparison
equal
deleted
inserted
replaced
837:31d02b334ba8 | 838:0920172d9478 |
---|---|
1828 button.textContent = "Delete"; | 1828 button.textContent = "Delete"; |
1829 button.onclick = function(event) | 1829 button.onclick = function(event) |
1830 { | 1830 { |
1831 var node = event.target.parentElement; | 1831 var node = event.target.parentElement; |
1832 node.parentElement.removeChild(node); | 1832 node.parentElement.removeChild(node); |
1833 } | 1833 }; |
1834 return button; | 1834 return button; |
1835 } | 1835 } |
1836 | 1836 |
1837 function SpecficationToHTML() | 1837 function SpecficationToHTML() |
1838 { | 1838 { |
1859 option = document.createElement("option"); | 1859 option = document.createElement("option"); |
1860 option.value = "MUSHRA"; | 1860 option.value = "MUSHRA"; |
1861 option.textContent = "MUSHRA"; | 1861 option.textContent = "MUSHRA"; |
1862 select.appendChild(option); | 1862 select.appendChild(option); |
1863 select.value = specificationNode.interfaceType; | 1863 select.value = specificationNode.interfaceType; |
1864 select.onchange = function(event) | |
1865 { | |
1866 specificationNode.interfaceType = event.currentTarget.value; | |
1867 }; | |
1864 var span = document.createElement("span"); | 1868 var span = document.createElement("span"); |
1865 span.textContent = "Interface Type"; | 1869 span.textContent = "Interface Type"; |
1866 div.appendChild(span); | 1870 div.appendChild(span); |
1867 div.appendChild(select); | 1871 div.appendChild(select); |
1868 // Project Return Attribute | 1872 // Project Return Attribute |
1871 span.textContent = "Project Return"; | 1875 span.textContent = "Project Return"; |
1872 var input = document.createElement("input"); | 1876 var input = document.createElement("input"); |
1873 input.value = specificationNode.projectReturn; | 1877 input.value = specificationNode.projectReturn; |
1874 input.id = "projectReturn"; | 1878 input.id = "projectReturn"; |
1875 input.style.margin = "5px"; | 1879 input.style.margin = "5px"; |
1880 input.onchange = function(event) { | |
1881 specificationNode.projectReturn = event.currentTarget.value; | |
1882 }; | |
1876 div.appendChild(span); | 1883 div.appendChild(span); |
1877 div.appendChild(input); | 1884 div.appendChild(input); |
1878 // Randomise Order | 1885 // Randomise Order |
1879 span = document.createElement("span"); | 1886 span = document.createElement("span"); |
1880 span.textContent = "Randomise Order"; | 1887 span.textContent = "Randomise Order"; |
1881 input = document.createElement("input"); | 1888 input = document.createElement("input"); |
1882 input.id = "randomiseOrder"; | 1889 input.id = "randomiseOrder"; |
1883 input.style.margin = "5px"; | 1890 input.style.margin = "5px"; |
1884 input.type = "checkbox"; | 1891 input.type = "checkbox"; |
1885 input.value = specificationNode.projectReturn; | 1892 input.checked = specificationNode.randomiseOrder; |
1893 input.onchange = function(event) { | |
1894 specificationNode.randomiseOrder = event.currentTarget.checked; | |
1895 }; | |
1886 div.appendChild(span); | 1896 div.appendChild(span); |
1887 div.appendChild(input); | 1897 div.appendChild(input); |
1888 setupNode.appendChild(div); | 1898 setupNode.appendChild(div); |
1889 | 1899 |
1890 // Now create the common Interface Node | 1900 // Now create the common Interface Node |
1914 var span = document.createElement("span"); | 1924 var span = document.createElement("span"); |
1915 span.textContent = interfaceOptions[1][i]; | 1925 span.textContent = interfaceOptions[1][i]; |
1916 var input = document.createElement("input"); | 1926 var input = document.createElement("input"); |
1917 input.type = "checkbox"; | 1927 input.type = "checkbox"; |
1918 input.id = interfaceOptions[0][i]; | 1928 input.id = interfaceOptions[0][i]; |
1929 input.setAttribute("name", "option"); | |
1919 div.appendChild(input); | 1930 div.appendChild(input); |
1920 div.appendChild(span); | 1931 div.appendChild(span); |
1921 commonInterface.appendChild(div); | 1932 commonInterface.appendChild(div); |
1922 for (var j=0; j<specificationNode.commonInterface.options.length; j++) | 1933 for (var j=0; j<specificationNode.commonInterface.options.length; j++) |
1923 { | 1934 { |
1925 { | 1936 { |
1926 input.checked = true; | 1937 input.checked = true; |
1927 break; | 1938 break; |
1928 } | 1939 } |
1929 } | 1940 } |
1941 input.onchange = function(event) { | |
1942 var id = event.currentTarget.id; | |
1943 if (event.currentTarget.checked) { | |
1944 specificationNode.commonInterface.options.push(new specificationNode.commonInterface.optionNode(event.currentTarget)); | |
1945 } else { | |
1946 for (var j=0; j<specificationNode.commonInterface.options.length; j++) | |
1947 { | |
1948 if (specificationNode.commonInterface.options[j].name == event.currentTarget.id) | |
1949 { | |
1950 specificationNode.commonInterface.options.splice(j,1); | |
1951 break; | |
1952 } | |
1953 } | |
1954 } | |
1955 }; | |
1930 } | 1956 } |
1931 for (var i=0; i<interfaceChecks[0].length; i++) | 1957 for (var i=0; i<interfaceChecks[0].length; i++) |
1932 { | 1958 { |
1933 var span = document.createElement("span"); | 1959 var span = document.createElement("span"); |
1934 span.textContent = interfaceChecks[1][i]; | 1960 span.textContent = interfaceChecks[1][i]; |
1935 var input = document.createElement("input"); | 1961 var input = document.createElement("input"); |
1936 input.type = "checkbox"; | 1962 input.type = "checkbox"; |
1937 input.id = interfaceChecks[0][i]; | 1963 input.id = interfaceChecks[0][i]; |
1964 input.setAttribute("name", "check"); | |
1938 div.appendChild(input); | 1965 div.appendChild(input); |
1939 div.appendChild(span); | 1966 div.appendChild(span); |
1940 commonInterface.appendChild(div); | 1967 commonInterface.appendChild(div); |
1941 for (var j=0; j<specificationNode.commonInterface.options.length; j++) | 1968 for (var j=0; j<specificationNode.commonInterface.options.length; j++) |
1942 { | 1969 { |
1944 { | 1971 { |
1945 input.checked = true; | 1972 input.checked = true; |
1946 break; | 1973 break; |
1947 } | 1974 } |
1948 } | 1975 } |
1976 input.onchange = function(event) { | |
1977 var id = event.currentTarget.id; | |
1978 if (event.currentTarget.checked) { | |
1979 specificationNode.commonInterface.options.push(new specificationNode.commonInterface.optionNode(event.currentTarget)); | |
1980 } else { | |
1981 for (var j=0; j<specificationNode.commonInterface.options.length; j++) | |
1982 { | |
1983 if (specificationNode.commonInterface.options[j].name == event.currentTarget.id) | |
1984 { | |
1985 specificationNode.commonInterface.options.splice(j,1); | |
1986 break; | |
1987 } | |
1988 } | |
1989 } | |
1990 }; | |
1949 } | 1991 } |
1950 setupNode.appendChild(commonInterface); | 1992 setupNode.appendChild(commonInterface); |
1951 // Now the Metric Node | 1993 // Now the Metric Node |
1952 var metrics = document.createElement("div"); | 1994 var metrics = document.createElement("div"); |
1953 metrics.id = "metrics"; | 1995 metrics.id = "metrics"; |
1983 if (specificationNode.metrics[j].enabled == supportedMetrics[0][i]) | 2025 if (specificationNode.metrics[j].enabled == supportedMetrics[0][i]) |
1984 { | 2026 { |
1985 input.checked = true; | 2027 input.checked = true; |
1986 } | 2028 } |
1987 } | 2029 } |
2030 input.onchange = function(event) | |
2031 { | |
2032 if (event.currentTarget.checked) { | |
2033 specificationNode.metrics.push(new specificationNode.metricNode(event.currentTarget.id)); | |
2034 } else { | |
2035 for (var j=0; j<specificationNode.metrics.length; j++) | |
2036 { | |
2037 if (specificationNode.metrics[j].enabled == event.currentTarget.id) | |
2038 { | |
2039 specificationNode.metrics.splice(j,1); | |
2040 break; | |
2041 } | |
2042 } | |
2043 } | |
2044 }; | |
1988 } | 2045 } |
1989 | 2046 |
1990 setupNode.appendChild(metrics); | 2047 setupNode.appendChild(metrics); |
1991 | 2048 |
1992 // Test Session Pre Test | 2049 // Test Session Pre Test |
2001 for (var j=0; j<specificationNode.preTest.options.length; j++) | 2058 for (var j=0; j<specificationNode.preTest.options.length; j++) |
2002 { | 2059 { |
2003 var node = PPSurveyToHTML(specificationNode.preTest.options[j]); | 2060 var node = PPSurveyToHTML(specificationNode.preTest.options[j]); |
2004 node.className = "SecondLevel"; | 2061 node.className = "SecondLevel"; |
2005 node.id = preTest.id+"-"+j; | 2062 node.id = preTest.id+"-"+j; |
2006 node.appendChild(createDeleteNodeButton()); | 2063 var del_button = document.createElement("button"); |
2064 del_button.textContent = "Delete"; | |
2065 del_button.onclick = function(event) { | |
2066 var node = event.currentTarget.parentElement; | |
2067 var id = node.id.split("-")[1]; | |
2068 specificationNode.preTest.options.splice(id,1); | |
2069 node.parentElement.removeChild(node); | |
2070 }; | |
2071 node.appendChild(del_button); | |
2007 preTest.appendChild(node); | 2072 preTest.appendChild(node); |
2008 } | 2073 } |
2009 setupNode.appendChild(preTest); | 2074 setupNode.appendChild(preTest); |
2010 | 2075 |
2011 // Test Session Post Test | 2076 // Test Session Post Test |
2021 for (var j=0; j<specificationNode.postTest.options.length; j++) | 2086 for (var j=0; j<specificationNode.postTest.options.length; j++) |
2022 { | 2087 { |
2023 var node = PPSurveyToHTML(specificationNode.postTest.options[j]); | 2088 var node = PPSurveyToHTML(specificationNode.postTest.options[j]); |
2024 node.className = "SecondLevel"; | 2089 node.className = "SecondLevel"; |
2025 node.id = postTest.id+"-"+j; | 2090 node.id = postTest.id+"-"+j; |
2026 node.appendChild(createDeleteNodeButton()); | 2091 var del_button = document.createElement("button"); |
2092 del_button.textContent = "Delete"; | |
2093 del_button.onclick = function(event) { | |
2094 var node = event.currentTarget.parentElement; | |
2095 var id = node.id.split("-")[1]; | |
2096 specificationNode.postTest.options.splice(id,1); | |
2097 node.parentElement.removeChild(node); | |
2098 }; | |
2099 node.appendChild(del_button); | |
2027 postTest.appendChild(node); | 2100 postTest.appendChild(node); |
2028 } | 2101 } |
2029 | 2102 |
2030 setupNode.appendChild(postTest); | 2103 setupNode.appendChild(postTest); |
2031 | 2104 |
2035 for (var i=0; i<specificationNode.audioHolders.length; i++) | 2108 for (var i=0; i<specificationNode.audioHolders.length; i++) |
2036 { | 2109 { |
2037 var aH = specificationNode.audioHolders[i]; | 2110 var aH = specificationNode.audioHolders[i]; |
2038 var aHTML = document.createElement("div"); | 2111 var aHTML = document.createElement("div"); |
2039 aHTML.name = "audioHolder"; | 2112 aHTML.name = "audioHolder"; |
2040 aHTML.id = "audioHolder-"+aH.id; | 2113 aHTML.id = "audioHolder-"+i; |
2041 aHTML.className = "topLevel"; | 2114 aHTML.className = "topLevel"; |
2042 aHTML.appendChild(createDeleteNodeButton()); | 2115 aHTML.appendChild(createDeleteNodeButton()); |
2043 destination.appendChild(aHTML); | 2116 destination.appendChild(aHTML); |
2044 var title = document.createElement("h2"); | 2117 var title = document.createElement("h2"); |
2045 title.textContent = "Audio Holder "+aH.id; | 2118 title.textContent = "Audio Holder "+aH.id; |
2052 var input = document.createElement("input"); | 2125 var input = document.createElement("input"); |
2053 input.id = aHTML.id+"-id"; | 2126 input.id = aHTML.id+"-id"; |
2054 input.value = aH.id; | 2127 input.value = aH.id; |
2055 input.onchange = function() | 2128 input.onchange = function() |
2056 { | 2129 { |
2057 event.currentTarget.parentElement.parentElement.childNodes[0].textContent = "Audio Holder "+event.currentTarget.value; | 2130 var IDSplit = event.currentTarget.id.split('-'); |
2131 var aholderID = IDSplit[0]+"-"+IDSplit[1]; | |
2132 var aholder = document.getElementById(aholderID); | |
2133 title = aholder.getElementsByTagName("h2")[0]; | |
2134 title.textContent = "Audio Holder "+event.currentTarget.value; | |
2135 specificationNode.audioHolders[IDSplit[1]].id = event.currentTarget.value; | |
2058 }; | 2136 }; |
2059 text.style.margin = "5px"; | 2137 text.style.margin = "5px"; |
2060 input.style.margin = "5px"; | 2138 input.style.margin = "5px"; |
2061 attributes.appendChild(text); | 2139 attributes.appendChild(text); |
2062 attributes.appendChild(input); | 2140 attributes.appendChild(input); |
2063 text = document.createElement("span"); | 2141 text = document.createElement("span"); |
2064 text.textContent = "Host URL: "; | 2142 text.textContent = "Host URL: "; |
2065 input = document.createElement("input"); | 2143 input = document.createElement("input"); |
2066 input.id = aHTML.id+"-hostURL"; | 2144 input.id = aHTML.id+"-hostURL"; |
2067 input.value = aH.hostURL; | 2145 input.value = aH.hostURL; |
2146 input.onchange = function() | |
2147 { | |
2148 var IDSplit = event.currentTarget.id.split('-'); | |
2149 specificationNode.audioHolders[IDSplit[1]].hostURL = event.currentTarget.value; | |
2150 }; | |
2068 text.style.margin = "5px"; | 2151 text.style.margin = "5px"; |
2069 input.style.margin = "5px"; | 2152 input.style.margin = "5px"; |
2070 attributes.appendChild(text); | 2153 attributes.appendChild(text); |
2071 attributes.appendChild(input); | 2154 attributes.appendChild(input); |
2072 text = document.createElement("span"); | 2155 text = document.createElement("span"); |
2073 text.textContent = "Loop Fragments: "; | 2156 text.textContent = "Loop Fragments: "; |
2074 input = document.createElement("input"); | 2157 input = document.createElement("input"); |
2075 input.id = aHTML.id+"-loop"; | 2158 input.id = aHTML.id+"-loop"; |
2076 input.type = "checkbox"; | 2159 input.type = "checkbox"; |
2077 input.checked = aH.loop; | 2160 input.checked = aH.loop; |
2161 input.onchange = function() | |
2162 { | |
2163 var IDSplit = event.currentTarget.id.split('-'); | |
2164 specificationNode.audioHolders[IDSplit[1]].loop = event.currentTarget.checked; | |
2165 }; | |
2078 text.style.margin = "5px"; | 2166 text.style.margin = "5px"; |
2079 input.style.margin = "5px"; | 2167 input.style.margin = "5px"; |
2080 attributes.appendChild(text); | 2168 attributes.appendChild(text); |
2081 attributes.appendChild(input); | 2169 attributes.appendChild(input); |
2082 text = document.createElement("span"); | 2170 text = document.createElement("span"); |
2083 text.textContent = "Randomise Order: "; | 2171 text.textContent = "Randomise Order: "; |
2084 input = document.createElement("input"); | 2172 input = document.createElement("input"); |
2085 input.id = aHTML.id+"-randomiseOrder"; | 2173 input.id = aHTML.id+"-randomiseOrder"; |
2086 input.type = "checkbox"; | 2174 input.type = "checkbox"; |
2087 input.checked = aH.randomiseOrder; | 2175 input.checked = aH.randomiseOrder; |
2176 input.onchange = function() | |
2177 { | |
2178 var IDSplit = event.currentTarget.id.split('-'); | |
2179 specificationNode.audioHolders[IDSplit[1]].randomiseOrder = event.currentTarget.checked; | |
2180 }; | |
2088 text.style.margin = "5px"; | 2181 text.style.margin = "5px"; |
2089 input.style.margin = "5px"; | 2182 input.style.margin = "5px"; |
2090 attributes.appendChild(text); | 2183 attributes.appendChild(text); |
2091 attributes.appendChild(input); | 2184 attributes.appendChild(input); |
2092 text = document.createElement("span"); | 2185 text = document.createElement("span"); |
2093 text.textContent = "Show Fragment Comments"; | 2186 text.textContent = "Show Fragment Comments"; |
2094 input = document.createElement("input"); | 2187 input = document.createElement("input"); |
2095 input.id = aHTML.id+"-elementComments"; | 2188 input.id = aHTML.id+"-elementComments"; |
2096 input.type = "checkbox"; | 2189 input.type = "checkbox"; |
2097 input.checked = aH.elementComments; | 2190 input.checked = aH.elementComments; |
2191 input.onchange = function() | |
2192 { | |
2193 var IDSplit = event.currentTarget.id.split('-'); | |
2194 specificationNode.audioHolders[IDSplit[1]].elementComments = event.currentTarget.checked; | |
2195 }; | |
2098 text.style.margin = "5px"; | 2196 text.style.margin = "5px"; |
2099 input.style.margin = "5px"; | 2197 input.style.margin = "5px"; |
2100 attributes.appendChild(text); | 2198 attributes.appendChild(text); |
2101 attributes.appendChild(input); | 2199 attributes.appendChild(input); |
2102 | 2200 |
2113 for (var j=0; j<aH.preTest.options.length; j++) | 2211 for (var j=0; j<aH.preTest.options.length; j++) |
2114 { | 2212 { |
2115 var node = PPSurveyToHTML(aH.preTest.options[j]); | 2213 var node = PPSurveyToHTML(aH.preTest.options[j]); |
2116 node.className = "SecondLevel"; | 2214 node.className = "SecondLevel"; |
2117 node.id = preTest.id+"-"+j; | 2215 node.id = preTest.id+"-"+j; |
2118 node.appendChild(createDeleteNodeButton()); | 2216 var button_delete = document.createElement("button"); |
2217 button_delete.textContent = "Delete"; | |
2218 button_delete.onclick = function(event) | |
2219 { | |
2220 var node = event.currentTarget.parentElement; | |
2221 var IDSplit = node.id.split("-"); | |
2222 var preTest = specificationNode.audioHolders[IDSplit[1]].preTest; | |
2223 preTest.options.splice(IDSplit[3],1); | |
2224 node.parentElement.removeChild(node); | |
2225 }; | |
2226 node.appendChild(button_delete); | |
2119 preTest.appendChild(node); | 2227 preTest.appendChild(node); |
2120 } | 2228 } |
2121 | 2229 |
2122 aHTML.appendChild(preTest); | 2230 aHTML.appendChild(preTest); |
2123 | 2231 |
2134 for (var j=0; j<aH.postTest.options.length; j++) | 2242 for (var j=0; j<aH.postTest.options.length; j++) |
2135 { | 2243 { |
2136 var node = PPSurveyToHTML(aH.postTest.options[j]); | 2244 var node = PPSurveyToHTML(aH.postTest.options[j]); |
2137 node.className = "SecondLevel"; | 2245 node.className = "SecondLevel"; |
2138 node.id = postTest.id+"-"+j; | 2246 node.id = postTest.id+"-"+j; |
2139 node.appendChild(createDeleteNodeButton()); | 2247 var button_delete = document.createElement("button"); |
2248 button_delete.textContent = "Delete"; | |
2249 button_delete.onclick = function(event) | |
2250 { | |
2251 var node = event.currentTarget.parentElement; | |
2252 var IDSplit = node.id.split("-"); | |
2253 var postTest = specificationNode.audioHolders[IDSplit[1]].postTest; | |
2254 postTest.options.splice(IDSplit[3],1); | |
2255 node.parentElement.removeChild(node); | |
2256 }; | |
2257 node.appendChild(button_delete); | |
2140 postTest.appendChild(node); | 2258 postTest.appendChild(node); |
2141 } | 2259 } |
2142 | 2260 |
2143 aHTML.appendChild(postTest); | 2261 aHTML.appendChild(postTest); |
2144 | 2262 |
2157 var text = document.createElement("span"); | 2275 var text = document.createElement("span"); |
2158 text.textContent = "ID:"; | 2276 text.textContent = "ID:"; |
2159 var input = document.createElement("input"); | 2277 var input = document.createElement("input"); |
2160 input.id = entry.id+"-id"; | 2278 input.id = entry.id+"-id"; |
2161 input.value = aH.audioElements[i].id; | 2279 input.value = aH.audioElements[i].id; |
2280 input.onchange = function() { | |
2281 var IDSplit = event.currentTarget.id.split("-"); | |
2282 var ahNode = specificationNode.audioHolders[IDSplit[1]]; | |
2283 ahNode.audioElements[IDSplit[3]].id = event.currentTarget.value; | |
2284 }; | |
2162 text.style.margin = "5px"; | 2285 text.style.margin = "5px"; |
2163 input.style.margin = "5px"; | 2286 input.style.margin = "5px"; |
2164 entry.appendChild(text); | 2287 entry.appendChild(text); |
2165 entry.appendChild(input); | 2288 entry.appendChild(input); |
2166 text = document.createElement("span"); | 2289 text = document.createElement("span"); |
2167 text.textContent = "URL:"; | 2290 text.textContent = "URL:"; |
2168 input = document.createElement("input"); | 2291 input = document.createElement("input"); |
2169 input.id = entry.id+"-URL"; | 2292 input.id = entry.id+"-URL"; |
2170 input.value = aH.audioElements[i].url; | 2293 input.value = aH.audioElements[i].url; |
2294 input.onchange = function() { | |
2295 var IDSplit = event.currentTarget.id.split("-"); | |
2296 var ahNode = specificationNode.audioHolders[IDSplit[1]]; | |
2297 ahNode.audioElements[IDSplit[3]].url = event.currentTarget.value; | |
2298 }; | |
2171 text.style.margin = "5px"; | 2299 text.style.margin = "5px"; |
2172 input.style.margin = "5px"; | 2300 input.style.margin = "5px"; |
2173 entry.appendChild(text); | 2301 entry.appendChild(text); |
2174 entry.appendChild(input); | 2302 entry.appendChild(input); |
2175 entry.appendChild(createDeleteNodeButton()); | 2303 var button_delete = document.createElement("button"); |
2304 button_delete.textContent = "Delete"; | |
2305 button_delete.onclick = function() { | |
2306 var node = event.currentTarget.parentElement; | |
2307 var IDSplit = node.id.split("-"); | |
2308 var ahNode = specificationNode.audioHolders[IDSplit[1]]; | |
2309 ahNode.audioElements.splice(IDSplit[3],1); | |
2310 node.parentElement.removeChild(node); | |
2311 }; | |
2312 entry.appendChild(button_delete); | |
2176 audioElems.appendChild(entry); | 2313 audioElems.appendChild(entry); |
2177 } | 2314 } |
2178 aHTML.appendChild(audioElems); | 2315 aHTML.appendChild(audioElems); |
2179 } | 2316 } |
2180 | 2317 |
2316 } | 2453 } |
2317 </style> | 2454 </style> |
2318 </head> | 2455 </head> |
2319 | 2456 |
2320 <body> | 2457 <body> |
2458 <div id="export"> | |
2459 <button id="exportToXML" onclick="specificationNode.exportToXML();">Export XML</button> | |
2460 </div> | |
2321 <div id="content"></div> | 2461 <div id="content"></div> |
2322 </body> | 2462 </body> |
2323 </html> | 2463 </html> |