[Pkg-mozext-commits] [greasemonkey] 25/62: Code style clean up.

David Prévot taffit at moszumanska.debian.org
Sun Sep 13 22:10:22 UTC 2015


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

taffit pushed a commit to branch master
in repository greasemonkey.

commit 1f12fda6d50e3a94c8025cb6eaa24a78a76dc5e8
Author: Anthony Lieuallen <arantius at gmail.com>
Date:   Wed Aug 19 12:19:26 2015 -0400

    Code style clean up.
---
 content/addons4-overlay.js  | 10 ++++------
 content/framescript.js      | 31 +++++++++++++------------------
 modules/GM_setClipboard.js  |  2 +-
 modules/documentObserver.js | 38 ++++++++++++++++++--------------------
 modules/parseScript.js      | 12 ++++++------
 5 files changed, 42 insertions(+), 51 deletions(-)

diff --git a/content/addons4-overlay.js b/content/addons4-overlay.js
index 43f8f1f..e36bb10 100644
--- a/content/addons4-overlay.js
+++ b/content/addons4-overlay.js
@@ -261,18 +261,16 @@ function onSortersClicked(aEvent) {
 function applySort() {
   if (userScriptViewId != gViewController.currentViewId) return;
 
-  var buttons = document.getElementById('greasemonkey-sort-bar')
-    .getElementsByTagName('button');
-
-  var button = getSortBy(buttons);
-
   // Find checked button.
+  var buttons = document.getElementById('greasemonkey-sort-bar')
+      .getElementsByTagName('button');
+  getSortBy(buttons);
   for (var i = 0, button = null; button = buttons[i]; i++) {
     if (button.hasAttribute('checkState')) break;
   }
 
   var ascending = sortByCheckStateValueDescending
-                  != button.getAttribute('checkState');
+      != button.getAttribute('checkState');
   var sortBy = button.getAttribute('sortBy').split(',');
 
   setSortBy(button);
diff --git a/content/framescript.js b/content/framescript.js
index c96bed2..f5807e6 100644
--- a/content/framescript.js
+++ b/content/framescript.js
@@ -25,18 +25,17 @@ var gStripUserPassRegexp = new RegExp('(://)([^:/]+)(:[^@/]+)?@');
 // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ //
 
 function contentObserver(win) {
-    if (!GM_util.getEnabled()) return;
+  if (!GM_util.getEnabled()) return;
 
-    var doc = win.document;
-    var url = doc.documentURI;
-    if (!GM_util.isGreasemonkeyable(url)) return;
+  var doc = win.document;
+  var url = doc.documentURI;
+  if (!GM_util.isGreasemonkeyable(url)) return;
 
-    // Listen for whichever kind of load event arrives first.
-    win.addEventListener('DOMContentLoaded', contentLoad, true);
-    win.addEventListener('load', contentLoad, true);
+  // Listen for whichever kind of load event arrives first.
+  win.addEventListener('DOMContentLoaded', contentLoad, true);
+  win.addEventListener('load', contentLoad, true);
 
-    runScripts('document-start', win);
-  
+  runScripts('document-start', win);
 };
 
 // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ //
@@ -168,19 +167,17 @@ function windowIsTop(aContentWin) {
   return true;
 };
 
+
 function windowCreated() {
-  OnNewDocument(content, contentObserver);
+  onNewDocument(content, contentObserver);
 }
 
-
 // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ // \\ //
 
 addEventListener('DOMContentLoaded', blankLoad);
 addEventListener('DOMWindowCreated', windowCreated);
 
-if(content) windowCreated();
-
-
+if (content) windowCreated();
 
 addMessageListener('greasemonkey:inject-delayed-script', injectDelayedScript);
 addMessageListener('greasemonkey:load-failed-script', loadFailedScript);
@@ -192,7 +189,5 @@ addMessageListener('greasemonkey:menu-command-run', function(aMessage) {
 });
 
 
-(function() {
-  initInstallPolicy();
-  initScriptProtocol();
-})();
+initInstallPolicy();
+initScriptProtocol();
diff --git a/modules/GM_setClipboard.js b/modules/GM_setClipboard.js
index 47a83e1..58d039c 100644
--- a/modules/GM_setClipboard.js
+++ b/modules/GM_setClipboard.js
@@ -36,7 +36,7 @@ function GM_setClipboard(aData, aType) {
     trans.setTransferData(FLAVOR_HTML, strVal, (aData.length * 2));
 
     // Add a text/unicode flavor (html converted to plain text).
-    var strVal = Cc['@mozilla.org/supports-string;1']
+    strVal = Cc['@mozilla.org/supports-string;1']
         .createInstance(Ci.nsISupportsString);
     var converter = Cc['@mozilla.org/feed-textconstruct;1']
         .createInstance(Ci.nsIFeedTextConstruct);
diff --git a/modules/documentObserver.js b/modules/documentObserver.js
index 288b69c..e867e23 100644
--- a/modules/documentObserver.js
+++ b/modules/documentObserver.js
@@ -1,6 +1,6 @@
 'use strict';
 
-var EXPORTED_SYMBOLS = ['OnNewDocument'];
+var EXPORTED_SYMBOLS = ['onNewDocument'];
 
 var Cu = Components.utils;
 
@@ -8,10 +8,10 @@ Cu.import('resource://gre/modules/Services.jsm');
 Cu.import('chrome://greasemonkey-modules/content/util.js');
 
 
-var callbacks = new WeakMap()
+var callbacks = new WeakMap();
 
-function OnNewDocument(topWindow, callback) {
-	callbacks.set(topWindow, callback)
+function onNewDocument(topWindow, callback) {
+  callbacks.set(topWindow, callback);
 }
 
 var contentObserver = {
@@ -19,23 +19,21 @@ var contentObserver = {
     if (!GM_util.getEnabled()) return;
 
     switch (aTopic) {
-      case 'document-element-inserted':
-        var doc = aSubject;
-        var win = doc && doc.defaultView;
-        if (!doc || !win) return;
-        var topWin = win.top;
-
-        var frameCallback = callbacks.get(topWin);
-
-        if(!frameCallback) return;
-
-        frameCallback(win)
-
-        break;
-      default:
-        dump('Content frame observed unknown topic: ' + aTopic + '\n');
+    case 'document-element-inserted':
+      var doc = aSubject;
+      var win = doc && doc.defaultView;
+      if (!doc || !win) return;
+      var topWin = win.top;
+
+      var frameCallback = callbacks.get(topWin);
+      if (!frameCallback) return;
+      frameCallback(win);
+
+      break;
+    default:
+      dump('Content frame observed unknown topic: ' + aTopic + '\n');
     }
   }
 };
 
-Services.obs.addObserver(contentObserver, 'document-element-inserted', false);
\ No newline at end of file
+Services.obs.addObserver(contentObserver, 'document-element-inserted', false);
diff --git a/modules/parseScript.js b/modules/parseScript.js
index f93c029..07402ea 100644
--- a/modules/parseScript.js
+++ b/modules/parseScript.js
@@ -22,13 +22,13 @@ function parse(aSource, aUri, aFailWhenMissing, aNoMetaOk) {
 
   var script = new Script();
 
-  var name = null;
+  var scriptName = null;
   if (aUri) script.downloadURL = aUri.spec;
   if (aUri && aUri.spec) {
-    name = aUri.spec;
-    name = name.substring(0, name.indexOf(".user.js"));
-    name = name.substring(name.lastIndexOf("/") + 1);
-    script._name = name;
+    scriptName = aUri.spec;
+    scriptName = scriptName.substring(0, scriptName.indexOf(".user.js"));
+    scriptName = scriptName.substring(scriptName.lastIndexOf("/") + 1);
+    script._name = scriptName;
   }
   if (aUri) script._namespace = aUri.host;
 
@@ -67,7 +67,7 @@ function parse(aSource, aUri, aFailWhenMissing, aNoMetaOk) {
             script['_' + data.keyword] = data.value;
         if ((data.keyword == 'name')
             && ((script['_' + data.keyword] == 'user-script')
-            || (script['_' + data.keyword] == name)))
+            || (script['_' + data.keyword] == scriptName)))
             script['_' + data.keyword] = data.value;
       }
 

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



More information about the Pkg-mozext-commits mailing list