uzer37
Junior Member | Редактировать | Профиль | Сообщение | Цитировать | Сообщить модератору
Цитата: перестал работать S3 Google Translator | Я пользую кнопку переводчик для Custom Buttons Код значка data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAABGdBTUEAAK/INwWK6QAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAPSSURBVHjaBMG5EYAwDADBk3iMh5AW6JZCaINiSElIbGmwxa4Uc47zYqRjTdBBaChlWjZR2ZPXeU36eP3uHvESoG5IzrTo/AKIZeamEwwwAJRj+MXMai/8+1OM6uObrjxfP7HcFZRjPvf0PyMnG9MXYVmBeeycbIuYGBiewPQABBDL528/wIx/DIyMbKyM3Rb3TxbrnT3MIPLgHgPjt68Mc11TGZYteMcgJcgqHheg2iqlxp/0kpW9mJmBYSNIH0AAsTAyMjL8//+fk42Fscvn4ekczYtHgc74xfBfRh7oVgYGRn4+hlA7doYAoW8MOs9OM4jxyymftrBfevHDr1igk9cDBBDQAAaG3/8ZXZx/vcjS/P2RgUFLG6iRiYER7Kf/DPyC/AylElcZZIU5GXhcIxhei8gwPD/5lPvNp49TBCR49gIEEMvPP//ZpDkZyw14OJgY+HXBmsGBAQKM/xlYPnAxKMX6MwhaGDHcevWLYc26cww7t1xiEJLmkdIR4soECCCW77/+OcpL86pyKYkAnfIXpAseqCAvMNz6zPCfg4Phy7krDN/vvGIw/fOJwdpXkuEP0HXnmf/bAAQQCzcrk6e4lBgHg4wYMCT/ITSDzGECRu6NcwxPcqsYuP//ZeBlZmLgYwJGNVDzf6DfH7gHSAIEEAs7G7MMCzcP2392Poa/DKj6Qfjff2CauHCZgenfb6AAMGxAgQY0gBGIWfQtuAACiOXnzz+3Xn765Szym4Hj9180A4Bx9ZOFjUE4JpiBk5WV4dfvP2CNwLQGinaGn6oqHwECiOXX799LHj7/mMghDFT8GyUEwGHw7T8bA6+NOQObAD/DOwFphgsPvjC8efmegYWFieGjMMcDgABi4eRgu/bmzbutf299Tv7+j4cBEQVAFsi0n8wM7Ax/GH4dPMLw89M/hmefeBh2PGdlYFcUZDB1UlwBEEDghPT954+JzK/v+D77pir2/ss/Bmam/wyQBMbIIML6k+GWgR2DjoUFg8a+/Qzqt+8x6EsLMpzQVdzHysmyESCAmJ0C40AKXzH+/36PleG71xNgOr3z6A/Di9c/GV6+AwbMvxcMC3s3M9x6959B2M6S4Y+qPMMFVo4Tv9hYY/8zMX0ECCCWH7/+MLAwM4NCex0zw6uX2jJfugU5BSzvPedg+PCVheH/378M1288Z3j98QfDXx6G3+Kqwgv+c/HXM/3+9RzkTYAAYtx05ArDuVvPwIb8+vOHgY0FGMiMjD5//jC6//vPKPDv71/m379+/wOGzEtWNpYFwIR6gQWYHhiAav+zsTIABBgAPzFaKBkj0YoAAAAASUVORK5CYII= Код кнопки var btn=this;btn.lastClick={X:0,Y:0};addEventListener("mouseup",function(e){if(e&&e.button==0&&e.view.top==content){var lc=btn.lastClick;lc.X=e.clientX;lc.Y=e.clientY;}},false);var safeHTMLParser=function(code){var gUnescapeHTML=Cc["@mozilla.org/feed-unescapehtml;1"].getService(Ci.nsIScriptableUnescapeHTML);var doc=document.implementation.createDocument(xhtmlns,"html",null);var body=document.createElementNS(xhtmlns,"body");doc.documentElement.appendChild(body);body.appendChild(gUnescapeHTML.parseFragment(code,false,null,body));return doc;};var createWindow=function(text,status,title,id,pos,size){var win=document.commandDispatcher.focusedWindow.top==content?document.commandDispatcher.focusedWindow:content;var doc=win.document,wId='ujs_window'+(id||''),w=doc.getElementById(wId);var keyDown=function(e){if(!e.shiftKey&&!e.ctrlKey&&!e.altKey&&e.keyCode==27)doc.getElementById(wId).closeWin()};if(w)w.closeWin();w=doc.createElement('div');w.setAttribute('style','position:fixed;display:block;visibility:hidden;left:0;top:0;width:auto;height:auto;border:1px solid gray;padding:3px;margin:0;z-index:99999;overflow:hidden;cursor:move;'+(typeof w.style.borderRadius==='string'?'background-color:#f3f5f7;padding-top:4px;border-radius:4px;box-shadow:0 0 12px rgba(0,0,0,.4);':'background:-o-skin("Window Skin");'));w.id=wId;w.closeWin=function(){doc.removeEventListener('keydown',keyDown,false);this.parentNode.removeChild(this);};w.addEle=function(str,style){var ele=doc.createElement('div');ele.setAttribute('style',style);if(str){ele.innerHTML=str;for(var el,all=ele.getElementsByTagName('*'),i=all.length;i--;){el=all[i];if(/^(script|frame|iframe|applet|embed|object)$/i.test(el.nodeName)){el.parentNode.removeChild(el);}else{for(var att=el.attributes,j=att.length;j--;){if(/^on[a-z]+$/i.test(att[j].name))att[j].value='';}}}};return this.appendChild(ele);};var img=doc.createElement('div');img.setAttribute('style','display:block;float:right;width:18px;height:18px;padding:0;margin:0;border:none;cursor:pointer;background-image:url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABIAAAASCAQAAAD8x0bcAAAAZElEQVR42mNgGNyAGQixsVGU/AdCXjCbHczmxKaMFywlAlWiw6DAwIZNmQhYGqJEDWoqFiAGVmKKTwk73CRJ/Ep0GIyhbsPpO4hbIG4TwKaMk0EZ7hYBBk1cvmNDEmbDrmSwAADE8h10+qICXwAAABl0RVh0U29mdHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAAASUVORK5CYII=");background:-o-skin("Caption Close Button Skin");');img.title=(win.navigator.language.indexOf('ru')==0)?'\u0417\u0430\u043A\u0440\u044B\u0442\u044C':'Close';img.addEventListener('click',function(){this.parentNode.closeWin()},false);w.appendChild(img);w.addEle(title,'display:table;color:#000;font:16px Times New Roman;width:auto;height:auto;padding:0;margin:0 2px;cursor:text;');var cnt=w.addEle(text,'display:block;border:1px solid #aaa;margin:2px 0 1px 0;padding:4px;background-color:#fafcfe;color:#000;font:14px Times New Roman;width:240px;height:120px;overflow:auto;cursor:text;');w.addEle(status,'display:table;color:#555;font:10px Times New Roman;width:auto;height:auto;padding:0;margin:0 2px;cursor:text;');w.addEventListener('mousedown',function(e){if(e.target==w){e.preventDefault();var grabX=e.clientX,grabY=e.clientY,origX=parseInt(w.style.left),origY=parseInt(w.style.top);var mouseMove=function(ev){w.style.left=origX+ev.clientX-grabX+'px';w.style.top=origY+ev.clientY-grabY+'px';};doc.addEventListener('mousemove',mouseMove,false);doc.addEventListener('mouseup',function(){doc.removeEventListener('mousemove',mouseMove,false)},false);}},false);doc.documentElement.appendChild(w);if(size){cnt.style.height=size.height;cnt.style.width=size.width;}else{for(var i=3;i<10;i++){if(cnt.scrollHeight>cnt.offsetHeight||cnt.scrollWidth>cnt.offsetWidth){cnt.style.height=50*i+'px';cnt.style.width=100*i+'px';}else break;}};var docEle=doc.compatMode=='CSS1Compat'?doc.documentElement:doc.body;var mX=docEle.clientWidth-w.offsetWidth,mY=docEle.clientHeight-w.offsetHeight;if(mX<0){cnt.style.width=parseInt(cnt.style.width)+mX+'px';mX=0};if(mY<0){cnt.style.height=parseInt(cnt.style.height)+mY+'px';mY=0};var hW=parseInt(w.offsetWidth/2);w.style.left=(pos&&pos.X<mX+hW?(pos.X>hW?pos.X-hW:0):mX)+'px';w.style.top=(pos&&pos.Y+10<mY?pos.Y+10:mY)+'px';w.style.visibility='visible';doc.addEventListener('keydown',keyDown,false);};var getSel=function(w){var s,d=w.document;if(d.selection){var r=d.selection.createRange();s=r?r.text:''}else{s=d.getSelection().toString();if(!s){var e,t=d.getElementsByTagName('textarea'),u=d.getElementsByTagName('input'),i=t.length;while(e=(i>0)?t[--i]:u[-i--])try{if(e.offsetHeight>0&&(s=e.value.substring(e.selectionStart,e.selectionEnd)))break}catch(x){}}};if(!s)for(var j=0,f;f=w.frames[j];j++){try{if(s=getSel(f))break}catch(x){}};return s};var ujs_google_translate=function(dir){var win=content,lng=win.navigator.language.slice(0,2),txt=getSel(win);if(txt){var xhr=new XMLHttpRequest();var encTxt='text='+encodeURIComponent(txt),post=encTxt.length>1024,l=dir.split('|');var url='http://translate.google.ru/?'+(post?'':encTxt+'&')+'sl='+l[0]+'&tl='+l[1]+'&hl='+lng+'&eotf=0&ujs=gtt';xhr.open(post?'POST':'GET',url,true);if(post)xhr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');xhr.onreadystatechange=function(){try{if(xhr.readyState==4&&xhr.status==200){var result='',status='',tmp=safeHTMLParser(xhr.responseText);var r=tmp.querySelector('#result_box');if(r){var p=r.getElementsByTagName('span');for(var i=0,n;n=p[i];i++){n.setAttribute('style','background-color:inherit;color:inherit;font-size:inherit;font-family:serif;');};result=r.innerHTML;};var sl=tmp.querySelector('#nc_sl'),dl=tmp.querySelector('#nc_dl'),tl=tmp.querySelector('#nc_tl');if(sl&&dl&&tl){status=((dl.value||sl.value)+' -\u203A '+tl.value).toUpperCase();};createWindow(result,status,'<a href="'+url.replace(/&/g,'&')+'" target="_blank" style="display:inline;padding:0;margin:0;text-decoration:none;border:none;color:#004FC4;font:13px Times New Roman;">(1000 символов) Открыть в Google</a>','_gt',btn.lastClick);}}catch(x){};};xhr.send(post?encTxt:null);}else{win.open('http://translate.google.ru/translate?u='+escape(win.location.href)+'&hl='+lng+'&langpair='+dir+'&tbb=1');};};btn.onclick=function(e){if(e.button==0)ujs_google_translate('auto|ru')};var contextMenu=document.getElementById("contentAreaContextMenu");var nextEleMenu=document.getElementById("context-inspect");var menuId="context-ext-google-translate";var menuItem=document.getElementById(menuId);if(menuItem){contextMenu.removeChild(menuItem.nextElementSibling);contextMenu.removeChild(menuItem.nextElementSibling);contextMenu.removeChild(menuItem);};menuItem=document.createElement("menuitem");menuItem.setAttribute("id",menuId);menuItem.setAttribute("label","Перевод на русский");menuItem.addEventListener("command",function(){ujs_google_translate('auto|ru')},false);contextMenu.insertBefore(menuItem,nextEleMenu);menuItem=document.createElement("menuitem");menuItem.setAttribute("id",menuId);menuItem.setAttribute("label","Перевод на английский");menuItem.addEventListener("command",function(){ujs_google_translate('auto|en')},false);contextMenu.insertBefore(menuItem,nextEleMenu);contextMenu.insertBefore(document.createElement("menuseparator"),nextEleMenu);addEventListener('keydown',function(e){if(e.shiftKey&&!e.ctrlKey&&e.altKey&&e.keyCode==84)ujs_google_translate('auto|ru');},false);/*Initialization Code*/ | Всего записей: 141 | Зарегистр. 30-11-2011 | Отправлено: 15:58 24-09-2017 | Исправлено: uzer37, 16:03 24-09-2017 |
|