Skip to content

Instantly share code, notes, and snippets.

@teramako
Created June 19, 2009 13:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save teramako/132599 to your computer and use it in GitHub Desktop.
Save teramako/132599 to your computer and use it in GitHub Desktop.
jetpack.future.import("slideBar");
const NAME = "wikipedia-ja", baseURL = "http://en.m.wikipedia.org";
function getSlidebar(){
return jetpack.tabs.focused.raw.ownerDocument.defaultView.slideBar;
}
function getSlideFeature(slidebar){
return slidebar.features.filter(function(F) "name" in F.args && F.args.name == NAME)[0];
}
jetpack.slideBar.append({
name: NAME,
icon: baseURL + "/favicon.ico",
url: baseURL,
onSelect: function(slide){
var sel = jetpack.tabs.focused.contentDocument.getSelection().toString();
if (sel){
slide.doc.location.href = baseURL + "/wiki?search=" + encodeURIComponent(sel);
}
slide({size: 300, persist: true});
},
});
jetpack.statusBar.append({
html: <>
<style><![CDATA[
#w-icon {
width: 16; height:16;
}
]]></style>
<img src={baseURL + "/favicon.ico"} id="w-icon"/>
</>,
onReady: function(doc){
statusDoc = doc;
$(doc).click(function(){
var slidebar = getSlidebar();
var feature = getSlideFeature(slidebar);
if(slidebar.shown && slidebar.shown === feature){
slidebar.slide(0);
} else {
slidebar.selectFeature(feature);
}
});
},
width:20
});
// vim: sw=2 ts=2 et:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment