jQuery(document).ready(function ($) {
// Zwischen Inhaltsübersicht und Content unterscheiden
if (document.location.href.indexOf("Content") > -1) {
contentAnpassen(document);
} else {
inhaltsuebersichtAnpassen(document);
}
});
function getHashLinkFor(eltext){
if(eltext.startsWith("Anlage"))
return (":Anl:" + eltext.substring(7));
else
return ":P:" + eltext;
}
function inhaltsuebersichtAnpassen(document) {
var rows = jQuery('tr');
if (jQuery('.linkAllContent').attr('href').indexOf('/de') == -1)
jQuery('.linkAllContent').attr('href', '/de' + jQuery('.linkAllContent').attr('href'));
var locString = document.location.toString().split(".aspx")[0];
//locString += '/' + document.location.toString().split(".aspx")[0].split("/").pop() + '_Content.aspx#';
locString += '/' + 'Content.aspx#';
rows.each(function (i, elem) {
var val = jQuery(elem);
var std = val.children('td');
if (std && std.first().next() && std.first().next().text().trim().length > 0 && std.first().next().text().trim() != "§§") {
std.first().html('' + std.first().text() + '');
}
});
// Verlinkung in den hochgestellten Referenzen entfernen
rows = jQuery('sup').not('.satz');
rows.each(function (i, elem) {
var val = jQuery(elem);
var std = val.children('a');
// durch den reinen Text ersetzen und dann ohne removeAttr arbeiten!?
val.html(std.first().text());
});
}
function replace(selector, a , b){
jQuery(selector).find(a).replaceWith(function() {
return '<'+b+'>' + jQuery(this).text() + ''+b+'>';
});
}
function showEntry(hashSel){
var entries = jQuery('div.ev');
entries.each(function (i, elem) {
var val = jQuery(elem);
if(val.attr("id") && val.attr("id").endsWith(hashSel)){
val.show();
val.addClass('currentShowEv');
}
});
}
function contentAnpassen(document) {
var ind = document.location.toString().split("#")[1];
if (ind) {
jQuery('div.ev').hide();
jQuery('h1').hide();
jQuery('h2').hide();
jQuery('.itergo_hide > h3').hide();
jQuery('.itergo_hide > h4').hide();
jQuery('.itergo_hide > h5').hide();
jQuery('.itergo_hide > h6').hide();
jQuery('h1.ev_titel').show(); // Neu...
jQuery('h2.ev_titel').show();
jQuery('.itergo_hide > .fussnote').hide();
jQuery('#it-content > .jurabsatz').hide();
jQuery('#it-content > .fn').hide();
jQuery('#it-content > hr').hide();
jQuery('.itergo_hide > p').hide();
jQuery('.itergo_hide > .gesetz_fassung_rechtsstand').hide();
jQuery('.itergo_hide > .fuss').hide();
var tas = "#it-content .currentShowEv";
replace(tas,'h1','h3');
replace(tas,'h2','h3');
replace(tas,'h4','h3');
replace(tas,'h5','h3');
replace(tas,'h6','h3');
if(ind.indexOf(":") == -1){
jQuery('div.ev').eq(ind).show();
jQuery('div.ev').eq(ind).addClass('currentShowEv');
}
else {
showEntry(ind);
}
jQuery('div.itergo_hide').show();
} else {
// Wurde die Seite ohne Index aufgerufen, dann soll der komplette Text angezeigt werden.
jQuery('div.itergo_hide').show();
}
// Verlinkung in den hochgestellten Referenzen entfernen
var rows = jQuery('sup').not('.satz');
rows.each(function (i, elem) {
var val = jQuery(elem);
var std = val.children('a');
// durch den reinen Text ersetzen und dann ohne removeAttr arbeiten!?
val.html(std.first().text());
});
// Verlinkung auf Images (jpg, gif) anpassen
var sitecorePath = "/~/media/Base/DAS/Gesetzestexte/";
var images = jQuery('div.ev img');
images.each(function (i, elem) {
var val = jQuery(elem);
var srcarray = val.attr('src').split('/');
var title = srcarray[srcarray.length - 1];
var suffix = title.split(".")[1];
val.attr('src', sitecorePath + suffix + "/" + title);
});
// Verlinkung auf PDFs anpassen
var pdfs = jQuery('a.extdoklink');
pdfs.each(function (i, elem) {
var val = jQuery(elem);
var url = val.attr('href');
var title = url.split("/").pop();
val.attr('href', sitecorePath + "pdf/" + title);
});
// Alle hochgestellten Ziffern, die keine Fußnoten sind, entfernen.
jQuery('sup.satz').remove();
}