lang_switcher

This commit is contained in:
messerbill 2013-07-05 20:03:06 +02:00
parent 0075ff484f
commit 9c1a00e360
2 changed files with 31 additions and 1 deletions

View File

@ -74,7 +74,7 @@
<!-- Three columns of text below the carousel -->
<div id="space" style="height: 7px; background: url(danube/page/default_page/pics/css/verlauf_bg.png); margin-left: 9px; margin-right: 9px;"></div>
<div id="languages" style="float: right; margin-right: 25px;"><a href="javascript:switchLocale('deDE');"><img src="http://mojotrollz.eu/web/danube/danube/page/js/flags/ger.jpg" /></a>
<a href="javascript:switchLocale('enUS');"><img src="http://mojotrollz.eu/web/danube/danube/page/js/flags/uk.jpg" /></a>
<a href="#" onclick="switchLocale('enUS'); return false;"><img src="http://mojotrollz.eu/web/danube/danube/page/js/flags/uk.jpg" /></a>
<a href="javascript:switchLocale('huHU');"><img src="http://mojotrollz.eu/web/danube/danube/page/js/flags/hu.jpg" /></a></div>
<div class="hero-unit" id="text" style="line-height: 180%; fonz-size: 80%; border-top-left-radius: 5; border-top-right-radius: 5; border-right: 1px solid black; border-left: 1px solid black; padding: 0; padding-top: 15px; padding-bottom: 40px; margin: 0; margin-bottom: 3px; margin-left: 8px; margin-right: 8px; padding-left: 45px; padding-right: 150px; background: url(danube/page/default_page/pics/css/text.png) bottom right no-repeat white;">

View File

@ -0,0 +1,30 @@
function switchLocale(locale){
reloadWithQueryStringVars({"lang": locale});
}
function reloadWithQueryStringVars (queryStringVars) {
var existingQueryVars = location.search ? location.search.substring(1).split("&") : [],
currentUrl = location.search ? location.href.replace(location.search,"") : location.href,
newQueryVars = {},
newUrl = currentUrl.replace(/#/g, "") + "?";
if(existingQueryVars.length > 0) {
for (var i = 0; i < existingQueryVars.length; i++) {
var pair = existingQueryVars[i].split("=");
newQueryVars[pair[0]] = pair[1];
}
}
if(queryStringVars) {
for (var queryStringVar in queryStringVars) {
newQueryVars[queryStringVar] = queryStringVars[queryStringVar];
}
}
if(newQueryVars) {
for (var newQueryVar in newQueryVars) {
newUrl += newQueryVar + "=" + newQueryVars[newQueryVar] + "&";
}
newUrl = newUrl.substring(0, newUrl.length-1);
window.location.href = newUrl;
} else {
window.location.href = location.href;
}
}