Skip to content

Commit

Permalink
Merge pull request #197 from ericawright/feature/linters
Browse files Browse the repository at this point in the history
Feature/linters
  • Loading branch information
bwinton committed May 13, 2016
2 parents 3cb5ac6 + 88124c8 commit 1020506
Show file tree
Hide file tree
Showing 10 changed files with 850 additions and 716 deletions.
48 changes: 48 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{
"env": {
"browser": true,
"es6": true
},
"extends": "eslint:recommended",
"plugins": [
"mozilla"
],
"globals": {
"Components": false,
"Services": false,
"Cc": false,
"Ci": false,
"TAB_DROP_TYPE": false,
"TabsInTitlebar": false
},
"rules": {
"mozilla/import-globals-from": 1,
"array-bracket-spacing": [2, "never"],
"camelcase": 0,
"comma-dangle": 0,
"comma-spacing": 2,
"computed-property-spacing": [2, "never"],
"curly": 2,
"default-case": 0,
"eqeqeq": [2, "smart"],
"generator-star-spacing": [2, {"before": false, "after": false}],
"id-blacklist": 0,
"indent": [2, 2],
"no-bitwise": 1,
"no-console": 1,
"no-empty-function": 0,
"no-magic-numbers": 0,
"no-mixed-spaces-and-tabs": [2, "smart-tabs"],
"no-shadow": 0,
"no-trailing-spaces": [2, {"skipBlankLines": false}],
"no-unused-vars": [2, {"vars": "local", "args": "none"}],
"object-curly-spacing": [2, "never"],
"no-var": 2,
"prefer-const": 0,
"quotes": [2, "single", "avoid-escape"],
"semi": [2, "always"],
"space-before-function-paren": [2, {"anonymous": "always", "named": "never"}],
"space-infix-ops": 2,
"space-unary-ops": 2
}
}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ build
skin/.DS_Store
TabCenterTest.zip
TabCenterTest.xpi
/node_modules/
npm-debug.log
41 changes: 22 additions & 19 deletions bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,18 @@
*
* ***** END LICENSE BLOCK ***** */

/* global Iterator:false, unload:false, vtInit:false, watchWindows:false, VerticalTabs:false, newPayload:false, sendPing:false, addPingStats:false, APP_SHUTDOWN:false */

/*exported install, startup, shutdown, uninstall*/

const {classes: Cc, interfaces: Ci, utils: Cu} = Components;

Cu.import("resource://gre/modules/Services.jsm");
Cu.import('resource://gre/modules/Services.jsm');

const RESOURCE_HOST = "tabcenter";
const RESOURCE_HOST = 'tabcenter';
const DEFAULT_PREFS = {
"browser.tabs.animate": false,
"browser.tabs.drawInTitlebar": false
'browser.tabs.animate': false,
'browser.tabs.drawInTitlebar': false
};

/**
Expand All @@ -53,64 +57,63 @@ function include(src) {
}

function setDefaultPrefs() {
let branch = Services.prefs.getDefaultBranch("");
for (let [name, value] in Iterator(DEFAULT_PREFS)) {
switch (typeof value) {
case "boolean":
case 'boolean':
Services.prefs.setBoolPref(name, value);
break;
case "number":
case 'number':
Services.prefs.setIntPref(name, value);
break;
case "string":
case 'string':
Services.prefs.setCharPref(name, value);
break;
}
}
}

function removeDefaultPrefs() {
let branch = Services.prefs.getDefaultBranch("");
for (let [name, value] in Iterator(DEFAULT_PREFS)) {
let branch = Services.prefs.getDefaultBranch('');
for (let [name] in Iterator(DEFAULT_PREFS)) {
branch.clearUserPref(name);
}
}

function install() {
}

var timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
let timer = Cc['@mozilla.org/timer;1'].createInstance(Ci.nsITimer);

function startup(data, reason) {
// Load helpers from utils.js.
include(data.resourceURI.spec + "utils.js");
include(data.resourceURI.spec + 'utils.js');

setDefaultPrefs();

// Register the resource:// alias.
let resource = Services.io.getProtocolHandler("resource")
let resource = Services.io.getProtocolHandler('resource')
.QueryInterface(Ci.nsIResProtocolHandler);
resource.setSubstitution(RESOURCE_HOST, data.resourceURI);
unload(function () {
resource.setSubstitution(RESOURCE_HOST, null);
});

// Initialize VerticalTabs object for each window.
Cu.import("resource://tabcenter/verticaltabs.jsm");
Cu.import('resource://tabcenter/verticaltabs.jsm');
unload(vtInit());
watchWindows(function(window) {
watchWindows(function (window) {
let vt = new VerticalTabs(window, {newPayload, addPingStats});
unload(vt.unload.bind(vt), window);
}, "navigator:browser");
}, 'navigator:browser');
timer.initWithCallback({notify: () => {
sendPing();
}}, 24*60*60*1000, Ci.nsITimer.TYPE_REPEATING_SLACK); // Every 24h.
}}, 24 * 60 * 60 * 1000, Ci.nsITimer.TYPE_REPEATING_SLACK); // Every 24h.
// }}, 20*1000, Ci.nsITimer.TYPE_REPEATING_SLACK); // Every 20s for debugging.
};
}

function shutdown(data, reason) {
sendPing();
if (reason == APP_SHUTDOWN) {
if (reason === APP_SHUTDOWN) {
return;
}
removeDefaultPrefs();
Expand Down
Loading

0 comments on commit 1020506

Please sign in to comment.