83 lines
2.4 KiB
JavaScript
Raw Permalink Normal View History

2015-03-22 11:03:39 +01:00
/**
* @licstart The following is the entire license notice for the
* JavaScript code in this page.
*
* Copyright (C) 2014 GNUnet e.V.
*
* The JavaScript code in this page is free software: you can
* redistribute it and/or modify it under the terms of the GNU
* General Public License (GNU GPL) as published by the Free Software
* Foundation, either version 3 of the License, or (at your option)
* any later version. The code is distributed WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU GPL for more details.
*
* As additional permission under GNU GPL version 3 section 7, you
* may distribute non-source (e.g., minimized or compacted) forms of
* that code without the copy of the GNU GPL normally required by
* section 4, provided you include this license notice and a URL
* through which recipients can access the Corresponding Source.
*
* @licend The above is the entire license notice
* for the JavaScript code in this page.
*/
// @license magnet:?xt=urn:btih:1f739d935676111cfff4b4693e3816e664797050&dn=gpl-3.0.txt GPL-v3-or-Later
2014-11-18 16:42:09 +01:00
function supports_html5_storage() {
try {
return 'sessionStorage' in window && window['sessionStorage'] !== null;
} catch (e) {
return false;
}
}
function setLang(l)
{
document.body.className=l;
if (supports_html5_storage()) {
sessionStorage.setItem('lang', l);
}
2015-02-08 00:43:48 +01:00
if (l == 'en') document.title = 'GNU Taler - Taxable Anonymous Libre Electronic Reserve';
if (l == 'de') document.title = 'GNU Taler - Taxierbare Anonyme Liberale Elektronische Reserven';
if (l == 'fr') document.title = 'GNU Taler - Taxable Anonyme Libre Électronique Réserve';
if (l == 'it') document.title = 'GNU Taler';
2014-11-18 16:42:09 +01:00
}
2014-11-18 17:10:57 +01:00
function get_default_lang()
{
langs = ['en', 'de', 'fr', 'it'];
2014-11-18 17:31:36 +01:00
2014-11-18 17:28:27 +01:00
for (var i in navigator.languages) {
2014-11-18 17:31:36 +01:00
for (var j in langs) {
2014-11-18 17:41:21 +01:00
if (navigator.languages[i].indexOf(langs[j]) != -1) {
2014-11-18 17:43:03 +01:00
return langs[j];
2014-11-18 17:19:42 +01:00
}
2014-11-18 17:10:57 +01:00
}
}
return 'en';
}
2014-11-18 16:42:09 +01:00
function loadLang()
{
2014-11-18 17:12:52 +01:00
l = 'null';
2014-11-18 16:42:09 +01:00
if (supports_html5_storage()) {
l = sessionStorage.getItem('lang');
}
2014-11-18 17:10:57 +01:00
2014-11-18 17:12:52 +01:00
if (l == 'null') l = get_default_lang();
2014-11-18 16:42:09 +01:00
setLang(l);
}
2014-11-18 19:15:32 +01:00
function activate_menu()
{
2014-11-18 22:07:45 +01:00
b = document.getElementsByClassName("m_" + document.URL.replace(/^.*(\\|\/|\:)/, '').split('.')[0])
2014-11-18 22:18:03 +01:00
for (i = 0; i < b.length; i++) {
s = b[i].getAttribute('class');
b[i].setAttribute('class', s + ' active');
}
2014-11-18 19:15:32 +01:00
}
2015-03-22 11:03:39 +01:00
// @license-end