-
Notifications
You must be signed in to change notification settings - Fork 0
/
pearlupdate.js
32 lines (30 loc) · 1.16 KB
/
pearlupdate.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
debug = false
function updatePage(tab) {
if (debug) console.log('requested on ' + tab.url)
setUrl(tab.url);
wordsString = getAllPearls();
toggled = loadToggle();
exact = loadExact();
if (debug) console.log('Exact ' + exact)
chrome.tabs.sendRequest(tab.id, {type: 'hilight', wordsString: wordsString, toggled: toggled, exact: exact}, function(response) {
if (debug && response) console.log('Totals :' + response.total)
if (response && response.total == 0) {
chrome.browserAction.setBadgeText( {text: '', tabId: tab.id} )
} else if (response && response.total ) {
chrome.browserAction.setBadgeText( {text: response.total + '', tabId: tab.id} )
} else {
if (debug) console.log('Nothing done');
}
});
}
function movePage(currElementId,typeCall,tab) {
if (debug) console.log('requested on ' + tab.url)
chrome.tabs.sendRequest(tab.id,{type: typeCall}, function(response) {
if (debug) console.log('Abs pos :' + response)
//if (response && response > -1) {
document.getElementById(currElementId).value = response + 1;
//} else {
// if(debug) console.log('Nothing done');
//}
});
}