-
Notifications
You must be signed in to change notification settings - Fork 4
/
index.js
57 lines (52 loc) · 1.3 KB
/
index.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
// Define keyboard shortcuts for showing and hiding a custom panel.
var { Cc, Ci } = require("chrome");
var { Hotkey } = require("sdk/hotkeys");
var panel = require("sdk/panel");
var timers = require("sdk/timers");
var data = require("sdk/self").data;
var runtime = require("sdk/system/runtime");
var osString = runtime.OS;
var osWarnFile;
// Load the right warning
if (osString === "Darwin") {
osWarnFile = "warnmac.html";
} else {
osWarnFile = "warn.html";
}
// Create the panel to show the warning
var myPanel = panel.Panel({
width: 300,
height: 80,
contentURL: data.url(osWarnFile),
});
// Display the warning
function showPanel() {
myPanel.show();
timers.setTimeout(function() {
myPanel.hide();
}, 2000);
}
var pressButton = function() {
// We're already showing the warning
if (myPanel.isShowing) {
myPanel.hide();
Cc['@mozilla.org/toolkit/app-startup;1']
.getService(Ci.nsIAppStartup)
.quit(Ci.nsIAppStartup.eAttemptQuit)
}
// Show the warning since we didn't quit yet
showPanel();
};
// Handle the keypress
var AccelQ = Hotkey({
combo: "accel-q",
onPress: function() {
pressButton();
}
});
var AccelShiftW = Hotkey({
combo: "accel-shift-w",
onPress: function() {
pressButton();
}
});