-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpopup.html
105 lines (69 loc) · 2.17 KB
/
popup.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
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="jquery-ui.js"></script>
<script>
_app_name = 'JunkDrawer \u2122';
$(document).ready(function(){
if (localStorage['lastPage'] == 'NaN')
localStorage['lastPage'] = 0;
if (localStorage['lastPage'] != 'undefined')
_id = localStorage['lastPage'];
else _id=0;
$('#counter').text(_id);
$('#title').text(_app_name);
loadPage(_id);
});
function back(){
if (_id <= 0)
return;
localStorage[_id] = $('#output_data').html();
_id--;
loadPage();
}
function forward(){
if (_id >= localStorage.length)
return;
localStorage[_id] = $('#output_data').html();
_id++;
loadPage();
}
function loadPage(){
content = localStorage[_id];
$('#output_data').html(content);
console.log('restoring: '+content);
console.log(localStorage);
$('#counter').text(_id);
localStorage['lastPage'] = _id;
$('*', '#output_data').draggable();
}
function init(){
console.log(localStorage);
if(localStorage['count'] =='undefined')
localStorage['count'] =0;
if (localStorage[localStorage.length -1] != ""){
content = localStorage[localStorage.length-1];
console.log('Restoring:' +content);
$('body').append(content);
}
}
function udate(){
chrome.tabs.getSelected(null, function(tab) {
chrome.tabs.sendRequest(tab.id, {counter: 1}, function handler(response) {
console.log('response:');
console.log(response);
localStorage[localStorage.length] = JSON.parse(response);
$('#output_data').append(JSON.parse(response));
});
});
}
</script>
<html>
<style>
body {
width: 400px;
}
</style>
<h3 id="title"></h3>
<a href="" onclick="back(); return false;" ><--</a> <a href="" onclick="forward(); return false;" >--></a><span id="counter"></span>
<div id="output_data"></div>
<input type="button" value="snap" onclick="udate()"/>
</html>