-
-
Notifications
You must be signed in to change notification settings - Fork 12
/
options.js
executable file
·76 lines (67 loc) · 2.87 KB
/
options.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/*function loadOptions() {
chrome.storage.sync.get({
saveLocally: false,
saveChromeBookmarks: true
}, function(items) {
//document.getElementById('handlePDF').checked = items.handlePDF;
document.getElementById('saveLocally').checked = items.saveLocally;
document.getElementById('saveChromeBookmarks').checked = items.saveChromeBookmarks;
});
}
function saveOptions() {
var saveLocally = document.getElementById("saveLocally").checked;
var saveChromeBookmarks = document.getElementById("saveChromeBookmarks").checked;
chrome.storage.sync.set({
saveLocally:saveLocally,
saveChromeBookmarks:saveChromeBookmarks
}, function() {
//window.close();
});
}
function restoreOptions() {
chrome.storage.sync.set({
saveLocally: false,
saveChromeBookmarks: true
}, function() {
//document.getElementById("handlePDF").checked = false;
document.getElementById('saveLocally').checked = false;
document.getElementById('saveChromeBookmarks').checked = true;
});
}*/
/*function donateOptions() {
chrome.tabs.create({ url: 'https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=R9JRASMAABUUE&item_name=Yawas+Web+and+PDF+Highlighter¤cy_code=USD&source=yawasextension' });
}*/
//document.addEventListener('DOMContentLoaded', loadOptions);
//document.querySelector('#save').addEventListener('click', saveOptions);
//document.querySelector('#restore').addEventListener('click', restoreOptions);
//document.querySelector('#donate').addEventListener('click', donateOptions);
//let handlePDFElem = document.getElementById("handlePDF");
//handlePDFElem.addEventListener('change',saveOptions);
//let saveLocallyElem = document.getElementById("saveLocally");
//saveLocallyElem.addEventListener('change',saveOptions);
//let saveChromeBookmarksElem = document.getElementById("saveChromeBookmarks");
//saveChromeBookmarksElem.addEventListener('change',saveOptions);
/*let importButton = document.getElementById('importChromeBookmarks');
importButton.addEventListener('click', () => {
importButton.textContent = 'Importing'
importButton.disabled = true
chrome.runtime.sendMessage({ msg: "startImportFunc" })
});*/
let searchButton = document.getElementById('searchChromeBookmarks');
searchButton.addEventListener('click', () => {
chrome.tabs.create({url:chrome.runtime.getURL('localsearch.html')})
window.close()
});
chrome.runtime.onMessage.addListener(async function requestCallback(request, sender, sendResponse) {
if (request.msg === 'importMessage') {
if (request.error) {
importmessage.textContent = request.error
importButton.textContent = 'Import'
importButton.disabled = false
}
else {
importmessage.textContent = `imported ${request.n} bookmarks`;
request.start ? importButton.disabled = true : importButton.disabled = false
}
}
});