Skip to content

Commit

Permalink
v2.2.3
Browse files Browse the repository at this point in the history
  • Loading branch information
ETY001 committed Feb 15, 2016
1 parent 890d5af commit 305401f
Show file tree
Hide file tree
Showing 9 changed files with 135 additions and 29 deletions.
6 changes: 6 additions & 0 deletions _locales/en_US/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,11 @@
},
"chat": {
"message": "Chat on Gitter"
},
"blockmanager": {
"message": "Block Manager"
},
"notitle_text": {
"message": "* No Title *"
}
}
6 changes: 6 additions & 0 deletions _locales/zh_CN/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,11 @@
},
"chat": {
"message": "Chat on Gitter"
},
"blockmanager": {
"message": "已屏蔽管理"
},
"notitle_text": {
"message": "* 没有设置书签名 *"
}
}
27 changes: 26 additions & 1 deletion css/default.css
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,15 @@ hr{
height: 100%;
overflow-y: scroll;
overflow-x: hidden;
width: 300px;
position: absolute;
top: 0;
right: -300px;
letter-spacing: .1em;
background-color: #eee;
}
.custom-restricted-width {
width: 100%;
}
.appname{
padding: 0 30px 0 20px;
Expand All @@ -60,6 +69,7 @@ hr{
.bookmark_info{
letter-spacing: .1em;
padding: 10px;
width: 680px;
}
#frame{
top: 0;
Expand All @@ -74,6 +84,21 @@ hr{
height:100%;
border: 0;
}
#bookmark_title{
#blockmanager_title{
font-weight: bolder;
font-size: 16px;
padding-left: 10px;
border-bottom: 1px solid #ddd;
}
#about{
margin: 0 auto;
padding: 15px 0px;
text-align: center;
}
.pure-menu-link{
padding: 0;
}
.pure-menu-item{
padding: 8px 12px;
border-bottom: 1px solid #ddd;
}
Binary file added img/publish_button_24.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 15 additions & 2 deletions js/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,28 +22,41 @@ chrome.runtime.onConnect.addListener(function(port) {
case 'lang':
var res_lang = {};
for(var i in cdata){
res_lang[cdata[i]] = chrome.i18n.getMessage(cdata[i]);
if(typeof(cdata[i])=='string'){
res_lang[cdata[i]] = chrome.i18n.getMessage(cdata[i]);
}
}
port.postMessage({ctype:ctype, cdata:res_lang});
break;
case 'getbookmark':
cpa_obj.sendEvent('Openbookmark', uid);
Bookmark.get_from_local(function(bm){
//console.log('get_bookmark_ok',bm);
cpa_obj.sendAppView("openbookmark_"+bm.title);
port.postMessage({ctype:ctype, cdata: bm});
cpa_obj.sendAppView("openbookmark_"+bm[0].title);
});
break;
case 'block':
cpa_obj.sendEvent('Block', uid);
Bookmark.set_jump(cdata);
port.postMessage({ctype:ctype, cdata: true});
break;
case 'cancelblock':
cpa_obj.sendEvent('CancelBlock', uid);
Bookmark.set_jump(cdata, 0);
port.postMessage({ctype:ctype, cdata:cdata });
break;
case 'remove_bookmark':
cpa_obj.sendEvent('rm_bookmark', uid);
Bookmark.rm_bookmark_by_id(cdata, function(){
port.postMessage({ctype:ctype, cdata: true});
});
break;
case 'get_block_list':
cpa_obj.sendEvent('get_block_list', uid);
Bookmark.get_block_list(function(list){
port.postMessage({ctype:ctype, cdata: list});
});
};
});
});
Expand Down
9 changes: 9 additions & 0 deletions js/bookmark.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,5 +156,14 @@ var Bookmark = {
}
}
}
},
//获取 block list
get_block_list: function(callback){
var tab_ids = [];
for(var i in Bookmark.jump){
tab_ids.push(i);
}
//console.log(tab_ids);
chrome.bookmarks.get(tab_ids, callback);
}
}
58 changes: 56 additions & 2 deletions js/show.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
$(function(){
function addweibo(tab){
var weibo_url = "http://www.jiathis.com/send/?webid=tsina&url="+tab.url+"&title=@ETY001%25"+encodeURI(tab.title);
$('#weibo').attr('href', weibo_url);
}
var tab_id;
var url;
if(window.localStorage.preview_switch=='on'){
Expand All @@ -18,16 +22,20 @@ $(function(){
"blocklist",
"blockmsg",
"nouse",
"chat"
"chat",
"blockmanager",
"notitle_text"
];

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

$('#block').click(function(){
port.postMessage({ctype:"block",cdata:tab_id});
port.postMessage({ctype:"getbookmark",cdata:false});
});
$('#nouse').click(function(){
port.postMessage({ctype:"remove_bookmark",cdata:tab_id});
port.postMessage({ctype:"getbookmark",cdata:false});
});

$('#openpreview').click(function(){
Expand All @@ -44,6 +52,17 @@ $(function(){
$('#openpreview').show();
});

$('#blockmanager').click(function(e){
e.stopPropagation();
port.postMessage({ctype:"get_block_list",cdata:false});
$('#blocklist').animate({right: 0});
});

$('#screen,#frame').click(function(e){
e.stopPropagation();
$('#blocklist').animate({right: "-"+$('#blocklist').width()+"px"});
});

port.postMessage({ctype:"getbookmark",cdata:false});
port.postMessage({ctype:"lang", cdata:lang_req});
port.onMessage.addListener(function(msg) {
Expand All @@ -53,7 +72,7 @@ $(function(){
switch (ctype) {
case 'getbookmark':
var title = cdata[0].title;
url = cdata[0].url;
url = cdata[0].url + "#review_bookmark";
tab_id = cdata[0].id;
$('#bookmark_title').html(title+" | "+url);
if(window.localStorage.preview_switch=='on'){
Expand All @@ -72,6 +91,9 @@ $(function(){
$('#blockmsg').html(cdata.blockmsg);
$('#nouse').html(cdata.nouse);
$('#chat').html(cdata.chat);
$('#blockmanager').html(cdata.blockmanager);
$('#blockmanager_title').html(cdata.blockmanager);
$('#notitle_text').val(cdata.notitle_text);
break;
case 'block':
if(cdata){
Expand All @@ -89,6 +111,38 @@ $(function(){
},2000);
}
break;
case 'get_block_list':
if(cdata){
var tmpl = '';
var notitle_text = $('#notitle_text').val();
for(var i in cdata){
tmpl += '<li id="blockitem_'+cdata[i].id+'" class="pure-menu-item">';
if(cdata[i].url.match(/javascript\:/)==null){
var list_url = cdata[i].url + "#review_bookmark";
} else {
var list_url = '#';
}
tmpl += '<a href="'+ list_url +'" class="pure-menu-link" target="_blank">';
if(cdata[i].title!=''){
var title = cdata[i].title;
} else {
var title = notitle_text;
}
tmpl += title +'</a><hr>';
tmpl += '<button data-id="'+cdata[i].id+'" class="cancelblock button-yellow pure-button">cancel</button></li>';
}
$('#blocklist .pure-menu-list').html( $(tmpl) );
$('.cancelblock').click(function(){
var tab_id = $(this).attr('data-id');
$(this).parent().animate({right: "-"+$('#blocklist').width()+"px"}, function(){
$(this).parent().remove();
});
port.postMessage({ctype:"cancelblock",cdata:tab_id});
});
}
break;
case 'cancelblock':
break;
}
});
});
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

"name": "__MSG_appname__",
"description": "__MSG_appdesc__",
"version": "2.2.2",
"version": "2.2.3",

"icons": {
"16": "img/icon-16.png",
Expand Down
39 changes: 16 additions & 23 deletions show.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,39 +24,32 @@ <h1 id="appname"></h1>
<button id="closepreivew" class="button-yellow pure-button"></button>
<button id="openpreview" class="button-success pure-button"></button>
&nbsp;
<a id="chat" href="https://gitter.im/ety001/bookmark-extension" target="_blank" class="button-secondary pure-button"></a>
<a id="donate" class="pure-button" target="_blank" href="http://www.domyself.me/donate"></a>
<button id="blockmanager" class="button-secondary pure-button"></button>
<span id="blockmsg" style="display:none;"></span>
<!--&nbsp;
<a id="weibo" href=""+ class="pure-button">
<img src="img/publish_button_24.gif">
</a>-->
</div>
</div>
<div id="frame">
<iframe src=""></iframe>
<iframe src="" sandbox=""></iframe>
</div>
</div>
<!--<div id="blocklist" class="pure-u-1-6">
<style>
.custom-restricted-width {
/* To limit the menu width to the content of the menu: */
display: inline-block;
/* Or set the width explicitly: */
/* width: 10em; */
}
</style>
<div id="blocklist">
<div class="pure-menu custom-restricted-width">
<span class="pure-menu-heading">Yahoo Sites</span>
<span id="blockmanager_title" class="pure-menu-heading"></span>
<ul class="pure-menu-list">
<li class="pure-menu-item"><a href="#" class="pure-menu-link">Flickr</a></li>
<li class="pure-menu-item"><a href="#" class="pure-menu-link">Messenger</a></li>
<li class="pure-menu-item"><a href="#" class="pure-menu-link">Sports</a></li>
<li class="pure-menu-item"><a href="#" class="pure-menu-link">Finance</a></li>
<li class="pure-menu-heading">More Sites</li>
<li class="pure-menu-item"><a href="#" class="pure-menu-link">Games</a></li>
<li class="pure-menu-item"><a href="#" class="pure-menu-link">News</a></li>
<li class="pure-menu-item"><a href="#" class="pure-menu-link">OMG!</a></li>
</ul>
</div>
</div>-->
<div id="about">
<a id="chat" href="https://gitter.im/ety001/bookmark-extension" target="_blank" class="button-secondary pure-button"></a>
&nbsp;
<a id="donate" class="pure-button" target="_blank" href="http://www.domyself.me/donate"></a><hr>
Powered by <a href="http://www.domyself.me" target="_blank">ETY001</a>
</div>
</div>
</div>
<input type="hidden" id="notitle_text" value="">
</body>
</html>

0 comments on commit 305401f

Please sign in to comment.