This repository was archived by the owner on Feb 24, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathwindows.js
63 lines (56 loc) · 2.07 KB
/
windows.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
59
60
61
62
63
var windows = {};
windows.browserAction = function() {
console.log(channel.connection_status);
if(channel.connection_status == 'connected') {
channel.socket.close();
} else if(channel.connection_status == 'disconnected') {
windows.connecting();
sockets.connect();
}
}
windows.openLink = function(link) {
newTab = {};
if(link.url.indexOf('://') === -1)
newTab.url = 'http://' + link.url;
else
newTab.url = link.url;
chrome.tabs.create(newTab, function(link) {
//TODO: handle link creation
});
}
windows.serverDown = function() {
channel.connection_status = "error";
chrome.browserAction.setIcon({'path': 'images/error.png'});
chrome.browserAction.setPopup({'popup': 'error_popup.html'});
chrome.browserAction.setTitle({'title': 'Server error. Click for more details.'});
}
windows.disconnected = function() {
channel.connection_status = "disconnected";
chrome.browserAction.setIcon({'path': 'images/disconnected.png'});
chrome.browserAction.setPopup({'popup': ''});
chrome.browserAction.onClicked.addListener(function(tab) {
sockets.connect();
});
chrome.browserAction.setTitle({'title': 'Disconnected. Click to connect.'});
}
windows.overQuota = function() {
channel.connection_status = "over_quota";
chrome.browserAction.setIcon({'path': 'images/error.png'});
chrome.browserAction.setPopup({'popup': 'quota_popup.html'});
chrome.browserAction.setTitle({'title': 'Over quota. Click for options.'});
}
windows.connecting = function() {
channel.connection_status = "connecting";
chrome.browserAction.setIcon({'path': 'images/connecting.png'});
chrome.browserAction.setPopup({'popup': ''});
chrome.browserAction.setTitle({'title': 'Connecting to the server...'});
}
windows.connected = function() {
channel.connection_status = "connected";
chrome.browserAction.setPopup({'popup': ''});
chrome.browserAction.onClicked.addListener(function(tab) {
channel.socket.close();
});
chrome.browserAction.setTitle({'title': 'Connected. Click to disconnect.'});
chrome.browserAction.setIcon({'path': 'images/connected.png'});
}