/* --- javascript.lib.js (legacy helper library, hardened) --- */
var JSLIBBOOT = new Array();
function isbootlib(lib)
{
if (typeof JSLIBBOOT[lib] != 'undefined')
{
return true;
}
else
{
return false;
}
}
function getURLParameter(name)
{
if (!isNaN(name)) return getURLPathParameter(name);
var sPageURL = window.location.search.substring(1);
var sURLVariables = sPageURL.split('&');
for (var i = 0; i < sURLVariables.length; i++)
{
var sParameterName = sURLVariables[i].split('=');
if (sParameterName[0] == name)
{
// decode safely
try {
return decodeURIComponent((sParameterName[1] || '').replace(/\+/g, ' '));
} catch (e) {
return sParameterName[1];
}
}
}
}
function first_split(str, char)
{
var str1 = str.toString();
var str2 = str1.split(char);
var str3 = str2[0].toString();
return str3;
}
function getURLPathParameter(pathnr)
{
var url = window.location.toString();
var sURLVariables = url.split('//');
url = sURLVariables[1];
sURLVariables = url.split('/');
for (var i = 0; i < sURLVariables.length; i++)
{
if (i == pathnr)
{
return sURLVariables[i];
}
}
return null;
}
function mydecode(html)
{
html = str_replace('<', '<', html);
html = str_replace('>', '>', html);
html = str_replace(''', "'", html);
html = str_replace('"', '"', html);
html = str_replace(''', "'", html);
return html;
}
function str_replace(search, replace, subject)
{
var result = "";
var oldi = 0;
for (var i = subject.indexOf(search)
; i > -1
; i = subject.indexOf(search, i))
{
result += subject.substring(oldi, i);
result += replace;
i += search.length;
oldi = i;
}
return result + subject.substring(oldi, subject.length);
}
/* Modern event helper (replaces legacy on* chaining) */
function addEvent(element, type, fn) {
if (!element) return;
element.addEventListener(type, fn, false);
}
function getPosition(element) {
const rect = element.getBoundingClientRect();
return {
x: rect.left + window.scrollX,
y: rect.top + window.scrollY
};
}
function getMyObjectInfo(obj)
{
var r = { top:0, left:0, width:0, height:0 };
var oldobj = obj;
if(!obj)
{
oldobj.getmy_top = r.top;
oldobj.getmy_left = r.left;
oldobj.getmy_width = r.width;
oldobj.getmy_height = r.height;
return false;
}
else if(typeof obj == 'string') obj = document.getElementById(obj);
if(typeof obj != 'object')
{
oldobj.getmy_top = r.top;
oldobj.getmy_left = r.left;
oldobj.getmy_width = r.width;
oldobj.getmy_height = r.height;
return false;
}
if(typeof obj.offsetTop != 'undefined') {
r.height = obj.offsetHeight;
r.width = obj.offsetWidth;
r.left = r.top = 0;
while (obj && obj.tagName != 'BODY') {
r.top += parseInt(obj.offsetTop);
r.left += parseInt(obj.offsetLeft);
obj = obj.offsetParent;
}
}
oldobj.getmy_top = r.top;
oldobj.getmy_left = r.left;
oldobj.getmy_width = r.width;
oldobj.getmy_height = r.height;
return true;
}
/* -------------------------
SAFE onload queue (no eval)
------------------------- */
const wbOnloadQueue = [];
var my_loaded_document = 0;
function wb_js_onload_func(fn /*, p1..pn */)
{
var args = Array.prototype.slice.call(arguments, 1);
wbOnloadQueue.push({ fn: fn, args: args });
}
function wb_js_onload_do()
{
while (wbOnloadQueue.length)
{
var item = wbOnloadQueue.shift();
try {
var f = (typeof item.fn === "function") ? item.fn : window[item.fn];
if (typeof f === "function") {
f.apply(null, item.args);
} else {
console.warn("wb_js_onload: function not found:", item.fn);
}
} catch (e) {
console.error("wb_js_onload error:", e);
}
}
}
/* No busy-wait. Provide async sleep helper. */
function sleep(ms) {
return new Promise(function(resolve){ setTimeout(resolve, ms); });
}
var mouse_X = 0, mouse_Y = 0;
document.addEventListener('mousemove', function(e)
{
mouse_X = e.pageX || (e.clientX + document.body.scrollLeft);
mouse_Y = e.pageY || (e.clientY + document.body.scrollTop);
}, false);
window.addEventListener('load', function() {
wb_js_onload_do();
my_loaded_document = 1;
// Keep draining queue for late registrations
setInterval(wb_js_onload_do, 500);
});
/* Fade-out helper for .erfolg / .fehler */
function aufloesenUndEntfernen(divElement, timeout) {
setTimeout(function() {
divElement.style.transition = 'opacity 5s';
divElement.style.opacity = '0';
var transitionEndListener = function() {
if (divElement.style.opacity === '0') {
divElement.removeEventListener('transitionend', transitionEndListener);
divElement.style.display = 'none';
divElement.remove();
}
};
divElement.addEventListener('transitionend', transitionEndListener);
}, timeout * 1000);
}
window.addEventListener('load', function() {
var divElemente = document.querySelectorAll('.erfolg, .fehler');
divElemente.forEach(function(divElement) {
aufloesenUndEntfernen(divElement, 5);
});
});
var pageParams = [
{ key: 'page', value: '1' },
{ key: 'seite', value: '2' }
];
function removeAllURLParameters() {
var url = new URL(window.location.href);
var newURL = url.origin + url.pathname + '?';
window.history.replaceState({ path: newURL }, '', newURL);
}
function removeURLParametersExcept(pageParams) {
var url = new URL(window.location.href);
var searchParams = new URLSearchParams(url.search);
var paramsToKeep = ['page', 'seite'];
// remove everything except keep-list
Array.from(searchParams.keys()).forEach(function(key) {
if (!paramsToKeep.includes(key)) {
searchParams.delete(key);
}
});
// set (not append) to avoid duplicates
pageParams.forEach(function(param) {
searchParams.set(param.key, param.value);
});
var newURL = url.origin + url.pathname + '?' + searchParams.toString();
window.history.replaceState({ path: newURL }, '', newURL);
}
JSLIBBOOT['JAVASCRIPT'] = 1;
function lib_highlight_back(urlaj) {
const highlighter = document.getElementById('highlighter');
const highlighterin = document.getElementById('highlighterin');
if (highlighter) {
highlighter.classList.remove('highlighterinaniin');
highlighter.style.position = 'absolute';
highlighter.style.left = '-10000px';
highlighter.style.top = '-10000px';
}
if (urlaj) {
ajaxrequerstabort();
}
if (highlighterin) {
highlighterin.innerHTML = '';
}
}
function lib_highlight(obj, text, urlaj, copyobjid, autoclose = 1) {
const highlighter = document.getElementById('highlighterin');
if (document.readyState !== 'complete' || !highlighter) return false;
highlighter.innerHTML = 'Daten werden geladen';
lib_highlight_position(obj);
if (autoclose === 1) {
obj.onmouseout = () => lib_highlight_back(urlaj);
addEvent(obj, "click", () => lib_highlight_back(urlaj));
}
let showin = 1;
if (!text && urlaj) {
setRequest(urlaj, 1, 'highlighterin', 1, 'lib_highlight_position', obj);
showin = 0;
} else if (copyobjid && document.getElementById(copyobjid)) {
text = document.getElementById(copyobjid).innerHTML;
} else if (!text && obj.title !== 'undefined' && obj.title !== '') {
text = obj.title;
} else if (!text && obj.alt !== 'undefined' && obj.alt !== '') {
text = obj.alt;
}
if (showin === 1) {
highlighter.innerHTML = text;
}
lib_highlight_position(obj);
}
function lib_highlight_position(obj)
{
document.getElementById('highlighter').classList.add('highlighterinaniin');
var a,element;
element=obj;
a=getPosition(element);
var vx = (a.x - Math.round(document.getElementById('highlighter').offsetWidth /2) + Math.round(obj.offsetWidth / 2));
if(vx < 1) vx = 1;
document.getElementById('highlighter').style.left = vx+"px";
document.getElementById('highlighter').style.top = (a.y - document.getElementById('highlighter').offsetHeight) + "px";
}
function init_lib_highlight()
{
var newO = document.createElement("div");
newO.setAttribute("id",'highlighter');
document.body.appendChild(newO);
document.getElementById('highlighter').innerHTML = mydecode('<div id="highlighterin"></div><div style="margin-top: -1px; width:100%; height: 11px; background: url('https://www.wohnmobil-markisen.de/images/nabe.png'); background-repeat: no-repeat; background-position: center top; z-index: 1002;"></div>');
lib_highlight_back();
}
wb_js_onload_func('init_lib_highlight');
function setCookie(cname, cvalue, exdays)
{
var d = new Date();
d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000));
var expires = "expires="+ d.toUTCString();
document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";
}
JSLIBBOOT['COOKIE'] = 1;
init_form_kalender_function_after_dat = new Array();
function init_form_kalender_str_replace(search, replace, subject)
{
var result = "";
var oldi = 0;
for (i = subject.indexOf (search)
; i > -1
; i = subject.indexOf (search, i))
{
result += subject.substring (oldi, i);
result += replace;
i += search.length;
oldi = i;
}
return result + subject.substring (oldi, subject.length);
}
function init_form_kalender_set_jd(tag, monat, jahr, id)
{
if(!isbootlib('AJAX')) return false;
jahr = jahr -1;
tag = 1;
document.getElementById(id+'_tag').value = tag;
document.getElementById(id+'_monat').value = monat;
document.getElementById(id+'_jahr').value = jahr;
if(document.getElementById(id).childNodes[4].innerHTML.length > 0) document.getElementById(id).childNodes[4].innerHTML = tag+'.'+monat+'.'+jahr;
setRequest('https://www.wohnmobil-markisen.de/ajax/calender.php?id='+id+'&atag='+document.getElementById(id+'_tag').value+'&amonat='+document.getElementById(id+'_monat').value+'&ajahr='+document.getElementById(id+'_jahr').value,1,id+'_kalenderanzeige');
}
function init_form_kalender_set_ju(tag, monat, jahr, id)
{
if(!isbootlib('AJAX')) return false;
jahr++;
tag=1;
document.getElementById(id+'_tag').value = tag;
document.getElementById(id+'_monat').value = monat;
document.getElementById(id+'_jahr').value = jahr;
if(document.getElementById(id).childNodes[4].innerHTML.length > 0) document.getElementById(id).childNodes[4].innerHTML = tag+'.'+monat+'.'+jahr;
setRequest('https://www.wohnmobil-markisen.de/ajax/calender.php?id='+id+'&atag='+document.getElementById(id+'_tag').value+'&amonat='+document.getElementById(id+'_monat').value+'&ajahr='+document.getElementById(id+'_jahr').value,1,id+'_kalenderanzeige');
}
function init_form_kalender_set_md(tag, monat, jahr, id)
{
if(!isbootlib('AJAX')) return false;
monat = monat -1;
tag=1;
if(monat < 1)
{
monat = 12;
jahr = jahr -1;
}
document.getElementById(id+'_tag').value = tag;
document.getElementById(id+'_monat').value = monat;
document.getElementById(id+'_jahr').value = jahr;
if(document.getElementById(id).childNodes[4].innerHTML.length > 0) document.getElementById(id).childNodes[4].innerHTML = tag+'.'+monat+'.'+jahr;
setRequest('https://www.wohnmobil-markisen.de/ajax/calender.php?id='+id+'&atag='+document.getElementById(id+'_tag').value+'&amonat='+document.getElementById(id+'_monat').value+'&ajahr='+document.getElementById(id+'_jahr').value,1,id+'_kalenderanzeige');
}
function init_form_kalender_set_mu(tag, monat, jahr, id)
{
if(!isbootlib('AJAX')) return false;
monat++;
tag=1;
if(monat > 12)
{
monat = 1;
jahr++;
}
document.getElementById(id+'_tag').value = tag;
document.getElementById(id+'_monat').value = monat;
document.getElementById(id+'_jahr').value = jahr;
if(document.getElementById(id).childNodes[4].innerHTML.length > 0) document.getElementById(id).childNodes[4].innerHTML = tag+'.'+monat+'.'+jahr;
setRequest('https://www.wohnmobil-markisen.de/ajax/calender.php?id='+id+'&atag='+document.getElementById(id+'_tag').value+'&amonat='+document.getElementById(id+'_monat').value+'&ajahr='+document.getElementById(id+'_jahr').value,1,id+'_kalenderanzeige');
}
function init_form_kalender_set_dat(tag,monat,jahr, id)
{
//alert(id+' '+tag+' '+monat+' '+jahr);
document.getElementById(id+'_tag').value = tag;
document.getElementById(id+'_monat').value = monat;
document.getElementById(id+'_jahr').value = jahr;
if(document.getElementById(id).childNodes[4].innerHTML.length > 0) document.getElementById(id).childNodes[4].innerHTML = tag+'.'+monat+'.'+jahr;
document.getElementById(id+'_kalenderanzeige').innerHTML = '';
if(init_form_kalender_function_after_dat[id] != null)
{
eval(init_form_kalender_function_after_dat[id] + '();');
}
}
function init_form_kalender(obj,atag,amonat,ajahr,text,function_after)
{
init_form_kalender_function_after_dat[obj.id] = function_after;
var oldid = obj.id;
getMyObjectInfo(obj);
var oldTop = obj.getmy_top;
var oldLeft = obj.getmy_left;
var oldonmouseover = obj.onmouseover;
var oldonmouseout = obj.onmouseoout;
tag = '<font id="((id))" class="form_kalender_button" onclick="setRequest('https://www.wohnmobil-markisen.de/ajax/calender_from.php',1,'details');" onmouseover=" this.style.cursor = 'pointer';" onmouseout=""><img src="https://www.wohnmobil-markisen.de/images/myicons/kalender.png" class="icon"> <b></b> <font></font></font>';
tag = init_form_kalender_str_replace('((id))',oldid+'_create',tag);
tag = init_form_kalender_str_replace('"','"',tag);
tag = init_form_kalender_str_replace('<','<',tag);
tag = init_form_kalender_str_replace('>','>',tag);
tag = init_form_kalender_str_replace(''',"'",tag);
obj.onerror = null;
obj.removeAttribute("onerror");
document.getElementById('dataholder').innerHTML += tag;
var tag = document.getElementById(oldid+'_create');
eltern = obj.parentNode;
eltern.replaceChild(document.getElementById(oldid+'_create'),obj);
obj = document.getElementById(oldid+'_create');
obj.id = oldid;
if(text.length > 0)
{
obj.childNodes[4].innerHTML = atag+'.'+amonat+'.'+ajahr;
obj.childNodes[2].innerHTML = text;
}
var newTextfield = document.createElement("textarea");
newTextfield.setAttribute("id",oldid+'_tag');
newTextfield.setAttribute("name",oldid+'_tag');
newTextfield.setAttribute("class",'form_noshow');
obj.appendChild(newTextfield);
document.getElementById(oldid+'_tag').value=atag;
var newTextfield = document.createElement("textarea");
newTextfield.setAttribute("id",oldid+'_monat');
newTextfield.setAttribute("name",oldid+'_monat');
newTextfield.setAttribute("class",'form_noshow');
obj.appendChild(newTextfield);
document.getElementById(oldid+'_monat').value=amonat;
var newTextfield = document.createElement("textarea");
newTextfield.setAttribute("id",oldid+'_jahr');
newTextfield.setAttribute("name",oldid+'_jahr');
newTextfield.setAttribute("class",'form_noshow');
obj.appendChild(newTextfield);
document.getElementById(oldid+'_jahr').value=ajahr;
document.getElementById('dataholder').innerHTML += '