This repository has been archived by the owner on Aug 27, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpopup.js
54 lines (49 loc) · 1.57 KB
/
popup.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
'use strict';
function setPauseStatus(status) {
if (status) {
$('#statusBar').text('Paused');
$('#btnStatus').text('Restart');
} else {
$('#statusBar').text('Working');
$('#btnStatus').text('Pause');
}
}
function verifyStatus() {
chrome.storage.local.get(['url', 'registered'], function(result) {
$.ajax({
url: result.url + 'plugins/zzz_ttrss_push_notifier/flag.php',
type: 'POST',
data: {test_regid: result.registered}
})
.done(function(data) {
$('#checkBar').text(data == 'ok' ? ', Server OK' : ', Error: need config');
})
.fail(function() {
$('#checkBar').text(', Cannot connect: check URL');
});
});
}
window.onload = function() {
$('#btnStatus').click(function() {
chrome.storage.local.get('paused', function(result) {
chrome.storage.local.set({paused: !result.paused});
setPauseStatus(!result.paused);
});
});
$('#apply').click(function() {
chrome.storage.local.set({timeout: parseInt($('#txtTimeout').val()),
url: $('#txtUrl').val(),
username: $('#txtUsername').val()
});
verifyStatus();
});
chrome.storage.local.get(['paused', 'url', 'username', 'registered', 'timeout'], function(result) {
setPauseStatus(result.paused);
$('#txtUrl').val(result.url);
$('#txtUsername').val(result.username);
var regID = result.registered;
$('#regID').text(regID ? regID : 'Unregistered');
$('#txtTimeout').val(result.timeout ? result.timeout : 15);
});
verifyStatus();
};