-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpopup.js
More file actions
42 lines (36 loc) · 948 Bytes
/
popup.js
File metadata and controls
42 lines (36 loc) · 948 Bytes
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
// popup.js
$(document).ready(function() {
$("#button").click(function() {
var textstr = $("#textbox").val();
if (!textstr) {
window.close();
}
else {
chrome.tabs.query({active: true, currentWindow: true }, function(tab) {
console.log(tab[0].url);
chrome.runtime.sendMessage({
type: "saveBookmark",
url: tab[0].url,
text: textstr
});
$('#textbox').val('');
var msg = textstr + ' saved';
$('#flash').html(msg);
$('#flash').toggleClass('flash-visible');
$('#flash').fadeIn('fast', function() {
window.close();
});
});
}
});
$("#textbox").keyup(function(event){
if(event.keyCode == 13){
$("#button").click();
}
});
$("#list").click(function() {
chrome.tabs.create({'url': chrome.extension.getURL('list.html')}, function(tab) {
// Tab opened.
});
});
});