/
settings.html
104 lines (99 loc) · 3.35 KB
/
settings.html
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>CPAN Helper</title>
<style>
html, body{ border:0; margin:0; padding:0; height:100%; }
body {
font-size:16px;
font-family:"Helvetica Neue", "Lucida Grande", Arial, Helvetica, "Hiragino Kaku Gothic Pro", "ヒラギノ角ゴ Pro W3", Meiryo, sans-serif;
font-weight:lighter;
background:#fff;
color:#141414;
}
a, a:visited { color:#666; text-decoration:none; }
a:hover { color:#426DC9; }
ul, ol { margin:0; padding:0; list-style:none; }
li { margin:0; padding:0; }
img { vertical-align:middle; }
footer { margin-top:100px; font-size:12px; text-align:right; }
#wrapper { margin:0 auto; padding:20px 0; width:600px; }
#wrapper h1 { font-weight:100; font-size:50px; letter-spacing:-1px; line-height:80%; color:#666; }
#wrapper h2 { font-weight:200; font-size:20px; }
#settings { margin:0 0 50px 0; }
#settings li { margin:0 0 10px 0; }
#settings .description { font-size:12px; color:#666; margin-left:10px; }
</style>
<script>
function init(){
var settings = JSON.parse(localStorage.getItem('settings'));
document.getElementById('notify-setting').checked = settings.notify;
document.getElementById('display-time').value = settings.display;
document.getElementById('notify-all').checked = settings.all;
document.getElementById('notify-favorites').value = settings.favorites;
allOrFavorite();
}
function save(){
var settings = {
notify: document.getElementById('notify-setting').checked,
display: document.getElementById('display-time').value,
all: document.getElementById('notify-all').checked,
favorites: document.getElementById('notify-favorites').value.split(',')
};
localStorage.setItem('settings', JSON.stringify(settings));
}
function allOrFavorite(){
var enableAll = document.getElementById('notify-all').checked;
var inputFavorite = document.getElementById('notify-favorites');
inputFavorite.disabled = enableAll ? true : false;
}
function saveAndClose(){
save();
chrome.tabs.getSelected(null, function(tab) {
chrome.tabs.remove(tab.id);
});
}
</script>
</head>
<body onload="init();">
<div id="wrapper">
<h1><img src="icon_128.png" />CPAN Helper</h1>
<h2>Settings</h2>
<ul id="settings">
<li>
<input type="checkbox" id="notify-setting">
<label for="notify-setting">Desktop notification</label>
</li>
<li>
Duration for desktop notification:
<select id="display-time">
<option value="0">0</option>
<option value="5">5</option>
<option value="10">10</option>
<option value="15">15</option>
<option value="20">20</option>
</select> sec
</li><br />
<li>
<input type="checkbox" id="notify-all" onclick="allOrFavorite()">
<label for="notify-all">Notify all releases</label>
</li>
<li>
or only notify watch modules and authors?<br /><br />
<input type="text" id="notify-favorites" size="60" />
<span class="description">ex. Plack,Text-Xslate,tokuhirom</span>
</li><!--<br />
<li>
<input type="checkbox" id="contentScript" onclick="">
<label for="contentScript">Content script on MetaCPAN</label>
</li>-->
</ul>
<button id="saveAndClose" onclick="saveAndClose()">Save & Close</button>
<footer>
The source code is available on
<a href="https://github.com/wata/CPANHelper" target="_blank">github</a>.
</footer>
</div>
</body>
</html>