Skip to content

Commit

Permalink
lookin good. demoable almost. (no xpi)
Browse files Browse the repository at this point in the history
  • Loading branch information
gauyeung committed Feb 2, 2009
1 parent 6119c05 commit d270ec9
Show file tree
Hide file tree
Showing 12 changed files with 53 additions and 51 deletions.
1 change: 1 addition & 0 deletions chrome.manifest
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
content siteannotator chrome/content/
skin siteannotator classic/1.0 chrome/skin/
overlay chrome://browser/content/browser.xul chrome://siteannotator/content/siteannotator.xul
14 changes: 9 additions & 5 deletions chrome/content/siteannotator.xul
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,19 @@
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script language="javascript" src="validator.js"/>
<statusbar id="status-bar">
<statusbarpanel id="siteannotate-panel" label="Accessibility errors: " />
<!--<statusbarpanel id="siteannotate-panel" label="Accessibility errors: " />-->
<statusbarpanel id="siteannotator-panel" label="Unvalidated">
<!--<image id="siteannotator-star" width="80" height="16" src="chrome://siteannotator/skin/img/star_16.png" />-->
</statusbarpanel>
</statusbar>

<toolbox id="navigator-toolbox">
<toolbar id="SiteAnnotatorToolbar" toolbarname="SiteAnnotator Toolbar">
<label value="SiteAnnotator Toolbar: "/>
<textbox id="GoogBarQuery" cols="1" size="50" />
<toolbarbutton id="SiteAnnotateButton"
label="Validate" oncommand="validator.validate();" />
<toolbarbutton id="rate_up" tooltiptext="Accessible page"
image="chrome://siteannotator/skin/img/check.png" oncommand="alert('Thank you for rating');" />
<toolbarbutton id="rate_down" tooltiptext="Not accessible page"
image="chrome://siteannotator/skin/img/cross.png" oncommand="alert('Thank you for rating');" />

</toolbar>
</toolbox>

Expand Down
89 changes: 43 additions & 46 deletions chrome/content/validator.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var validator_URLlistener = {
var validator_URLlistener = { // listens to changes in URL
QueryInterface: function(aIID)
{
if (aIID.equals(Components.interfaces.nsIWebProgressListener) ||
Expand All @@ -11,7 +11,6 @@ var validator_URLlistener = {
{
validator.validate(aURI);
},

onStateChange: function() {},
onProgressChange: function() {},
onStatusChange: function() {},
Expand All @@ -22,85 +21,83 @@ var validator_URLlistener = {
var validator = {
curr_page_URL: null,
URL: "http://projectpossibility.org/projects/handicapannotate/dev/request.php",
//"http://169.232.161.6/dev/request.php",

init: function() {
// Listen for webpage loads
gBrowser.addProgressListener(validator_URLlistener,
Components.interfaces.nsIWebProgress.NOTIFY_STATE_DOCUMENT);
//var appcontent = document.getElementById("appcontent"); // browser
//appcontent.addEventListener("DOMContentLoaded", function() { validator.onPageLoad(); }, false);
},
uninit: function() {
gBrowser.removeProgressListener(validator_URLlistener);
},

// onLoad: function(e) { // initialization code
// this.initialized = true; //do something with this later
// //this.strings = document.getElementById("handicapannotator-strings");
// },
display_cb: function(responsetxt) {
alert("display_cb got " + responsetxt);
var panel = document.getElementById("siteannotate-panel");
//panel.setAttribute("label", "Accessibility errors: " + responsetxt);
panel.setAttribute("label", "bobobobAccessibility errors: " + responsetxt);
display_cb: function(responsetxt) { // callback to display to status bar
//alert("display_cb got " + responsetxt);
var panel = document.getElementById("siteannotator-panel");
var image = document.createElement("image");
image.setAttribute("width", "80");
image.setAttribute("height", "16");
if (responsetxt < 0) {
panel.setAttribute("label", "Unvalidated");
return;
}
else if (responsetxt <= 10)
image.setAttribute("src", "chrome://siteannotator/skin/img/star_16_5.png");
else if (responsetxt <= 25)
image.setAttribute("src", "chrome://siteannotator/skin/img/star_16_4.png");
else if (responsetxt <= 60)
image.setAttribute("src", "chrome://siteannotator/skin/img/star_16_3.png");
else if (responsetxt <= 200)
image.setAttribute("src", "chrome://siteannotator/skin/img/star_16_2.png");
else
image.setAttribute("src", "chrome://siteannotator/skin/img/star_16_1.png");
if (panel.hasChildNodes() ) {
while (panel.childNodes.length >= 1 )
panel.removeChild(panel.firstChild );
}
panel.removeAttribute("label");
panel.appendChild(image);
},

validate: function(aURI) {
if (aURI.spec == this.curr_page_URL //page did not change. don't re-validate
|| aURI.spec == "" //e.g. opened/switched to a new tab/window
|| ((aURI.spec.search(/http:\/\//) == -1)
&& (aURI.spec.search(/https:\/\//) == -1)))
&& (aURI.spec.search(/https:\/\//) == -1))) {
return;
}
else {
var pos = aURI.spec.search(/\?/);
if (pos > 0)
this.curr_page_URL = aURI.spec.substr(0, pos);
else
this.curr_page_URL = aURI.spec;
this.curr_page_URL = pos > 0 ? aURI.spec.substr(0, pos) : aURI.spec;
var panel = document.getElementById("siteannotator-panel");
if (panel.hasChildNodes() ) {
while (panel.childNodes.length >= 1 ) panel.removeChild(panel.firstChild );
}
panel.setAttribute("label", "Unvalidated");
}

var xmlHttp = new XMLHttpRequest();
if (xmlHttp == null) {
alert ("Your browser does not support AJAX!");
alert("Your browser does not support AJAX!");
return;
}
alert("curr_page_URL == " + this.curr_page_URL);
var curr;
// if (doc) {
// alert("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa");
// curr = doc.location;
// alert("aaa: "+curr);
// }
// else {
// alert("zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz");
// curr = window.top.content.document.location;
// alert("zzz: "+curr);
// }
curr = this.curr_page_URL;
var param = "?url=" + curr + "&sid=" + Math.random();
//alert("curr_page_URL == " + this.curr_page_URL);
var param = "?url=" + this.curr_page_URL + "&sid=" + Math.random();
xmlHttp.onreadystatechange = function() {
if (xmlHttp.readyState == 4) {
if (xmlHttp.status == 200) {
alert("status is 200");
//alert("status is 200");
validator.display_cb(xmlHttp.responseText);
alert("status was 200");
}
else
alert("2statechanged: " + xmlHttp.status);
alert("statechanged error status: " + xmlHttp.status);
}
};
alert("about to open(" + this.URL + param + ")");
//alert("about to open(" + this.URL + param + ")");
xmlHttp.open("GET", this.URL + param, true);
xmlHttp.send(null);
alert("2345");
},
// onPageLoad: function(aEvent) {
// alert("onpageload triggered");
// var doc = aEvent.originalTarget; // doc is document that triggered "onload" event
// alert(doc);
// alert(doc.id);
// validator.validate(doc);
// },
};
//window.addEventListener("load", function(e) { validator.onLoad(e); }, false);
window.addEventListener("load", function(e) { validator.init(e); }, false);
window.addEventListener("unload", function(e) { validator.uninit(e); }, false);
Binary file added chrome/skin/img/check.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added chrome/skin/img/cross.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added chrome/skin/img/star_16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added chrome/skin/img/star_16_0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added chrome/skin/img/star_16_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added chrome/skin/img/star_16_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added chrome/skin/img/star_16_3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added chrome/skin/img/star_16_4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added chrome/skin/img/star_16_5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit d270ec9

Please sign in to comment.