//Code
$(document).ready(function() {
/*
loadmodule hack by schattle.de
Rewrites all links to corresponding menu-links if exists
Avoids the problem of non-loaded modules in "readmore" or category-links
*/
// change
var menuLink = '#menu a'; // Menu-Link - example: '#mainmenu a'
var toRewrite = '#main a'; // Limit what to rewrite. Must NOT include the menu above!
var debugline = '#debugline'; // For debugging. Change to your debugline (optional)
//no changes beyond
$(toRewrite).each(function() {
var domain = document.domain;
var href = $(this).attr('href');
var outerThis = this;
var linkText = $(this).text();
if (href.startsWith('http') && href.indexOf(domain,0) == -1) { // no rewrite for external link
$(debugline).html($('.debugline').html()+'External-Link found: '+linkText+' -> '+href+'<br>');
return;
}
// If SEO off we have the string &ID=
// No rewrite when no ID (startpage, images, mailto ...)
else if (href.search(/&id=\d*/) > -1){
var refID = href.match(/&id=\d*/);
refID = refID[0].replace('&id=', '');
var isCat = href.indexOf('view=category');
if ( isCat > -1 ){ //find menu item with corresponding category-link
$('a.maximenuck').each(function() {
var hasCat = $(this).attr('href').indexOf('view=category');
var hasID = $(this).attr('href').indexOf('&id='+refID);
if( hasCat > -1 && hasID > -1 ){
var linkText = $(outerThis).text();
var menuURL = $(this).attr('href');
$(debugline).html($('.debugline').html()+'LINK:'+linkText+' -> '+href+' menuURL:'+menuURL+' Cat'+'<br>');
$(outerThis).attr('href',menuURL);
return false;
}
});
}
else { //find menu item with corresponding article-link
$('a.maximenuck').each(function() {
var hasArticle = $(this).attr('href').indexOf('view=article');
var hasID = $(this).attr('href').indexOf('&id='+refID);
if( hasArticle > -1 && hasID > -1 ){
var linkText = $(outerThis).text();
var menuURL = $(this).attr('href');
$(debugline).html($('.debugline').html()+'LINK:'+linkText+' -> '+href+' menuURL:'+menuURL+' Article'+'<br>');
$(outerThis).attr('href',menuURL);
return false;
}
});
}
return;
}
// Else case is as follows:
// 1.) No ID = no rewrite because menuID is undefined
// 2.) If SEO is ON, we have a unique Alias behind the last slash (The Menu-Alias MUST be equal!)
else {
var aliasArr = href.split('/');
var aliasRef = aliasArr[aliasArr.length - 1];
var menuURL = $(menuLink+'[href*="'+aliasRef+'"]').attr('href');
$(debugline).html($('.debugline').html()+'No ID or SEO ON: '+linkText+' -> '+href+' menuURL:'+menuURL+'<br>');
$(this).attr('href',menuURL);
return;
}
});
// End loadmodule hack
});
//code:
$(document).ready(function() {
// Change to whatever you want
var standardLangText = "Standardsprache"; //String to display if "Simple" ist active
var easyLangText = "Einfache Sprache"; //String to display if "Standard" ist active
// No Changes beyond here
function setCookie(n,w,e){
var a = new Date();
a = new Date(a.getTime() +e);
document.cookie = n+'='+w+'; expires='+a.toGMTString()+';';
}
function getCookie(n){
a = document.cookie;
res = '';
while(a != ''){
while(a.substr(0,1) == ' '){a = a.substr(1,a.length);}
cookieName = a.substring(0,a.indexOf('='));
if(a.indexOf(';') != -1) cookieVal = a.substring(a.indexOf('=')+1,a.indexOf(';'));
else cookieVal = a.substr(a.indexOf('=')+1,a.length);
if(n == cookieName) res = cookieVal;
i = a.indexOf(';')+1;
if(i == 0) i = a.length
a = a.substring(i,a.length);
}
return(res)
}
function deleteCookie(n){
document.cookie = n+'=; expires=Thu, 01-Jan-70 00:00:01 GMT;';
}
// initial we read the cookie if set
if (getCookie('isSimple') == 'yes'){
$('.standard').hide('fast', function(){
//callback here if needed
});
$('.simple').show('fast', function(){
$(this).addClass('open');
$('.toggler').text(standardLangText);
$('.toggler').addClass("toggelt");
});
}
else {
$('.simple').hide('fast', function(){
//callback here if needed
});
$('.standard').show('fast', function(){
$('.toggler').text(easyLangText);
$('.toggler').removeClass("toggelt");
$(this).removeClass('open');
});
}
// Switch Lang and set cookie
$('.toggler').on('click', function(){
if ($('.simple').hasClass('open')){
setCookie('isSimple', 'no', '1000*60*60*24*365');
$('.simple').hide('fast', function(){
$('.standard').show('fast', function(){
});
$('.toggler').text(easyLangText);
$('.toggler').removeClass("toggelt");
$(this).removeClass('open');
});
}
else {
setCookie('isSimple', 'yes', '1000');
$('.simple').show('fast', function(){
$('.standard').hide('fast', function(){
});
$(this).addClass('open');
$('.toggler').text(standardLangText);
$('.toggler').addClass("toggelt");
});
}
});
//end switch simple language
});