diff options
author | Julian Kirsch <kirschju@sec.in.tum.de> | 2014-11-18 16:42:09 +0100 |
---|---|---|
committer | Julian Kirsch <kirschju@sec.in.tum.de> | 2014-11-18 16:42:09 +0100 |
commit | e036707bd7e026b387ed06bb0de20bb44a1a4976 (patch) | |
tree | 8b4db4c6d897f0d42d69c9fdb04b2fd17c1822f2 | |
parent | 0d59eda9946147382ed5e253be131761429ee89a (diff) | |
download | www-e036707bd7e026b387ed06bb0de20bb44a1a4976.tar.gz www-e036707bd7e026b387ed06bb0de20bb44a1a4976.tar.bz2 www-e036707bd7e026b387ed06bb0de20bb44a1a4976.zip |
Javascript - Language setting storage
-rw-r--r-- | about.html | 2 | ||||
-rw-r--r-- | citizens.html | 2 | ||||
-rw-r--r-- | common/header.inc | 1 | ||||
-rw-r--r-- | developers.html | 2 | ||||
-rw-r--r-- | governments.html | 2 | ||||
-rw-r--r-- | investors.html | 2 | ||||
-rw-r--r-- | lang.js | 28 | ||||
-rw-r--r-- | main.html | 2 | ||||
-rw-r--r-- | merchants.html | 2 | ||||
-rw-r--r-- | news.html | 2 |
10 files changed, 37 insertions, 8 deletions
@@ -6,7 +6,7 @@ <meta name="description" content=""> <!--# include file="common/header.inc" --> </head> - <body class="en"> + <body class="en" onLoad="loadLang();"> <div class="container"> <!--# include file="common/navigation.inc" --> <!-- Jumbotron --> diff --git a/citizens.html b/citizens.html index 1f3964da..95eeba65 100644 --- a/citizens.html +++ b/citizens.html @@ -6,7 +6,7 @@ <meta name="description" content=""> <!--# include file="common/header.inc" --> </head> - <body class="en"> + <body class="en" onLoad="loadLang();"> <div class="container"> <!--# include file="common/navigation.inc" --> <!-- Jumbotron --> diff --git a/common/header.inc b/common/header.inc index 11081912..163582c4 100644 --- a/common/header.inc +++ b/common/header.inc @@ -10,6 +10,7 @@ <link href="justified-nav.css" rel="stylesheet"> <link href="lang.css" rel="stylesheet"> <link href="styles.css" rel="stylesheet"> + <script src="lang.js"></script> <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries --> <!--[if lt IE 9]> diff --git a/developers.html b/developers.html index 75f952a1..26c25d2c 100644 --- a/developers.html +++ b/developers.html @@ -6,7 +6,7 @@ <meta name="description" content=""> <!--# include file="common/header.inc" --> </head> - <body class="en"> + <body class="en" onLoad="loadLang();"> <div class="container"> <!--# include file="common/navigation.inc" --> <!-- Jumbotron --> diff --git a/governments.html b/governments.html index 45313701..dab9bb18 100644 --- a/governments.html +++ b/governments.html @@ -6,7 +6,7 @@ <meta name="description" content=""> <!--# include file="common/header.inc" --> </head> - <body class="en"> + <body class="en" onLoad="loadLang();"> <div class="container"> <!--# include file="common/navigation.inc" --> <!-- Jumbotron --> diff --git a/investors.html b/investors.html index 9fa62a58..49cf589d 100644 --- a/investors.html +++ b/investors.html @@ -6,7 +6,7 @@ <meta name="description" content=""> <!--# include file="common/header.inc" --> </head> - <body class="en"> + <body class="en" onLoad="loadLang();"> <div class="container"> <!--# include file="common/navigation.inc" --> <!-- Jumbotron --> diff --git a/lang.js b/lang.js new file mode 100644 index 00000000..db23ba52 --- /dev/null +++ b/lang.js @@ -0,0 +1,28 @@ +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); + } +} + +function loadLang() +{ + if (supports_html5_storage()) { + l = sessionStorage.getItem('lang'); + if (l == '') { + l = window.navigator.userLanguage || window.navigator.language; + } + } else { + l = window.navigator.userLanguage || window.navigator.language; + } + setLang(l); +} @@ -8,7 +8,7 @@ <meta name="description" content="Anonymous electronic payments for civil society"> <!--# include file="common/header.inc" --> </head> - <body class="en"> + <body class="en" onLoad="loadLang();"> <div class="container"> <!--# include file="common/navigation.inc" --> <!-- Jumbotron --> diff --git a/merchants.html b/merchants.html index 6177f57d..203e1cde 100644 --- a/merchants.html +++ b/merchants.html @@ -6,7 +6,7 @@ <meta name="description" content=""> <!--# include file="common/header.inc" --> </head> - <body class="en"> + <body class="en" onLoad="loadLang();"> <div class="container"> <!--# include file="common/navigation.inc" --> <!-- Jumbotron --> @@ -6,7 +6,7 @@ <meta name="description" content=""> <!--# include file="common/header.inc" --> </head> - <body class="en"> + <body class="en" onLoad="loadLang();"> <div class="container"> <!--# include file="common/navigation.inc" --> <!-- Jumbotron --> |