Skip to content

Commit

Permalink
Rename to JabRef Browser Extension
Browse files Browse the repository at this point in the history
  • Loading branch information
tobiasdiez committed Nov 7, 2019
1 parent f010306 commit 6ab05cd
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 21 deletions.
20 changes: 10 additions & 10 deletions background.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ browser.tabs.query({})
.then((tabs) => {
// We wait a bit before injection to give Zotero time to load the translators
setTimeout(() => {
console.log("JabFox: Inject into open tabs %o", tabs);
console.log("JabRef: Inject into open tabs %o", tabs);
for (let tab of tabs) {
lookForTranslators(tab);
}
Expand Down Expand Up @@ -65,16 +65,16 @@ function lookForTranslators(tab) {
return;
}

console.log("JabFox: Searching for translators for %o", tab);
console.log("JabRef: Searching for translators for %o", tab);
Zotero.Translators.getWebTranslatorsForLocation(tab.url, tab.url).then((translators) => {
if (translators[0].length == 0) {
// No translators found, so hide button
console.log("JabFox: No translators found");
console.log("JabRef: No translators found");
browser.pageAction.hide(tab.id);
} else {
// Potential translators found, Zotero will check if these can detect something on the website.
// We will be notified about the result of this check using the `onTranslators` method below, so nothing to do here.
console.log("JabFox: Found potential translators %o", translators[0]);
console.log("JabRef: Found potential translators %o", translators[0]);
}
});
}
Expand All @@ -84,7 +84,7 @@ function evalInTab(code) {
code: code
})
.then(
result => console.log(`JabFox: code executed`),
result => console.log(`JabRef: code executed`),
error => console.log(`Error: ${error}`));
}

Expand All @@ -101,10 +101,10 @@ onTranslators = function(translators, instanceID, contentType) {
var tab = tabs[0];

if (translators.length == 0) {
console.log("JabFox: Found no suitable translators for tab %o", JSON.parse(JSON.stringify(tab)));
console.log("JabRef: Found no suitable translators for tab %o", JSON.parse(JSON.stringify(tab)));
browser.pageAction.hide(tab.id);
} else {
console.log("JabFox: Found translators %o for tab %o", translators, JSON.parse(JSON.stringify(tab)));
console.log("JabRef: Found translators %o for tab %o", translators, JSON.parse(JSON.stringify(tab)));

browser.pageAction.show(tab.id);
browser.pageAction.setTitle({
Expand All @@ -116,10 +116,10 @@ onTranslators = function(translators, instanceID, contentType) {
}

browser.runtime.onMessage.addListener(function(message, sender, sendResponse) {
console.log("JabFox: message in background.js: %o", JSON.parse(JSON.stringify(message)))
console.log("JabRef: message in background.js: %o", JSON.parse(JSON.stringify(message)))
if (message.popupOpened) {
// The popup opened, i.e. the user clicked on the page action button
console.log("JabFox: Popup opened confirmed");
console.log("JabRef: Popup opened confirmed");

browser.tabs.query({
active: true,
Expand All @@ -128,7 +128,7 @@ browser.runtime.onMessage.addListener(function(message, sender, sendResponse) {
.then((tabs) => {
var tab = tabs[0];

console.log("JabFox: Start translation for tab %o", JSON.parse(JSON.stringify(tab)));
console.log("JabRef: Start translation for tab %o", JSON.parse(JSON.stringify(tab)));
Zotero.Connector_Browser.saveWithTranslator(tab, 0);
});
} else if (message.eval) {
Expand Down
4 changes: 2 additions & 2 deletions bibtexConverter.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
convertToBibTex = function(items) {
console.log("JabFox: Convert items to BibTeX: %o", items);
console.log("JabRef: Convert items to BibTeX: %o", items);
var deferred = Zotero.Promise.defer();

var translation = new Zotero.Translate.Export();
Expand Down Expand Up @@ -46,7 +46,7 @@ Zotero.Translate.ItemGetter.prototype = {

browser.runtime.onMessage.addListener(message => {
if (message.convertToBibTex) {
console.log("JabFox: Got task to convert %o to BibTeX", message.convertToBibTex);
console.log("JabRef: Got task to convert %o to BibTeX", message.convertToBibTex);
return convertToBibTex(message.convertToBibTex);
}
});
8 changes: 4 additions & 4 deletions connector.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Zotero.Connector = new function() {
this.callMethod = Zotero.Promise.method(function(options, data, cb, tab) {
console.log("JabFox: Tried to contact Zotero standalone: " + options);
console.log("JabRef: Tried to contact Zotero standalone: " + options);
throw new Error("Zotero Offline");
})

Expand Down Expand Up @@ -60,20 +60,20 @@ Zotero.Connector = new function() {
browser.runtime.sendMessage({
"onSendToJabRef": "sendToJabRefStarted"
});
console.log("JabFox: Send BibTeX to JabRef: %o", bibtex);
console.log("JabRef: Send BibTeX to JabRef: %o", bibtex);

browser.runtime.sendNativeMessage("org.jabref.jabref", {
"text": bibtex
})
.then(response => {
console.log("JabFox: Got response from JabRef: %o with details %o", response.message, response.output);
console.log("JabRef: Got response from JabRef: %o with details %o", response.message, response.output);
if (response.message == 'ok') {
browser.runtime.sendMessage({
"popupClose": "close"
});
}
}, error => {
console.error("JabFox: Error connecting to JabRef: %o", error);
console.error("JabRef: Error connecting to JabRef: %o", error);
});
}
}
2 changes: 1 addition & 1 deletion data/options.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>JabFox</title>
<title>JabRef Browser Extension</title>
<link rel="stylesheet" href="options.css" />
</head>

Expand Down
4 changes: 2 additions & 2 deletions data/progressPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ window.addEventListener("load", function load(event) {
"popupOpened": "opened"
});

console.log("JabFox: Popup opened")
console.log("JabRef: Popup opened")
}, false);

browser.runtime.onMessage.addListener(function(message, sender, sendResponse) {
if (message.popupClose) {
// The popup should be closed
window.close();
console.log("JabFox: Popup closed");
console.log("JabRef: Popup closed");
} else if (message.onConvertToBibtex) {
document.getElementById("status").innerHTML = 'Convert to BibTeX...';
// = "";
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "jabfox",
"name": "jabrefbrowserextension",
"scripts": {
"prepare": "ncp node_modules/webextension-polyfill/dist/browser-polyfill.min.js browser-polyfill.min.js",
"dev:firefox": "web-ext run",
Expand Down Expand Up @@ -46,7 +46,7 @@
"dependencies": {},
"repository": {
"type": "git",
"url": "https://github.com/JabRef/JabFox.git"
"url": "https://github.com/JabRef/JabRef-Browser-Extension.git"
},
"license": "AGPL-3.0-or-later"
}

0 comments on commit 6ab05cd

Please sign in to comment.