From 3ecea836872f3230f3d662a049a710a2a086d84a Mon Sep 17 00:00:00 2001 From: retep998 Date: Tue, 2 Apr 2013 11:38:38 -0400 Subject: [PATCH] Removed the outdated test files. Formatted all existing files. Started a scriptapi. Signed-off-by: retep998 --- TestJScripts.html | 86 +++++++++-------- analyze.js | 214 +++++++++++++++++++++---------------------- listener.html | 141 ++++++++++++++-------------- listener.js | 49 +++++----- scriptapi.js | 3 + test (outdated).html | 15 --- test (outdated).js | 17 ---- 7 files changed, 255 insertions(+), 270 deletions(-) create mode 100644 scriptapi.js delete mode 100644 test (outdated).html delete mode 100644 test (outdated).js diff --git a/TestJScripts.html b/TestJScripts.html index a6c1564..2148d9e 100644 --- a/TestJScripts.html +++ b/TestJScripts.html @@ -1,43 +1,55 @@ - - + + - This is the title of the document
-
This is the header
-
-
-
-
-
-
table headingTable Cell
-

Level 1 Heading


- Anchor
- This is an object that normally holds a video but I'm too lazy to find one
- This is a menu
-
-

This is a paragraph


- This is a quotation
- This is a summary
-
-
-

-

-
- -
-
-
    -
  1. list item
  2. -
-
div
- -
This is the footer
+ This is the title of the document +
+
+ This is the header
+ +
+
+ +
+ +
+ +
+
table headingTable Cell
+

Level 1 Heading

+
+ Anchor
+ This is an object that normally holds a video but I'm too lazy to find one
+ This is a menu +
+
+

This is a paragraph

+
+ This is a quotation
+ This is a summary
+
+ +
+
+
+
+
+
+ +
+
+
    +
  1. list item
  2. +
+
div
+ +
This is the footer
diff --git a/analyze.js b/analyze.js index ec1f492..e1426d1 100644 --- a/analyze.js +++ b/analyze.js @@ -5,116 +5,116 @@ function analyze() { var validtags = ["A", "BUTTON", "FORM", "IMG", "INPUT", "LINK", "OPTION", "SELECT", "TABLE", "TEXTAREA"]; if (validtags.indexOf(all[i].tagName) < 0) continue; info[0] = all[i].tagName; - switch(info[0]) { - case "INPUT": - info[1] = all[i].getAttribute("type"); - break; - case "A": - info[1] = all[i].getAttribute("href"); - break; - case "BUTTON": - info[1] = all[i].getAttribute("name"); - info[2] = all[i].getAttribute("type"); - info[3] = all[i].getAttribute("value"); - info[4] = all[i].getAttribute("form"); - break; - case "FORM": - info[1] = all[i].getAttribute("name"); - info[2] = all[i].getAttribute("length"); - info[3] = all[i].getAttribute("target"); - info[4] = all[i].getAttribute("action"); - break; - case "IMG": - info[1] = all[i].getAttribute("name"); - info[2] = all[i].getAttribute("src"); - info[3] = all[i].getAttribute("align"); - break; - case "INPUT": - info[1] = all[i].getAttribute("name"); - info[2] = all[i].getAttribute("type"); - info[3] = all[i].getAttribute("value"); - break; - case "LINK": - info[1] = all[i].getAttribute("href"); - info[2] = all[i].getAttribute("type"); - info[3] = all[i].getAttribute("charset"); - break; - case "OPTION": - info[1] = all[i].getAttribute("text"); - info[2] = all[i].getAttribute("value"); - info[3] = all[i].getAttribute("index"); - break; - case "SELECT": - info[1] = all[i].getAttribute("type"); - info[2] = all[i].getAttribute("name"); - info[3] = all[i].getAttribute("size"); - break; - case "TABLE": - info[1] = all[i].getAttribute("summmary"); - info[2] = all[i].getAttribute("caption"); - break; - case "TEXTAREA": - info[1] = all[i].getAttribute("name"); - info[2] = all[i].getAttribute("type"); - info[3] = all[i].getAttribute("value"); - break; - - } + switch (info[0]) { + case "INPUT": + info[1] = all[i].getAttribute("type"); + break; + case "A": + info[1] = all[i].getAttribute("href"); + break; + case "BUTTON": + info[1] = all[i].getAttribute("name"); + info[2] = all[i].getAttribute("type"); + info[3] = all[i].getAttribute("value"); + info[4] = all[i].getAttribute("form"); + break; + case "FORM": + info[1] = all[i].getAttribute("name"); + info[2] = all[i].getAttribute("length"); + info[3] = all[i].getAttribute("target"); + info[4] = all[i].getAttribute("action"); + break; + case "IMG": + info[1] = all[i].getAttribute("name"); + info[2] = all[i].getAttribute("src"); + info[3] = all[i].getAttribute("align"); + break; + case "INPUT": + info[1] = all[i].getAttribute("name"); + info[2] = all[i].getAttribute("type"); + info[3] = all[i].getAttribute("value"); + break; + case "LINK": + info[1] = all[i].getAttribute("href"); + info[2] = all[i].getAttribute("type"); + info[3] = all[i].getAttribute("charset"); + break; + case "OPTION": + info[1] = all[i].getAttribute("text"); + info[2] = all[i].getAttribute("value"); + info[3] = all[i].getAttribute("index"); + break; + case "SELECT": + info[1] = all[i].getAttribute("type"); + info[2] = all[i].getAttribute("name"); + info[3] = all[i].getAttribute("size"); + break; + case "TABLE": + info[1] = all[i].getAttribute("summmary"); + info[2] = all[i].getAttribute("caption"); + break; + case "TEXTAREA": + info[1] = all[i].getAttribute("name"); + info[2] = all[i].getAttribute("type"); + info[3] = all[i].getAttribute("value"); + break; + + } generatescript(info); } } function generatescript(info) { - var command; - switch(info[0]) { -case "A": -command = "window.location.href = '" + info[1] + "';" -break; -case "BUTTON": -command = "button.name = '" + info[1] + "';" -+ "button.type = '" + info[2] + "';" -+ "button.value = '" + info[3] + "';" -+ "button.form = '" + info[4] + "';"; -break; -case "FORM": -command = "form.name = '" + info[1] + "';" -+ "form.length = '" + info[2] + "';" -+ "form.target = '" + info[3] + "';" -+ "form.action = '" + info[4] + "';"; -break; -case "IMG": -command = "img.name = '" + info[1] + "';" -+ "img.src = '" + info[2] + "';" -+ "img.align = '" + info[3] + "';"; -break; -case "INPUT": -command = "input.name = '" + info[1] + "';" -+ "input.type = '" + info[2] + "';" -+ "input.value = '" + info[3] + "';"; -break; -case "LINK": -command = "link.href = '" + info[1] + "';" -+ "link.type = '" + info[2] + "';" -+ "link.charset = '" + info[3] + "';"; -break; -case "OPTION": -command = "option.text = '" + info[1] + "';" -+ "option.value = '" + info[2] + "';" -+ "option.index = '" + info[3] + "';"; -break; -case "SELECT": -command = "select.type = '" + info[1] + "';" -+ "select.name = '" + info[2] + "';" -+ "select.size = '" + info[3] + "';"; -break; -case "TABLE": -command = "table.summary = '" + info[1] + "';" -+ "table.caption = '" + info[2] + "';"; -break; -case "TEXTAREA": -command = "window.location.name = '" + info[1] + "';" -+ "table.type = '" + info[2] + "';" -+ "table.value = '" + info[3] + "';"; -break; -} + var command; + switch (info[0]) { + case "A": + command = "window.location.href = '" + info[1] + "';" + break; + case "BUTTON": + command = "button.name = '" + info[1] + "';" + + "button.type = '" + info[2] + "';" + + "button.value = '" + info[3] + "';" + + "button.form = '" + info[4] + "';"; + break; + case "FORM": + command = "form.name = '" + info[1] + "';" + + "form.length = '" + info[2] + "';" + + "form.target = '" + info[3] + "';" + + "form.action = '" + info[4] + "';"; + break; + case "IMG": + command = "img.name = '" + info[1] + "';" + + "img.src = '" + info[2] + "';" + + "img.align = '" + info[3] + "';"; + break; + case "INPUT": + command = "input.name = '" + info[1] + "';" + + "input.type = '" + info[2] + "';" + + "input.value = '" + info[3] + "';"; + break; + case "LINK": + command = "link.href = '" + info[1] + "';" + + "link.type = '" + info[2] + "';" + + "link.charset = '" + info[3] + "';"; + break; + case "OPTION": + command = "option.text = '" + info[1] + "';" + + "option.value = '" + info[2] + "';" + + "option.index = '" + info[3] + "';"; + break; + case "SELECT": + command = "select.type = '" + info[1] + "';" + + "select.name = '" + info[2] + "';" + + "select.size = '" + info[3] + "';"; + break; + case "TABLE": + command = "table.summary = '" + info[1] + "';" + + "table.caption = '" + info[2] + "';"; + break; + case "TEXTAREA": + command = "window.location.name = '" + info[1] + "';" + + "table.type = '" + info[2] + "';" + + "table.value = '" + info[3] + "';"; + break; + } alert(command); } diff --git a/listener.html b/listener.html index 5c6f88b..74d219c 100644 --- a/listener.html +++ b/listener.html @@ -2,74 +2,81 @@ - This is the title of the document
-
This is the header
-
-
-
-
-
-
table headingTable Cell
-

Level 1 Heading


- Anchor
- This is an object that normally holds a video but I'm too lazy to find one
- This is a menu
-
-

This is a paragraph


- This is a quotation
- This is a summary
-
-
-

-

-
- -
-
-
    -
  1. list item
  2. -
-
div
- -
This is the footer
+ This is the title of the document +
+
+ This is the header
+ +
+
+ +
+ +
+ +
+
table headingTable Cell
+

Level 1 Heading

+
+ Anchor
+ This is an object that normally holds a video but I'm too lazy to find one
+ This is a menu +
+
+

This is a paragraph

+
+ This is a quotation
+ This is a summary
+
+ +
+
+
+
+
+
+ +
+
+
    +
  1. list item
  2. +
+
div
+ +
This is the footer
- \ No newline at end of file + diff --git a/listener.js b/listener.js index 7a90269..209fc2a 100644 --- a/listener.js +++ b/listener.js @@ -1,32 +1,27 @@ var spans = document.getElementsByTagName("*"); -if (window.attachEvent) {window.attachEvent('onload', your_function);} -else if (window.addEventListener) {window.addEventListener('load', your_function, false);} -else {document.addEventListener('load', your_function, false);} -for(i=0;i - - - What is this I don't even. - - - -

Sup?

- Click me to analyze the page. -
- - -
- - diff --git a/test (outdated).js b/test (outdated).js deleted file mode 100644 index bb717db..0000000 --- a/test (outdated).js +++ /dev/null @@ -1,17 +0,0 @@ -function analyze() { - var all = document.getElementsByTagName("*"); - for (var i = 0; i < all.length; ++i) { - var info = new Array(); - var validtags = ["A", "BUTTON", "FORM", "IMG", "INPUT", "LINK", "OPTION", "SELECT", "TABLE", "TEXTAREA"]; - if (validtags.indexOf(all[i].tagName) < 0) continue; - info[0] = all[i].tagName; - info[1] = all[i].getAttribute("id"); - info[2] = all[i].getAttribute("name"); - info[3] = all[i].getAttribute("class"); - info[4] = all[i].getAttribute("type"); - dostuff(info); - } -} -function dostuff(info) { - alert(JSON.stringify(info)); -}