[Pkg-mozext-commits] [itsalltext] 314/459: linted!

David Prévot taffit at moszumanska.debian.org
Tue Feb 24 23:26:33 UTC 2015


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository itsalltext.

commit f1f75c0ced72760d42a94565216b64aa19985b25
Author: Christian Höltje <docwhat at gmail.com>
Date:   Sat Mar 15 23:34:42 2008 -0400

    linted!
---
 Makefile                          |  35 ++-
 src/chrome/content/API.js         |  40 ++--
 src/chrome/content/Color.js       | 206 +++++++++--------
 src/chrome/content/badeditor.js   |  25 ++-
 src/chrome/content/cacheobj.js    | 390 +++++++++++++++++++-------------
 src/chrome/content/itsalltext.js  | 458 ++++++++++++++++++--------------------
 src/chrome/content/monitor.js     |  74 +++---
 src/chrome/content/preferences.js |  45 ++--
 8 files changed, 704 insertions(+), 569 deletions(-)

diff --git a/Makefile b/Makefile
index afccc12..ed926a4 100644
--- a/Makefile
+++ b/Makefile
@@ -20,8 +20,7 @@
 # but I strongly suggest you get jslint and jsmin working.
 JSLINT     := jslint
 YC         := yuicompressor
-#JSMIN      := jsmin
-JSMIN      := cat
+YC_JSFLAGS := --type js --charset UTF-8
 ZIP        := zip
 PROJNICK   := itsalltext
 PROJNAME   := "It's All Text!"
@@ -42,6 +41,8 @@ SOURCES_NONCHROME:=src/chrome.manifest src/gpl.txt src/install.rdf src/defaults/
 SOURCES:=$(SOURCES_CHROME) $(SOURCES_NONCHROME)
 SOURCES_JS:=$(shell echo "$(SOURCES)" | xargs -n 1 echo | grep -E '\.js$$')
 SOURCES_JS_LINT:=$(patsubst %.js, lint/%.js.lint, $(SOURCES_JS))
+SOURCES_JS_WARN:=$(patsubst %.js, lint/%.js.warn, $(SOURCES_JS))
+SOURCES_JS_LINT_PRE:=$(patsubst %.lint, %.lint-pre, $(filter %.lint,$(SOURCES_JS_LINT)))
 JARS:=chrome/content.jar chrome/en-US.jar
 
 STAGE1_OUT:=$(patsubst src/%, stage1/%, $(SOURCES))
@@ -97,7 +98,7 @@ stage1/%: src/%
 
 stage1/%.js: src/%.js
 	$(Q)mkdir -p $(dir $@)
-	$(Q)cat $< | sed 's/999.@@VERSION@@/$(VERSION)/g' | $(JSMIN) > $@
+	$(Q)$(YC) $(YC_JSFLAGS) -o $@ $<
 
 
 #################
@@ -133,23 +134,33 @@ build: final
 ##
 ## Lint checks for possible problems.
 .PHONY: lint
-lint: $(SOURCES_JS_LINT)
+lint: $(SOURCES_JS_LINT) $(SOURCES_JS_WARN)
 
-$(SOURCES_JS_LINT): lint/%.js.lint: %.js Makefile
-	$(info linting $(notdir $<) ...)
+.INTERMEDIATE: $(SOURCES_JS_LINT_PRE)
+
+$(SOURCES_JS_LINT_PRE): lint/%.js.lint-pre: %.js Makefile
 	$(Q)mkdir -p $(dir $@)
-	$(Q)perl -p -e 's/^(\s*)const(\s+)/$$1var$$2/' $< > $@.pre
-	$(Q)echo "*** Linting $<" > $@
-	$(Q)$(JSLINT) -p $@.pre >> $@
-	$(Q)$(YC) --type js --charset UTF-8 --warn -o /dev/null $@.pre >> $@ 2>&1
+	$(Q)perl -p -e 's!^(\s*)(const)(\s+)!$$1var$$3!' $< > $@
+
+$(SOURCES_JS_LINT): %.js.lint: %.js.lint-pre
+	$(info linting $(patsubst %.lint-pre,%,$(notdir $<)) ...)
+	$(Q)rm -f $@
+	$(Q)$(JSLINT) -p $< |\
+		perl -p -e 's!^(jslint: linting )lint/(.*)\.lint-pre!********* $$1$$2!' >> $@
+$(SOURCES_JS_WARN): lint/%.js.warn: %.js Makefile
+	$(info warning $(patsubst %.lint-pre,%,$(notdir $<)) ...)
+	$(Q)echo '********* checking $< *********' > $@
+	$(Q)$(YC) $(YC_JSFLAGS) --verbose -o /dev/null $< 2>&1 |\
+		grep -vE '^\[INFO\] It is recommended to use Sun' >> $@
 
 .PHONY: lintcheck
 lintcheck: $(SOURCES_JS_LINT)
-	$(Q)egrep -q '^lint at |^\[WARNING\]' $(SOURCES_JS_LINT) ; test $$? != 0
+	$(Q)egrep -q '^lint at '    $(SOURCES_JS_LINT) ; test $$? != 0
+	$(Q)egrep -q '^\[WARNING\]' $(SOURCES_JS_WARN) ; test $$? != 0
 
 .PHONY: showlint
 showlint: lint
-	$(Q)find ./lint -type f -name '*.lint' -print0 | xargs -0 cat | egrep -v '^jslint: No problems found in'
+	$(Q)find ./lint -type f \( -name '*.lint' -o -name '*.warn' \) -print0 | xargs -0 cat
 
 ##
 ## Narf is a magick keyword that should stop builds from working
diff --git a/src/chrome/content/API.js b/src/chrome/content/API.js
index 4f688f5..807fd7b 100644
--- a/src/chrome/content/API.js
+++ b/src/chrome/content/API.js
@@ -1,3 +1,6 @@
+/*extern Components, ItsAllText, XPathResult */
+/*jslint undef: true, nomen: true, evil: false, browser: true, white: true */
+
 /*
   This file is used to allow external editors to work inside your chrome XUL.
 
@@ -45,7 +48,9 @@
 
 (function () {
     /* Load up the main It's All Text! file */
-    var objScriptLoader = Components.classes["@mozilla.org/moz/jssubscript-loader;1"].getService(Components.interfaces.mozIJSSubScriptLoader);
+    var objScriptLoader = Components.classes["@mozilla.org/moz/jssubscript-loader;1"].getService(Components.interfaces.mozIJSSubScriptLoader),
+        openEditorCommand,
+        onload;
     objScriptLoader.loadSubScript('chrome://itsalltext/content/itsalltext.js');
 
     /**
@@ -56,11 +61,15 @@
      * @param {String} id The id of textarea or textbody that should be opened in the editor.
      * @param {String} extension The extension of the file used as a temporary file. Example: '.css' (optional)
      */
-    var openEditorCommand = function(event) {
-        var id = this.getAttribute("itsalltext-control");
-        var extension = this.getAttribute("itsalltext-extension");
-        var node = document.getElementById(id);
-        var narf=ItsAllText.debug;
+    openEditorCommand = function (event) {
+        var id = this.getAttribute("itsalltext-control"),
+        extension = this.getAttribute("itsalltext-extension"),
+        node,
+        cache_object,
+        narf = ItsAllText.debug;
+
+        node = document.getElementById(id);
+
         narf('oec narf 1', id, extension, node);
 
         /* The only way I can adjust the background of the textbox is
@@ -69,9 +78,11 @@
         node.style.MozAppearance = 'none';
         narf('oec narf 2');
 
-        var cache_object = node && ItsAllText.getCacheObj(node);
+        cache_object = node && ItsAllText.getCacheObj(node);
         narf('oec narf 3', cache_object);
-        if(!cache_object) { return; }
+        if (!cache_object) {
+            return;
+        }
         narf('oec narf 4');
         cache_object.edit(extension);
 
@@ -80,22 +91,25 @@
     };
 
 
-    var onload = function (event) {
+    onload = function (event) {
+        var nodes = [],
+        node,
+        i,
+        nodesIter;
         /* Start watching the document, but force it. */
         ItsAllText.new_monitor.startPage({originalTarget: document}, true);
 
         /* Turn on all the hidden CSS */
-        var nodes = [], i;
-        var nodesIter = document.evaluate("//node()[@itsalltext-control]",
+        nodesIter = document.evaluate("//node()[@itsalltext-control]",
                                           document, null,
                                           XPathResult.UNORDERED_NODE_ITERATOR_TYPE, null);
 
-        var node = nodesIter.iterateNext();
+        node = nodesIter.iterateNext();
         while (node) {
             nodes.push(node);
             node = nodesIter.iterateNext();
         }
-        for(i in nodes) {
+        for (i in nodes) {
             if (nodes.hasOwnProperty(i)) {
                 node = nodes[i];
                 node.addEventListener('command', openEditorCommand, true);
diff --git a/src/chrome/content/Color.js b/src/chrome/content/Color.js
index abcdd67..8f01499 100644
--- a/src/chrome/content/Color.js
+++ b/src/chrome/content/Color.js
@@ -1,3 +1,4 @@
+/*jslint undef: true, nomen: true, evil: false, browser: true, white: true */
 /**
  * Author: Lachlan Hunt
  * Date: 2005-11-24
@@ -16,10 +17,24 @@
  *   Color("rgba(255, 255, 255, 1.0)");
  *   Color("white"); - CSS 2.1 Color keywords only
  */
-var Color = function() {
+var Color = function () {
+    var keyword,
+        func,
+        clamp,
+        alphaBlend,
+        value,
+        components,
+        pattern,
+        key,
+        base,
+        m,
+        r,
+        g,
+        b,
+        a;
 
     // CSS 2.1 Colour Keywords
-	var keyword = {
+    keyword = {
         maroon   : "#800000",
         red      : "#ff0000",
         orange   : "#ffA500",
@@ -40,7 +55,7 @@ var Color = function() {
     };
 
     // CSS Functional Notations and Hex Patterns
-	var func = {
+    func = {
         rgb   : /^rgb\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*\);?$/,
         "rgb%"  : /^rgb\(\s*(\d{1,3})%\s*,\s*(\d{1,3})%\s*,\s*(\d{1,3})%\s*\);?$/,
         rgba  : /^rgba\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*((?:\d+(?:\.\d+)?)|(?:\.\d+))\s*\);?$/,
@@ -50,87 +65,100 @@ var Color = function() {
     };
 
     /**
-	 * Clamp the value between the low value and the high value
+     * Clamp the value between the low value and the high value
      * @private
-	 */
-	var clamp = function(value, low, high) {
-		if (value < low) {
-			value = low;
-		}
-		else if (value > high) {
-			value = high;
-		}
-		return value;
-	};
+     */
+    clamp = function (value, low, high) {
+        if (value < low) {
+            value = low;
+        }
+        else if (value > high) {
+            value = high;
+        }
+        return value;
+    };
 
     /**
      * @private
      */
-    var alphaBlend = function(forground, background, alpha) {
-		return Math.round(background * (1.0 - alpha) + forground * (alpha));
-	};
-
-	/*
-	 * Return the colour in hexadecimal notation: #RRGGBB. e.g. #FF9933
-	 * @param bg - Optional parameter used for calculating the colour if an alpha value less than 1.0 has been specified.
-	 *             If not specified, the alpha value will be ignored.
-	 */
-    this.hex = function(bg) {
-        var r, g, b;
-		if (bg) {
-			r = alphaBlend(this.red, bg.red, this.alpha);
-			g = alphaBlend(this.green, bg.green, this.alpha);
-			b = alphaBlend(this.blue, bg.blue, this.alpha);
-		} else {
-			r = this.red;
-			g = this.green;
-			b = this.blue;
-		}
-
-		var strHexR = r.toString(16).toUpperCase();
-		var strHexG = g.toString(16).toUpperCase();
-		var strHexB = b.toString(16).toUpperCase();
-
-		if (strHexR.length < 2) { strHexR = "0" + strHexR; }
-		if (strHexG.length < 2) { strHexG = "0" + strHexG; }
-		if (strHexB.length < 2) { strHexB = "0" + strHexB; }
-
-		return "#" + strHexR + strHexG + strHexB;
-	};
+    alphaBlend = function (forground, background, alpha) {
+        return Math.round(background * (1.0 - alpha) + forground * (alpha));
+    };
+
+    /*
+     * Return the colour in hexadecimal notation: #RRGGBB. e.g. #FF9933
+     * @param bg - Optional parameter used for calculating the colour if an alpha value less than 1.0 has been specified.
+     *             If not specified, the alpha value will be ignored.
+     */
+    this.hex = function (bg) {
+        var r,
+            g,
+            b,
+            strHexR,
+            strHexG,
+            strHexB;
+        if (bg) {
+            r = alphaBlend(this.red, bg.red, this.alpha);
+            g = alphaBlend(this.green, bg.green, this.alpha);
+            b = alphaBlend(this.blue, bg.blue, this.alpha);
+        } else {
+            r = this.red;
+            g = this.green;
+            b = this.blue;
+        }
+
+        strHexR = r.toString(16).toUpperCase();
+        strHexG = g.toString(16).toUpperCase();
+        strHexB = b.toString(16).toUpperCase();
+
+        if (strHexR.length < 2) {
+            strHexR = "0" + strHexR;
+        }
+        if (strHexG.length < 2) {
+            strHexG = "0" + strHexG;
+        }
+        if (strHexB.length < 2) {
+            strHexB = "0" + strHexB;
+        }
+
+        return "#" + strHexR + strHexG + strHexB;
+    };
 
     /**
-	 * Return the colour in CSS rgb() functional notation, using integers 0-255: rgb(255, 255 255);
-	 * @param bg - Optional parameter used for calculating the colour if an alpha value less than 1.0 has been specified.
-	 *             If not specified, the alpha value will be ignored.
-	 */
-	this.rgb = function(bg) {
-        var r, g, b;
-		if (bg) {
-			r = alphaBlend(this.red, bg.red, this.alpha);
-			g = alphaBlend(this.green, bg.green, this.alpha);
-			b = alphaBlend(this.blue, bg.blue, this.alpha);
-		} else {
-			r = this.red;
-			g = this.green;
-			b = this.blue;
-		}
-
-		return "rgb(" + r + ", " + g + ", " + b + ")";
-	};
+     * Return the colour in CSS rgb() functional notation, using integers 0-255: rgb(255, 255 255);
+     * @param bg - Optional parameter used for calculating the colour if an alpha value less than 1.0 has been specified.
+     *             If not specified, the alpha value will be ignored.
+     */
+    this.rgb = function (bg) {
+        var r,
+            g,
+            b;
+        if (bg) {
+            r = alphaBlend(this.red, bg.red, this.alpha);
+            g = alphaBlend(this.green, bg.green, this.alpha);
+            b = alphaBlend(this.blue, bg.blue, this.alpha);
+        } else {
+            r = this.red;
+            g = this.green;
+            b = this.blue;
+        }
+
+        return "rgb(" + r + ", " + g + ", " + b + ")";
+    };
 
     /**
-	 * Return the colour in CSS rgba() functional notation, using integers 0-255 for color components: rgb(255, 255 255, 1.0);
-	 * @param bg - Optional parameter used for calculating the colour if an alpha value less than 1.0 has been specified.
-	 *             If not specified, and there is an alpha value, black will be used as the background colour.
-	 */
-	this.rgba = function() {
-		return "rgba(" + this.red + ", " + this.green + ", " + this.blue + ", " + this.alpha + ")";
-	};
+     * Return the colour in CSS rgba() functional notation, using integers 0-255 for color components: rgb(255, 255 255, 1.0);
+     * @param bg - Optional parameter used for calculating the colour if an alpha value less than 1.0 has been specified.
+     *             If not specified, and there is an alpha value, black will be used as the background colour.
+     */
+    this.rgba = function () {
+        return "rgba(" + this.red + ", " + this.green + ", " + this.blue + ", " + this.alpha + ")";
+    };
 
     /**
      * Returns a Color object with the values inverted. Ignores alpha.
      */
-    this.invert = function() {
+    this.invert = function () {
         return new Color("rgb(" +
                          (255 - this.red) + ", " +
                          (255 - this.green) + ", " +
@@ -138,15 +166,17 @@ var Color = function() {
     };
 
     /**
-	 * Blend this colour with the colour specified and return a pallet with all the steps in between.
-	 * @param color - The colour to blend with
-	 * @param steps - The number of steps to take to reach the color.
-	 */
-	this.blend = function(color, steps) {
-        var pallet = [];
-        var r, g, b, i;
-
-        var step = {
+     * Blend this colour with the colour specified and return a pallet with all the steps in between.
+     * @param color - The colour to blend with
+     * @param steps - The number of steps to take to reach the color.
+     */
+    this.blend = function (color, steps) {
+        var pallet = [],
+            r,
+            g,
+            b,
+            i,
+            step = {
             red   : (alphaBlend(color.red, this.red, color.alpha) - this.red) / steps,
             green : (alphaBlend(color.green, this.green, color.alpha) - this.green) / steps,
             blue  : (alphaBlend(color.blue,  this.blue,  color.alpha) - this.blue) / steps
@@ -158,17 +188,13 @@ var Color = function() {
             pallet.push(new Color(r, g, b));
         }
         return pallet;
-	};
+    };
 
     /**
-	 * Constructor function
-	 */
+     * Constructor function
+     */
     this.toString = this.hex;
 
-    var value;
-    var components, pattern;
-    var key, base, m;
-    var r, g, b, a;
     if (arguments.length >= 3) {
         /* r, g, b or r, g, b, a */
         r = arguments[0];
@@ -217,9 +243,9 @@ var Color = function() {
             components = [0, "255", "255", "255", "1.0"];
         }
 
-        this.red   = clamp(Math.round(parseInt(components[1],base) * m), 0, 255);
-        this.green = clamp(Math.round(parseInt(components[2],base) * m), 0, 255);
-        this.blue  = clamp(Math.round(parseInt(components[3],base) * m), 0, 255);
+        this.red   = clamp(Math.round(parseInt(components[1], base) * m), 0, 255);
+        this.green = clamp(Math.round(parseInt(components[2], base) * m), 0, 255);
+        this.blue  = clamp(Math.round(parseInt(components[3], base) * m), 0, 255);
 
         if (typeof(components[4]) === 'undefined' || isNaN(components[4])) {
             this.alpha = 1;
diff --git a/src/chrome/content/badeditor.js b/src/chrome/content/badeditor.js
index f0b8b2d..e050400 100644
--- a/src/chrome/content/badeditor.js
+++ b/src/chrome/content/badeditor.js
@@ -1,4 +1,5 @@
-/*jslint nomen: true, evil: false, browser: true */
+/*jslint undef: true, nomen: true, evil: false, browser: true, white: true */
+
 /**
  * Pass back the values that that the user selected.
  */
@@ -9,29 +10,29 @@ function onOK() {
     return true;
 }
 function doOnload() {
-    var locale = document.getElementById("strings");
-    var params = window['arguments'][0];
-    var reason = document.getElementById('reason');
-    var textnode = '**error**';
+    var locale = document.getElementById("strings"),
+        params = window['arguments'][0],
+        reason = document.getElementById('reason'),
+        textnode = '**error**';
     /* Errors are from
      * http://lxr.mozilla.org/seamonkey/source/xpcom/base/nsError.h#262 */
-    if(params.exception == 'NS_ERROR_FILE_INVALID_PATH' ||
+    if (params.exception == 'NS_ERROR_FILE_INVALID_PATH' ||
        params.exception == 'NS_ERROR_FILE_UNRECOGNIZED_PATH' ||
        params.exception == 'NS_ERROR_FILE_TARGET_DOES_NOT_EXIST' ||
        params.exception == 'NS_ERROR_FILE_INVALID_PATH' ||
        params.exception == 'NS_ERROR_FILE_NOT_FOUND' ||
-       params.exception == 'NS_ERROR_FILE_NAME_TOO_LONG' ) {
+       params.exception == 'NS_ERROR_FILE_NAME_TOO_LONG') {
         textnode = locale.getFormattedString('bad.noent', [params.path]);
-    } else if(params.exception == 'NS_ERROR_FILE_ACCESS_DENIED' ||
+    } else if (params.exception == 'NS_ERROR_FILE_ACCESS_DENIED' ||
               params.exception == 'NS_ERROR_FILE_IS_DIRECTORY' ||
-              params.exception == 'NS_ERROR_FILE_IS_LOCKED' ) {
+              params.exception == 'NS_ERROR_FILE_IS_LOCKED') {
         textnode = locale.getFormattedString('bad.noexec', []);
 
     /* At this point, we don't know exactly why it failed...
      * Try some heuristics. */
-    } else if(!params.path) {
-        textnode = locale.getFormattedString('bad.noset',[]);
-    } else if(params.exists) {
+    } else if (!params.path) {
+        textnode = locale.getFormattedString('bad.noset', []);
+    } else if (params.exists) {
         textnode = locale.getFormattedString('bad.noexec', []);
     } else {
         textnode = locale.getFormattedString('bad.noent', [params.path]);
diff --git a/src/chrome/content/cacheobj.js b/src/chrome/content/cacheobj.js
index f2fb1c2..29d25ec 100644
--- a/src/chrome/content/cacheobj.js
+++ b/src/chrome/content/cacheobj.js
@@ -1,3 +1,5 @@
+/*extern ItsAllText, Components */
+/*jslint undef: true, nomen: true, evil: false, browser: true, white: true */
 /*
  *  It's All Text! - Easy external editing of web forms.
  *
@@ -16,15 +18,17 @@
  *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-/*jslint nomen: true, evil: false, browser: true */
-
 /**
  * A Cache object is used to manage the node and the file behind it.
  * @constructor
  * @param {Object} node A DOM Node to watch.
  */
 function CacheObj(node) {
-    var that = this;
+    var that = this,
+        doc = node.ownerDocument,
+        host,
+        hash,
+        extension;
 
     /* Gumdrop Image URL */
     that.gumdrop_url    = 'chrome://itsalltext/locale/gumdrop.png';
@@ -43,7 +47,6 @@ function CacheObj(node) {
     that.is_focused = false;
 
     that.node_id = that.getNodeIdentifier(node);
-    var doc = node.ownerDocument;
 
     /* This is a unique identifier for use on the web page to prevent the
      * web page from knowing what it's connected to.
@@ -54,19 +57,19 @@ function CacheObj(node) {
                                  that.node_id ].join(':'));
     // @todo [security] Add a serial to the uid hash.
 
-    node.setAttribute(ItsAllText.MYSTRING+'_UID', that.uid);
+    node.setAttribute(ItsAllText.MYSTRING + '_UID', that.uid);
     ItsAllText.tracker[that.uid] = that;
 
     /* Figure out where we will store the file.  While the filename can
      * change, the directory that the file is stored in should not!
      */
-    var host = window.escape(doc.location.hostname);
-    var hash = that.hashString([ doc.location.protocol,
-                                 doc.location.port,
-                                 doc.location.search,
-                                 doc.location.pathname,
-                                 that.node_id ].join(':'));
-    that.base_filename = [host, hash.slice(0,10)].join('.');
+    host = window.escape(doc.location.hostname);
+    hash = that.hashString([ doc.location.protocol,
+                             doc.location.port,
+                             doc.location.search,
+                             doc.location.pathname,
+                             that.node_id].join(':'));
+    that.base_filename = [host, hash.slice(0, 10)].join('.');
     /* The current extension.
      * @type String
      */
@@ -83,7 +86,7 @@ function CacheObj(node) {
     that.edit_count = 0;
 
     /* Set the default extension and create the nsIFile object. */
-    var extension = node.getAttribute('itsalltext-extension');
+    extension = node.getAttribute('itsalltext-extension');
     if (typeof(extension) != 'string' || !extension.match(/^[.a-z0-9]+$/i)) {
         extension = ItsAllText.getExtensions()[0];
     }
@@ -96,7 +99,7 @@ function CacheObj(node) {
      * the mouse waved over it.
      * @param {Event} event The event object.
      */
-    that.mouseover = function(event) {
+    that.mouseover = function (event) {
         if (event.type === 'focus') {
             that.is_focused = true;
         }
@@ -116,7 +119,7 @@ function CacheObj(node) {
      * the mouse waved over it and the moved off.
      * @param {Event} event The event object.
      */
-    that.mouseout = function(event) {
+    that.mouseout = function (event) {
         if (that.button_fade_timer) {
             clearTimeout(that.button_fade_timer);
         }
@@ -126,13 +129,14 @@ function CacheObj(node) {
         }
         that.is_focused = false;
 
-        var style = that.button?that.button.style:null, f;
-        var cur  = 0.7;
-        var dest = 0;
-        var fps  = 12;
-        var num_frames = (ItsAllText.preferences.fade_time * fps);
-        var increment = (cur - dest) / num_frames;
-        var wait = (1 / fps) / 1000;
+        var style = that.button?that.button.style:null,
+            f,
+            cur  = 0.7,
+            dest = 0,
+            fps  = 12,
+            num_frames = (ItsAllText.preferences.fade_time * fps),
+            increment = (cur - dest) / num_frames,
+            wait = (1 / fps) / 1000;
         if (style) {
             f = function () {
                 cur -= increment;
@@ -151,14 +155,14 @@ function CacheObj(node) {
 /**
  * Destroys the object, unallocating as much as possible to prevent leaks.
  */
-CacheObj.prototype.destroy = function() {
+CacheObj.prototype.destroy = function () {
     ItsAllText.debug('destroying', this.node_id, this.uid);
-    var node = this.node;
-    var doc  = this.node.ownerDocument;
-    var html = doc.getElementsByTagName('html')[0];
+    var node = this.node,
+        doc  = this.node.ownerDocument,
+        html = doc.getElementsByTagName('html')[0];
 
-    node.removeAttribute(ItsAllText.MYSTRING+'_UID');
-    html.removeAttribute(ItsAllText.MYSTRING+'_id_serial');
+    node.removeAttribute(ItsAllText.MYSTRING + '_UID');
+    html.removeAttribute(ItsAllText.MYSTRING + '_id_serial');
 
     delete this.node;
     delete this.button;
@@ -170,7 +174,7 @@ CacheObj.prototype.destroy = function() {
  * Set the extension for the file to ext.
  * @param {String} ext The extension.  Must include the dot.  Example: .txt
  */
-CacheObj.prototype.setExtension = function(ext) {
+CacheObj.prototype.setExtension = function (ext) {
     if (ext == this.extension && this.file) {
         return; /* It's already set.  No problem. */
     }
@@ -178,7 +182,7 @@ CacheObj.prototype.setExtension = function(ext) {
     /* Create the nsIFile object */
     var file = ItsAllText.factoryFile();
     file.initWithFile(ItsAllText.getEditDir());
-    file.append([this.base_filename,ext].join(''));
+    file.append([this.base_filename, ext].join(''));
 
     this.extension = ext;
     this.file = file;
@@ -193,13 +197,13 @@ CacheObj.prototype.setExtension = function(ext) {
  * if the file exists already.  It also deletes all existing files for
  * this cache object.
  */
-CacheObj.prototype.initFromExistingFile = function() {
-    var base = this.base_filename;
-    var fobj = ItsAllText.getEditDir();
-    var entries = fobj.directoryEntries;
-    var ext = null;
-    var tmpfiles = /(\.bak|.tmp|~)$/;
-    var entry;
+CacheObj.prototype.initFromExistingFile = function () {
+    var base = this.base_filename,
+        fobj = ItsAllText.getEditDir(),
+        entries = fobj.directoryEntries,
+        ext = null,
+        tmpfiles = /(\.bak|.tmp|~)$/,
+        entry;
     while (entries.hasMoreElements()) {
         entry = entries.getNext();
         entry.QueryInterface(Components.interfaces.nsIFile);
@@ -209,10 +213,10 @@ CacheObj.prototype.initFromExistingFile = function() {
                 ext = entry.leafName.slice(base.length);
                 continue;
             }
-            try{
+            try {
                 entry.remove(false);
-            } catch(e) {
-                that.debug('unable to remove',entry,'because:',e);
+            } catch (e) {
+                ItsAllText.debug('unable to remove', entry, 'because:', e);
             }
         }
     }
@@ -226,21 +230,27 @@ CacheObj.prototype.initFromExistingFile = function() {
  * Returns a unique identifier for the node, within the document.
  * @returns {String} the unique identifier.
  */
-CacheObj.prototype.getNodeIdentifier = function(node) {
-    var id   = node.getAttribute('id');
-    var name, doc, attr, serial;
+CacheObj.prototype.getNodeIdentifier = function (node) {
+    var id   = node.getAttribute('id'),
+        name,
+        doc,
+        attr,
+        serial;
     if (!id) {
         name = node.getAttribute('name');
         doc = node.ownerDocument.getElementsByTagName('html')[0];
-        attr = ItsAllText.MYSTRING+'_id_serial';
+        attr = ItsAllText.MYSTRING + '_id_serial';
 
         /* Get a serial that's unique to this document */
         serial = doc.getAttribute(attr);
-        if (serial) { serial = parseInt(serial, 10)+1;
-        } else { serial = 1; }
-        id = [ItsAllText.MYSTRING,'generated_id',name,serial].join('_');
-        doc.setAttribute(attr,serial);
-        node.setAttribute('id',id);
+        if (serial) {
+            serial = parseInt(serial, 10) + 1;
+        } else {
+            serial = 1;
+        }
+        id = [ItsAllText.MYSTRING, 'generated_id', name, serial].join('_');
+        doc.setAttribute(attr, serial);
+        node.setAttribute('id', id);
     }
     return id;
 };
@@ -249,12 +259,11 @@ CacheObj.prototype.getNodeIdentifier = function(node) {
  * Convert to this object to a useful string.
  * @returns {String} A string representation of this object.
  */
-CacheObj.prototype.toString = function() {
+CacheObj.prototype.toString = function () {
     return [ "CacheObj",
-             " uid=",this.uid,
-             " timestamp=",this.timestamp,
-             " size=",this.size
-    ].join('');
+             " uid=", this.uid,
+             " timestamp=", this.timestamp,
+             " size=", this.size].join('');
 };
 
 /**
@@ -262,7 +271,7 @@ CacheObj.prototype.toString = function() {
  *
  * @param {boolean} clobber Should an existing file be clobbered?
  */
-CacheObj.prototype.write = function(clobber) {
+CacheObj.prototype.write = function (clobber) {
     clobber = typeof(clobber) === 'boolean'?clobber:true;
     var foStream, conv, text;
 
@@ -273,7 +282,7 @@ CacheObj.prototype.write = function(clobber) {
 
         /* write, create, truncate */
         foStream.init(this.file, 0x02 | 0x08 | 0x20,
-                      parseInt('0600',8), 0);
+                      parseInt('0600', 8), 0);
 
         /* We convert to charset */
         conv = Components.
@@ -305,9 +314,9 @@ CacheObj.prototype.write = function(clobber) {
  * @param {String} attr The CSS-style attribute to fetch (not DOM name).
  * @returns attribute
  */
-CacheObj.prototype.getStyle = function(node, attr) {
-    var view  = node ? node.ownerDocument.defaultView : null;
-    var style = view.getComputedStyle(node, '');
+CacheObj.prototype.getStyle = function (node, attr) {
+    var view  = node ? node.ownerDocument.defaultView : null,
+        style = view.getComputedStyle(node, '');
     return  style.getPropertyCSSValue(attr).cssText;
 };
 
@@ -319,29 +328,38 @@ CacheObj.prototype.getStyle = function(node, attr) {
  * @param {String} extension The extension of the file to edit.
  * @param {boolean} clobber Should an existing file be clobbered?
  */
-CacheObj.prototype.edit = function(extension, clobber) {
-    ItsAllText.debug('edit(',extension,', ',clobber,')');
+CacheObj.prototype.edit = function (extension, clobber) {
+    ItsAllText.debug('edit(', extension, ', ', clobber, ')');
     extension = typeof(extension) === 'string'?extension:this.extension;
     this.setExtension(extension);
 
-    var filename = this.write(clobber);
+    var filename = this.write(clobber),
+        program = null,
+        process,
+        args,
+        result,
+        ec,
+        params,
+        procutil;
+    procutil = Components.classes["@mozilla.org/process/util;1"];
     this.initial_background = this.node.style.backgroundColor;
     this.initial_color      = this.node.style.color;
-    var program = null;
-    const procutil = Components.classes["@mozilla.org/process/util;1"];
 
-    var process;
-    var args, result, ec, params;
 
     try {
         program = ItsAllText.getEditor();
         // checks
-        if (program === null)        { throw {name:"Editor is not set."}; }
-        if (!program.exists())       { throw {name:"NS_ERROR_FILE_NOT_FOUND"}; }
+        if (program === null) {
+            throw {name: "Editor is not set."};
+        }
+        if (!program.exists()) {
+            throw {name: "NS_ERROR_FILE_NOT_FOUND"};
+        }
         /* Mac check because of
          * https://bugzilla.mozilla.org/show_bug.cgi?id=322865 */
         if (!(ItsAllText.isDarwin() || program.isExecutable())) {
-            throw {name:"NS_ERROR_FILE_ACCESS_DENIED"}; }
+            throw {name: "NS_ERROR_FILE_ACCESS_DENIED"};
+        }
 
         // create an nsIProcess
         process = procutil.createInstance(Components.interfaces.nsIProcess);
@@ -357,16 +375,16 @@ CacheObj.prototype.edit = function(extension, clobber) {
         ec = process.run(false, args, args.length, result);
         this.private_is_watching = true;
         this.edit_count++;
-    } catch(e) {
-        params = {out:null,
-                      exists: program ? program.exists() : false,
-                      path: ItsAllText.preferences.editor,
-                      exception: e.name };
+    } catch (e) {
+        params = { out: null,
+                   exists: program ? program.exists() : false,
+                   path: ItsAllText.preferences.editor,
+                   exception: e.name };
         window.openDialog('chrome://itsalltext/content/badeditor.xul',
                           null,
-                          "chrome,titlebar,toolbar,centerscreen,modal",
+                          "chrome, titlebar, toolbar, centerscreen, modal",
                           params);
-        if(params.out !== null && params.out.do_preferences) {
+        if (params.out !== null && params.out.do_preferences) {
             ItsAllText.openPreferences(true);
             this.edit(extension);
         }
@@ -376,12 +394,12 @@ CacheObj.prototype.edit = function(extension, clobber) {
 /**
  * Delete the file from disk.
  */
-CacheObj.prototype.remove = function() {
-    if(this.file.exists()) {
+CacheObj.prototype.remove = function () {
+    if (this.file.exists()) {
         try {
             this.file.remove();
-        } catch(e) {
-            that.debug('remove(',this.file.path,'): ',e);
+        } catch (e) {
+            ItsAllText.debug('remove(', this.file.path, '): ', e);
             return false;
         }
     }
@@ -391,16 +409,18 @@ CacheObj.prototype.remove = function() {
 /**
  * Read the file from disk.
  */
-CacheObj.prototype.read = function() {
+CacheObj.prototype.read = function () {
     /* read file, reset ts & size */
-    var DEFAULT_REPLACEMENT_CHARACTER = 65533;
-    var buffer = [];
-    var fis, istream, str;
+    var DEFAULT_REPLACEMENT_CHARACTER = 65533,
+        buffer = [],
+        fis,
+        istream,
+        str;
 
     try {
         fis = Components.classes["@mozilla.org/network/file-input-stream;1"].
             createInstance(Components.interfaces.nsIFileInputStream);
-        fis.init(this.file, 0x01, parseInt('00400',8), 0);
+        fis.init(this.file, 0x01, parseInt('00400', 8), 0);
         // MODE_RDONLY | PERM_IRUSR
 
         istream = Components.classes["@mozilla.org/intl/converter-input-stream;1"].
@@ -419,7 +439,7 @@ CacheObj.prototype.read = function() {
         this.size      = this.file.fileSize;
 
         return buffer.join('');
-    } catch(e) {
+    } catch (e) {
         return null;
     }
 };
@@ -428,15 +448,15 @@ CacheObj.prototype.read = function() {
  * Has the file object changed?
  * @returns {boolean} returns true if the file has changed on disk.
  */
- CacheObj.prototype.hasChanged = function() {
-     /* Check exists.  Check ts and size. */
-     return this.private_is_watching &&
-         this.file &&
-         this.file.exists() &&
-         this.file.isReadable() &&
-         (this.file.lastModifiedTime != this.timestamp ||
-          this.file.fileSize         != this.size);
- };
+CacheObj.prototype.hasChanged = function () {
+    /* Check exists.  Check ts and size. */
+    return this.private_is_watching &&
+           this.file &&
+           this.file.exists() &&
+           this.file.isReadable() &&
+           (this.file.lastModifiedTime != this.timestamp ||
+            this.file.fileSize         != this.size);
+};
 
 /**
  * Part of the fading technique.
@@ -444,14 +464,14 @@ CacheObj.prototype.read = function() {
  * @param {int}    step   Size of a step.
  * @param {delay}  delay  Delay in microseconds.
  */
-CacheObj.prototype.fadeStep = function(background_pallet, color_pallet, step, delay) {
+CacheObj.prototype.fadeStep = function (background_pallet, color_pallet, step, delay) {
     var that = this;
-    return function() {
+    return function () {
         if (step < background_pallet.length) {
             that.node.style.backgroundColor = background_pallet[step].hex();
             that.node.style.color = color_pallet[step].hex();
             step++;
-            setTimeout(that.fadeStep(background_pallet, color_pallet, step, delay),delay);
+            setTimeout(that.fadeStep(background_pallet, color_pallet, step, delay), delay);
         } else {
             that.node.style.backgroundColor = that.initial_background;
             that.node.style.color = that.initial_color;
@@ -464,16 +484,16 @@ CacheObj.prototype.fadeStep = function(background_pallet, color_pallet, step, de
  * @param {int} steps  Number of steps in the transition.
  * @param {int} delay  How long to wait between delay (microseconds).
  */
-CacheObj.prototype.fade = function(steps, delay) {
-    var color             = this.getStyle(this.node, 'color');
-    var color_stop        = new ItsAllText.Color(color);
-    var color_start       = new ItsAllText.Color('black');
-    var color_pallet      = color_start.blend(color_stop, steps);
-
-    var background        = this.getStyle(this.node, 'background-color');
-    var background_stop   = new ItsAllText.Color(background);
-    var background_start  = new ItsAllText.Color('yellow');
-    var background_pallet = background_start.blend(background_stop, steps);
+CacheObj.prototype.fade = function (steps, delay) {
+    var color             = this.getStyle(this.node, 'color'),
+        color_stop        = new ItsAllText.Color(color),
+        color_start       = new ItsAllText.Color('black'),
+        color_pallet      = color_start.blend(color_stop, steps),
+
+        background        = this.getStyle(this.node, 'background-color'),
+        background_stop   = new ItsAllText.Color(background),
+        background_start  = new ItsAllText.Color('yellow'),
+        background_pallet = background_start.blend(background_stop, steps);
     setTimeout(this.fadeStep(background_pallet, color_pallet, 0, delay), delay);
 };
 
@@ -481,7 +501,7 @@ CacheObj.prototype.fade = function(steps, delay) {
  * Update the node from the file.
  * @returns {boolean} Returns true ifthe file changed.
  */
-CacheObj.prototype.update = function() {
+CacheObj.prototype.update = function () {
     var value;
     ItsAllText.debug('narf update', this.file.path);
     if (this.hasChanged()) {
@@ -498,7 +518,7 @@ CacheObj.prototype.update = function() {
 /**
  * Capture keypresses to do the hotkey edit.
  */
-CacheObj.prototype.keypress = function(event) {
+CacheObj.prototype.keypress = function (event) {
     var km = ItsAllText.marshalKeyEvent(event), cobj;
     if (km === ItsAllText.preferences.hotkey) {
         cobj = ItsAllText.getCacheObj(event.target);
@@ -512,7 +532,7 @@ CacheObj.prototype.keypress = function(event) {
  * The function to execute when a gumdrop is clicked.
  * @param {Object} event The event that triggered this.
  */
-CacheObj.prototype.onClick = function(event) {
+CacheObj.prototype.onClick = function (event) {
     var cobj = ItsAllText.getCacheObj(event.target);
     cobj.edit();
     event.stopPropagation();
@@ -523,7 +543,7 @@ CacheObj.prototype.onClick = function(event) {
  * The function to execute when a gumdrop is right clicked (context)
  * @param {Object} event The event that triggered this.
  */
-CacheObj.prototype.onContext = function(event) {
+CacheObj.prototype.onContext = function (event) {
     /* This took forever to fix; roughly 80+ man hours were spent
      * over 5 months trying to make this stupid thing work.
      * The documentation is completely wrong and useless.
@@ -537,8 +557,8 @@ CacheObj.prototype.onContext = function(event) {
      * This is actually fixed in FF3 by replacing it with something
      * sane....openPopup()
      */
-    var cobj = ItsAllText.getCacheObj(event.target);
-    var popup = ItsAllText.rebuildMenu(cobj.uid);
+    var cobj = ItsAllText.getCacheObj(event.target),
+        popup = ItsAllText.rebuildMenu(cobj.uid);
 
     if (popup.openPopup) {
         /* FF3 breath of sanity. */
@@ -560,15 +580,20 @@ CacheObj.prototype.onContext = function(event) {
  * Add the gumdrop to a textarea.
  * @param {Object} cache_object The Cache Object that contains the node.
  */
-CacheObj.prototype.addGumDrop = function() {
-    var cache_object = this;
+CacheObj.prototype.addGumDrop = function () {
+    var cache_object = this,
+        node,
+        doc,
+        gumdrop,
+        parent,
+        nextSibling;
     if (cache_object.button !== null) {
         cache_object.adjust();
         return; /*already done*/
     }
 
     // Add the textarea mouseovers even if the button is disabled
-    var node = cache_object.node;
+    node = cache_object.node;
     ItsAllText.listen(node, "mouseover", ItsAllText.hitch(cache_object, "mouseover"), false);
     ItsAllText.listen(node, "mouseout",  ItsAllText.hitch(cache_object, "mouseout"),  false);
     ItsAllText.listen(node, "focus",     ItsAllText.hitch(cache_object, "mouseover"), false);
@@ -582,12 +607,14 @@ CacheObj.prototype.addGumDrop = function() {
     if (ItsAllText.getDisableGumdrops()) {
         return;
     }
-    ItsAllText.debug('addGumDrop()',cache_object);
+    ItsAllText.debug('addGumDrop()', cache_object);
 
-    var doc = node.ownerDocument;
-    if (!node.parentNode) { return; }
+    doc = node.ownerDocument;
+    if (!node.parentNode) {
+        return;
+    }
 
-    var gumdrop = doc.createElementNS(ItsAllText.XHTMLNS, "img");
+    gumdrop = doc.createElementNS(ItsAllText.XHTMLNS, "img");
     gumdrop.setAttribute('src', this.gumdrop_url);
 
     if (ItsAllText.getDebug()) {
@@ -606,10 +633,10 @@ CacheObj.prototype.addGumDrop = function() {
     gumdrop.style.setProperty('border',   'none',     'important');
     gumdrop.style.setProperty('zIndex',   '32768',    'important');
 
-    gumdrop.style.setProperty('width',  this.gumdrop_width+'px',  'important');
-    gumdrop.style.setProperty('height', this.gumdrop_height+'px', 'important');
+    gumdrop.style.setProperty('width',  this.gumdrop_width + 'px', 'important');
+    gumdrop.style.setProperty('height', this.gumdrop_height + 'px', 'important');
 
-    gumdrop.setAttribute(ItsAllText.MYSTRING+'_UID', cache_object.uid);
+    gumdrop.setAttribute(ItsAllText.MYSTRING + '_UID', cache_object.uid);
 
     // Click event handlers
     ItsAllText.listen(gumdrop, "click", ItsAllText.hitch(cache_object, 'onClick'), false);
@@ -618,8 +645,8 @@ CacheObj.prototype.addGumDrop = function() {
 // narf    gumdrop.addEventListener("contextmenu", cache_object.onContext, false);
 
     // Insert it into the document
-    var parent = node.parentNode;
-    var nextSibling = node.nextSibling;
+    parent = node.parentNode;
+    nextSibling = node.nextSibling;
 
     if (nextSibling) {
         parent.insertBefore(gumdrop, nextSibling);
@@ -640,22 +667,31 @@ CacheObj.prototype.addGumDrop = function() {
 /**
  * Updates the position of the gumdrop, incase the textarea shifts around.
  */
-CacheObj.prototype.adjust = function() {
-    var gumdrop  = this.button;
-    var el       = this.node;
-    var doc      = el.ownerDocument;
+CacheObj.prototype.adjust = function () {
+    var gumdrop  = this.button,
+        el       = this.node,
+        doc      = el.ownerDocument,
+        style,
+        display,
+        cstyle,
+        left,
+        top,
+        coord,
+        pos;
 
     if (ItsAllText.getDisableGumdrops()) {
-        if(gumdrop && gumdrop.style.display != 'none') {
+        if (gumdrop && gumdrop.style.display != 'none') {
             gumdrop.style.setProperty('display', 'none', 'important');
         }
         return;
     }
 
-    var style    = gumdrop.style;
-    if (!gumdrop || !el) { return; }
-    var display  = '';
-    var cstyle = doc.defaultView && doc.defaultView.getComputedStyle(el, '');
+    style    = gumdrop.style;
+    if (!gumdrop || !el) {
+        return;
+    }
+    display  = '';
+    cstyle = doc.defaultView && doc.defaultView.getComputedStyle(el, '');
     if ((cstyle && (cstyle.display == 'none' ||
                     cstyle.visibility == 'hidden')) ||
         el.getAttribute('readonly') ||
@@ -671,10 +707,9 @@ CacheObj.prototype.adjust = function() {
      * Position the gumdrop.
      * Updates in case the DOM changes.
      */
-    var left, top, coord;
-    var pos = ItsAllText.preferences.gumdrop_position;
+    pos = ItsAllText.preferences.gumdrop_position;
     if (pos === 'upper-right' || pos === 'lower-right') {
-        left = Math.max(1, el.offsetWidth-this.gumdrop_width);
+        left = Math.max(1, el.offsetWidth - this.gumdrop_width);
     } else {
         left = 0;
     }
@@ -691,11 +726,15 @@ CacheObj.prototype.adjust = function() {
         left += coord[0];
         top  += coord[1];
     }
-    if(left && top) {
-        left = [left,'px'].join('');
-        top  = [top,'px'].join('');
-        if(style.left != left) { style.setProperty('left', left, 'important');}
-        if(style.top != top)   { style.setProperty('top',  top, 'important');}
+    if (left && top) {
+        left = [left, 'px'].join('');
+        top  = [top, 'px'].join('');
+        if (style.left != left) {
+            style.setProperty('left', left, 'important');
+        }
+        if (style.top != top) {
+            style.setProperty('top',  top, 'important');
+        }
     }
 };
 
@@ -706,36 +745,81 @@ CacheObj.prototype.adjust = function() {
  * @param {String} some_string The string to hash.
  * @returns {String} a hashed string.
  */
-CacheObj.prototype.hashString = function(some_string) {
-    var converter = Components.classes["@mozilla.org/intl/scriptableunicodeconverter"].createInstance(Components.interfaces.nsIScriptableUnicodeConverter);
+CacheObj.prototype.hashString = function (some_string) {
+    var converter = Components.classes["@mozilla.org/intl/scriptableunicodeconverter"].createInstance(Components.interfaces.nsIScriptableUnicodeConverter),
+        result = {},
+        data,
+        ch,
+        hash,
+        toHexString,
+        retval = [],
+        i;
     converter.charset = "UTF-8";
 
     /* result is the result of the hashing.  It's not yet a string,
      * that'll be in retval.
      * result.value will contain the array length
      */
-    var result = {};
+    result = {};
 
     /* data is an array of bytes */
-    var data = converter.convertToByteArray(some_string, result);
-    var ch   = Components.classes["@mozilla.org/security/hash;1"].createInstance(Components.interfaces.nsICryptoHash);
+    data = converter.convertToByteArray(some_string, result);
+    ch   = Components.classes["@mozilla.org/security/hash;1"].createInstance(Components.interfaces.nsICryptoHash);
 
     ch.init(ch.MD5);
     ch.update(data, data.length);
-    var hash = ch.finish(true);
+    hash = ch.finish(true);
 
     // return the two-digit hexadecimal code for a byte
-    var toHexString = function(charCode) {
+    toHexString = function (charCode) {
         return ("0" + charCode.toString(36)).slice(-2);
     };
 
     // convert the binary hash data to a hex string.
-    var retval = [], i;
-    for(i in hash) {
+    for (i in hash) {
         if (hash.hasOwnProperty(i)) {
             retval[i] = toHexString(hash.charCodeAt(i));
         }
     }
 
-    return(retval.join(""));
+    return (retval.join(""));
+};
+
+/**
+ * Returns a cache object
+ * Note: These UIDs are only unique for Its All Text.
+ * @param {Object} node A dom object node or ID to one.
+ * @returns {String} the UID or null.
+ */
+ItsAllText.getCacheObj = function (node) {
+    var str = ItsAllText.MYSTRING + "_UID",
+        id = null;
+    if (typeof(node) === 'string') {
+        id = node;
+    } else if (node && node.hasAttribute(str)) {
+        id = node.getAttribute(str);
+    }
+    if (id && ItsAllText.tracker.hasOwnProperty(id)) {
+        return ItsAllText.tracker[id];
+    } else {
+        return null;
+    }
+};
+
+/**
+ * Creates a cache object, unless one exists already.
+ * Note: These UIDs are only unique for Its All Text.
+ * @param {DOMElement} node A dom object node or id to one.
+ * @param {Boolean} create_gumdrop Should a gumdrop be created (html).
+ * @returns {String} the UID or null.
+ */
+ItsAllText.makeCacheObj = function (node, create_gumdrop) {
+    var cobj = ItsAllText.getCacheObj(node);
+    if (!cobj) {
+        cobj = new ItsAllText.CacheObj(node);
+        if (create_gumdrop) {
+            cobj.addGumDrop();
+        }
+    }
+    return cobj;
 };
diff --git a/src/chrome/content/itsalltext.js b/src/chrome/content/itsalltext.js
index 76ea1f6..f6e17d3 100644
--- a/src/chrome/content/itsalltext.js
+++ b/src/chrome/content/itsalltext.js
@@ -1,3 +1,6 @@
+/*extern Components, Firebug, getBoolPref, openDialog, getBrowser, gBrowser */
+/*jslint undef: true, nomen: true, evil: false, browser: true, white: true */
+
 /*
  *  It's All Text! - Easy external editing of web forms.
  *
@@ -16,20 +19,19 @@
  *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-/*jslint nomen: true, evil: false, browser: true */
-
 // @todo [9] IDEA: dropdown list for charsets (utf-8, western-iso, default)?
 // @todo [wish] Have a menu/context menu item for turning on monitoring/watch.
 // @todo [9] Menu item to pick the file to load into a textarea.
 // @todo [9] IDEA: Hot-keys opening the context menu.
 
-var ItsAllText = function() {
+var ItsAllText = function () {
     /**
      * This data is all private, which prevents security problems and it
      * prevents clutter and collection.
      * @type Object
      */
-    var that = this;
+    var that = this,
+        loadthings;
 
     /**
      * Used for tracking all the all the textareas that we are watching.
@@ -75,7 +77,7 @@ var ItsAllText = function() {
      * @param {Array} arr Array of strings to replace in the string.
      * @returns String
      */
-    that.localeFormat = function(name, arr) {
+    that.localeFormat = function (name, arr) {
         return this.getLocale().formatStringFromName(name, arr, arr.length);
     };
     /**
@@ -83,7 +85,7 @@ var ItsAllText = function() {
      * @param {String} name Locale property name
      * @returns String
      */
-    that.localeString = function(name) {
+    that.localeString = function (name) {
         return this.getLocale().GetStringFromName(name);
     };
 
@@ -91,12 +93,13 @@ var ItsAllText = function() {
      * Create an error message from given arguments.
      * @param {Object} message One or more objects to be made into strings...
      */
-    that.logString = function() {
-        var args = Array.prototype.slice.apply(arguments,[0]);
-        for (var i=0; i<args.length; i++) {
+    that.logString = function () {
+        var args = Array.prototype.slice.apply(arguments, [0]),
+            i;
+        for (i = 0; i < args.length; i++) {
             try {
                 args[i] = "" + args[i];
-            } catch(e) {
+            } catch (e) {
                 Components.utils.reportError(e);
                 args[i] = 'toStringFailed';
             }
@@ -110,14 +113,14 @@ var ItsAllText = function() {
      * I release this.
      * @param {Object} message One or more objects can be passed in to display.
      */
-    that.log = function() {
-        var message = that.logString.apply(that, arguments);
+    that.log = function () {
         const consoleService = Components.classes["@mozilla.org/consoleservice;1"];
-        var obj = consoleService.getService(Components.interfaces.nsIConsoleService);
+        var message = that.logString.apply(that, arguments),
+            obj = consoleService.getService(Components.interfaces.nsIConsoleService);
         try {
             // idiom: Convert arguments to an array for easy handling.
             obj.logStringMessage(message);
-        } catch(e) {
+        } catch (e) {
             Components.utils.reportError(message);
         }
     };
@@ -127,9 +130,9 @@ var ItsAllText = function() {
      * globally logged (firebug only logs locally).
      * @param {Object} message One or more objects can be passed in to display.
      */
-    that.debuglog = function() {
+    that.debuglog = function () {
         if (that.preferences.debug) {
-            that.log.apply(that,arguments);
+            that.log.apply(that, arguments);
         }
     };
 
@@ -138,13 +141,13 @@ var ItsAllText = function() {
      * Requires Firebug.
      * @param {Object} message One or more objects can be passed in to display.
      */
-    that.debug = function() {
+    that.debug = function () {
         var message = that.logString.apply(that, arguments);
-        window.dump(message+'\n');
+        window.dump(message + '\n');
         if (that.preferences && that.preferences.debug) {
             try {
                 Firebug.Console.logFormatted(arguments);
-            } catch(e) {
+            } catch (e) {
             }
         }
     };
@@ -154,7 +157,7 @@ var ItsAllText = function() {
      * @param {String} path A path to initialize the object with (optional).
      * @returns {nsILocalFile}
      */
-    that.factoryFile = function(path) {
+    that.factoryFile = function (path) {
         var file = Components.
             classes["@mozilla.org/file/local;1"].
             createInstance(Components.interfaces.nsILocalFile);
@@ -168,7 +171,7 @@ var ItsAllText = function() {
      * Returns the directory where we put files to edit.
      * @returns nsILocalFile The location where we should write editable files.
      */
-    that.getEditDir = function() {
+    that.getEditDir = function () {
         /* Where is the directory that we use. */
         var fobj = Components.classes["@mozilla.org/file/directory_service;1"].
             getService(Components.interfaces.nsIProperties).
@@ -176,7 +179,7 @@ var ItsAllText = function() {
         fobj.append(that.MYSTRING);
         if (!fobj.exists()) {
             fobj.create(Components.interfaces.nsIFile.DIRECTORY_TYPE,
-                        parseInt('0700',8));
+                        parseInt('0700', 8));
         }
         if (!fobj.isDirectory()) {
             that.error(that.localeFormat('problem_making_directory', [fobj.path]));
@@ -187,7 +190,7 @@ var ItsAllText = function() {
     /* Clean the edit directory whenever we create a new window. */
     that.cleanEditDir();
 
-    var loadthings = function() {
+    loadthings = function () {
         /* Load the various bits needed to make this work. */
         var loader = Components.classes["@mozilla.org/moz/jssubscript-loader;1"].getService(Components.interfaces.mozIJSSubScriptLoader);
         loader.loadSubScript('chrome://itsalltext/content/Color.js', that);
@@ -210,11 +213,11 @@ var ItsAllText = function() {
          * @param {String} aData The name of the pref to fetch.
          * @returns {Object} The value of the preference.
          */
-        private_get: function(aData) {
-            var po = that.preference_observer;
-            var real_type = po.types[aData];
-            var type = real_type === 'Float' ? 'Char' : real_type;
-            var retval = '';
+        private_get: function (aData) {
+            var po = that.preference_observer,
+                real_type = po.types[aData],
+                type = real_type === 'Float' ? 'Char' : real_type,
+                retval = '';
             retval = po.private_branch['get' + type + 'Pref'](aData);
             return real_type === 'Float' ? parseFloat(retval) : retval;
         },
@@ -224,14 +227,14 @@ var ItsAllText = function() {
          * @param {String} aData The name of the pref to change.
          * @param {Object} value The value to set.
          */
-        private_set: function(aData, value) {
-            var po = that.preference_observer;
-            var real_type = po.types[aData];
-            var type = real_type === 'Float' ? 'Char' : real_type;
+        private_set: function (aData, value) {
+            var po = that.preference_observer,
+                real_type = po.types[aData],
+                type = real_type === 'Float' ? 'Char' : real_type;
             if (real_type === 'Float') {
                 value = '' + parseFloat(value);
             }
-            po.private_branch['set'+type+'Pref'](aData, value);
+            po.private_branch['set' + type + 'Pref'](aData, value);
         }
     };
 
@@ -258,15 +261,16 @@ var ItsAllText = function() {
         /**
          * Register the observer.
          */
-        register: function() {
+        register: function () {
             var prefService = Components.
                 classes["@mozilla.org/preferences-service;1"].
-                getService(Components.interfaces.nsIPrefService);
-            this.private_branch = prefService.getBranch("extensions."+that.MYSTRING+".");
+                getService(Components.interfaces.nsIPrefService),
+                type;
+            this.private_branch = prefService.getBranch("extensions." + that.MYSTRING + ".");
             this.private_branch.QueryInterface(Components.interfaces.nsIPrefBranch2);
             this.private_branch.addObserver("", this, false);
             /* setup the preferences */
-            for(var type in this.types) {
+            for (type in this.types) {
                 if (this.types.hasOwnProperty(type)) {
                     that.preferences[type] = that.preferences.private_get(type);
                 }
@@ -277,8 +281,10 @@ var ItsAllText = function() {
          * Unregister the observer. Not currently used, but may be
          * useful in the future.
          */
-        unregister: function() {
-            if (!this.private_branch) {return;}
+        unregister: function () {
+            if (!this.private_branch) {
+                return;
+            }
             this.private_branch.removeObserver("", this);
         },
 
@@ -288,8 +294,10 @@ var ItsAllText = function() {
          * @param {String} aData The name of the pref that's been changed (relative to the aSubject).
          * @param {String} aTopic The string defined by NS_PREFBRANCH_PREFCHANGE_TOPIC_ID
          */
-        observe: function(aSubject, aTopic, aData) {
-            if (aTopic != "nsPref:changed") {return;}
+        observe: function (aSubject, aTopic, aData) {
+            if (aTopic != "nsPref:changed") {
+                return;
+            }
             if (that.preferences) {
                 that.preferences[aData] = that.preferences.private_get(aData);
                 if (aData == 'refresh') {
@@ -304,7 +312,7 @@ var ItsAllText = function() {
      * A Preference Option: What character set should the file use?
      * @returns {String} the charset to be used.
      */
-    that.getCharset = function() {
+    that.getCharset = function () {
         return that.preferences.charset;
     };
 
@@ -312,14 +320,13 @@ var ItsAllText = function() {
      * A Preference Option: How often should we search for new content?
      * @returns {int} The number of seconds between checking for new content.
      */
-    that.getRefresh = function() {
+    that.getRefresh = function () {
         var refresh = that.preferences.refresh;
         if (!refresh || refresh < 1) {
-            that.debug('Invalid refresh:',refresh);
+            that.debug('Invalid refresh:', refresh);
             refresh = 1;
         }
-        var retval = 1000*refresh;
-        return retval;
+        return 1000 * refresh;
 
     };
 
@@ -327,7 +334,7 @@ var ItsAllText = function() {
      * Returns true if the system is running Mac OS X.
      * @returns {boolean} Is this a Mac OS X system?
      */
-    that.isDarwin = function() {
+    that.isDarwin = function () {
         /* more help:
          http://developer.mozilla.org/en/docs/Code_snippets:Miscellaneous#Operating_system_detection
         */
@@ -350,9 +357,9 @@ var ItsAllText = function() {
      * http://lxr.mozilla.org/seamonkey/source/xpcom/base/nsError.h#262
      * @returns {nsILocalFile} A file object of the editor.
      */
-    that.getEditor = function() {
-        var editor = that.preferences.editor;
-        var retval = null;
+    that.getEditor = function () {
+        var editor = that.preferences.editor,
+            retval = null;
 
         if (editor === '' && that.isDarwin()) {
             editor = '/usr/bin/open';
@@ -369,7 +376,7 @@ var ItsAllText = function() {
      * A Preference Option: should we display debugging info?
      * @returns {bool}
      */
-    that.getDebug = function() {
+    that.getDebug = function () {
         return that.preferences.debug;
     };
 
@@ -377,7 +384,7 @@ var ItsAllText = function() {
      * A Preference Option: Are the edit gumdrops disabled?
      * @returns {bool}
      */
-    that.getDisableGumdrops = function() {
+    that.getDisableGumdrops = function () {
         return that.preferences.gumdrop_position === 'none';
     };
 
@@ -385,9 +392,9 @@ var ItsAllText = function() {
      * A Preference Option: The list of extensions
      * @returns Array
      */
-    that.getExtensions = function() {
-        var string = that.preferences.extensions.replace(/[\n\t ]+/g,'');
-        var extensions = string.split(',');
+    that.getExtensions = function () {
+        var string = that.preferences.extensions.replace(/[\n\t ]+/g, ''),
+            extensions = string.split(',');
         if (extensions.length === 0) {
             return ['.txt'];
         } else {
@@ -403,15 +410,14 @@ var ItsAllText = function() {
      * and utilityOverlay.js's openPreferences()
      */
     that.openPreferences = function (wait) {
-        wait = typeof(wait)=='boolean'?wait:false;
-        var paneID = that.MYSTRING + '_preferences';
-        var instantApply = getBoolPref("browser.preferences.instantApply", false) && !wait;
-        var features = "chrome,titlebar,toolbar,centerscreen" + (instantApply ? ",dialog=no" : ",modal");
-
-        const xpcom_wm = Components.classes["@mozilla.org/appshell/window-mediator;1"];
-        var wm = xpcom_wm.getService(Components.interfaces.nsIWindowMediator);
-        var win = wm.getMostRecentWindow("Browser:Preferences");
-        var pane;
+        wait = typeof(wait) == 'boolean' ? wait : false;
+        var paneID = that.MYSTRING + '_preferences',
+            instantApply = getBoolPref("browser.preferences.instantApply", false) && !wait,
+            features = "chrome,titlebar,toolbar,centerscreen" + (instantApply ? ",dialog=no" : ",modal"),
+            xpcom_wm = Components.classes["@mozilla.org/appshell/window-mediator;1"],
+            wm = xpcom_wm.getService(Components.interfaces.nsIWindowMediator),
+            win = wm.getMostRecentWindow("Browser:Preferences"),
+            pane;
         if (win) {
             win.focus();
             if (paneID) {
@@ -428,20 +434,22 @@ var ItsAllText = function() {
      * A Preference Option: Append an extension
      * @returns Array
      */
-    that.appendExtensions = function(ext) {
-        ext = ext.replace(/[\n\t ]+/g,'');
-        var current = that.getExtensions();
-        for(var i=0; i<current.length; i++) {
-            if(ext == current[i]) {
+    that.appendExtensions = function (ext) {
+        var current = that.getExtensions(),
+            value,
+            i;
+        ext = ext.replace(/[\n\t ]+/g, '');
+        for (i = 0; i < current.length; i++) {
+            if (ext == current[i]) {
                 return; // Don't add a duplicate.
             }
         }
 
-        var value = that.preferences.extensions;
-        if(value.replace(/[\t\n ]+/g) === '') {
+        value = that.preferences.extensions;
+        if (value.replace(/[\t\n ]+/g) === '') {
             value = ext;
         } else {
-            value = [value,',',ext].join('');
+            value = [value, ',', ext].join('');
         }
         that.preferences.private_set('extensions', value);
     };
@@ -449,51 +457,14 @@ var ItsAllText = function() {
     // @todo [wish] Profiling and optimization.
 
     /**
-     * Returns a cache object
-     * Note: These UIDs are only unique for Its All Text.
-     * @param {Object} node A dom object node or ID to one.
-     * @returns {String} the UID or null.
-     */
-    that.getCacheObj = function(node) {
-        var str = that.MYSTRING+"_UID";
-        var id = null;
-        if (typeof(node) === 'string') {
-            id = node;
-        } else if (node && node.hasAttribute(str)) {
-            id = node.getAttribute(str);
-        }
-        if (id && that.tracker.hasOwnProperty(id)) {
-            return that.tracker[id];
-        } else {
-            return null;
-        }
-    };
-
-    /**
-     * Creates a cache object, unless one exists already.
-     * Note: These UIDs are only unique for Its All Text.
-     * @param {DOMElement} node A dom object node or id to one.
-     * @param {Boolean} create_gumdrop Should a gumdrop be created (html).
-     * @returns {String} the UID or null.
-     */
-    that.makeCacheObj = function(node, create_gumdrop) {
-        var cobj = that.getCacheObj(node);
-        if (!cobj) {
-            cobj = new ItsAllText.CacheObj(node);
-            if (create_gumdrop) {
-                cobj.addGumDrop();
-            }
-        }
-        return cobj;
-    };
-
-    /**
      * Cleans out all old cache objects.
      */
-    that.cleanCacheObjs = function() {
-        var count = 0;
-        var cobj, id, cdoc;
-        for(id in that.tracker) {
+    that.cleanCacheObjs = function () {
+        var count = 0,
+            cobj,
+            id,
+            cdoc;
+        for (id in that.tracker) {
             if (that.tracker.hasOwnProperty(id)) {
                 cobj = that.tracker[id];
                 cdoc = cobj.node.ownerDocument;
@@ -513,12 +484,16 @@ var ItsAllText = function() {
      * Refresh Textarea.
      * @param {Object} node A specific textarea dom object to update.
      */
-    that.refreshTextarea = function(node, is_chrome) {
+    that.refreshTextarea = function (node, is_chrome) {
         var cobj = ItsAllText.getCacheObj(node);
-        if(!cobj) { return; }
+        if (!cobj) {
+            return;
+        }
 
         cobj.update();
-        if (!is_chrome) { cobj.addGumDrop(); }
+        if (!is_chrome) {
+            cobj.addGumDrop();
+        }
     };
 
     // @todo [wish] Refresh textarea on editor quit.
@@ -530,19 +505,19 @@ var ItsAllText = function() {
      * Refresh Document.
      * @param {Object} doc The document to refresh.
      */
-    that.refreshDocument = function(doc) {
-        if(!doc.location) {
+    that.refreshDocument = function (doc) {
+        if (!doc.location) {
             return; // it's being cached, but not shown.
         }
         var is_chrome = (doc.location.protocol == 'chrome:' &&
-                         doc.location.href != that.README);
-        var nodes = doc.getElementsByTagName('textarea');
-        var i;
-        for(i=0; i < nodes.length; i++) {
+                         doc.location.href != that.README),
+            nodes = doc.getElementsByTagName('textarea'),
+            i;
+        for (i = 0; i < nodes.length; i++) {
             that.refreshTextarea(nodes[i], is_chrome);
         }
         nodes = doc.getElementsByTagName('textbox');
-        for(i=0; i < nodes.length; i++) {
+        for (i = 0; i < nodes.length; i++) {
             that.refreshTextarea(nodes[i], is_chrome);
         }
     };
@@ -553,13 +528,13 @@ var ItsAllText = function() {
      * @param {Object} container If unset, then this will use the offsetParent of node. Pass in null to go all the way to the root.
      * @return {Array} The X & Y page offsets
      */
-    that.getContainingBlockOffset = function(node, container) {
-        if(typeof(container) == 'undefined') {
+    that.getContainingBlockOffset = function (node, container) {
+        if (typeof(container) == 'undefined') {
             container = node.offsetParent;
         }
-        var pos = [node.offsetLeft, node.offsetTop];
-        var pnode = node.offsetParent;
-        while(pnode && (container === null || pnode != container)) {
+        var pos = [node.offsetLeft, node.offsetTop],
+            pnode = node.offsetParent;
+        while (pnode && (container === null || pnode != container)) {
             pos[0] += pnode.offsetLeft || 0;
             pos[1] += pnode.offsetTop  || 0;
             pos[0] -= pnode.scrollLeft || 0;
@@ -573,15 +548,13 @@ var ItsAllText = function() {
     /**
      * marshals a keypress event.
      */
-    that.marshalKeyEvent = function(event) {
-        var marshal = [
-                       event.altKey  ? 1 : 0,
+    that.marshalKeyEvent = function (event) {
+        var marshal = [event.altKey  ? 1 : 0,
                        event.ctrlKey ? 1 : 0,
                        event.metaKey ? 1 : 0,
                        event.shiftKey ? 1 : 0,
                        event.charCode,
-                       event.keyCode
-        ];
+                       event.keyCode];
         marshal = marshal.join(':');
         return marshal;
     };
@@ -621,10 +594,10 @@ var ItsAllText = function() {
     /**
      * Converts a marshalled key event into a string.
      */
-    that.keyMarshalToString = function(km) {
-        var e = km.split(':');
-        var out = [];
-        var c = parseInt(e[5], 10);
+    that.keyMarshalToString = function (km) {
+        var e = km.split(':'),
+            out = [],
+            c = parseInt(e[5], 10);
         if (e[0] === '1') {
             out.push('alt');
         }
@@ -641,7 +614,7 @@ var ItsAllText = function() {
             if (that.keyMap.hasOwnProperty(c)) {
                 out.push(that.keyMap[c]);
             } else {
-                out.push('code:'+c);
+                out.push('code:' + c);
             }
         } else {
             out.push(String.fromCharCode(e[4]).toUpperCase());
@@ -654,14 +627,14 @@ var ItsAllText = function() {
      */
     that.old_monitor = {
         id: null,
-        last_now:0,
+        last_now: 0,
         documents: [],
         /**
          * Starts or restarts the document old_monitor.
          */
-        restart: function() {
-            var rate = that.getRefresh();
-            var id   = that.old_monitor.id;
+        restart: function () {
+            var rate = that.getRefresh(),
+                id   = that.old_monitor.id;
             if (id) {
                 clearInterval(id);
             }
@@ -671,15 +644,22 @@ var ItsAllText = function() {
          * watches the document 'doc'.
          * @param {Object} doc The document to watch.
          */
-        watch: function(doc, force) {
-            var contentType, location, is_html, is_usable, is_my_readme;
+        watch: function (doc, force) {
+            // fish
+            var contentType,
+                location,
+                is_html,
+                is_usable,
+                is_my_readme,
+                documents,
+                i;
             if (!force) {
                 /* Check that this is a document we want to play with. */
                 contentType = doc.contentType;
                 location = doc.location;
-                is_html = (contentType=='text/html' ||
-                           contentType=='text/xhtml' ||
-                           contentType=='application/xhtml+xml');
+                is_html = (contentType == 'text/html' ||
+                           contentType == 'text/xhtml' ||
+                           contentType == 'application/xhtml+xml');
                 //var is_xul=(contentType=='application/vnd.mozilla.xul+xml');
                 is_usable = (is_html) &&
                     location &&
@@ -692,7 +672,7 @@ var ItsAllText = function() {
                      * uncaught exception: [Exception... "Component returned failure code: 0x80004003 (NS_ERROR_INVALID_POINTER) [nsIDOMLocation.href]"  nsresult: "0x80004003 (NS_ERROR_INVALID_POINTER)"  location: "JS frame :: chrome://itsalltext/chrome/itsalltext.js :: anonymous :: line 634"  data: no]
 Line 0
                     */
-                } catch(e) {
+                } catch (e) {
                     is_my_readme = false;
                     is_usable = false;
                 }
@@ -702,9 +682,8 @@ Line 0
                 }
             }
 
-            var documents = that.old_monitor.documents;
-            var i;
-            for(i in documents) {
+            documents = that.old_monitor.documents;
+            for (i in documents) {
                 if (documents[i] === doc) {
                     // Found it, don't watch it twice.
                     that.debug('narf: double watch: ', doc.location);
@@ -719,21 +698,22 @@ Line 0
          * Callback to be used by restart()
          * @private
          */
-        watcher: function(offset) {
-            var old_monitor = that.old_monitor;
-            var rate = that.getRefresh();
-
-            var now = Date.now();
+        watcher: function (offset) {
+            var old_monitor = that.old_monitor,
+                rate = that.getRefresh(),
+                now = Date.now(),
+                documents,
+                i,
+                doc;
             if (now - old_monitor.last_now < Math.round(rate * 0.9)) {
-                that.debug('old_monitor.watcher(',offset,') -- skipping catchup refresh');
+                that.debug('old_monitor.watcher(', offset, ') -- skipping catchup refresh');
                 return;
             }
             old_monitor.last_now = now;
 
             /* Walk the documents looking for changes */
-            var documents = old_monitor.documents;
-            var i, doc;
-            for(i in documents) {
+            documents = old_monitor.documents;
+            for (i in documents) {
                 if (documents.hasOwnProperty(i)) {
                     doc = documents[i];
                     if (doc.location) {
@@ -746,19 +726,19 @@ Line 0
          * Stops watching doc.
          * @param {Object} doc The document to watch.
          */
-        unwatch: function(doc) {
-            var documents = that.old_monitor.documents;
-            var i;
-            for(i in documents) {
+        unwatch: function (doc) {
+            var documents = that.old_monitor.documents,
+                i;
+            for (i in documents) {
                 if (documents[i] === doc) {
                     that.debug('unwatch()ing', doc && doc.location);
                     delete documents[i];
                 }
             }
             that.cleanCacheObjs();
-            for(i=documents.length - 1; i >= 0; i--) {
-                if(typeof(documents[i]) === 'undefined') {
-                    documents.splice(i,1);
+            for (i = documents.length - 1; i >= 0; i--) {
+                if (typeof(documents[i]) === 'undefined') {
+                    documents.splice(i, 1);
                 }
             }
         }
@@ -768,9 +748,9 @@ Line 0
      * Open the editor for a selected node.
      * @param {Object} node The textarea to get.
      */
-    that.onEditNode = function(node) {
+    that.onEditNode = function (node) {
         var cobj = that.getCacheObj(node);
-        if(cobj) {
+        if (cobj) {
             cobj.edit();
         }
         return;
@@ -780,9 +760,9 @@ Line 0
      * Triggered when the context menu is shown.
      * @param {Object} event The event passed in by the event handler.
      */
-    that.onContextMenu = function(event) {
+    that.onContextMenu = function (event) {
         var tid, node, tag, is_disabled, cobj, menu, cstyle, doc;
-        if(event.target) {
+        if (event.target) {
             tid = event.target.id;
             if (tid == "itsalltext-context-popup" ||
                 tid == "contentAreaContextMenu") {
@@ -814,8 +794,8 @@ Line 0
         return true;
     };
 
-    that.openReadme = function() {
-        browser = getBrowser();
+    that.openReadme = function () {
+        var browser = getBrowser();
         browser.selectedTab = browser.addTab(that.README, null);
     };
 
@@ -865,27 +845,28 @@ Line 0
  * @param {String} method The method on object to call
  * @returns {Function} A wrapped call to object.method() which passes the arguments.
  */
-ItsAllText.prototype.hitch = function(object, method) {
-  if (!object[method]) {
-    throw "method '" + method + "' does not exist on object '" + object + "'";
-  }
+ItsAllText.prototype.hitch = function (object, method) {
+    if (!object[method]) {
+        throw "method '" + method + "' does not exist on object '" + object + "'";
+    }
 
-  var staticArgs = Array.prototype.splice.call(arguments, 2, arguments.length);
+    var staticArgs = Array.prototype.splice.call(arguments, 2, arguments.length);
 
-  return function() {
-    // make a copy of staticArgs (don't modify it because it gets reused for
-    // every invocation).
-    var args = staticArgs.concat();
+    return function () {
+        // make a copy of staticArgs (don't modify it because it gets reused for
+        // every invocation).
+        var args = staticArgs.concat(),
+            i;
 
-    // add all the new arguments
-    for (var i = 0; i < arguments.length; i++) {
-      args.push(arguments[i]);
-    }
+        // add all the new arguments
+        for (i = 0; i < arguments.length; i++) {
+            args.push(arguments[i]);
+        }
 
-    // invoke the original function with the correct this object and
-    // the combined list of static and dynamic arguments.
-    return object[method].apply(object, args);
-  };
+        // invoke the original function with the correct this object and
+        // the combined list of static and dynamic arguments.
+        return object[method].apply(object, args);
+    };
 };
 
 /**
@@ -936,8 +917,8 @@ ItsAllText.prototype.eventToKeyprint = function (event) {
  * @return {String}
  */
 ItsAllText.prototype.keyprintToString = function (keyprint) {
-    var split = keyprint.split(':');
-    var string = [];
+    var split = keyprint.split(':'),
+        string = [];
     if (split[0] === 'true') {
         string.push('Ctrl');
     }
@@ -953,7 +934,7 @@ ItsAllText.prototype.keyprintToString = function (keyprint) {
     if (split[4] === '0') {
         string.push(String.fromCharCode(split[5]));
     } else {
-        string.push('keyCode=',split[4]);
+        string.push('keyCode=', split[4]);
     }
     return string.join(' ');
 };
@@ -962,20 +943,20 @@ ItsAllText.prototype.keyprintToString = function (keyprint) {
 /**
  * Cleans out the edit directory, deleting all old files.
  */
-ItsAllText.prototype.cleanEditDir = function(force) {
+ItsAllText.prototype.cleanEditDir = function (force) {
     force = typeof(force) === 'boolean'?force:false;
-    var last_week = Date.now() - (1000*60*60*24*7);
-    var fobj = this.getEditDir();
-    var entries = fobj.directoryEntries;
-    var entry;
+    var last_week = Date.now() - (1000 * 60 * 60 * 24 * 7),
+        fobj = this.getEditDir(),
+        entries = fobj.directoryEntries,
+        entry;
     while (entries.hasMoreElements()) {
         entry = entries.getNext();
         entry.QueryInterface(Components.interfaces.nsIFile);
-        if(force || !entry.exists() || entry.lastModifiedTime < last_week){
-            try{
+        if (force || !entry.exists() || entry.lastModifiedTime < last_week) {
+            try {
                 entry.remove(false);
-            } catch(e) {
-                this.log('unable to remove',entry,'because:',e);
+            } catch (e) {
+                this.log('unable to remove', entry, 'because:', e);
             }
         }
     }
@@ -986,18 +967,17 @@ ItsAllText.prototype.cleanEditDir = function(force) {
  * The command that is called when picking a new extension.
  * @param {Event} event
  */
-ItsAllText.prototype.menuNewExtEdit = function(event) {
-    var that = this;
-    var uid = this.private_current_uid;
-    var cobj = that.getCacheObj(uid);
-
-    var params = {out:null};
+ItsAllText.prototype.menuNewExtEdit = function (event) {
+    var that = this,
+        uid = this.private_current_uid,
+        cobj = that.getCacheObj(uid),
+        params = {out: null},
+        ext;
     window.openDialog("chrome://itsalltext/content/newextension.xul", "",
     "chrome, dialog, modal, resizable=yes", params).focus();
-    var ext;
     if (params.out) {
-        ext = params.out.extension.replace(/[\n\t ]+/g,'');
-        if(params.out.do_save) {
+        ext = params.out.extension.replace(/[\n\t ]+/g, '');
+        if (params.out.do_save) {
             that.appendExtensions(ext);
         }
         cobj.edit(ext);
@@ -1010,13 +990,13 @@ ItsAllText.prototype.menuNewExtEdit = function(event) {
  * @param {string} ext
  * @param {boolean} clobber
  */
-ItsAllText.prototype.menuExtEdit = function(ext, clobber, event) {
-    var uid = this.private_current_uid;
+ItsAllText.prototype.menuExtEdit = function (ext, clobber, event) {
+    var uid = this.private_current_uid,
+        cobj;
     if (ext !== null) {
         ext = typeof(ext) === 'string'?ext:event.target.getAttribute('label');
     }
-    this.debug('menuExtEdit:',uid, ext, clobber);
-    var cobj = this.getCacheObj(uid);
+    this.debug('menuExtEdit:', uid, ext, clobber);
     //narf this.monitor.watch(cobj.node.ownerDocument);
     cobj.edit(ext, clobber);
 };
@@ -1026,27 +1006,27 @@ ItsAllText.prototype.menuExtEdit = function(ext, clobber, event) {
  * @private
  * @param {String} uid The UID to show in the option menu.
  */
-ItsAllText.prototype.rebuildMenu = function(uid, menu_id, is_disabled) {
+ItsAllText.prototype.rebuildMenu = function (uid, menu_id, is_disabled) {
     menu_id = typeof(menu_id) == 'string'?menu_id:'itsalltext-optionmenu';
-    is_disabled = (typeof(is_disabled) == 'undefined'||!is_disabled)?false:(is_disabled&&true);
-    var i;
-    var that = this;
-    var exts = that.getExtensions();
-    var menu = document.getElementById(menu_id);
-    var items = menu.childNodes;
-    var items_length = items.length - 1; /* We ignore the preferences item */
-    var node;
+    is_disabled = (typeof(is_disabled) === 'undefined' || !is_disabled) ? false : (is_disabled && true);
+    var i,
+        that = this,
+        exts = that.getExtensions(),
+        menu = document.getElementById(menu_id),
+        items = menu.childNodes,
+        items_length = items.length - 1, /* We ignore the preferences item */
+        node,
+        magic_stop_node = null,
+        magic_start = null,
+        magic_stop = null,
+        cobj = that.getCacheObj(uid);
     that.private_current_uid = uid;
-    var magic_stop_node = null;
-    var magic_start = null;
-    var magic_stop = null;
-    var cobj = that.getCacheObj(uid);
 
     // Find the beginning and end of the magic replacement parts.
-    for(i=0; i<items_length; i++) {
+    for (i = 0; i < items_length; i++) {
         node = items[i];
         if (node.nodeName.toLowerCase() == 'menuseparator') {
-            if(magic_start === null) {
+            if (magic_start === null) {
                 magic_start = i;
             } else if (magic_stop === null) {
                 magic_stop = i;
@@ -1058,7 +1038,7 @@ ItsAllText.prototype.rebuildMenu = function(uid, menu_id, is_disabled) {
     }
 
     // Remove old magic bits
-    for(i = magic_stop - 1; i > magic_start; i--) {
+    for (i = magic_stop - 1; i > magic_start; i--) {
         menu.removeChild(items[i]);
     }
 
@@ -1071,11 +1051,11 @@ ItsAllText.prototype.rebuildMenu = function(uid, menu_id, is_disabled) {
     }
 
     // Insert the new magic bits
-    for(i=0; i<exts.length; i++) {
+    for (i = 0; i < exts.length; i++) {
         node = document.createElementNS(that.XULNS, 'menuitem');
         node.setAttribute('label', that.localeFormat('edit_ext', [exts[i]]));
-        (function() {
-            var ext=exts[i];
+        (function () {
+            var ext = exts[i];
             that.listen(node, 'command', that.hitch(that, 'menuExtEdit', ext, true), false);
         })();
         node.setAttribute('disabled', is_disabled?'true':'false');
@@ -1087,9 +1067,9 @@ ItsAllText.prototype.rebuildMenu = function(uid, menu_id, is_disabled) {
 /**
  * Returns the locale object for translation.
  */
-ItsAllText.prototype.getLocale = function() {
-    const string_bundle = Components.classes["@mozilla.org/intl/stringbundle;1"];
-    var obj = string_bundle.getService(Components.interfaces.nsIStringBundleService);
+ItsAllText.prototype.getLocale = function () {
+    var string_bundle = Components.classes["@mozilla.org/intl/stringbundle;1"],
+        obj = string_bundle.getService(Components.interfaces.nsIStringBundleService);
     /**
      * A localization bundle.  Use it like so:
      * ItsAllText.locale.getStringFromName('blah');
diff --git a/src/chrome/content/monitor.js b/src/chrome/content/monitor.js
index ffd0e30..5a012ac 100644
--- a/src/chrome/content/monitor.js
+++ b/src/chrome/content/monitor.js
@@ -1,3 +1,5 @@
+/*extern HTMLDocument, gBrowser, ItsAllText */
+/*jslint undef: true, nomen: true, evil: false, browser: true, white: true */
 /*
  *  It's All Text! - Easy external editing of web forms.
  *
@@ -16,17 +18,16 @@
  *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-/*jslint nomen: true, evil: false, browser: true */
-
 function new_monitor(iat) {
+    var hitch_re = /^hitched_/,
+        method;
     this.iat = iat;
     this.iat.debug('new_monitor');
 
-    var hitch_re = /^hitched_/;
     for (method in this) {
         if (hitch_re.test(method)) {
 
-            this.iat.debug('hitching ', method ,' -> ', method.replace(hitch_re, ''));
+            this.iat.debug('hitching ', method, ' -> ', method.replace(hitch_re, ''));
             this[method.replace(hitch_re, '')] = this.iat.hitch(this, method);
         }
     }
@@ -38,8 +39,8 @@ new_monitor.destroy = function () {
 };
 
 new_monitor.prototype.hitched_restart = function () {
-    var rate = this.iat.getRefresh();
-    var id   = this.id;
+    var rate = this.iat.getRefresh(),
+        id   = this.id;
     if (id) {
         clearInterval(id);
     }
@@ -47,8 +48,9 @@ new_monitor.prototype.hitched_restart = function () {
 };
 
 new_monitor.prototype.hitched_registerPage = function (event) {
+    var doc, appContent;
     if (event.originalTarget instanceof HTMLDocument) {
-        var doc = event.originalTarget;
+        doc = event.originalTarget;
         if (doc.defaultView.frameElement) {
             // Frame within a tab was loaded. doc should be the root document of
             // the frameset. If you don't want do anything when frames/iframes
@@ -56,14 +58,14 @@ new_monitor.prototype.hitched_registerPage = function (event) {
             // return;
             // Find the root document:
             while (doc.defaultView.frameElement) {
-                doc=doc.defaultView.frameElement.ownerDocument;
+                doc = doc.defaultView.frameElement.ownerDocument;
             }
         }
 
         this.iat.debug('registerPage: ', doc && doc.location);
 
         /* appContent is the browser chrome. */
-        var appContent = document.getElementById("appcontent");
+        appContent = document.getElementById("appcontent");
         this.iat.listen(appContent, 'DOMContentLoaded', this.startPage, true);
         this.iat.listen(document, 'unload', this.stopPage, true);
         this.iat.listen(gBrowser.tabContainer, 'TabSelect', this.watcher, true);
@@ -77,15 +79,21 @@ new_monitor.prototype.hitched_watcher = function (offset, init) {
         offset.type === 'TabSelect') {
         init = true;
     }
-    var rate = this.iat.getRefresh();
-    var now = Date.now();
+    var rate = this.iat.getRefresh(),
+        now = Date.now(),
+        doc,
+        nodes = [],
+        i,
+        cobj,
+        node,
+        is_html,
+        is_xul;
     if (!init && now - this.last_watcher_call < Math.round(rate * 0.9)) {
-        this.iat.debug('watcher(',offset,'/',(now - this.last_watcher_call),') -- skipping catchup refresh');
+        this.iat.debug('watcher(', offset, '/', (now - this.last_watcher_call), ') -- skipping catchup refresh');
         return;
     }
     this.last_watcher_call = now;
 
-    var doc;
     if (typeof(gBrowser) === 'undefined') {
         /* If we're in chrome. */
         doc = document;
@@ -94,10 +102,8 @@ new_monitor.prototype.hitched_watcher = function (offset, init) {
         doc = gBrowser.selectedBrowser.contentDocument;
     }
     this.iat.debug('watcher: ', offset, init, doc && doc.location);
-    var nodes = [];
-    var i, cobj, node;
-    var is_html = this.isHTML(doc);
-    var is_xul  = this.isXUL(doc);
+    is_html = this.isHTML(doc);
+    is_xul  = this.isXUL(doc);
     if (is_html) {
         /* HTML */
         nodes = doc.getElementsByTagName('textarea');
@@ -108,7 +114,7 @@ new_monitor.prototype.hitched_watcher = function (offset, init) {
         this.stopPage({originalTarget: doc});
         return;
     }
-    for(i=0; i < nodes.length; i++) {
+    for (i = 0; i < nodes.length; i++) {
         node = nodes[i];
         if (init) {
             cobj = ItsAllText.makeCacheObj(node, is_html);
@@ -122,14 +128,15 @@ new_monitor.prototype.hitched_watcher = function (offset, init) {
 };
 
 new_monitor.prototype.hitched_startPage = function (event, force) {
-    var doc = event.originalTarget;
+    var doc = event.originalTarget,
+        unsafeWin;
     this.iat.debug('startPage', doc && doc.location, force);
     if (!(force || this.isHTML(doc))) {
         this.stopPage(event);
         return;
     }
 
-    var unsafeWin = doc.defaultView.wrappedJSObject;
+    unsafeWin = doc.defaultView.wrappedJSObject;
     if (unsafeWin) {
         this.iat.listen(unsafeWin, 'pagehide', this.stopPage);
     }
@@ -141,33 +148,38 @@ new_monitor.prototype.hitched_startPage = function (event, force) {
 };
 
 new_monitor.prototype.hitched_stopPage = function (event) {
-    var doc = event.originalTarget;
+    var doc = event.originalTarget,
+        unsafeWin;
     this.iat.debug('stopPage', doc && doc.location);
 
-    var unsafeWin = doc.defaultView.wrappedJSObject;
+    unsafeWin = doc.defaultView.wrappedJSObject;
     this.iat.unlisten(unsafeWin, 'pagehide', this.stopPage);
 };
 
 new_monitor.prototype.isXUL = function (doc) {
-    var contentType = doc && doc.contentType;
-    var is_xul=(contentType=='application/vnd.mozilla.xul+xml');
-    var is_my_readme;
+    var contentType = doc && doc.contentType,
+        is_xul = (contentType == 'application/vnd.mozilla.xul+xml'),
+        is_my_readme;
     try {
         is_my_readme = location && location.href == this.iat.README;
-    } catch(e) {
+    } catch (e) {
         is_my_readme = false;
     }
     return is_xul && !is_my_readme;
 };
 
 new_monitor.prototype.isHTML = function (doc) {
-    var contentType, location, is_html, is_usable, is_my_readme;
+    var contentType,
+        location,
+        is_html,
+        is_usable,
+        is_my_readme;
     /* Check that this is a document we want to play with. */
     contentType = doc.contentType;
     location = doc.location;
-    is_html = (contentType=='text/html' ||
-               contentType=='text/xhtml' ||
-               contentType=='application/xhtml+xml');
+    is_html = (contentType == 'text/html' ||
+               contentType == 'text/xhtml' ||
+               contentType == 'application/xhtml+xml');
     is_usable = is_html &&
                 location &&
                 location.protocol !== 'about:' &&
@@ -179,7 +191,7 @@ new_monitor.prototype.isHTML = function (doc) {
          * uncaught exception: [Exception... "Component returned failure code: 0x80004003 (NS_ERROR_INVALID_POINTER) [nsIDOMLocation.href]"  nsresult: "0x80004003 (NS_ERROR_INVALID_POINTER)"  location: "JS frame :: chrome://itsalltext/chrome/itsalltext.js :: anonymous :: line 634"  data: no]
          * Line 0
          */
-    } catch(e) {
+    } catch (e) {
         is_my_readme = false;
         is_usable = false;
     }
diff --git a/src/chrome/content/preferences.js b/src/chrome/content/preferences.js
index ca0cd19..7cbc77d 100644
--- a/src/chrome/content/preferences.js
+++ b/src/chrome/content/preferences.js
@@ -1,3 +1,5 @@
+/*extern Components, ItsAllText */
+/*jslint undef: true, nomen: true, evil: false, browser: true, white: true */
 // @todo [6] [pref] Better strategy for getting the default editor: EDITOR env variable or view_source.editor.path
 // @todo [8] [pref] Option to make the textarea uneditable when using editor.
 
@@ -5,19 +7,23 @@
  * Open a filepicker to select the value of the editor.
  */
 function pref_editor_select() {
-    var locale = document.getElementById("strings");
+    var locale = document.getElementById("strings"),
+        pref_editor = document.getElementById('pref_editor'),
+        nsIFilePicker = Components.interfaces.nsIFilePicker,
+        fp,
+        initdir,
+        rv,
+        file,
+        editor;
 
-    var pref_editor = document.getElementById('pref_editor');
-    var nsIFilePicker = Components.interfaces.nsIFilePicker;
-
-    var fp = Components.classes["@mozilla.org/filepicker;1"].
+    fp = Components.classes["@mozilla.org/filepicker;1"].
         createInstance(nsIFilePicker);
     fp.init(window,
             locale.getString('picker.window.title'),
             nsIFilePicker.modeOpen);
     fp.appendFilters(nsIFilePicker.filterApps);
 
-    var initdir = Components.classes["@mozilla.org/file/local;1"].
+    initdir = Components.classes["@mozilla.org/file/local;1"].
         createInstance(Components.interfaces.nsILocalFile);
     try {
         initdir.initWithPath(pref_editor.value);
@@ -25,13 +31,11 @@ function pref_editor_select() {
         if (initdir.exists() && initdir.isDirectory()) {
             fp.displayDirectory = initdir;
         }
-    } catch(e) {
+    } catch (e) {
         // Ignore error, the pref may not have been set or who knows.
     }
 
-    var rv = fp.show();
-    var file;
-    var editor;
+    rv = fp.show();
     if (rv == nsIFilePicker.returnOK) {
         file = fp.file;
         pref_editor.value = file.path;
@@ -42,9 +46,12 @@ function pref_editor_select() {
 }
 
 function update_hotkey(disp) {
-    var str, km = ItsAllText.preferences.hotkey;
+    var str,
+        km = ItsAllText.preferences.hotkey;
     if (typeof(km) === 'undefined') {
-        setTimeout(function () { update_hotkey(disp); }, 100);
+        setTimeout(function () {
+                update_hotkey(disp);
+            }, 100);
         return;
     }
     if (km === '') {
@@ -70,21 +77,21 @@ function pref_grab(disp, e) {
 }
 
 function setHelp(text) {
-    var help = document.getElementById('help');
+    var help = document.getElementById('help'),
+        textnode = document.createTextNode(text);
     while (help.firstChild) {
         help.removeChild(help.firstChild);
     }
-    var textnode = document.createTextNode(text);
     help.appendChild(textnode);
 }
 
 function pref_onload() {
-    var locale = document.getElementById("strings");
+    var locale = document.getElementById("strings"),
+        editor,
+        box,
+        desc,
+        textnode;
     document.getElementById('browse').focus();
-    var editor;
-    var box;
-    var desc;
-    var textnode;
     if (window['arguments'] && window['arguments'][0] && window['arguments'][0] == 'badeditor') {
         editor = document.getElementById('editor');
         editor.style.color = 'black';

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/itsalltext.git



More information about the Pkg-mozext-commits mailing list