Skip to content

Commit 305401f

Browse files
author
ETY001
committed
v2.2.3
1 parent 890d5af commit 305401f

File tree

9 files changed

+135
-29
lines changed

9 files changed

+135
-29
lines changed

_locales/en_US/messages.json

+6
Original file line numberDiff line numberDiff line change
@@ -61,5 +61,11 @@
6161
},
6262
"chat": {
6363
"message": "Chat on Gitter"
64+
},
65+
"blockmanager": {
66+
"message": "Block Manager"
67+
},
68+
"notitle_text": {
69+
"message": "* No Title *"
6470
}
6571
}

_locales/zh_CN/messages.json

+6
Original file line numberDiff line numberDiff line change
@@ -61,5 +61,11 @@
6161
},
6262
"chat": {
6363
"message": "Chat on Gitter"
64+
},
65+
"blockmanager": {
66+
"message": "已屏蔽管理"
67+
},
68+
"notitle_text": {
69+
"message": "* 没有设置书签名 *"
6470
}
6571
}

css/default.css

+26-1
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,15 @@ hr{
5252
height: 100%;
5353
overflow-y: scroll;
5454
overflow-x: hidden;
55+
width: 300px;
56+
position: absolute;
57+
top: 0;
58+
right: -300px;
59+
letter-spacing: .1em;
60+
background-color: #eee;
61+
}
62+
.custom-restricted-width {
63+
width: 100%;
5564
}
5665
.appname{
5766
padding: 0 30px 0 20px;
@@ -60,6 +69,7 @@ hr{
6069
.bookmark_info{
6170
letter-spacing: .1em;
6271
padding: 10px;
72+
width: 680px;
6373
}
6474
#frame{
6575
top: 0;
@@ -74,6 +84,21 @@ hr{
7484
height:100%;
7585
border: 0;
7686
}
77-
#bookmark_title{
87+
#blockmanager_title{
7888
font-weight: bolder;
89+
font-size: 16px;
90+
padding-left: 10px;
91+
border-bottom: 1px solid #ddd;
92+
}
93+
#about{
94+
margin: 0 auto;
95+
padding: 15px 0px;
96+
text-align: center;
97+
}
98+
.pure-menu-link{
99+
padding: 0;
100+
}
101+
.pure-menu-item{
102+
padding: 8px 12px;
103+
border-bottom: 1px solid #ddd;
79104
}

img/publish_button_24.gif

2.78 KB
Loading

js/background.js

+15-2
Original file line numberDiff line numberDiff line change
@@ -22,28 +22,41 @@ chrome.runtime.onConnect.addListener(function(port) {
2222
case 'lang':
2323
var res_lang = {};
2424
for(var i in cdata){
25-
res_lang[cdata[i]] = chrome.i18n.getMessage(cdata[i]);
25+
if(typeof(cdata[i])=='string'){
26+
res_lang[cdata[i]] = chrome.i18n.getMessage(cdata[i]);
27+
}
2628
}
2729
port.postMessage({ctype:ctype, cdata:res_lang});
2830
break;
2931
case 'getbookmark':
32+
cpa_obj.sendEvent('Openbookmark', uid);
3033
Bookmark.get_from_local(function(bm){
3134
//console.log('get_bookmark_ok',bm);
32-
cpa_obj.sendAppView("openbookmark_"+bm.title);
3335
port.postMessage({ctype:ctype, cdata: bm});
36+
cpa_obj.sendAppView("openbookmark_"+bm[0].title);
3437
});
3538
break;
3639
case 'block':
3740
cpa_obj.sendEvent('Block', uid);
3841
Bookmark.set_jump(cdata);
3942
port.postMessage({ctype:ctype, cdata: true});
4043
break;
44+
case 'cancelblock':
45+
cpa_obj.sendEvent('CancelBlock', uid);
46+
Bookmark.set_jump(cdata, 0);
47+
port.postMessage({ctype:ctype, cdata:cdata });
48+
break;
4149
case 'remove_bookmark':
4250
cpa_obj.sendEvent('rm_bookmark', uid);
4351
Bookmark.rm_bookmark_by_id(cdata, function(){
4452
port.postMessage({ctype:ctype, cdata: true});
4553
});
4654
break;
55+
case 'get_block_list':
56+
cpa_obj.sendEvent('get_block_list', uid);
57+
Bookmark.get_block_list(function(list){
58+
port.postMessage({ctype:ctype, cdata: list});
59+
});
4760
};
4861
});
4962
});

js/bookmark.js

+9
Original file line numberDiff line numberDiff line change
@@ -156,5 +156,14 @@ var Bookmark = {
156156
}
157157
}
158158
}
159+
},
160+
//获取 block list
161+
get_block_list: function(callback){
162+
var tab_ids = [];
163+
for(var i in Bookmark.jump){
164+
tab_ids.push(i);
165+
}
166+
//console.log(tab_ids);
167+
chrome.bookmarks.get(tab_ids, callback);
159168
}
160169
}

js/show.js

+56-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
$(function(){
2+
function addweibo(tab){
3+
var weibo_url = "http://www.jiathis.com/send/?webid=tsina&url="+tab.url+"&title=@ETY001%25"+encodeURI(tab.title);
4+
$('#weibo').attr('href', weibo_url);
5+
}
26
var tab_id;
37
var url;
48
if(window.localStorage.preview_switch=='on'){
@@ -18,16 +22,20 @@ $(function(){
1822
"blocklist",
1923
"blockmsg",
2024
"nouse",
21-
"chat"
25+
"chat",
26+
"blockmanager",
27+
"notitle_text"
2228
];
2329

2430
var port = chrome.runtime.connect({name: "bookmark_manager_ety001"});
2531

2632
$('#block').click(function(){
2733
port.postMessage({ctype:"block",cdata:tab_id});
34+
port.postMessage({ctype:"getbookmark",cdata:false});
2835
});
2936
$('#nouse').click(function(){
3037
port.postMessage({ctype:"remove_bookmark",cdata:tab_id});
38+
port.postMessage({ctype:"getbookmark",cdata:false});
3139
});
3240

3341
$('#openpreview').click(function(){
@@ -44,6 +52,17 @@ $(function(){
4452
$('#openpreview').show();
4553
});
4654

55+
$('#blockmanager').click(function(e){
56+
e.stopPropagation();
57+
port.postMessage({ctype:"get_block_list",cdata:false});
58+
$('#blocklist').animate({right: 0});
59+
});
60+
61+
$('#screen,#frame').click(function(e){
62+
e.stopPropagation();
63+
$('#blocklist').animate({right: "-"+$('#blocklist').width()+"px"});
64+
});
65+
4766
port.postMessage({ctype:"getbookmark",cdata:false});
4867
port.postMessage({ctype:"lang", cdata:lang_req});
4968
port.onMessage.addListener(function(msg) {
@@ -53,7 +72,7 @@ $(function(){
5372
switch (ctype) {
5473
case 'getbookmark':
5574
var title = cdata[0].title;
56-
url = cdata[0].url;
75+
url = cdata[0].url + "#review_bookmark";
5776
tab_id = cdata[0].id;
5877
$('#bookmark_title').html(title+" | "+url);
5978
if(window.localStorage.preview_switch=='on'){
@@ -72,6 +91,9 @@ $(function(){
7291
$('#blockmsg').html(cdata.blockmsg);
7392
$('#nouse').html(cdata.nouse);
7493
$('#chat').html(cdata.chat);
94+
$('#blockmanager').html(cdata.blockmanager);
95+
$('#blockmanager_title').html(cdata.blockmanager);
96+
$('#notitle_text').val(cdata.notitle_text);
7597
break;
7698
case 'block':
7799
if(cdata){
@@ -89,6 +111,38 @@ $(function(){
89111
},2000);
90112
}
91113
break;
114+
case 'get_block_list':
115+
if(cdata){
116+
var tmpl = '';
117+
var notitle_text = $('#notitle_text').val();
118+
for(var i in cdata){
119+
tmpl += '<li id="blockitem_'+cdata[i].id+'" class="pure-menu-item">';
120+
if(cdata[i].url.match(/javascript\:/)==null){
121+
var list_url = cdata[i].url + "#review_bookmark";
122+
} else {
123+
var list_url = '#';
124+
}
125+
tmpl += '<a href="'+ list_url +'" class="pure-menu-link" target="_blank">';
126+
if(cdata[i].title!=''){
127+
var title = cdata[i].title;
128+
} else {
129+
var title = notitle_text;
130+
}
131+
tmpl += title +'</a><hr>';
132+
tmpl += '<button data-id="'+cdata[i].id+'" class="cancelblock button-yellow pure-button">cancel</button></li>';
133+
}
134+
$('#blocklist .pure-menu-list').html( $(tmpl) );
135+
$('.cancelblock').click(function(){
136+
var tab_id = $(this).attr('data-id');
137+
$(this).parent().animate({right: "-"+$('#blocklist').width()+"px"}, function(){
138+
$(this).parent().remove();
139+
});
140+
port.postMessage({ctype:"cancelblock",cdata:tab_id});
141+
});
142+
}
143+
break;
144+
case 'cancelblock':
145+
break;
92146
}
93147
});
94148
});

manifest.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
"name": "__MSG_appname__",
1010
"description": "__MSG_appdesc__",
11-
"version": "2.2.2",
11+
"version": "2.2.3",
1212

1313
"icons": {
1414
"16": "img/icon-16.png",

show.html

+16-23
Original file line numberDiff line numberDiff line change
@@ -24,39 +24,32 @@ <h1 id="appname"></h1>
2424
<button id="closepreivew" class="button-yellow pure-button"></button>
2525
<button id="openpreview" class="button-success pure-button"></button>
2626
&nbsp;
27-
<a id="chat" href="https://gitter.im/ety001/bookmark-extension" target="_blank" class="button-secondary pure-button"></a>
28-
<a id="donate" class="pure-button" target="_blank" href="http://www.domyself.me/donate"></a>
27+
<button id="blockmanager" class="button-secondary pure-button"></button>
2928
<span id="blockmsg" style="display:none;"></span>
29+
<!--&nbsp;
30+
<a id="weibo" href=""+ class="pure-button">
31+
<img src="img/publish_button_24.gif">
32+
</a>-->
3033
</div>
3134
</div>
3235
<div id="frame">
33-
<iframe src=""></iframe>
36+
<iframe src="" sandbox=""></iframe>
3437
</div>
3538
</div>
36-
<!--<div id="blocklist" class="pure-u-1-6">
37-
<style>
38-
.custom-restricted-width {
39-
/* To limit the menu width to the content of the menu: */
40-
display: inline-block;
41-
/* Or set the width explicitly: */
42-
/* width: 10em; */
43-
}
44-
</style>
39+
<div id="blocklist">
4540
<div class="pure-menu custom-restricted-width">
46-
<span class="pure-menu-heading">Yahoo Sites</span>
47-
41+
<span id="blockmanager_title" class="pure-menu-heading"></span>
4842
<ul class="pure-menu-list">
49-
<li class="pure-menu-item"><a href="#" class="pure-menu-link">Flickr</a></li>
50-
<li class="pure-menu-item"><a href="#" class="pure-menu-link">Messenger</a></li>
51-
<li class="pure-menu-item"><a href="#" class="pure-menu-link">Sports</a></li>
52-
<li class="pure-menu-item"><a href="#" class="pure-menu-link">Finance</a></li>
53-
<li class="pure-menu-heading">More Sites</li>
54-
<li class="pure-menu-item"><a href="#" class="pure-menu-link">Games</a></li>
55-
<li class="pure-menu-item"><a href="#" class="pure-menu-link">News</a></li>
56-
<li class="pure-menu-item"><a href="#" class="pure-menu-link">OMG!</a></li>
5743
</ul>
5844
</div>
59-
</div>-->
45+
<div id="about">
46+
<a id="chat" href="https://gitter.im/ety001/bookmark-extension" target="_blank" class="button-secondary pure-button"></a>
47+
&nbsp;
48+
<a id="donate" class="pure-button" target="_blank" href="http://www.domyself.me/donate"></a><hr>
49+
Powered by <a href="http://www.domyself.me" target="_blank">ETY001</a>
50+
</div>
51+
</div>
6052
</div>
53+
<input type="hidden" id="notitle_text" value="">
6154
</body>
6255
</html>

0 commit comments

Comments
 (0)