-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path#popup.js#
85 lines (74 loc) · 1.83 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
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
$(document).ready(
function(){
//initialize status is
var bg = chrome.extension.getBackgroundPage();
var status = localStorage["status"];
if(localStorage.keyword){
var initArr = arraydb.parse("keyword");
for(var i = 0; i < initArr.length; i++){
$("#formDomain").append(
$("<option>")
.html(initArr[i])
.val(initArr[i])
);
}
}
//alert some message
/*
var alertmsg = function(elm){
switch(elm){
case blankAlert:
$("#blankAlert").text("write Domain");
break;
case alert_start:
$("#alert_end").text("start!").;
break;
case alert_end:
$("#alert_end").text("End!").css("color", "red");
break;
}
};*/
var alertmsg = function(elm, text){
$(elm).text(text).css("color", "red");
};
$("#add").on("click",
function(){
var form = $("#form").first().val();
if(!form) alertmsg();
if(!localStorage.length){
bg.keyword.push(form);
var keyword = bg.keyword.toString();
localStorage["keyword"] = keyword;
}else{
arraydb.push("keyword", form);
}
$("#formDomain").append(
$("<option>")
.html(form)
.val(form)
);
$("#form").val("");
});
$("#delButton").on("click",
function(){
var delkey = $("#formDomain option:selected").val();
if(!delkey) alertmsg(del);
var str = localStorage["keyword"].split(",");
arraydb.del("keyword", delkey);
$("#formDomain option:selected").remove();
}
);
$("#startButton").on("click",
function(){
var hour = parseInt($("#hour").val()) * bg.TIME.HOUR;
if(isNaN(hour)) hour = 0;
var min = parseInt($("#min").val()) * bg.TIME.MIN;
if(isNaN(min)) min = 0;
var period = hour + min;
alertmsg("#alert_start", "start!");
chrome.extension.sendRequest(period);
$("#hour").val("");
$("#min").val("");
}
);
});