-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathsave_butt.js
More file actions
78 lines (60 loc) · 1.99 KB
/
save_butt.js
File metadata and controls
78 lines (60 loc) · 1.99 KB
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
// document.addEventListener('DOMContentLoaded', function() {
// var saveButton = document.getElementById('save_button');
// saveButton.addEventListener('click', function() {
// // Find html elements.
// var textArea = document.getElementById('my_text');
// var div = document.getElementById('view_text');
// // Put the text in a variable so we can manipulate it.
// var text = textArea.value;
// // Print the text in the div made for it.
// div.innerHTML = text;
// }, false);
// }, false);
//get url
function getCurrentTabUrl(callback) {
var queryInfo = {
active: true,
currentWindow: true
};
chrome.tabs.query(queryInfo, function(tabs) {
var tab = tabs[0];
var url = tab.url;
callback(url);
return url;
});
}
// function renderURL(statusText) {
// document.getElementById('urlArea').textContent = statusText;
// }
// function storeURL(statusText) {
// //return statusText;
// text = statusText;
// return text
// }
//get url button functionality
// document.addEventListener('DOMContentLoaded', function() {
// var getUrl = document.getElementById('getUrl');
// getUrl.addEventListener('click', function() {
// getCurrentTabUrl(function(url) {
// storeURL(url);
// });
// }, false);
// }, false);
window.onload = function() {
var box = document.getElementById('view_text');
var myline = getCurrentTabUrl(function(url) {
myline = url;
});
chrome.storage.sync.set({myline: ''});
chrome.storage.sync.get(myline, function(data) {
box.innerHTML = data.myline;
});
document.getElementById('save_button').onclick = function() {
var note = document.getElementById('my_text').value;
note = note.replace(/\n/gi, "<br />");
chrome.storage.sync.set({myline: note}, function(data){
//alert('Success!');
alert(myline);
});
}
}