Pengguna:Endo999/GoogleTrans.js: Perbedaan antara revisi
Konten dihapus Konten ditambahkan
ie11 support added |
|||
Baris 1:
/**
* GoogleTrans
*
// Konqueror (in fact the code is disabled on Konqueror)▼
* Works on MSIE, Firefox, Epiphany, Safari, Chrome, and Opera (still has bugs
// this has only been tested on the monobook and vector skins▼
*
* Selected text translation (up to 500 characters) only on MSIE, Firefox, Epiphany, and Chrome.
*
*
* Documentation of the API:
* - https://developers.google.com/translate/
*
* Relevant policies and terms:
* - https://developers.google.com/translate/v2/terms
* - https://developers.google.com/terms/
* - https://www.google.com/policies/privacy/
*/
/*
Disclaimer
The author of this code is not responsible for any
use of it, but will endeavor to fix any problems that is
reported to him.
*/
Baris 36 ⟶ 47:
//var SCGoogleTransPersistString = 'TranslationPopups'; // if pt or es wikis
var userLang = mw.config.get( 'wgUserLanguage' );
var contentLang =
{▼
if(userLang != contentLang) {
}
Baris 48 ⟶ 59:
// need to set document.domain here, each language should set this field here
document.domain = mw.config.get( 'wgServer' ).substring( mw.config.get( 'wgServer' ).lastIndexOf("//")+2);
Baris 87 ⟶ 98:
var SCPopupBackgroundColor = "beige"; // you can set the popup background color here
var SCbIsIE11 = false;
if(navigator.appVersion.match(/rv:([0-9][0-9])\./i))
▲{
var version1 = new Number(RegExp.$1);
if(version1 >= 11)
{
SCbIsFirefox35=false;
SCbIsSafari=false;
SCbIsChrome=false;
SCbIsOperal11=false;
SCbIsIE9 = true;
SCbIsIE = false;
SCbIsFirefox35Like=true;
SCbIsMozilla = true;
SCbIsIE11 = true;
}
}
mw.util.addCSS(
'.SCuserData { behavior:url(#default#userdata);} ' +
Baris 156 ⟶ 182:
jQuery(
function () {
var span1 = document.createElement('DIV');
Baris 177 ⟶ 203:
function SCGoogleLanguageLoaded(response) {
if(1=== 0 && response.data && response.data.languages)
{
var i;
Baris 638 ⟶ 664:
var olddefaultlang = SCLanguageDefaultTo;
var bSameAsContent = false;
if(
bSameAsContent = true;
if(!b2digitsLangNotSupported && !bSameAsContent)
Baris 714 ⟶ 740:
'onMouseover="javascript:SCdonthide=true;" ' +
'>';
if(SCbIsIE11)
{
SClanguageprompt1 =
'<small class="SCxTranslation"><a ' + 'href="javascript:SCSettings();" ' +
'onMouseover="javascript:SCdonthide=true;" ' +
'onMousedown="javascript:SCdonthide=true;" ' +
'>';
}
var SClanguageprompt2 =
Baris 814 ⟶ 848:
}
var SCbIsSafari = false;
Baris 871 ⟶ 907:
if(version1 >= 4)
SCbIsFirefox35 = true;
}
SCbIsIE11 = false;
if(navigator.appVersion.match(/rv:([0-9][0-9])\./i))
{
var version1 = new Number(RegExp.$1);
if(version1 >= 11)
{
SCbIsFirefox35=false;
SCbIsSafari=false;
SCbIsChrome=false;
SCbIsOperal11=false;
SCbIsIE9 = true;
SCbIsIE = false;
SCbIsFirefox35Like=true;
SCbIsMozilla = true;
SCbIsIE11 = true;
}
}
Baris 931 ⟶ 985:
{
SCShiftKey = true;
}
else
Baris 1.247 ⟶ 1.302:
if(SCwindows >= SCMaxwindows)
return;
Baris 1.275 ⟶ 1.331:
if(SCbIsIE && children.length > SCTooManyTextElements*2)
return;
for(i=0;i<children.length;i++)
Baris 1.286 ⟶ 1.343:
}
}
// if there are too many text elements to parse just return
Baris 1.293 ⟶ 1.351:
return;
}
if(!(SCbIsIE||SCbIsOpera||SCbIsPre4Safari) && window.getSelection)
{
Baris 1.304 ⟶ 1.362:
SelectionAnchorNode = userSelection.anchorNode;
SelectionAnchorOffset = userSelection.anchorOffset;
for(i=0;i<children.length;i++)
{
Baris 1.313 ⟶ 1.371:
*/
if(!SCbIsIE11 && userSelection.containsNode(children[i],true))
{
SCselectionarray[i] = new Array();
SCselectionstart[i] = -1;
SCselectionend[i] = -1;
SCAreWordsInSelection(userSelection,SCselectionarray[i],
children[i],i);
SCselection[i] = false;
}
else
{
SCselectionarray[i] = new Array();
SCselection[i] = false;
Baris 1.345 ⟶ 1.407:
}
*/
for(i=0;i<children.length;i++)
{
Baris 1.401 ⟶ 1.464:
SCbIsWordInSelection = false;
var words;
if(SCLanguageDefaultFrom.match(/ja|zh/i))
Baris 3.548 ⟶ 3.612:
}
// SCMakeGoogleLanguages();
mw.util.addPortletLink('p-cactions',"javascript:SCSettings()", title, "ca-TransPopsId", SCstrChangeOptions, "");
}
);
|