-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathpopup.js
43 lines (37 loc) · 1.2 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
function message(val){
$(".message").text(val);
}
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-84918034-1']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = 'https://ssl.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
$(document).ready(function(){
//set input to previously saved value
chrome.storage.local.get("definedURL", function(result){
if(result.definedURL!=undefined){
$(".urlinput").attr("placeholder",result.definedURL);
}else{
$(".urlinput").attr("placeholder","type url here...");
}
});
//handle update
$(".urlbutton").click(function(){
$(".message").text($(".urlinput").val());
chrome.storage.local.set({'definedURL': $(".urlinput").val()}, function() {
// Notify that we saved.
message('Settings saved');
_gaq.push(['_trackEvent', 'url_updated', $(".urlinput").val()]);
});
});
//allow update when enter is pressed
$('input').keypress(function (e) {
if (e.which == 13) {
$(".urlbutton").click();
return false;
}
});
});