Permalink
Browse files

add status bar

  • Loading branch information...
benmmurphy committed Oct 29, 2010
1 parent 28b33a0 commit 211a24d2b944b101d89da24966ded3cd78248e68
Showing with 58 additions and 4 deletions.
  1. +9 −0 README
  2. +3 −0 chrome/content/firefoxOverlay.xul
  3. +24 −2 chrome/content/module.js
  4. +22 −2 chrome/content/overlay.js
View
9 README
@@ -0,0 +1,9 @@
+uses the javascript beautifier from jsbeautifier.org to beautify all http responses with the mime type text/javascript or application/javascript.
+
+WARNING: this plugin is applied globally and may screw up your web browsing session.
+
+KNOWN ISSUES
+------------
+
+* doesn't handle character encoding properly
+* weird errors when calling 'this.originalListener.onStartRequest(request, context);'
@@ -1,4 +1,7 @@
<overlay id="jsbeautifier"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<script type="application/x-javascript" src="chrome://jsbeautifier/content/overlay.js"/>
+ <statusbar id="status-bar">
+ <statusbarpanel id="jsbStatus" label="JSB"/>
+ </statusbar>
</overlay>
View
@@ -1,6 +1,27 @@
var EXPORTED_SYMBOLS = ["jsbeautifier"];
-var jsbeautifier = {};
+var jsbeautifier = {active:false, listeners: []};
+
+jsbeautifier.addListener = function(l) {
+ this.listeners.push(l);
+};
+
+jsbeautifier.removeListener = function(l) {
+ var i = this.listeners.indexOf(l);
+ if (i < 0) {
+ return;
+ }
+ Components.utils.reportError("removing listener: " + i);
+ this.listeners.splice(i, 1);
+ Components.utils.reportError("listeners: " + this.listeners);
+};
+
+jsbeautifier.toggle = function() {
+ this.active = !this.active;
+ for (var i = 0; i < this.listeners.length; ++i) {
+ this.listeners[i]();
+ }
+};
var jsb = function() {
@@ -12,7 +33,8 @@ var jsb = function() {
var httpRequestObserver = {
observe: function(subject, topic, data) {
- if (topic == 'http-on-examine-response' || topic == 'http-on-examine-cached-response') {
+
+ if (jsbeautifier.active && (topic == 'http-on-examine-response' || topic == 'http-on-examine-cached-response')) {
if (subject instanceof Components.interfaces.nsIHttpChannel) {
var newListener = new JSBeautifierListener();
subject.QueryInterface(Ci.nsITraceableChannel);
View
@@ -1,3 +1,23 @@
-
Components.utils.import("resource://modules/module.js");
-jsbeautifier.Worker = Worker;
+jsbeautifier.Worker = Worker;
+
+function update_text() {
+ document.getElementById("jsbStatus").label = jsbeautifier.active ? "JSB ON" : "JSB OFF";
+};
+
+function toggle() {
+ jsbeautifier.toggle();
+};
+
+function load() {
+ update_text();
+ jsbeautifier.addListener(update_text);
+ document.getElementById("jsbStatus").addEventListener("click", toggle, false);
+};
+
+function unload() {
+ jsbeautifier.removeListener(update_text);
+};
+
+window.addEventListener("load", load, false);
+window.addEventListener("unload", unload, false);

0 comments on commit 211a24d

Please sign in to comment.