forked from jeremys/Notifier-for-Google-Wave
/
options.html
238 lines (211 loc) · 10.1 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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Notifier for Google Wave - Options</title>
<link rel="shortcut icon" HREF="icon_16.png">
<link rel="stylesheet" type="text/css" href="options.css">
<script type="text/javascript" src="jquery.js"></script>
<script>
var bkg = chrome.extension.getBackgroundPage();
// Saves options to localStorage.
function save_options() {
bkg.settings.pollInterval = parseInt($('#refresh').val()) * 60000;
bkg.settings.timeout = 1000 * 15;
bkg.settings.appsDomain = $('#apps_domain_value').val();
bkg.settings.popupNotification = $('#popupNotification')[0].checked;
bkg.settings.soundNotification = $('#soundNotification')[0].checked;
bkg.settings.hideNavBox = $('#hideNavBox')[0].checked;
bkg.settings.hideContactsBox = $('#hideContactsBox')[0].checked;
bkg.settings.hideSearchBox = $('#hideSearchBox')[0].checked;
bkg.settings.hidePreviewBox = $('#hidePreviewBox')[0].checked;
var iconRadios = document.forms[0].icon_set;
for(var i in iconRadios) {
if(iconRadios[i].checked) {
bkg.settings.iconsSet = iconRadios[i].value;
break;
}
}
refresh_extension();
$('#options_saved').fadeIn('fast');
$('#options_saved').fadeOut(3000);
}
// Restores select box state to saved value from localStorage.
$(function() {
$('#refresh').val(bkg.settings.pollInterval / 60000);
//$('#timeout').val(bkg.settings.timeout / 1000);
$('#apps_domain_value').val(bkg.settings.appsDomain);
$('#popupNotification')[0].checked = bkg.settings.popupNotification;
if(bkg.settings.popupNotification) {
$('#notifications_text').show();
} else {
$('#notifications_text').hide();
}
$('#soundNotification')[0].checked = bkg.settings.soundNotification;
$('#hideNavBox')[0].checked = bkg.settings.hideNavBox;
$('#hideContactsBox')[0].checked = bkg.settings.hideContactsBox;
$('#hideSearchBox')[0].checked = bkg.settings.hideSearchBox;
$('#hidePreviewBox')[0].checked = bkg.settings.hidePreviewBox;
if(bkg.settings.appsDomain == "") {
$('#apps_domain_check')[0].checked = "";
$('#apps_domain_value_text').hide();
} else {
$('#apps_domain_check')[0].checked = "checked";
$('#apps_domain_value').val(bkg.settings.appsDomain);
$('#apps_domain_value_text').show();
}
var iconRadios = document.forms[0].icon_set;
var iconFound = false;
for(var i in iconRadios) {
if(iconRadios[i].value == bkg.settings.iconsSet) {
iconRadios[i].checked = true;
iconFound = true;
break;
}
}
print_perm();
});
function print_perm(){
var perm = webkitNotifications.checkPermission();
if(perm == 0) {
document.getElementById('notification_permission').innerHTML = 'are activated';
document.getElementById('notification_permission').style.color = 'green';
document.getElementById('request').style.display = "none";
} else if(perm == 1) {
document.getElementById('notification_permission').innerHTML = 'are not activated';
document.getElementById('notification_permission').style.color = 'orange';
document.getElementById('request').style.display = "";
} else if(perm == 2) {
document.getElementById('notification_permission').innerHTML = 'are forbidden';
document.getElementById('notification_permission').style.color = 'red';
document.getElementById('request').style.display = "";
}
}
function toggle_popup() {
var perm = webkitNotifications.checkPermission();
if(perm == 0) {
document.getElementById('notification_permission').innerHTML = 'are activated';
document.getElementById('notification_permission').style.color = 'green';
document.getElementById('request').style.display = "none";
} else if(perm == 1) {
document.getElementById('notification_permission').innerHTML = 'are not activated';
document.getElementById('notification_permission').style.color = 'orange';
document.getElementById('request').style.display = "";
} else if(perm == 2) {
document.getElementById('notification_permission').innerHTML = 'are forbidden';
document.getElementById('notification_permission').style.color = 'red';
document.getElementById('request').style.display = "";
}
$('#notifications_text').toggle();
}
// Toggle display of input text for apps domain based on checkbox state.
function toggle_appsdomain() {
$('#apps_domain_value_text').toggle();
$('#apps_domain_value').val('');
}
// Refresh the extension by reseting timer.
function refresh_extension() {
bkg.refresh();
}
</script>
</head>
<body>
<form onsubmit="return false;">
<div id="body-container">
<div id="header"><h1>Notifier for Google Wave</h1></div>
<div id="extensionTemplate">
<div id="container" class="vbox-container">
<div id="top" class="wbox" style="padding-right: 5px">
<div class="section-header">
<table cellpadding="0" cellspacing="0" width="100%">
<tr valign="center">
<td>
<span class="section-header-title">Options</span>
</td>
</tr>
</table>
</div>
</div>
<div id="developer_tools" class="wbox-dev-mode showInDevMode">
<div class="developer-mode">
General
</div>
</div>
<div class="developer-mode-content">
Refresh Rate: <select id="refresh">
<option value="1">1 minute</option>
<option value="5">5 minutes</option>
<option value="10">10 minutes</option>
<option value="15">15 minutes</option>
<option value="20">20 minutes</option>
<option value="25">25 minutes</option>
<option value="30">30 minutes</option>
</select>
</div>
<div id="developer_tools" class="wbox-dev-mode showInDevMode">
<div class="developer-mode-top">
Notifications
</div>
</div>
<div class="developer-mode-content">
Enable popup notifications: <input id="popupNotification" type="checkbox" onclick="toggle_popup();"> <span id="notifications_text" style="display:none;">Notifications <span id="notification_permission">are not supported yet in your browser</span>. <span id="request" style="display:none;"> <button onclick="webkitNotifications.requestPermission(print_perm);" type="button" class="btn">Activate notifications</button></span></span><br/>
Enable sound notifications: <input id="soundNotification" type="checkbox">
</div>
<div id="developer_tools" class="wbox-dev-mode showInDevMode">
<div class="developer-mode-top">
When opening Google Wave
</div>
</div>
<div class="developer-mode-content">
Hide nav box: <input id="hideNavBox" type="checkbox"><br/>
Hide contacts box: <input id="hideContactsBox" type="checkbox"><br/>
Hide search box: <input id="hideSearchBox" type="checkbox"><br/>
Don't show preview popup of unread waves: <input id="hidePreviewBox" type="checkbox">
</div>
<div id="developer_tools" class="wbox-dev-mode showInDevMode">
<div class="developer-mode-top">
Google Apps
</div>
</div>
<div class="developer-mode-content">
Activate: <input type="checkbox" id="apps_domain_check" onclick="toggle_appsdomain();"/><br/>
<span id="apps_domain_value_text" style="display:none;">Domain: https://wave.google.com/a/<input id="apps_domain_value" type="text" placeholder="yourdomain.com" value=""/>/</span>
</div>
<div id="developer_tools" class="wbox-dev-mode showInDevMode">
<div class="developer-mode-top">
Icons
</div>
</div>
<div class="developer-mode-content">
<span><input type="radio" name="icon_set" value="set1" /><img src="/icons/set1/not_logged_in.png" /><img src="icons/set1/no_new.png" /><img src="icons/set1/new.png" /></span><br />
<span><input type="radio" name="icon_set" value="set2" /><img src="/icons/set2/not_logged_in.png" /><img src="icons/set2/no_new.png" /><img src="icons/set2/new.png" /></span><br />
<span><input type="radio" name="icon_set" value="set3" /><img src="/icons/set3/not_logged_in.png" /><img src="icons/set3/no_new.png" /><img src="icons/set3/new.png" /></span><br />
</div>
</div>
<div class="content">
<div class="extension" jsselect="extensions">
<table width="100%" cellpadding="2" cellspacing="0">
<tr>
<td width="62" height="50" align="center" valign="top"> </td>
<td valign="top"> </td>
<td width="100"> </td>
<td align="right" valign="center" width="700">
<span id="options_saved" class="info-message" style="display:none;">Options saved! The extension has been refreshed.</span> <button onclick="save_options();">Save</button> <button onclick="refresh_extension();">Refresh extension</button> <button onclick="window.close();">Close</button>
</td>
</tr>
</table>
</div>
<div id="get-moar-extensions">By Zachary “Gamer_Z.” Yaro (<a href="http://github.com/zmyaro/wave-notifier" target="_blank">github</a>).</div>
<div class="credits">
Original “Notifier for Google Wave” extension by <a href="http://www.jeremyselier.com">Jeremy Selier</a>, with the help of <a href="http://www.google.com/profiles/artiom.chi">Artiom Chilaru</a> and Joakim Andersson
<br/>
<a href="http://github.com/jeremys/Notifier-for-Google-Wave">Source code licensed under the Apache License.</a>
<br/>
Some icons by <a href="http://desc.se/">destructoBOT</a>, some others thanks to <a href="http://midgardination.deviantart.com/art/iChrome-Icon-Template-138927254">Midgardination</a>
</div>
</div>
</div>
</div>
</form>
</body>
</html>