Define

By mayabelle Uploaded Jun 15, 2009
//Dictionary Jetpack
jetpack.statusBar.append({
		html: "<span style='background-color:yellow;font-size:7pt;font-weight:bold;font-family:verdana,tahoma,arial,helvetica;'>Define</span>",
		width:55,
		onReady: function(doc) {
		$(doc).click(function(){
			var rnd = Math.floor(Math.random()*1000);
			var wrd = jetpack.tabs.focused.contentDocument.getSelection();
			if(wrd!=""){
				$.get("http://google.com/search",{q: "define:"+wrd}, function(data){
					var cTab=jetpack.tabs.focused;
					var handle=cTab.contentDocument.createElement("img");
					handle.setAttribute("onclick","document.body.removeChild(document.getElementById('dfjtpck"+rnd+"'))");
					handle.setAttribute("style","background-color:black;position:fixed;bottom:386px;right:1px;");
					handle.setAttribute("src","http://ericburling.org/jetpacks/close-icon.gif");
					var div=cTab.contentDocument.createElement("div");
					div.setAttribute("style","text-align:left;border:1px solid;position:fixed;width:450px;bottom:0px;height:400px;right:0px;background-color:white;overflow:auto;");
					var def=cTab.contentDocument.createElement("div");
					def.setAttribute("style","width:400px");
					def.innerHTML=data.substr(data.indexOf("Definitions of"),data.indexOf("</ul>")-data.indexOf("Definitions of"));   
					div.appendChild(handle);
					div.appendChild(def);
					div.setAttribute("id","dfjtpck"+rnd);
					cTab.contentDocument.body.appendChild(div);
					delete cTab;
					delete handle;
					delete div;
					delete def;
					delete wrd;
					delete rnd;
				});
			}
		});
}});