diff options
Diffstat (limited to 'nontrivial utility/nontriv.html')
-rw-r--r-- | nontrivial utility/nontriv.html | 135 |
1 files changed, 135 insertions, 0 deletions
diff --git a/nontrivial utility/nontriv.html b/nontrivial utility/nontriv.html new file mode 100644 index 0000000..aaf49ba --- /dev/null +++ b/nontrivial utility/nontriv.html @@ -0,0 +1,135 @@ +<!doctype html> + +<head> +</head> +<body> + +<script> +window.onload = function (){ + var s = Object.getOwnPropertyNames(window); + + var kids = document.getElementById("categories").children; + for(var i = 0; i < kids.length; i++){ + var checkbox = "<input name='opt' id='cat_"+kids[i].id+"' type='checkbox'></input>"; + kids[i].insertAdjacentHTML("beforeend",checkbox+"Check entire category\n"); + document.getElementById("cat_"+kids[i].id).addEventListener("click",function(){ + var nontriv = document.getElementById(this.id.substring(4,this.id.length)); + for(var j = 0; j < nontriv.children.length; j++){ + if(this.checked){ + nontriv.children[j].checked = true; + } else{ + nontriv.children[j].checked = false; + } + } + }); + } + + for(var i = 0; i < s.length; i++){ + var checkbox = "<input name='opt' id='"+s[i]+"' type='checkbox'></input>"; + + if(s[i].indexOf("HTML") == 0){ + document.getElementById("html").insertAdjacentHTML("beforeend",checkbox + s[i] + "\n"); + }else if(s[i].indexOf("CSS") == 0){ + document.getElementById("css").insertAdjacentHTML("beforeend",checkbox + s[i] + "\n"); + }else if(s[i].indexOf("SVG") == 0){ + document.getElementById("svg").insertAdjacentHTML("beforeend",checkbox + s[i] + "\n"); + }else if(s[i].indexOf("on") == 0){ + document.getElementById("event").insertAdjacentHTML("beforeend",checkbox + s[i] + "\n"); + }else if(s[i].indexOf("RTC") == 0){ + document.getElementById("rtc").insertAdjacentHTML("beforeend",checkbox + s[i] + "\n"); + }else if(s[i].indexOf("HTML") == 0){ + document.getElementById("html").insertAdjacentHTML("beforeend",checkbox + s[i] + "\n"); + }else if(s[i].indexOf("VR") == 0){ + document.getElementById("vr").insertAdjacentHTML("beforeend",checkbox + s[i] + "\n"); + }else if(s[i].indexOf("WebGL") == 0){ + document.getElementById("webgl").insertAdjacentHTML("beforeend",checkbox + s[i] + "\n"); + }else if(s[i].indexOf("DOM") == 0){ + document.getElementById("dom").insertAdjacentHTML("beforeend",checkbox + s[i] + "\n"); + }else if(s[i].indexOf("IDB") == 0){ + document.getElementById("idb").insertAdjacentHTML("beforeend",checkbox + s[i] + "\n"); + }else if(s[i].indexOf("Audio") != -1){ + document.getElementById("audio").insertAdjacentHTML("beforeend",checkbox + s[i] + "\n"); + }else if(s[i].indexOf("Gamepad") == 0){ + document.getElementById("gamepad").insertAdjacentHTML("beforeend",checkbox + s[i] + "\n"); + }else if(s[i].indexOf("Media") == 0){ + document.getElementById("media").insertAdjacentHTML("beforeend",checkbox + s[i] + "\n"); + }else if(s[i].indexOf("Event") != -1){ + document.getElementById("event2").insertAdjacentHTML("beforeend",checkbox + s[i] + "\n"); + }else{ + document.getElementById("other").insertAdjacentHTML("beforeend",checkbox + s[i] + "\n"); + } + } + + document.getElementById("gen").addEventListener("click",function(){ + var temp = document.getElementsByName("opt"); + var outputjson = {}; + for(var i = 1; i < temp.length; i++){ + outputjson[temp[i].id] = temp[i].checked; + } + document.getElementById("output").innerHTML = JSON.stringify(outputjson, null, '\t'); + }); + document.getElementById("read").addEventListener("click",function(){ + var inputjson = JSON.parse(document.getElementById("injson").value); + console.log(inputjson); + var keys = Object.keys(inputjson); + for(var i = 0; i < keys.length; i++){ + console.log(inputjson[keys[i]]); + if(inputjson[keys[i]] == true){ + document.getElementById(keys[i]).checked = true; + } else{ + document.getElementById(keys[i]).checked = false; + } + } + return; + }); +} +</script> + +This page allows us to generate the allowed/disallowed object JSON. +<br> +<br> +We know it's up to date because it iterates over all keys of the window variable (which is the global object for browsers) +<br> +<br> +(True = nontrivial, false = trivial) +<br><br><br> +<textarea id="injson" rows="4" cols="50"></textarea> +<br> +<input id="read" type="button" value="Load JSON"></input> +<br> +<input id="gen" type="button" value="Generate"></input> +<br> +<pre id="output"></pre> +<div id="categories"> + +<pre id="webgl">WebGL +</pre> +<pre id="svg">SVG +</pre> +<pre id="html">HTML +</pre> +<pre id="css">CSS +</pre> +<pre id="event">Events +</pre> +<pre id="rtc">WebRTC +</pre> +<pre id="vr">VR +</pre> +<pre id="dom">DOM +</pre> +<pre id="idb">IDB +</pre> +<pre id="audio">Audio +</pre> +<pre id="gamepad">Gamepad +</pre> +<pre id="media">Media +</pre> +<pre id="event2">Other events +</pre> +<pre id="other">All else +</pre> + +</div> +</body> |