aboutsummaryrefslogtreecommitdiff
path: root/nontrivial utility
diff options
context:
space:
mode:
authorNateN1222 <nathannichols454@gmail.com>2017-10-28 10:38:20 -0500
committerNateN1222 <nathannichols454@gmail.com>2017-10-28 10:38:20 -0500
commitda22a14cd285d6646db7b7d1ce1281689d01159f (patch)
treef2b14931e983086ea4546ba421e12e25650c87db /nontrivial utility
parentf9bd00d49a9de977ecbf75b5fda6d0372483b2e2 (diff)
cleaned up source and added license info
Diffstat (limited to 'nontrivial utility')
-rw-r--r--nontrivial utility/README4
-rw-r--r--nontrivial utility/nontriv.html135
2 files changed, 139 insertions, 0 deletions
diff --git a/nontrivial utility/README b/nontrivial utility/README
new file mode 100644
index 0000000..1947bd0
--- /dev/null
+++ b/nontrivial utility/README
@@ -0,0 +1,4 @@
+
+A utility that generates the JSON that the background script uses to determine if something is user defined, trivial or nontrivial.
+
+It is important to recognize that the objects that this script finds are likely dependent on what browser this script is running on since it gets the list by reading the contents of the global object. Make sure this is run on an up to date browser.
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>