MediaWiki:Common.js: Porovnání verzí
Z The Last Kingdom UO Wiki
Bez shrnutí editace |
Bez shrnutí editace značka: ruční vrácení zpět |
||
| (Není zobrazeno 5 mezilehlých verzí od stejného uživatele.) | |||
| Řádek 2: | Řádek 2: | ||
$(function () { | $(function () { | ||
if ($('# | function createSwitcher() { | ||
if ($('#lang-switcher').length) return; | |||
$('body').append( | |||
'<div id="lang-switcher" style="position:fixed;top:10px;right:10px;z-index:9999;background:#fff;padding:6px 12px;border:1px solid #ccc;border-radius:6px;font-size:14px;box-shadow:0 2px 6px rgba(0,0,0,0.2);">' + | |||
'<a href="#" id="lang-cs">Čeština</a> | ' + | |||
'<a href="#" id="lang-en">English</a>' + | |||
'</div>' | |||
); | |||
window.googleTranslateElementInit = function () { | $('#lang-en').click(function (e) { | ||
e.preventDefault(); | |||
document.cookie = "googtrans=/cs/en;path=/"; | |||
location.reload(); | |||
}); | |||
}; | $('#lang-cs').click(function (e) { | ||
e.preventDefault(); | |||
document.cookie = "googtrans=;path=/;expires=Thu, 01 Jan 1970 00:00:00 UTC;"; | |||
location.reload(); | |||
}); | |||
} | |||
function loadGoogle() { | |||
if ($('#google_translate_element').length) return; | |||
$('body').append('<div id="google_translate_element" style="display:none;"></div>'); | |||
window.googleTranslateElementInit = function () { | |||
new google.translate.TranslateElement({ | |||
pageLanguage: 'cs', | |||
includedLanguages: 'cs,en', | |||
autoDisplay: false | |||
}, 'google_translate_element'); | |||
}; | |||
$.getScript('https://translate.google.com/translate_a/element.js?cb=googleTranslateElementInit'); | |||
} | |||
createSwitcher(); | |||
loadGoogle(); | |||
// Reinforce switcher after translation DOM rewrite | |||
setTimeout(createSwitcher, 2000); | |||
}); | }); | ||
}); | }); | ||