aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorRahiel Kasim <rahielkasim@gmail.com>2017-05-06 13:12:12 +0200
committerRahiel Kasim <rahielkasim@gmail.com>2017-05-06 13:12:12 +0200
commit37c7fb052ba7b808a8143e228590561a921d1aa9 (patch)
tree37cb90a459ff6fece8bd6a4575ccb660a79af0c7
parent1794284178e98e15b46e9ea8302f8001918b64ff (diff)
code formatting, remove temporary code
-rw-r--r--.eslintrc.json43
-rw-r--r--LICENSE.txt2
-rw-r--r--chromium/archiveror.js32
-rw-r--r--firefox/lib/main.js30
-rw-r--r--package.json20
-rw-r--r--webpack.config.js4
6 files changed, 68 insertions, 63 deletions
diff --git a/.eslintrc.json b/.eslintrc.json
index 08a0fd0..180e8ba 100644
--- a/.eslintrc.json
+++ b/.eslintrc.json
@@ -10,27 +10,28 @@
"sourceType": "module"
},
"rules": {
- "indent": [2, 4],
- "linebreak-style": [2, "unix"],
- "quotes": 0,
- "semi": [2, "always"],
- "brace-style": [2, "1tbs", {"allowSingleLine": true}],
- "comma-style": 2,
- "eqeqeq": 2,
- "dot-notation": 2,
+ "indent": ["error", 4],
+ "linebreak-style": ["error", "unix"],
+ "quotes": ["error", "double", {"allowTemplateLiterals": true}],
+ "semi": ["error", "always"],
+ "brace-style": ["error", "1tbs", {"allowSingleLine": true}],
+ "comma-style": "error",
+ "comma-dangle": ["error", "only-multiline"],
+ "eqeqeq": "error",
+ "dot-notation": "error",
"no-unused-vars": 1,
- "no-spaced-func": 2,
- "space-before-blocks": 2,
- "space-before-function-paren": [2, {"anonymous": "always", "named": "never"}],
- "space-in-parens": 2,
- "space-infix-ops": 2,
- "space-unary-ops": 2,
- "keyword-spacing": 2,
- "block-spacing": 2,
- "key-spacing": 2,
- "comma-spacing": 2,
- "no-trailing-spaces": 2,
- "eol-last": 2,
- "no-var": 2
+ "no-spaced-func": "error",
+ "space-before-blocks": "error",
+ "space-before-function-paren": ["error", {"anonymous": "always", "named": "never"}],
+ "space-in-parens": "error",
+ "space-infix-ops": "error",
+ "space-unary-ops": "error",
+ "keyword-spacing": "error",
+ "block-spacing": "error",
+ "key-spacing": "error",
+ "comma-spacing": "error",
+ "no-trailing-spaces": "error",
+ "eol-last": "error",
+ "no-var": "error"
}
}
diff --git a/LICENSE.txt b/LICENSE.txt
index 74e34ec..49db015 100644
--- a/LICENSE.txt
+++ b/LICENSE.txt
@@ -1,4 +1,4 @@
-Copyright (c) 2015-2016 Rahiel Kasim
+Copyright (c) 2015-2017 Rahiel Kasim
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
diff --git a/chromium/archiveror.js b/chromium/archiveror.js
index 4fd384e..03d5bd5 100644
--- a/chromium/archiveror.js
+++ b/chromium/archiveror.js
@@ -75,7 +75,7 @@ function showArchive(url, bookmark) {
// Notify user if we have an archive of the current page
chrome.storage.local.get({archiveMode: "online", archiveBookmarks: true}, function (items) {
if (items.archiveMode === "local")
- showBadge('_' + url, items.archiveBookmarks);
+ showBadge("_" + url, items.archiveBookmarks);
else
showBadge(url, items.archiveBookmarks);
});
@@ -83,7 +83,7 @@ function showArchive(url, bookmark) {
function showBadge(url, archiveBookmarks) {
chrome.storage.local.get(url, function (data) {
if (data[url]) {
- let taburl = normalURL(url).split('#')[0];
+ let taburl = normalURL(url).split("#")[0];
chrome.tabs.query({"url": taburl}, function (tabs) {
changeBadge(tabs, buttonTitle.present, "!", "#FFB90F");
});
@@ -94,7 +94,7 @@ function showArchive(url, bookmark) {
}
function normalURL(url) {
- if (url[0] === '_')
+ if (url[0] === "_")
return url.slice(1);
else
return url;
@@ -118,8 +118,8 @@ function archiveClick(tab) {
if (text === buttonTitle.present) {
chrome.storage.local.get({archiveMode: "online"}, function (items) {
if (items.archiveMode === "local") {
- chrome.storage.local.get('_' + tab.url, function (data) {
- let url = data['_' + tab.url].filename;
+ chrome.storage.local.get("_" + tab.url, function (data) {
+ let url = data["_" + tab.url].filename;
chrome.tabs.create({"url": "file://" + url});
});
} else {
@@ -147,7 +147,7 @@ function archive(url, save, tab, bookmark) {
} else {
if (typeof tab === "undefined") { // for bookmark visit / creation
// tabs.query doesn't match fragment identifiers
- url = url.split('#')[0];
+ url = url.split("#")[0];
chrome.tabs.query({"url": url}, function (tabs) {
downloadBlock.push(tabs[0].id);
getPath(bookmark, function (path) {
@@ -164,8 +164,8 @@ function silentDownload(url, filename, path, callback) {
// silently download to archiveDir
chrome.storage.local.get({archiveDir: "Archiveror"}, function (items) {
filename = items.archiveDir + path + filename;
- chrome.downloads.download({url: url, filename: filename, saveAs: false,
- conflictAction: "overwrite"}, callback);
+ chrome.downloads.download({
+ url: url, filename: filename, saveAs: false, conflictAction: "overwrite"}, callback);
});
}
@@ -294,7 +294,7 @@ function getPath(bookmark, callback) {
if (node.parentId)
getParent(node);
else
- callback(nodes.reverse().join('/') + '/');
+ callback(nodes.reverse().join("/") + "/");
});
}
}
@@ -327,7 +327,7 @@ function moveLocal(id, moveInfo) {
function moveBookmark(bookmarks) {
let bookmark = bookmarks[0];
if (bookmark.hasOwnProperty("url")) {
- let key = '_' + bookmark.url;
+ let key = "_" + bookmark.url;
chrome.storage.local.get(key, function (items) {
let data = items[key];
// check if we need to move anything
@@ -405,7 +405,7 @@ function removeBookmark(id, removeInfo) {
getBookmarkTree();
let url = bookmark.url;
- let key = '_' + url;
+ let key = "_" + url;
chrome.storage.local.get(key, function (items) {
// What if deleting the file fails?
chrome.downloads.removeFile(items[key].id);
@@ -420,13 +420,3 @@ function removeBookmark(id, removeInfo) {
}
}
chrome.bookmarks.onRemoved.addListener(removeBookmark);
-
-// TODO: preference migration, remove this somewhere 2017
-chrome.storage.local.get({archiveService: null}, function (items) {
- let service = items.archiveService;
- if (typeof service === "string") {
- chrome.storage.local.set({archiveServices: [service]}, function () {
- chrome.storage.local.remove("archiveService");
- });
- }
-});
diff --git a/firefox/lib/main.js b/firefox/lib/main.js
index a5e79cb..ec0d27e 100644
--- a/firefox/lib/main.js
+++ b/firefox/lib/main.js
@@ -1,11 +1,11 @@
-const buttons = require('sdk/ui/button/action');
+const buttons = require("sdk/ui/button/action");
const clipboard = require("sdk/clipboard");
const cm = require("sdk/context-menu");
const Hotkey = require("sdk/hotkeys").Hotkey;
const preferences = require("sdk/simple-prefs");
const Request = require("sdk/request").Request;
const ss = require("sdk/simple-storage");
-const tabs = require('sdk/tabs');
+const tabs = require("sdk/tabs");
const bookmarks = require("./bookmarks");
const { get_archiving_url, is_local, services } = require("./../utils.js");
@@ -37,17 +37,23 @@ if (!ss.storage.data)
let data = ss.storage.data;
-const defaultButton = {label: "Archive Page",
- icon: {"16": "./icon-16.png",
- "32": "./icon-32.png",
- "64": "./icon-64.png"}
- };
+const defaultButton = {
+ label: "Archive Page",
+ icon: {
+ "16": "./icon-16.png",
+ "32": "./icon-32.png",
+ "64": "./icon-64.png"
+ }
+};
-const showButton = {label: "Go to archived page",
- icon: {"16": "./icon-16-star.png",
- "32": "./icon-32-star.png",
- "64": "./icon-64-star.png"}
- };
+const showButton = {
+ label: "Go to archived page",
+ icon: {
+ "16": "./icon-16-star.png",
+ "32": "./icon-32-star.png",
+ "64": "./icon-64-star.png"
+ }
+};
let button = buttons.ActionButton({
id: "archive-button",
diff --git a/package.json b/package.json
index 84abf42..b3ff808 100644
--- a/package.json
+++ b/package.json
@@ -19,16 +19,22 @@
"url": "https://github.com/rahiel/archiveror/issues"
},
"devDependencies": {
- "babel-cli": "^6.18.0",
- "babel-loader": "^6.2.7",
- "babel-preset-es2015": "^6.18.0",
- "eslint": "^3.9.1",
- "jpm": "^1.2.2",
- "webpack": "^2.1.0-beta.25"
+ "babel-cli": "^6.24.1",
+ "babel-loader": "^7.0.0",
+ "babel-preset-es2015": "^6.24.1",
+ "eslint": "^3.19.0",
+ "jpm": "^1.3.1",
+ "source-map-loader": "^0.2.1",
+ "webpack": "^2.5.0"
},
"babel": {
"presets": [
- ["es2015", { "modules": false }]
+ [
+ "es2015",
+ {
+ "modules": false
+ }
+ ]
]
}
}
diff --git a/webpack.config.js b/webpack.config.js
index 62d8153..f626153 100644
--- a/webpack.config.js
+++ b/webpack.config.js
@@ -1,12 +1,14 @@
+/* global __dirname */
module.exports = {
entry: {
"dist-chromium/archiveror": "./chromium/archiveror.js",
"dist-chromium/options": "./chromium/options.js"
},
output: {
- path: "./",
+ path: __dirname + "/",
filename: "[name].js"
},
+ devtool: "source-map",
module: {
loaders: [
{