text: /* Copyright 2011 Google Inc. All Rights Reserved. */ (function(){var h=!0,i=null,j=!1,l=RegExp("<[^>]*>","g"),m=RegExp("[<>]","g"),n="\" ' ( ) , - . / 1 2 2012 : ? a about and are as be but com for from have i in is it like may more my next not of on search that the this to was when with you your".split(" "),o={},r=0,s=-1,v=-1,w=function(a,b){for(var c=0,e=a.length;c<e;c++)if(b==a[c])return h;return j},x=function(){o=JSON.parse(window.localStorage.options)},y=function(a,b,c){"initialize"==a.type&&(a={instanceId:r++},c(a))},z=function(a,b,c){"options"==a.type&&
  c({options:o})},B=function(a,b,c){if(!("fetch_raw"!=a.type&&"fetch_html"!=a.type)){_gaq&&_gaq.push(["_trackEvent","lookup",a.type]);-1!=s&&v!=a.instanceId&&chrome.tabs.sendRequest(s,{type:"hide",instanceId:v});"fetch_raw"==a.type?(s=b.tab.id,v=a.instanceId):v=s=-1;var b=a.query.replace(l,""),b=b.replace(m,""),b=b.substring(0,100).toLowerCase(),e={request:a,sanitizedQuery:b,dictResponse:i,translateResponse:i,numResponses:0,callback:c},c="pr,de";"fetch_html"==a.type&&(c="pr,de,sy");google.language.define(b,
  o.language,o.language,function(a){A(a,"dict",e)},{restricts:c});"en"!=o.language&&google.language.define(b,"en","en",function(a){A(a,"enDict",e)},{restricts:c});var d=new XMLHttpRequest;d.open("GET","https://clients5.google.com/translate_a/t?client=dict-chrome-ex&sl=auto&tl="+o.language+"&q="+b,h);d.onreadystatechange=function(){if(d.readyState==4)try{var a=JSON.parse(d.responseText);A(a,"translate",e)}catch(b){A(i,"translate",e)}};d.send();chrome.tabs.getSelected(i,function(a){var b=window.setTimeout(function(){A({lang:"unknown"},
  "tabLang",e)},800);chrome.tabs.detectLanguage(a.id,function(a){window.clearTimeout(b);A({lang:a},"tabLang",e)})})}},A=function(a,b,c){if("dict"==b)c.dictResponse=a;else if("enDict"==b)c.enDictResponse=a;else if("translate"==b)c.translateResponse=a;else{if(c.tabLang)return;c.tabLang="he"==a.lang?"iw":a.lang}a=3;"en"!=o.language&&(a=4);c.numResponses++;if(c.numResponses==a){var e=b=C(c.dictResponse);"en"!=o.language&&(e=C(c.enDictResponse));var d=D(c.translateResponse,h),a=i;if(c.translateResponse&&
  c.translateResponse.ld_result&&(a=c.translateResponse.ld_result.srclangs))for(var f=0,k=a.length;f<k;f++)a[f]=a[f].toLowerCase();k=j;if(!b||"licensedDef"!=b.type){var f=o.language.toLowerCase(),g=d&&d.srcLang.toLowerCase()!=f;if(g&&a&&!w(a,f)||!b&&g)k=h}a=k?"translation":"definition";!b&&!d&&(a="none");_gaq&&_gaq.push(["_trackEvent","lookup","type_"+a]);a="http://translate.google.com/translate_t?source=dict-chrome-ex&sl=auto&tl="+o.language+"&q="+encodeURIComponent(c.sanitizedQuery);f="http://www.google.com/search?source=dict-chrome-ex&defl="+
  o.language+"&hl="+o.language+"&q="+encodeURIComponent(c.sanitizedQuery)+"&tbo=1&tbs=dfn:1";if("fetch_html"==c.request.type){if(k)if(b=c.translateResponse,e=D(b,j)){e='<div class="translate-main">'+e.meaningText+'</div><div class="translate-attrib">('+e.attribution+")</div>";d="";if(b.dict&&0<b.dict.length){d='<h3 class="dct-tl">Translated definitions</h3>';f=0;for(k=b.dict.length;f<k;f++){for(var g=b.dict[f],d=d+("<b>"+g.pos+"</b><ol>"),p=0,q=g.terms.length;p<q;p++){var t=g.terms[p];0<t.length&&(d+=
  "<li>"+t+"</li>")}d+="</ol>"}}a=e+d+('<br><div class="translate-powered">Powered by <a href="'+a+'" class="translate-link">Google Translate</a></div><br>')}else a="";else if(a=c.dictResponse,!a||a.error)a="";else{b=google.language.dictionary.createResultHtml(a);a=document.createElement("div");a.innerHTML=b;b=a.getElementsByTagName("a");for(e=b.length-1;0<=e;e--)d=b[e],"Google Dictionary"==d.innerText&&0==d.href.lastIndexOf("http://www.google.com/dictionary",0)&&(d.href=f);a=a.innerHTML}a={eventKey:c.request.eventKey,
  sanitizedQuery:c.sanitizedQuery,html:a}}else{g=i;k&&d?(g=d,g.moreUrl=a,e&&(e.audio&&"en"==d.srcLang.toLowerCase())&&(g.audio=e.audio)):b&&(g=b,g.moreUrl=f);g&&!g.prettyQuery&&(g.prettyQuery=c.sanitizedQuery);a=j;if(("true"==o.popupDblclick&&"none"==o.popupDblclickKey||"true"==o.popupSelect&&"none"==o.popupSelectKey)&&w(n,c.sanitizedQuery))a=h;a={eventKey:c.request.eventKey,sanitizedQuery:c.sanitizedQuery,meaningObj:g,showOptionsTip:a}}c.callback(a)}},D=function(a,b){if(!a||a.sentences[0].orig.toLowerCase()==
  a.sentences[0].trans.toLowerCase())return i;var c=a.sentences[0].orig.toLowerCase(),e=a.sentences[0].trans.toLowerCase(),d=e;if(b&&a.dict&&0<a.dict.length)for(var f=0,k=a.dict.length;f<k;f++)for(var g=a.dict[f],p=0,q=0,t=g.terms.length;q<t&&2>p;q++){var u=g.terms[q].toLowerCase();0<u.length&&(u!=c&&u!=e)&&(d+=", "+u,p++)}(c=window["gdx.LANG_MAP"][a.src.toLowerCase()])||(c=a.src);return{type:"translation",meaningText:d,attribution:"Translated from "+c,srcLang:a.src}},E=function(a,b){for(var c=0,e;e=
  a[c];c++)if(e.type&&e.type==b&&e.text)return e.text;return""},F=function(a){if(!a||0==a.length)return i;for(var b=0,c;c=a[b];b++)for(var e=0,d;d=c.entries[e];e++)if("meaning"==d.type&&d.terms&&0<d.terms.length){var f=E(d.terms,"text");if(f)return a=E(c.terms,"sound").replace("http://","https://"),{prettyQuery:E(c.terms,"text"),meaningText:f,audio:a,attribution:E(d.terms,"url")}}return i},C=function(a){if(!a||a.error)return i;var b=F(a.primaries);b?(b.attribution="",b.type="licensedDef"):(b=F(a.webDefinitions))&&
  (b.type="webDef");return b},G=G||j;
  if("undefined"==typeof G||!G){dict_api.load("https://clients5.google.com?client=dict-chrome-ex","1","en");var H=window.localStorage.options,I={};H&&(I=JSON.parse(H));var J=I,K={};K.language=J.language||"en";var L=function(a,b){return"true"==a||"false"==a?a:a==h?"true":a==j?"false":b};K.popupDblclick=L(J.popupDblclick,"true");K.popupSelect=L(J.popupSelect,"false");K.enableHttps=L(J.enableHttps,"true");K.popupDblclickKey=J.popupDblclickKey||"none";K.popupSelectKey=J.popupSelectKey||"ctrl";J.popupMode&&
  ("popup_disabled"==J.popupMode?K.popupDblclick="false":"popup_key_ctrl"==J.popupMode&&(K.popupDblclickKey="ctrl",K.popupSelect="true",K.popupSelectKey="ctrl"));o=K;window.localStorage.options=JSON.stringify(o);chrome.extension.onRequest.addListener(y);chrome.extension.onRequest.addListener(z);chrome.extension.onRequest.addListener(B);window["gdx.updateOptions"]=x};})();
  