-
Notifications
You must be signed in to change notification settings - Fork 3
/
ui.js
58 lines (53 loc) · 1.25 KB
/
ui.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
var buttons = require('sdk/ui/button/action');
var tabs = require("sdk/tabs");
var conf = require('./conf');
var sniff = require("./sniff");
var file = require("./file");
exports.updateUI = updateUI;
var button = buttons.ActionButton({
id: "mozilla-link",
label: "Save audio",
icon: "./audiosaver_blue_32.png",
onClick: handleClick
});
function handleClick(state) {
if (conf.getPath()) {
if (!conf.get("Enabled")) {
sniff.start();
conf.set("Enabled", true);
} else {
sniff.stop();
conf.set("Enabled", false);
}
} else {
require("sdk/notifications").notify({
text: "Save audio, disabled. Set the directory to save audio"
});
}
updateUI();
}
function updateUI() {
if (!conf.getPath()) {
button.state("window", {
icon: "./audiosaver_gray_32.png",
label: "Save audio, disabled. Set the directory to save audio",
});
sniff.stop();
return;
} else {
button.state("window", {
label: "Save audio",
});
}
if (conf.get("Enabled")) {
button.state("window", {
icon: "./audiosaver_blue_32.png",
label: "Save audio",
});
} else {
button.state("window", {
icon: "./audiosaver_gray_32.png",
label: "Save audio, disabled",
});
}
}