aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorRahiel Kasim <rahielkasim@gmail.com>2018-04-11 15:42:52 +0200
committerRahiel Kasim <rahielkasim@gmail.com>2018-04-11 15:42:52 +0200
commit666fd7f4723a0dbfced60f41aeb21aa7bf7fb66d (patch)
tree3de38b0f830aacb8652c61ad42ef25d7994297a6
parent5640b2af727761549d4d0fb29fc6330c1490ab61 (diff)
prefer camelCase for consistency
-rw-r--r--.eslintrc.json1
-rw-r--r--package.json6
-rw-r--r--src/archiveror.js20
-rw-r--r--src/options.js26
-rw-r--r--src/utils.js4
5 files changed, 29 insertions, 28 deletions
diff --git a/.eslintrc.json b/.eslintrc.json
index 5839c7d..3cf1937 100644
--- a/.eslintrc.json
+++ b/.eslintrc.json
@@ -18,6 +18,7 @@
"comma-style": "error",
"comma-dangle": ["error", "only-multiline"],
"curly": ["error", "multi-line"],
+ "camelcase": "warn",
"eqeqeq": "error",
"dot-notation": "error",
"no-unused-vars": 1,
diff --git a/package.json b/package.json
index e431a2f..32d9b97 100644
--- a/package.json
+++ b/package.json
@@ -18,11 +18,11 @@
},
"devDependencies": {
"babel-core": "^6.26.0",
- "babel-loader": "^7.1.2",
+ "babel-loader": "^7.1.4",
"babel-preset-es2015": "^6.24.1",
- "eslint": "^4.10.0",
+ "eslint": "^4.19.1",
"source-map-loader": "^0.2.3",
- "web-ext": "^2.2.2",
+ "web-ext": "^2.6.0",
"webpack": "^3.8.1"
},
"babel": {
diff --git a/src/archiveror.js b/src/archiveror.js
index b38c670..18a49a1 100644
--- a/src/archiveror.js
+++ b/src/archiveror.js
@@ -1,8 +1,8 @@
-import { get_archiving_url, is_local, services, hasPageCapture } from "./utils.js";
+import { getArchivingURL, isLocal, services, hasPageCapture } from "./utils.js";
function archive_is(url) {
- if (is_local(url)) return;
+ if (isLocal(url)) return;
let request = new XMLHttpRequest();
request.open("POST", "https://archive.is/submit/", true);
request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
@@ -26,33 +26,33 @@ function postArchive(url, link) {
// archive url online at services (a list of strings)
function archivePage(url, services) {
- if (is_local(url)) return; // don't archive internal pages, "file://", "chrome://", etc.
+ if (isLocal(url)) return; // don't archive internal pages, "file://", "chrome://", etc.
let tabId, link;
chrome.storage.local.get({archiveServices: ["archive.is"], email: ""}, function (items) {
if (services === undefined) {
services = items.archiveServices;
}
for (let service of services) {
- link = get_archiving_url(url, service, items.email);
+ link = getArchivingURL(url, service, items.email);
chrome.tabs.create({url: link}, function (tab) {
tabId = tab.id;
// support updating clipboard with new link from archive.is "save the page again"
- chrome.tabs.onUpdated.addListener(url_to_clipboard);
- chrome.tabs.onRemoved.addListener(url_to_clipboard);
+ chrome.tabs.onUpdated.addListener(URLToClipboard);
+ chrome.tabs.onRemoved.addListener(URLToClipboard);
});
}
});
let re = /.*(?:archive|perma|webcitation)\.(?:is|cc|org).*/;
- function url_to_clipboard(tab_id, changeInfo, tab) {
- if (tab_id !== tabId) { // ignore other tabs
+ function URLToClipboard(thisTabId, changeInfo, tab) {
+ if (thisTabId !== tabId) { // ignore other tabs
return;
}
// remove listeners if the tab was closed and if user navigated away from archive
if (changeInfo.hasOwnProperty("isWindowClosing") || !re.test(tab.url)) {
- chrome.tabs.onUpdated.removeListener(url_to_clipboard);
- chrome.tabs.onRemoved.removeListener(url_to_clipboard);
+ chrome.tabs.onUpdated.removeListener(URLToClipboard);
+ chrome.tabs.onRemoved.removeListener(URLToClipboard);
} else {
writeClipboard(tab.url);
}
diff --git a/src/options.js b/src/options.js
index 721905b..a7f837c 100644
--- a/src/options.js
+++ b/src/options.js
@@ -1,9 +1,9 @@
import { hasPageCapture } from "./utils.js";
-function save_options() {
+function saveOptions() {
- function get_options(name) {
+ function getOptions(name) {
// get the selected options by name
let checkboxes = document.getElementsByName(name);
let options = [];
@@ -15,8 +15,8 @@ function save_options() {
return options;
}
- let mode = get_options("mode")[0];
- let services = get_options("service");
+ let mode = getOptions("mode")[0];
+ let services = getOptions("service");
let dir = document.getElementById("dir").value;
// TODO: check dir for forbidden characters
@@ -32,16 +32,16 @@ function save_options() {
});
}
-function restore_options() {
+function restoreOptions() {
chrome.storage.local.get({ // below are the default values
archiveBookmarks: true,
archiveDir: "Archiveror",
archiveMode: "online",
archiveServices: ["archive.is"],
email: "",
- }, set_options);
+ }, setOptions);
- function set_options(items) {
+ function setOptions(items) {
if (items.archiveBookmarks === true) {
document.getElementById("bookmarks").checked = true;
}
@@ -60,20 +60,20 @@ function restore_options() {
}
}
}
-document.addEventListener("DOMContentLoaded", restore_options);
-document.getElementById("local").addEventListener("click", show_local);
-document.getElementById("online").addEventListener("click", show_local);
+document.addEventListener("DOMContentLoaded", restoreOptions);
+document.getElementById("local").addEventListener("click", showLocal);
+document.getElementById("online").addEventListener("click", showLocal);
let inputs = document.querySelectorAll(`input[type="checkbox"], input[type="radio"]`);
for (let input of inputs) {
- input.addEventListener("change", save_options);
+ input.addEventListener("change", saveOptions);
}
let textInputs = document.querySelectorAll(`input[type="text"]`);
for (let input of textInputs) {
- input.addEventListener("input", save_options);
+ input.addEventListener("input", saveOptions);
}
-function show_local() {
+function showLocal() {
let local = document.getElementById("local").checked;
if (local === true) {
document.getElementById("local_options").style.display = "block";
diff --git a/src/utils.js b/src/utils.js
index f1e7599..b8e081e 100644
--- a/src/utils.js
+++ b/src/utils.js
@@ -2,14 +2,14 @@ export const services = ["archive.is", "archive.org", "perma.cc", "webcitation.o
const blacklist = ["file://", "about:", "chrome://", "http://127.0.0.1", "http://localhost"];
-export function is_local(url) {
+export function isLocal(url) {
for (let b of blacklist) {
if (url.startsWith(b)) return true;
}
return false;
}
-export function get_archiving_url(page, service, email) {
+export function getArchivingURL(page, service, email) {
let url = "https://archive.is/?run=1&url=" + encodeURIComponent(page); // default
if (service === "archive.org") {
// breaks if page is URI encoded