[Pkg-mozext-commits] [itsalltext] 269/459: linting is better, use yuicompressor to check for missing things, etc.

David Prévot taffit at moszumanska.debian.org
Tue Feb 24 23:26:28 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 7ef11462609bbe25261c44c5d17cc01f2a495f5e
Author: docwhat at gerf.org <docwhat at gerf.org>
Date:   Mon Oct 1 11:01:30 2007 -0400

    linting is better, use yuicompressor to check for missing things, etc.
---
 .hgignore                        |  1 +
 Makefile                         | 25 ++++++++++++++----------
 src/chrome/content/API.js        | 10 ++++++----
 src/chrome/content/cacheobj.js   | 11 ++++++-----
 src/chrome/content/itsalltext.js | 42 ++++++++++++++++++----------------------
 5 files changed, 47 insertions(+), 42 deletions(-)

diff --git a/.hgignore b/.hgignore
index d1a2670..e649d05 100644
--- a/.hgignore
+++ b/.hgignore
@@ -3,3 +3,4 @@ syntax:regexp
 ^\.[^/]+/
 ^[^/]+\.xpi/
 ^\.todo$
+\.[^/]+-stamp$
diff --git a/Makefile b/Makefile
index 1b7b85b..a1d6370 100644
--- a/Makefile
+++ b/Makefile
@@ -1,5 +1,5 @@
 #
-#  
+#
 #  It's All Text - Easy external editing of web forms.
 #  Copyright (C) 2006-2007 Christian Höltje
 #
@@ -19,6 +19,7 @@
 # If you don't have jslint or jsmin, you can replace these with cat...
 # but I strongly suggest you get jslint and jsmin working.
 JSLINT     := jslint
+YC         := yuicompressor
 #JSMIN      := jsmin
 JSMIN      := cat
 ZIP        := zip
@@ -59,10 +60,10 @@ else
 endif
 
 .PHONY: default
-default: lint narf final
+default: lintcheck narf final
 
 .PHONY: all
-all: lint narf docs final
+all: lintcheck narf docs final
 
 ## Release a new xpi
 .PHONY: release
@@ -87,7 +88,7 @@ version_check:
 .PHONY: stage1
 stage1: .stage1-stamp
 
-.stage1-stamp: Makefile narf lint $(STAGE1_OUT)
+.stage1-stamp: Makefile narf lintcheck $(STAGE1_OUT)
 	$(Q)touch $@
 
 stage1/%: src/%
@@ -134,16 +135,20 @@ build: final
 .PHONY: lint
 lint: $(SOURCES_JS_LINT)
 
-$(SOURCES_JS_LINT): lint/%.js.lint: %.js
+$(SOURCES_JS_LINT): lint/%.js.lint: %.js Makefile
+	$(info linting $(notdir $<) ...)
 	$(Q)mkdir -p $(dir $@)
 	$(Q)perl -p -e 's/^(\s*)const(\s+)/$$1var$$2/' $< > $@.pre
-	$(Q)$(JSLINT) -p $@.pre > $@
-	$(Q)if [ `wc -l $@|cut -d' ' -f1` -ne 1 ]; then\
-	     touch --date='1972-01-01' "$@"; echo "lint: $@"; false; fi
+	$(Q)echo "*** Linting $<" > $@
+	$(Q)$(JSLINT) -p $@.pre >> $@
+	$(Q)$(YC) --type js --charset UTF-8 --warn -o /dev/null $@.pre >> $@ 2>&1
+
+.PHONY: lintcheck
+lintcheck: $(SOURCES_JS_LINT)
+	$(Q)egrep -q '^lint at |^\[WARNING\]' $(SOURCES_JS_LINT) ; test $$? != 0
 
 .PHONY: showlint
-showlint: 
-	$(Q)$(QMAKE) -k lint || :
+showlint: lint
 	$(Q)find ./lint -type f -name '*.lint' -print0 | xargs -0 cat | egrep -v '^jslint: No problems found in'
 
 ##
diff --git a/src/chrome/content/API.js b/src/chrome/content/API.js
index 116aae3..66d5dc4 100644
--- a/src/chrome/content/API.js
+++ b/src/chrome/content/API.js
@@ -53,7 +53,7 @@
         ItsAllText.monitor.watch(document, true);
 
         /* Turn on all the hidden CSS */
-        var nodes = [];
+        var nodes = [], i;
         var nodesIter = document.evaluate("//node()[@itsalltext-control]",
                                           document, null,
                                           XPathResult.UNORDERED_NODE_ITERATOR_TYPE, null);
@@ -69,9 +69,11 @@
             return false;
         };
         for(i in nodes) {
-            node = nodes[i];
-            node.addEventListener('command', command, true);
-            node.style.display = '-moz-box';
+            if (nodes.hasOwnProperty(i)) {
+                node = nodes[i];
+                node.addEventListener('command', command, true);
+                node.style.display = '-moz-box';
+            }
         }
 
     };
diff --git a/src/chrome/content/cacheobj.js b/src/chrome/content/cacheobj.js
index 84e1352..932a0a4 100644
--- a/src/chrome/content/cacheobj.js
+++ b/src/chrome/content/cacheobj.js
@@ -298,7 +298,7 @@ CacheObj.prototype.edit = function(extension, clobber) {
     const procutil = Components.classes["@mozilla.org/process/util;1"];
 
     var process;
-    var args, result, ec, e, params;
+    var args, result, ec, params;
 
     try {
         program = ItsAllText.getEditor();
@@ -362,7 +362,7 @@ CacheObj.prototype.read = function() {
     /* read file, reset ts & size */
     var DEFAULT_REPLACEMENT_CHARACTER = 65533;
     var buffer = [];
-    var fis, istream, str, e;
+    var fis, istream, str;
 
     try {
         fis = Components.classes["@mozilla.org/network/file-input-stream;1"].
@@ -521,7 +521,6 @@ CacheObj.prototype.addGumDrop = function() {
 
     var gumdrop = doc.createElementNS(ItsAllText.XHTMLNS, "img");
     gumdrop.setAttribute('src', this.gumdrop_url);
-    var gid = cache_object.getNodeIdentifier(gumdrop);
 
     if (ItsAllText.getDebug()) {
         gumdrop.setAttribute('title', cache_object.node_id);
@@ -648,9 +647,11 @@ CacheObj.prototype.hashString = function(some_string) {
     };
 
     // convert the binary hash data to a hex string.
-    var retval = [];
+    var retval = [], i;
     for(i in hash) {
-        retval[i] = toHexString(hash.charCodeAt(i));
+        if (hash.hasOwnProperty(i)) {
+            retval[i] = toHexString(hash.charCodeAt(i));
+        }
     }
 
     return(retval.join(""));
diff --git a/src/chrome/content/itsalltext.js b/src/chrome/content/itsalltext.js
index 03e739f..4de3c07 100644
--- a/src/chrome/content/itsalltext.js
+++ b/src/chrome/content/itsalltext.js
@@ -38,12 +38,6 @@ var ItsAllText = function() {
     that.tracker = {};
 
     /**
-     * Keeps track of all the refreshes we are running.
-     * @type Array
-     */
-    var cron = [null]; // Eat the 0th position
-
-    /**
      * A constant, a string used for things like the preferences.
      * @type String
      */
@@ -110,7 +104,6 @@ var ItsAllText = function() {
      */
     that.log = function() {
         var message = that.logString.apply(that, arguments);
-        var e;
         const consoleService = Components.classes["@mozilla.org/consoleservice;1"];
         var obj = consoleService.getService(Components.interfaces.nsIConsoleService);
         try {
@@ -251,7 +244,9 @@ var ItsAllText = function() {
             this.private_branch.addObserver("", this, false);
             /* setup the preferences */
             for(var type in this.types) {
-                that.preferences[type] = that.preferences.private_get(type);
+                if (this.types.hasOwnProperty(type)) {
+                    that.preferences[type] = that.preferences.private_get(type);
+                }
             }
         },
 
@@ -455,19 +450,19 @@ var ItsAllText = function() {
      * Cleans out all old cache objects.
      */
     that.cleanCacheObjs = function() {
-        doc = typeof(doc) === 'undefined'?null:doc;
         var count = 0;
         var cobj, id, cdoc;
         for(id in that.tracker) {
-            cobj = that.tracker[id];
-            cdoc = cobj.node.ownerDocument;
-            if (!cdoc.defaultView || !cdoc.location) {
-                cobj.destroy();
-                cdoc = null;
-                delete cobj;
-                delete that.tracker[id];
-            } else {
-                count += 1;
+            if (that.tracker.hasOwnProperty(id)) {
+                cobj = that.tracker[id];
+                cdoc = cobj.node.ownerDocument;
+                if (!cdoc.defaultView || !cdoc.location) {
+                    cobj.destroy();
+                    cdoc = null;
+                    delete that.tracker[id];
+                } else {
+                    count += 1;
+                }
             }
         }
         that.debuglog('tracker count:', count);
@@ -598,12 +593,13 @@ var ItsAllText = function() {
             var documents = monitor.documents;
             //that.debuglog('monitor.watcher(',offset,'): ', documents.length);
             var i, doc;
-            var did_delete = false;
             for(i in documents) {
-                doc = documents[i];
-                if (doc.location) {
-                    //that.debuglog('refreshing', doc.location);
-                    that.refreshDocument(doc);
+                if (documents.hasOwnProperty(i)) {
+                    doc = documents[i];
+                    if (doc.location) {
+                        //that.debuglog('refreshing', doc.location);
+                        that.refreshDocument(doc);
+                    }
                 }
             }
         },

-- 
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