Skip to content

Instantly share code, notes, and snippets.

Created Mar 6, 2010
Embed
What would you like to do?
jetpack.future.import('slideBar');
var html = <>
<html lang="ja">
<head>
<style type="text/css">
<![CDATA[
#overrideDiv {
border:1px solid gray;margin-bottom:30px;
clear:both;width:90%;background:#fff;
height:150px;overflow:auto;position:fixed;top:0;
}
#overrideDiv li {list-stype:sequare;displya:block;padding-left:30px}
#overrideDiv img {border:1px solid #ccc}
h3{margin-left:10px}
]]>
</style>
<base target="_blank" />
</head>
<body>
<div id="overrideDiv"></div>
</body>
</html>
</>.toXMLString();
/*
var useFlag=false;
function setState(flag) {
jetpack.statusBar.append({
html: "<strong></strong>",
width: 145,
onReady : function (widget) {
if(!flag) $('strong', widget).text('');
else $('strong', widget).text('cut mode');
}
});
}
function onLoadCutSelection(slider) {
var _doc = slider.contentDocument;
jetpack.selection.onSelection(function(){
var html = jetpack.selection.html;
_doc = slider.contentDocument;
$('#container', _doc).append('<li>'+html+'</li>');
});
//jetpack.selection.html = "<b style=\"color:red\">" + html + "</b>";
};
jetpack.future.import("selection");
jetpack.slideBar.append({
width: 300,
html: html,
onReady: function(slider) {
onLoadCutSelection(slider);
}
});
*/
/*
var _slider=jetpack.slideBar.append({
width: 300,
html: html,
onReady: function(slider) {
//_doc = slider.contentDocument;
}
});
*/
jetpack.future.import("menu");
jetpack.menu.context.page.add({
label:"What do you want to do?",
menu : new jetpack.Menu(
['Get Img','Get Link','Close']
),
command: function (i) {
//console.log(i.label);
//return false;
if(i.label==='Get Link')
copyAllUrl();
else if(i.label=='Close')
clear();
else
copyAllImg();
}
});
function initDiv() {
doc=jetpack.tabs.focused.contentDocument;
if($('#overrideDiv',doc).length<1)
$('body',doc).prepend(html);
}
function clear() {
doc=jetpack.tabs.focused.contentDocument;
$('#overrideDiv', doc).remove();
}
function copyAllUrl() {
initDiv();
var str='';
var i=0;
$('a',doc).each(function() {
if($(this).html()!='') {
str=str+'<li><a href="'+$(this).attr('href')+'">'+$(this).html()+'</a></li>';
i++;
}
});
str='<H3>Collection Url link ('+i+')</H3>'+str;
$('#overrideDiv', doc).html(str);
}
function copyAllImg() {
initDiv();
var str='';
var i=0;
$('img',doc).each(function() {
str=str+'<li><img src="'+$(this).attr('src')+'"/></li>';
i++;
});
str='<H3>Collection Image ('+i+')</H3>'+str;
$('#overrideDiv', doc).html(str);
//console.log($('img',doc).html());//test
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment