[Pkg-mozext-commits] [itsalltext] 203/459: New version of lint: It doesn't like 'var's in a sub-block.

David Prévot taffit at moszumanska.debian.org
Tue Feb 24 23:26:21 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 04e132c74f4cd0f51a1e152f8959b8ff2fbce2d4
Author: docwhat at gerf.org <docwhat at gerf.org>
Date:   Mon Apr 9 16:50:43 2007 -0400

    New version of lint: It doesn't like 'var's in a sub-block.
---
 src/chrome/content/Color.js       | 37 +++++++++++++++++-------------
 src/chrome/content/cacheobj.js    | 37 ++++++++++++++++++------------
 src/chrome/content/itsalltext.js  | 48 +++++++++++++++++++++++----------------
 src/chrome/content/preferences.js | 18 ++++++++++-----
 4 files changed, 83 insertions(+), 57 deletions(-)

diff --git a/src/chrome/content/Color.js b/src/chrome/content/Color.js
index 9812e3d..bea88a8 100644
--- a/src/chrome/content/Color.js
+++ b/src/chrome/content/Color.js
@@ -76,10 +76,11 @@ var Color = function() {
 	 *             If not specified, the alpha value will be ignored.
 	 */
     this.hex = function(bg) {
+        var r, g, b;
 		if (bg) {
-			var r = alphaBlend(this.red, bg.red, this.alpha);
-			var g = alphaBlend(this.green, bg.green, this.alpha);
-			var b = alphaBlend(this.blue, bg.blue, this.alpha);
+			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;
@@ -103,10 +104,11 @@ var Color = function() {
 	 *             If not specified, the alpha value will be ignored.
 	 */
 	this.rgb = function(bg) {
+        var r, g, b;
 		if (bg) {
-			var r = alphaBlend(this.red, bg.red, this.alpha);
-			var g = alphaBlend(this.green, bg.green, this.alpha);
-			var b = alphaBlend(this.blue, bg.blue, this.alpha);
+			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;
@@ -162,13 +164,17 @@ var Color = 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 */
-        var r = arguments[0];
-        var g = arguments[1];
-        var b = arguments[2];
-        var a = arguments[3];
+        r = arguments[0];
+        g = arguments[1];
+        b = arguments[2];
+        a = arguments[3];
       
         this.red   = (!isNaN(r)) ? clamp(r, 0, 255) : 0;
         this.green = (!isNaN(g)) ? clamp(g, 0, 255) : 0;
@@ -176,18 +182,17 @@ var Color = function() {
         this.alpha = (!isNaN(a)) ? clamp(a, 0.0, 1.0) : 1.0;
     } else if (arguments.length == 1) {
         /* CSS Colour keyword or value */
-        var value = keyword[arguments[0]] ? keyword[arguments[0]] : arguments[0];
-        var components, pattern;
+        value = keyword[arguments[0]] ? keyword[arguments[0]] : arguments[0];
       
-        for (var key in func) {
+        for (key in func) {
             if (func[key].test(value)) {
                 pattern = key;
             }
         }
 
         components = value.match(func[pattern]);
-        var base = 10;
-        var m = 1; // Multiplier for percentage values
+        base = 10;
+        m = 1; // Multiplier for percentage values
       
         switch (pattern) {
         case "rgb%":
diff --git a/src/chrome/content/cacheobj.js b/src/chrome/content/cacheobj.js
index 53d7e43..89b0ad3 100644
--- a/src/chrome/content/cacheobj.js
+++ b/src/chrome/content/cacheobj.js
@@ -119,8 +119,9 @@ CacheObj.prototype.initFromExistingFile = function() {
     var entries = fobj.directoryEntries;
     var ext = null;
     var tmpfiles = /(\.bak|.tmp|~)$/;
+    var entry;
     while (entries.hasMoreElements()) {
-        var entry = entries.getNext();
+        entry = entries.getNext();
         entry.QueryInterface(Components.interfaces.nsIFile);
         if (entry.leafName.indexOf(base) === 0) {
             // startswith
@@ -146,13 +147,14 @@ CacheObj.prototype.initFromExistingFile = function() {
  */
 CacheObj.prototype.getNodeIdentifier = function(node) {
     var id   = node.getAttribute('id');
+    var name, doc, attr, serial;
     if (!id) {
-        var name = node.getAttribute('name');
-        var doc = node.ownerDocument.getElementsByTagName('html')[0];
-        var attr = ItsAllText.MYSTRING+'_id_serial';
+        name = node.getAttribute('name');
+        doc = node.ownerDocument.getElementsByTagName('html')[0];
+        attr = ItsAllText.MYSTRING+'_id_serial';
         
         /* Get a serial that's unique to this document */
-        var serial = doc.getAttribute(attr);
+        serial = doc.getAttribute(attr);
         if (serial) { serial = parseInt(serial, 10)+1;
         } else { serial = 1; }
         id = [ItsAllText.MYSTRING,'generated_id',name,serial].join('_');
@@ -235,6 +237,8 @@ CacheObj.prototype.edit = function(extension) {
     this.initial_background = this.node.style.backgroundColor;
     this.initial_color      = this.node.style.color;
     var program = null; 
+    var process;
+    var args, result, ec, e, params;
              
     try {
         program = ItsAllText.getEditor();
@@ -247,7 +251,7 @@ CacheObj.prototype.edit = function(extension) {
             throw {name:"NS_ERROR_FILE_ACCESS_DENIED"}; }
 
         // create an nsIProcess
-        var process = Components.
+        process = Components.
             classes["@mozilla.org/process/util;1"].
             createInstance(Components.interfaces.nsIProcess);
         process.init(program);
@@ -257,12 +261,12 @@ CacheObj.prototype.edit = function(extension) {
         // called process terminates.
         // Second and third params are used to pass command-line arguments
         // to the process.
-        var args = [filename];
-        var result = {};
-        var ec = process.run(false, args, args.length, result);
+        args = [filename];
+        result = {};
+        ec = process.run(false, args, args.length, result);
         this._is_watching = true;
     } catch(e) {        
-        var params = {out:null,
+        params = {out:null,
                       exists: program ? program.exists() : false,
                       path: ItsAllText.preferences.editor,
                       exception: e.name };
@@ -299,20 +303,21 @@ CacheObj.prototype.read = function() {
     /* read file, reset ts & size */
     var DEFAULT_REPLACEMENT_CHARACTER = 65533;
     var buffer = [];
+    var fis, istream, str, e;
          
     try {
-        var fis = Components.
+        fis = Components.
             classes["@mozilla.org/network/file-input-stream;1"].
             createInstance(Components.interfaces.nsIFileInputStream);
         fis.init(this.file, 0x01, parseInt('00400',8), 0); 
         // MODE_RDONLY | PERM_IRUSR
              
-        var istream = Components.
+        istream = Components.
             classes["@mozilla.org/intl/converter-input-stream;1"].
             createInstance(Components.interfaces.nsIConverterInputStream);
         istream.init(fis, ItsAllText.getCharset(), 4096, DEFAULT_REPLACEMENT_CHARACTER);
              
-        var str = {};
+        str = {};
         while (istream.readString(4096, str) !== 0) {
             buffer.push(str.value);
         }
@@ -390,8 +395,9 @@ CacheObj.prototype.fade = function(steps, delay) {
  * @returns {boolean} Returns true ifthe file changed.
  */
 CacheObj.prototype.update = function() {
+    var value;
     if (this.hasChanged()) {
-        var value = this.read();
+        value = this.read();
         if (value !== null) {
             this.fade(20, 100);
             this.node.value = value;
@@ -513,11 +519,12 @@ CacheObj.prototype.adjust = function() {
     /* Reposition the gumdrops incase the dom changed. */
     var left = Math.max(1, el.offsetWidth-this.gumdrop_width);
     var top  = el.offsetHeight;
+    var coord;
     if (el.offsetParent === gumdrop.offsetParent) {
         left += el.offsetLeft;
         top  += el.offsetTop;
     } else {
-        var coord = ItsAllText.getContainingBlockOffset(el, gumdrop.offsetParent);
+        coord = ItsAllText.getContainingBlockOffset(el, gumdrop.offsetParent);
         left += coord[0];
         top  += coord[1];
     }
diff --git a/src/chrome/content/itsalltext.js b/src/chrome/content/itsalltext.js
index 67155cd..5064cb7 100644
--- a/src/chrome/content/itsalltext.js
+++ b/src/chrome/content/itsalltext.js
@@ -118,9 +118,10 @@ var ItsAllText = function() {
      */
     that.log = function() {
         var message = that.logString.apply(that, arguments);
+        var consoleService, e;
         try {
             // idiom: Convert arguments to an array for easy handling.
-            var consoleService = Components.
+            consoleService = Components.
                 classes["@mozilla.org/consoleservice;1"].
                 getService(Components.interfaces.nsIConsoleService);
             consoleService.logStringMessage(message);
@@ -197,8 +198,9 @@ var ItsAllText = function() {
         var last_week = Date.now() - (1000*60*60*24*7);
         var fobj = that.getEditDir();
         var entries = fobj.directoryEntries;
+        var entry;
         while (entries.hasMoreElements()) {
-            var entry = entries.getNext();
+            entry = entries.getNext();
             entry.QueryInterface(Components.interfaces.nsIFile);
             if(force || !entry.exists() || entry.lastModifiedTime < last_week){
                 try{
@@ -418,10 +420,11 @@ var ItsAllText = function() {
 
         var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"].getService(Components.interfaces.nsIWindowMediator);
         var win = wm.getMostRecentWindow("Browser:Preferences");
+        var pane;
         if (win) {
             win.focus();
             if (paneID) {
-                var pane = win.document.getElementById(paneID);
+                pane = win.document.getElementById(paneID);
                 win.document.documentElement.showPane(pane);
             }
         } else {
@@ -481,8 +484,9 @@ var ItsAllText = function() {
      */
     that.cleanCacheObjs = function() {
         var count = 0;
-        for(var id in that.tracker) {
-            var cobj = that.tracker[id];
+        var cobj, id;
+        for(id in that.tracker) {
+            cobj = that.tracker[id];
             if (cobj.node.ownerDocument.location === null) {
                 that.debug('cleaning %s', id);
                 delete cobj.node;
@@ -573,17 +577,18 @@ var ItsAllText = function() {
          * @param {Object} doc The document to watch.
          */
         watch: function(doc, force) {
+            var contentType, location, is_html, is_usable, is_my_readme;
             if (!force) {
                 /* Check that this is a document we want to play with. */
-                var contentType = doc.contentType;
-                var location = doc.location;
-                var is_html = (contentType=='text/html' ||
+                contentType = doc.contentType;
+                location = doc.location;
+                is_html = (contentType=='text/html' ||
                                contentType=='text/xhtml');
                 //var is_xul=(contentType=='application/vnd.mozilla.xul+xml');
-                var is_usable = (is_html) && 
+                is_usable = (is_html) && 
                     location.protocol != 'about:' &&
                     location.protocol != 'chrome:';
-                var is_my_readme = location.href == that.README;
+                is_my_readme = location.href == that.README;
                 if (!(is_usable || is_my_readme)) { 
                     that.debuglog('watch(): ignoring -- ',
                                   location, contentType);
@@ -612,10 +617,10 @@ var ItsAllText = function() {
             /* Walk the documents looking for changes */
             var documents = monitor.documents;
             that.debuglog('monitor.watcher(',offset,'): ', documents.length);
-            var i;
+            var i, doc;
             var did_delete = false;
             for(i in documents) {
-                var doc = documents[i];
+                doc = documents[i];
                 if (doc.location) {
                     that.debuglog('refreshing', doc.location);
                     that.refreshDocument(doc);
@@ -672,26 +677,27 @@ var ItsAllText = function() {
      * @param {Object} event The event passed in by the event handler.
      */
     that.onContextMenu = function(event) {
+        var tid, node, tag, is_disabled, cobj, menu;
         if(event.target) {
-            var tid = event.target.id;
+            tid = event.target.id;
             if (tid == "itsalltext-context-popup" ||
                 tid == "contentAreaContextMenu") {
-                var node = document.popupNode;
-                var tag = node.nodeName.toLowerCase();
-                var is_disabled = (!(tag == 'textarea' || 
+                node = document.popupNode;
+                tag = node.nodeName.toLowerCase();
+                is_disabled = (!(tag == 'textarea' || 
                                      tag == 'textbox') ||
                                    node.style.display == 'none' ||
                                    node.getAttribute('readonly') ||
                                    node.getAttribute('disabled')
                                    );
                 if (tid == "itsalltext-context-popup") {
-                    var cobj = that.getCacheObj(node);
+                    cobj = that.getCacheObj(node);
                     that.rebuildMenu(cobj.uid,
                                      'itsalltext-context-popup',
                                      is_disabled);
                 } else {
                     // tid == "contentAreaContextMenu"
-                    var menu = document.getElementById("itsalltext-contextmenu");
+                    menu = document.getElementById("itsalltext-contextmenu");
                     menu.setAttribute('hidden', is_disabled);
                 }
                     
@@ -701,10 +707,11 @@ var ItsAllText = function() {
     };
 
     that.checkVersion = function() {
+        var browser;
         if( that.preferences._get('lastversion') != that.VERSION) {
             setTimeout(function(){
                 try{
-                    var browser = getBrowser();
+                    browser = getBrowser();
                     browser.selectedTab = browser.addTab(that.README, null);
                     that.preferences._set('lastversion', that.VERSION);
                 } catch(e) {
@@ -765,8 +772,9 @@ ItsAllText.prototype.menuNewExtEdit = function(event) {
     var params = {out:null};       
     window.openDialog("chrome://itsalltext/chrome/newextension.xul", "",
     "chrome, dialog, modal, resizable=yes", params).focus();
+    var ext;
     if (params.out) {
-        var ext = params.out.extension.replace(/[\n\t ]+/g,'');
+        ext = params.out.extension.replace(/[\n\t ]+/g,'');
         if(params.out.do_save) {
             that.appendExtensions(ext);
         }
diff --git a/src/chrome/content/preferences.js b/src/chrome/content/preferences.js
index 4d05a87..8807595 100644
--- a/src/chrome/content/preferences.js
+++ b/src/chrome/content/preferences.js
@@ -30,10 +30,12 @@ function pref_editor_select() {
     }
   
     var rv = fp.show();
+    var file;
+    var editor;
     if (rv == nsIFilePicker.returnOK) {
-        var file = fp.file;
+        file = fp.file;
         pref_editor.value = file.path;
-        var editor = document.getElementById('editor');
+        editor = document.getElementById('editor');
         editor.style.color = 'inherit';
         editor.style.backgroundColor = 'inherit';
     }
@@ -51,17 +53,21 @@ function setHelp(text) {
 function pref_onload() {
     var locale = document.getElementById("strings");
     document.getElementById('browse').focus();
+    var editor;
+    var box;
+    var desc;
+    var textnode;
     if (window['arguments'] && window['arguments'][0] && window['arguments'][0] == 'badeditor') {
-        var editor = document.getElementById('editor');
+        editor = document.getElementById('editor');
         editor.style.color = 'black';
         editor.style.backgroundColor = '#fb4';
-        var box = document.getElementById('help');
+        box = document.getElementById('help');
         // Clean it out
         while (box.firstChild) {
             box.removeChild(box.firstChild);
         }
-        var desc = document.createElement('description');
-        var textnode = document.createTextNode(locale.getFormattedString('problem.editor', [editor.value]));
+        desc = document.createElement('description');
+        textnode = document.createTextNode(locale.getFormattedString('problem.editor', [editor.value]));
         desc.appendChild(textnode);
         desc.style.maxWidth = '18em';
         box.appendChild(desc);

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