Removed the outdated test files.

Formatted all existing files.
Started a scriptapi.

Signed-off-by: retep998 <retep998@verizon.net>
This commit is contained in:
retep998 2013-04-02 11:38:38 -04:00
parent 44761bed69
commit 3ecea83687
7 changed files with 255 additions and 270 deletions

View File

@ -1,43 +1,55 @@
<html>
<head name="headName" id="headId">
<script type="text/javascript" src="analyze.js"></script>
<script type="text/javascript" src="listener.js"></script>
<script type="text/javascript" src="analyze.js"></script>
<script type="text/javascript" src="listener.js"></script>
</head>
<body name="bodyName" id="bodyId">
<title name="titleName" id="titleId">This is the title of the document</title><br />
<header name="headerName" id="headerId">This is the header<br />
<nav name="navName" id="navId">This is the navigational menu</nav><br />
</header>
<table name="tableName" id="tableId"><br />
<th name="tableHeadName" id="tableHeadId">table heading</th><br />
<td>Table Cell</td><br />
</table>
<h1 name="headingName" id="headingId">Level 1 Heading</h1><br />
<a href="#" id="anchorId" name="anchorName">Anchor</a><br />
<object name="objectName" id="objectId">This is an object that normally holds a video but I'm too lazy to find one</object><br />
<menu name="menuName" id="menuId">This is a menu</menu><br />
<img src="http://www.natural-environment.com/images/banners/banner_7_glasshouse_mountains.jpg" name="imageName" id="imageId"><br />
<p name="paraName" id="paraId">This is a paragraph</p><br />
<q name="quoteName" id="quoteId">This is a quotation</q><br />
<summary name="summaryName" id="summaryId">This is a summary</summary><br />
<time name="timeName" id="timeId">This is a timestamp</time><br />
<button value="button" type="button" name="buttonName" id="buttonId" onClick="analyze()">Analyze Javascript</button> <br />
<hr name="horizontalRuleName" id="horizontalRuleId"><br />
<form name="formName" id="formId"><br />
<label name="labelName" id="labelId">This is a label</label><br />
<select>
<option value="volvo" name="volvoName" id="volvoId">Volvo</option>
<option value="saab" name="saabName" id="saabId">Saab</option>
<option value="mercedes" name="mercedesName" id="mercedesId">Mercedes</option>
<option value="audi" name="audiName" id="audiId">Audi</option>
</select>
<input type="submit" value="Submit" name="submitButton" id="submitId"><br />
</form>
<ol name="orderedListName" id="orderListId">
<li name="listItemName" id="listItemId">list item</li>
</ol>
<div name="divName" id="divId">div</div>
<iframe src="http://www.google.com" name="iframeName" id="iframeId">This is an iframe</iframe>
<footer name="footerName" id="footerId">This is the footer</footer>
<title name="titleName" id="titleId">This is the title of the document</title>
<br />
<header name="headerName" id="headerId">
This is the header<br />
<nav name="navName" id="navId">This is the navigational menu</nav>
<br />
</header>
<table name="tableName" id="tableId">
<br />
<th name="tableHeadName" id="tableHeadId">table heading</th>
<br />
<td>Table Cell</td>
<br />
</table>
<h1 name="headingName" id="headingId">Level 1 Heading</h1>
<br />
<a href="#" id="anchorId" name="anchorName">Anchor</a><br />
<object name="objectName" id="objectId">This is an object that normally holds a video but I'm too lazy to find one</object><br />
<menu name="menuName" id="menuId">This is a menu</menu>
<br />
<img src="http://www.natural-environment.com/images/banners/banner_7_glasshouse_mountains.jpg" name="imageName" id="imageId"><br />
<p name="paraName" id="paraId">This is a paragraph</p>
<br />
<q name="quoteName" id="quoteId">This is a quotation</q><br />
<summary name="summaryName" id="summaryId">This is a summary</summary><br />
<time name="timeName" id="timeId">This is a timestamp</time><br />
<button value="button" type="button" name="buttonName" id="buttonId" onclick="analyze()">Analyze Javascript</button>
<br />
<hr name="horizontalRuleName" id="horizontalRuleId">
<br />
<form name="formName" id="formId">
<br />
<label name="labelName" id="labelId">This is a label</label><br />
<select>
<option value="volvo" name="volvoName" id="volvoId">Volvo</option>
<option value="saab" name="saabName" id="saabId">Saab</option>
<option value="mercedes" name="mercedesName" id="mercedesId">Mercedes</option>
<option value="audi" name="audiName" id="audiId">Audi</option>
</select>
<input type="submit" value="Submit" name="submitButton" id="submitId"><br />
</form>
<ol name="orderedListName" id="orderListId">
<li name="listItemName" id="listItemId">list item</li>
</ol>
<div name="divName" id="divId">div</div>
<iframe src="http://www.google.com" name="iframeName" id="iframeId">This is an iframe</iframe>
<footer name="footerName" id="footerId">This is the footer</footer>
</body>
</html>

View File

@ -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);
}

View File

@ -2,74 +2,81 @@
<head name="headName" id="headId">
</head>
<script>
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<spans.length;i++)
spans[i].addEventListener("click", this.doSomething);
function your_function()
{
alert("Done Loading!");
}
function doSomething(e)
{
var targ;
if (!e)
{
var e=window.event;
}
if (e.target)
{
targ=e.target;
}
else if (e.srcElement)
{
targ=e.srcElement;
}
var tname;
var idname;
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 < spans.length; i++)
spans[i].addEventListener("click", this.doSomething);
function your_function() {
alert("Done Loading!");
}
function doSomething(e) {
var targ;
if (!e) {
var e = window.event;
}
if (e.target) {
targ = e.target;
}
else if (e.srcElement) {
targ = e.srcElement;
}
var tname;
var idname;
idname = targ.id;
tname = targ.tagName;
alert("You clicked on a " + tname + " element. Named "+ idname +".");
}
idname = targ.id;
tname = targ.tagName;
alert("You clicked on a " + tname + " element. Named " + idname + ".");
}
</script>
<body name="bodyName" id="bodyId">
<title name="titleName" id="titleId">This is the title of the document</title><br />
<header name="headerName" id="headerId">This is the header<br />
<nav name="navName" id="navId">This is the navigational menu</nav><br />
</header>
<table name="tableName" id="tableId"><br />
<th name="tableHeadName" id="tableHeadId">table heading</th><br />
<td>Table Cell</td><br />
</table>
<h1 name="headingName" id="headingId">Level 1 Heading</h1><br />
<a href="#" id="anchorId" name="anchorName">Anchor</a><br />
<object name="objectName" id="objectId">This is an object that normally holds a video but I'm too lazy to find one</object><br />
<menu name="menuName" id="menuId">This is a menu</menu><br />
<img src="http://www.natural-environment.com/images/banners/banner_7_glasshouse_mountains.jpg" name="imageName" id="imageId"><br />
<p name="paraName" id="paraId">This is a paragraph</p><br />
<q name="quoteName" id="quoteId">This is a quotation</q><br />
<summary name="summaryName" id="summaryId">This is a summary</summary><br />
<time name="timeName" id="timeId">This is a timestamp</time><br />
<button value="button" type="button" name="buttonName" id="buttonId">Click Me!</button> <br />
<hr name="horizontalRuleName" id="horizontalRuleId"><br />
<form name="formName" id="formId"><br />
<label name="labelName" id="labelId">This is a label</label><br />
<select>
<option value="volvo" name="volvoName" id="volvoId">Volvo</option>
<option value="saab" name="saabName" id="saabId">Saab</option>
<option value="mercedes" name="mercedesName" id="mercedesId">Mercedes</option>
<option value="audi" name="audiName" id="audiId">Audi</option>
</select>
<input type="submit" value="Submit" name="submitButton" id="submitId"><br />
</form>
<ol name="orderedListName" id="orderListId">
<li name="listItemName" id="listItemId">list item</li>
</ol>
<div name="divName" id="divId">div</div>
<iframe src="http://www.google.com" name="iframeName" id="iframeId">This is an iframe</iframe>
<footer name="footerName" id="footerId">This is the footer</footer>
<title name="titleName" id="titleId">This is the title of the document</title>
<br />
<header name="headerName" id="headerId">
This is the header<br />
<nav name="navName" id="navId">This is the navigational menu</nav>
<br />
</header>
<table name="tableName" id="tableId">
<br />
<th name="tableHeadName" id="tableHeadId">table heading</th>
<br />
<td>Table Cell</td>
<br />
</table>
<h1 name="headingName" id="headingId">Level 1 Heading</h1>
<br />
<a href="#" id="anchorId" name="anchorName">Anchor</a><br />
<object name="objectName" id="objectId">This is an object that normally holds a video but I'm too lazy to find one</object><br />
<menu name="menuName" id="menuId">This is a menu</menu>
<br />
<img src="http://www.natural-environment.com/images/banners/banner_7_glasshouse_mountains.jpg" name="imageName" id="imageId"><br />
<p name="paraName" id="paraId">This is a paragraph</p>
<br />
<q name="quoteName" id="quoteId">This is a quotation</q><br />
<summary name="summaryName" id="summaryId">This is a summary</summary><br />
<time name="timeName" id="timeId">This is a timestamp</time><br />
<button value="button" type="button" name="buttonName" id="buttonId">Click Me!</button>
<br />
<hr name="horizontalRuleName" id="horizontalRuleId">
<br />
<form name="formName" id="formId">
<br />
<label name="labelName" id="labelId">This is a label</label><br />
<select>
<option value="volvo" name="volvoName" id="volvoId">Volvo</option>
<option value="saab" name="saabName" id="saabId">Saab</option>
<option value="mercedes" name="mercedesName" id="mercedesId">Mercedes</option>
<option value="audi" name="audiName" id="audiId">Audi</option>
</select>
<input type="submit" value="Submit" name="submitButton" id="submitId"><br />
</form>
<ol name="orderedListName" id="orderListId">
<li name="listItemName" id="listItemId">list item</li>
</ol>
<div name="divName" id="divId">div</div>
<iframe src="http://www.google.com" name="iframeName" id="iframeId">This is an iframe</iframe>
<footer name="footerName" id="footerId">This is the footer</footer>
</body>
</html>
</html>

View File

@ -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<spans.length;i++)
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 < spans.length; i++)
spans[i].addEventListener("click", this.doSomething);
function your_function()
{
alert("Done Loading!");
function your_function() {
alert("Done Loading!");
}
function doSomething(e)
{
var targ;
if (!e)
{
var e=window.event;
}
if (e.target)
{
targ=e.target;
}
else if (e.srcElement)
{
targ=e.srcElement;
}
var tname;
var idname;
function doSomething(e) {
var targ;
if (!e) {
var e = window.event;
}
if (e.target) {
targ = e.target;
}
else if (e.srcElement) {
targ = e.srcElement;
}
var tname;
var idname;
idname = targ.id;
tname = targ.tagName;
alert("You clicked on a " + tname + " element. Named "+ idname +".");
idname = targ.id;
tname = targ.tagName;
alert("You clicked on a " + tname + " element. Named " + idname + ".");
}

3
scriptapi.js Normal file
View File

@ -0,0 +1,3 @@
function script_click_a(url) {
window.location.href = url;
}

View File

@ -1,15 +0,0 @@
<!doctype html>
<html>
<head>
<title>What is this I don't even.</title>
<script type="text/javascript" src="test.js"></script>
</head>
<body>
<h1 id="poke">Sup?</h1>
<a href="javascript:analyze();">Click me to analyze the page.</a>
<form class="blah">
<input id="foo" name="lel" type="text" />
<input id="bar" type="submit" />
</form>
</body>
</html>

View File

@ -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));
}