$(document).ready(function() {
var data = new Object();
$('.ddc-hit-bibl').each(function() {
var content = $(this);
data["text"] = $(this).siblings('.ddc-hit-text').text();
data["word"] = $(this).siblings('.ddc-hit-text').children('.ddc-hl').text();
$(this).siblings('.ddc-hit-metafull').children('.ddc-metalist').find('table th').each(function(){
if($(this).text() == "Autor:") {
data["author"] = $(this).next().text();
}
})
$(this).siblings('.ddc-hit-metafull').children('.ddc-metalist').find('table th').each(function(){
if($(this).text() == "Titel:") {
data["title"] = $(this).next().text();
}
})
$(this).siblings('.ddc-hit-metafull').children('.ddc-metalist').find('table th').each(function(){
if($(this).text() == "Datum:") {
data["year"] = $(this).next().text();
}
})
$(this).siblings('.ddc-hit-metafull').children('.ddc-metalist').find('table th').each(function(){
if($(this).text().trim() == "Seite:") {
data["pages"] = $(this).next().text();
}
})
$(this).siblings('.ddc-hit-metafull').children('.ddc-metalist').find('table th').each(function(){
if($(this).text().trim() == "Bibl:") {
data["bibl"] = $(this).next().text();
}
})
var re = new RegExp(data["author"],"g");
var bibl = data["bibl"].replace(re, "");
re = new RegExp(data["title"],"g");
bibl = bibl.replace(re, "");
re = new RegExp("In: [^,]*","g");
bibl = bibl.replace(re, "");
re = new RegExp("[0-9]{4}[ ]*[[][0-9]{4}][,]*","g");
bibl = bibl.replace(re, "");
re = new RegExp(data["year"] + "[,]*","g");
bibl = bibl.replace(re, "");
re = new RegExp("S. " + data["pages"],"g");
bibl = bibl.replace(re, "");
re = new RegExp(": , ","g");
bibl = bibl.replace(re, "");
re = new RegExp("[^:]+[:][^:]+","g");
if (re.test (bibl)) {
data["city"] = bibl.match(/([^:]+)[:][^:]+/)[1].trim();
data["publisher"] = bibl.match(/[^:]+[:]([^:]+)/)[1].trim();
}
var output = "<span style=\"color:green\">"
var text = data["text"].trim();
text = text.replace (/[»]/g, "‚");
text = text.replace (/[«]/g, "'");
text = text.replace (/["]/g, "‚")
var re = new RegExp(data["word"],"g");
text = text.replace(re, "''" + data["word"] + "''");
output = output + ":[1] „" + text + "“<ref>";
output = output + "{{Literatur|";
output = output + "Autor=" + data["author"];
output = output + "|Titel=" + data["title"];
if (data["publisher"]) {
output = output + "|Verlag=" + data["publisher"]
};
if (data["city"]) {
output = output + "|Ort=" + data["city"]
};
output = output + "|Jahr=" + data["year"];
output = output + "|Seiten=" + data["pages"] + "}}</ref>";
output = output + "</span>";
content.after(output);
});
});