jetpack.future.import("selection");
jetpack.tabs.onReady( function(widget){
console.log("onReady");
jetpack.selection.onSelection(colorit);
});
// A list of colors
var colors = "red,green,blue,purple".split(/,/);
// Color selected text with the next color
function colorit() {
var tcolor = colors.shift(); // extract first and move remaining left
if(tcolor=="blue") unlisten(colorit); // this does not seem to
disconnect the eh
if(tcolor=="purple") unlisten(dummy);
colors.push(tcolor); // making a 'ring' of our colors
jetpack.selection.html = colorme(jetpack.selection.html,tcolor);
}
function unlisten(eh){
console.log("unbind="+jetpack.selection.onSelection+"\n"+eh);
jetpack.selection.onSelection(dummy);
jetpack.selection.onSelection.unbind(eh);
}
function dummy(){
console.log("dummy");
}
function colorme(txt,c){
var spret="<span style='color: " + c + "'>"+txt+"</span>";
console.log("colorme="+c)
return spret;
}