taler-www

Main taler.net website
Log | Files | Refs | Submodules | README | LICENSE

commit e036707bd7e026b387ed06bb0de20bb44a1a4976
parent 0d59eda9946147382ed5e253be131761429ee89a
Author: Julian Kirsch <kirschju@sec.in.tum.de>
Date:   Tue, 18 Nov 2014 16:42:09 +0100

Javascript - Language setting storage

Diffstat:
Mabout.html | 2+-
Mcitizens.html | 2+-
Mcommon/header.inc | 1+
Mdevelopers.html | 2+-
Mgovernments.html | 2+-
Minvestors.html | 2+-
Alang.js | 28++++++++++++++++++++++++++++
Mmain.html | 2+-
Mmerchants.html | 2+-
Mnews.html | 2+-
10 files changed, 37 insertions(+), 8 deletions(-)

diff --git a/about.html b/about.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/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 @@ -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 @@ -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 @@ -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 @@ -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 @@ -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); +} diff --git a/main.html b/main.html @@ -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 @@ -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/news.html b/news.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 -->