-
Notifications
You must be signed in to change notification settings - Fork 1
/
pp.js~
48 lines (41 loc) · 1.14 KB
/
pp.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
44
45
46
47
48
$(document).ready( function() {
//console.log("add");
updateList();
function updateList(){
chrome.storage.sync.get( null, function (items){
//console.log(items);
if (items.length==0){
$(".lst").html("<li>Reading List is empty!</li>");
} else {
$(".lst").html("");
}
var i;
for (var k in items){
//console.log(items[k]['title'] + 'aa');
var lin; var tit;
if (items[k].value.indexOf("http") == 0){
lin = items[k]['value'];
tit = items[k]['value'].replace(/\-/g, " ").split("://")[1].split("/")[1];
} else {
lin = "http://www.quora.com" + items[k]['value'];
tit = items[k]['value'].replace(/\-/g, " ").split("/");
if (tit[2] == 'answers?'){
tit = tit[1] + "?";
} else {
tit = tit[2] + "?";
}
}
if (items[k]['title'] != '') tit = items[k]['title'];
$(".lst").append("<a target='_blank' class='oplink' key='" + k + "' href='" + lin + "'><li>" + tit + "</li></a>");
}
$('.oplink').click( function() {
chrome.storage.sync.remove($(this).attr("key"));
//return false;
});
});
}
$(".clr").click(function(){
chrome.storage.sync.clear();
updateList();
});
});