-
Notifications
You must be signed in to change notification settings - Fork 0
/
options.html
117 lines (91 loc) · 3.31 KB
/
options.html
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Options</title>
<link href="options.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="container">
<h1>
<img src='images/tickletab-48.png' style="vertical-align: middle;margin: 1em" title="Tickle Tab" alt="Tickle Tab"/>Tickle Tab
</h1>
<section>
<section-head>What is this about?</section-head>
<section-content>TickleTab implements the Tickler idea of David Allen's GTD.
It saves all the tabs you don't need right now and presents them again at the specified date.
</section-content>
</section>
<section>
<section-head>Options</section-head>
<section-content>
A value for an ignored option: <input id="txtOption01" type="text" oninput="markDirty()">
</section-content>
</section>
<div>
<input type="button" id="btnSave" onclick="save()" value="Save"/>
</div>
<br>
<div>
<input type="button" id="btnExport" onclick="exportTabsToBookmarks()" value="Export Tickle Tabs to Bookmarks"/>
</div>
</div>
<script>
var txtOption01;
var btnSave;
init();
function init() {
txtOption01 = document.getElementById("txtOption01");
btnSave = document.getElementById("btnSave");
txtOption01.value = localStorage.sOption01 || "";
markClean();
}
function save() {
localStorage.sOption01 = txtOption01.value;
markClean();
chrome.extension.getBackgroundPage().init();
}
function markDirty() {
btnSave.disabled = false;
}
function markClean() {
btnSave.disabled = true;
}
function exportTabsToBookmarks() {
var sBookmarkRootId = null;
var sBookmarkRootTitle = "TickleTabs";
// Create a bookmark root folder.
chrome.bookmarks.getChildren('1', function(ajNode) {
// Find an existing folder.
for (i = 0; i < ajNode.length; i++) {
if (ajNode[i].title == sBookmarkRootTitle) {
sBookmarkRootId = ajNode[i].id;
break;
}
}
// If no folder was found ...
if (sBookmarkRootId == null) {
// ... create one and export tabs.
chrome.bookmarks.create({"parentId": "1", "title": sBookmarkRootTitle}, function(jNode) {
sBookmarkRootId = jNode.id;
var aaTabs = chrome.extension.getBackgroundPage().STORAGE.getAllTickleTabs();
// For each date
for (iDate in aaTabs) {
// get key
var sKeyFormatted = aaTabs[iDate].key.substr(0, 4) + "-" + aaTabs[iDate].key.substr(4, 2) + "-" + aaTabs[iDate].key.substr(6, 2);
// For each tab
for (iTab in aaTabs[iDate].value) {
chrome.bookmarks.create({"parentId": sBookmarkRootId, "title": sKeyFormatted + " " + aaTabs[iDate].value[iTab].title, "url": aaTabs[iDate].value[iTab].url});
}
}
}
);
} else {
// ... exit.
alert("Bookmark folder '" + sBookmarkRootTitle + "' already exists.");
}
});
}
</script>
</body>
</html>