-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwebpage.js
58 lines (51 loc) · 1.75 KB
/
webpage.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
function Page(url, title, isLiked, isBookmarked) {
this.url = url;
this.title = title;
this.isLiked = isLiked;
this.isBookmarked = isBookmarked;
this.timeVisited = [];
this.parentTabs = [];
this.timeSpent = 0;
}
// function addIdleTime(url, idleTime) {
// TASKS[CTASKID].history.find((page) = > page.url === url).idleTime = idleTime;
// }
// function getTotalTimeSpent(Page) {
// var timeSpent = Page.timeSpent;
// var idleTime = Page.idleTime;
// t_timeSpent = 0
// for (var i = 0; i < timeSpent.length; i++) {
// t_timeSpent = t_timeSpent + timeSpent[i]
// }
// actualTimeSpent = t_timeSpent;
// return actualTimeSpent;
// }
function returnPage(page, url) {
return page.url === url;
}
// function updateExitTime(url, time) {
// var pageIndex = indexOfElementWithProperty(TASKS[CTASKID].history, "url", url);
// if (pageIndex != -1) {
// var page = TASKS[CTASKID].history[pageIndex];
// page.exitTimes.push(time);
// var duration = returnDuration(page.timeVisited[page.timeVisited.length - 1], time);
// page.timeSpent.push(duration);
// page.totalTimeSpent = getTotalTimeSpent(page);
// }
// }
function likePage(url, content, method) {
if (TASKS[CTASKID].likedPages.indexOf(url) > -1) {
TASKS[CTASKID].likedPages.splice([TASKS[CTASKID].likedPages.indexOf(url)],1);
} else {
TASKS[CTASKID].likedPages.push(url);
}
if (method === "shortcut") {
chrome.tabs.sendMessage(activeTabId, {
"type": "page-liked-with-shortcut"
});
}
updateStorage("TASKS", TASKS);
lunrIndex.addDoc({'url': url, 'content': content});
// updatePreferredDomain(url);
// removeFromPageContentAndTextLog(url);
}