Initial Commit after switching from SVN to git

This commit is contained in:
2026-05-03 01:43:52 +02:00
parent ab8638e5bb
commit a4284234b2
910 changed files with 359931 additions and 0 deletions
+857
View File
@@ -0,0 +1,857 @@
const isIE = /MSIE\/|Trident/ig.test(window.navigator.userAgent) || typeof window.document.documentMode !== 'undefined';
const isfileapi = (window.File && window.FileReader && window.FileList && window.Blob) ? true : false;
var $ocms = {
auth: {}, no: function (e) {
e.stopPropagation();
}, vmin: function (f) {
var w = $(window).width * (f || 1), h = $(window).height * (f || 1);
return w < h ? w : h;
}, rpx: function (rem) {
return rem * parseFloat(getComputedStyle(document.documentElement).fontSize);
}, pattern: {
date_ger: '^(0?[1-9]|[12][0-9]|3[01])[\\.\\-](0?[1-9]|1[012])[\\.\\-]\\d{4}$',
date_us: '^(0?[1-9]|1[012])[\\\\](0?[1-9]|[12][0-9]|3[01])[\\\\]\\d{4}$',
date_serial: '\\d{4}[\\-]^(0?[1-9]|1[012])[\\-](0?[1-9]|[12][0-9]|3[01])$'
}, rdm: function (ln) {
var c = typeof ln === 'number' ? ln : (typeof ln === 'string' ? parseInt(ln) : 7);
if (isNaN(c) === true || typeof c === 'undefined') {
c = 7;
}
return Math.random().toString(36).substring(c);
}, login: {}, t: {
dn: ['So', 'Mo', 'Di', 'Mi', 'Do', 'Fr', 'Sa'], mn: ['Januar', 'Februar', 'März', 'April', 'Mai', 'Juni', 'Juli', 'August', 'September', 'Oktober', 'November', 'Dezember'], ma: ['Jan', 'Feb', 'Mrz', 'Apr', 'Mai', 'Jun', 'Jul', 'Aug', 'Sep', 'Okt', 'Nov', 'Dez']
}, failure: function (jqXHR) {
alert($t.f1 + '\n' + (jqXHR.internalText || ''));
}, baseurl: '/do', url: (c) => ($ocms.baseurl + '/' + (c || '')).replace(/\/\//, '/'),
cexi: null
};
function deepCopy (inObject) {
var outObject, value, key
if (typeof inObject !== "object" || inObject === null) {
return inObject // Return the value if inObject is not an object
}
// Create an array or object to hold the values
outObject = Array.isArray(inObject) ? [] : {};
for (key in inObject) {
value = inObject[key];
// Recursively (deep) copy for nested objects, including arrays
outObject[key] = deepCopy(value);
}
return outObject;
};
function fields_definition(p1, label_pl, flds) {
this.label_sng = Array.isArray(p1) === true ? '' : p1 ||'';
this.label_pl = Array.isArray(p1) === true ? '' : label_pl || '';
this.fields = Array.isArray(p1) === true ? p1 : (flds || []);
this.itm = function (name) {
for (var fi = 0; fi < this.fields.length; fi++) {
if (this.fields[fi].name === name) {
return this.fields[fi];
}
}
return null;
}
this.lbl = function (name) {
var ld = {}, n = typeof name === 'string';
for (var fi = 0; fi < this.fields.length; fi++) {
if (n ===true) {
if (this.fields[fi].name === name) {
return this.fields[fi];
}
} else {
ld[this.fields[fi].name] = this.fields[fi].label;
}
}
return (n === true ? null : ld);
}
this.contains = function (name) {
for (var fi = 0; fi < this.fields.length; fi++) {
if (this.fields[fi].name === name) {
return true;
}
}
return false;
}
this.rem = function (name) {
var r = false, f = function (nme) {
for (var fi = 0; fi < this.fields.length; fi++) {
if (this.fields[fi].name === nme) {
this.fields.splice(fi, 1);
r = true;
break;
}
}
}
if (typeof (name) === 'string') {
f.call(this, name);
} else if (Array.isArray(name) === true) {
for (var ai = 0; ai < name.length; ai++) {
f.call(this, name[ai]);
}
}
return r;
}
this.replace = function (name, newfield) {
for (var fi = 0; fi < this.fields.length; fi++) {
if (this.fields[fi].name === name) {
this.fields.splice(fi, 1, newfield);
return newfield;
}
}
return null;
}
this.set = function (name, value, prop) {
prop = prop || 'value';
for (var fi = 0; fi < this.fields.length; fi++) { /* loop through array */
if (this.fields[fi].name === name) {
this.fields[fi][prop] = value;
return this.fields[fi]; /* return if found = break loop */
}
}
return null;
}
this.sets = function (name, obj) {
if (typeof obj === 'object' && Object.keys(obj).length > 0) {
for (var fi = 0; fi < this.fields.length; fi++) { /* loop through array */
if (this.fields[fi].name === name) {
$.extend(this.fields[fi], obj);
return this.fields[fi]; /* return if found = break loop */
}
}
}
return null;
}
this.applyValues = function (vals) {
var t = this;
$.each(vals || {}, function (ri, rx) {
t.set(ri, rx);
});
return t;
}
this.clone = function (names) {
let c = [];
if (Array.isArray(names || '')) {
let value, key;
for (key in (this.fields || [])) {
value = this.fields[key];
if ((value.name ||'') !== '' && names.includes(value.name) === true) {
// Recursively (deep) copy for nested objects, including arrays
c.push(deepCopy(value));
}
}
} else {
c = deepCopy(this.fields || []);
}
return new fields_definition(this.label_sng || '', this.label_pl || '', c);
}
}
function rpx(rem) {
return rem * parseFloat(getComputedStyle(document.documentElement).fontSize);
}
function vw(f) {
return $(window).width() * (f || 1);
}
function vh(f) {
return $(window).height() * (f || 1);
}
function hh() {
return $('header:first').height() || 0;
}
function ne(inp, alt) {
return (inp || '') === '' ? (alt || '') : inp;
}
function pad(i, n) { return (i || '').toString().padStart(n, '0').substr(-1 * n); }
function parseISO(s) {
let si = s || '';
if (si === '') { return null };
if (/\d{4}-[01]\d-[0-3]\dT[0-2]\d:[0-5]\d:[0-5]\d\.\d+([+-][0-2]\d:[0-5]\d|Z)/.test(si) === true) {
return new Date(si);
} else {
var b = s.split(/\D/);
return new Date(b[0], b[1] - 1, b[2], b[3], b[4], b[5]);
}
}
function parseISOLocal(s) {
let si = s || '';
if (si === '') { return null };
var b = s.split(/\D/);
return new Date(b[0], b[1] - 1, b[2], b[3], b[4], b[5]);
}
function fnum(i, style) {
/* { style: 'decimal/currency/percent', currency: 'USD/EUR', currencyDisplay: 'symbol/code/name', minimumIntegerDigits: 1, minimumFractionDigits: 2, maximumFractionDigits: 3, useGrouping: true } */
return new Intl.NumberFormat(($t.lng || 'de-DE'), style || {}).format(i);
}
function fdt(i, fmt) {
if (typeof i === 'undefined') { return ''; }
try {
var f = fmt || 'DD.MM.YYYY HH:mm';
if (f === 'dts') {
f = 'yyyy-MM-dd';
}
if (f === 'iso') {
if (typeof i === 'string') { i = parseISO(i); }
return i.toISOString();
} else if (typeof moment === 'function') {
return (typeof i !== 'undefined' && (typeof i === 'string' && i !== '')) ? moment(i).format(f) : '';
} else {
if (typeof i === 'string') { i = parseISO(i); }
var pd = function (i, n) { var t = ('0000' + i.toString()); return t.slice(t.length - (n || 2)); }
var t = f + '';
t = t.replace(/ddd/ig, ($t.dn || $ocms.t.dn)[i.getDay()]);
t = t.replace(/dd/ig, pd(i.getDate()));
t = t.replace(/MMMM/g, ($t.mn || $ocms.t.mn)[i.getMonth()]);
t = t.replace(/MMM/g, ($t.ma || $ocms.t.ma)[i.getMonth()]);
t = t.replace(/MM/g, pd(i.getMonth() + 1));//January is 0!
t = t.replace(/yyyy/ig, pd(i.getFullYear(), 4));
t = t.replace(/yy/ig, pd(i.getFullYear()));
t = t.replace(/hh/ig, pd(i.getHours()));
t = t.replace(/mm/g, pd(i.getMinutes()));
t = t.replace(/ss/ig, pd(i.getSeconds()));
return t;
}
} catch (e) {
return '';
}
}
Date.prototype.isValid = function () {
return !isNaN(this);
};
Date.prototype.format = function (fmt) {
return fdt(this,fmt);
};
Date.prototype.addDays = function (days) {
this.setDate(this.getDate() + days);
return this;
};
Date.prototype.isBetween = function (date1, date2) {
return this > date1 && this < date2;
};
Date.prototype.diff = function (date1) {
var diffTime = Math.abs(date1 - this), diffDays = Math.ceil(diffTime / (1000 * 60 * 60 * 24));
return diffDays;
};
Date.prototype.year = function () {
return this.getFullYear();
};
Date.prototype.month = function () {
return this.getMonth() + 1;
};
Date.prototype.date = function () {
return this.getDate();
};
String.prototype.ne = function (alt) {
let t = (this || '').trim();
return t === '' ? (alt || '') : t;
};
/* eine = extend if not empty */
String.prototype.eine = function(pre, su) {
let t = (this || '').trim();
return t === '' ? '' : ((pre || '') + t + (su || ''));
};
function jine(a, sep) { return a.map((v, i) => (v || '')).filter((v, i) => v !== '').join(sep) };
function parseDt(datestring, format, newformat) {
datestring = (datestring || '').substr(0, format.length);
var cvalid = function (fmt) {
var result, reg = /[^yMdhms0-9]/ig, valid = true;
while ((result = reg.exec(fmt)) !== null) {
valid = valid && fmt.substr(result.index, 1) === datestring.substr(result.index, 1);
}
var vr = (datestring.length === fmt.length) && valid;
if (vr === true) {
vfmt = fmt;
}
return vr;
}, vfmt = format, isvalid = datestring.length > 0 && format.split(';').some(cvalid);
if (isvalid === true) {
var ndt = [0, 0, 0, 0, 0, 0, 0], np = 'yMdhms';
var result, reg = /(mm{1,2}|dd{1,2}|MM{1,2}|(yy){2,4}|ss{1,2}|hh{1,2})(?!\w)/g, valid = true;
while ((result = reg.exec(vfmt)) !== null) {
ndt[np.indexOf(result[0].substr(0, 1))] = parseInt((result[0] === 'yy' ? '20' : '') + datestring.substr(result.index, result[0].length)) - (result[0].substr(0, 1) === 'M' ? 1 : 0);
}
var dt = new (Function.prototype.bind.apply(Date, [null].concat(ndt)))();
return (typeof newformat === 'string') ? fdt(dt, newformat) : dt;
} else {
return false;
}
}
function bool(i, alt) {
return typeof i === 'boolean' ? i : (typeof alt === 'boolean' ? alt : false);
}
function booln(i, alt) {
var r = false;
if (typeof i === 'boolean') {
r = i;
} else if (typeof i === 'number') {
r = (i === 1);
} else {
r = (typeof alt === 'boolean' ? alt : false);
}
return r;
}
/* set getHash method, IE9 safe */
var h = (typeof window.location.hash === 'undefined');
$ocms.getHash = h ? function () {
return document.URL.substr(document.URL.indexOf('#'));
} : function () { return window.location.hash; };
$ocms.initNav = function () {
$('body').click(function (e) {
$('#toggle-nav').removeClass('active');
});
var nbtn = $('#toggle-nav');
$('.nav_menu').click(function (e) {
if (nbtn.hasClass('active') === true) {
e.stopPropagation();
}
});
nbtn.click(function (e) {
e.stopPropagation();
$(this).toggleClass('active');
});
};
$ocms.initScroll = function () {
let hd = $('header');
let initialHeaderHeight = hd.height(), sec = $('main > section');
$(window).scroll(function (e) {
let scrollTop = $(window).scrollTop(), b = $('body');
b.toggleClass('unfocus', scrollTop > (vh() - initialHeaderHeight * 1.2));
b.toggleClass('btb', scrollTop > (vh() * 0.5 - initialHeaderHeight));
});
};
$ocms.cf_reset = function () {
return $('#contentframe').empty();
};
(function ($) {
/* @description: jQuery - scrollTo
* @author: Dr. Stefan Ott
* @version: 1.0
*/
$.fn.scrollTo = function (key) {
if ($(this).length > 0) {
var ost = $(this).offset().top || 0;
if (ost > 0) {
$('html, body').animate({
scrollTop: ost - hh()
}, 2000);
}
}
};
$.fn.ldng = function (onoff) {
var st = true;
if (typeof onoff === 'boolean') {
st = onoff;
} else if (typeof onoff === 'number') {
st = onoff > 0;
}
return $(this).toggleClass('loading', st);
};
if (typeof $.noop !== 'function') {
$.noop = function () {};
}
/* @description: determines if element has the attribute
* @author: Dr. Stefan Ott
* @version: 1.0
*/
$.fn.hasAttr = function (AttName) {
var attr = $(this).attr(AttName);
return (typeof attr !== 'undefined' && attr !== false);
};
$.fn.parseCssPx = function (key) {
try {
return parseFloat($(this).css(key).replace('px', '') || 0);
} catch (e) {
return 0.0;
}
};
/* @description: returns the higher value
* @author: Dr. Stefan Ott
* @version: 1.0
*/
$.max = function (val1, val2) {
if (isNaN(val1) && isNaN(val2)) { return null; }
else if (isNaN(val1) && !isNaN(val2)) { return val2; }
else if (!isNaN(val2) && isNaN(val2)) { return val1; }
else if (val1 >= val2) { return val1; }
else { return val2; }
};
/* @description: returns the lower value
* @author: Dr. Stefan Ott
* @version: 1.0
*/
$.min = function (val1, val2) {
if (isNaN(val1) && isNaN(val2)) { return null; }
else if (isNaN(val1) && !isNaN(val2)) { return val2; }
else if (!isNaN(val2) && isNaN(val2)) { return val1; }
else if (val1 <= val2) { return val1; }
else { return val2; }
};
/* @description: returns the value to the limit
* @author: Dr. Stefan Ott
* @version: 1.0
*/
$.lim = function (val, lim) {
if (isNaN(val)) { return null; }
else if (isNaN(lim)) { return val; }
else if (lim <= val) { return lim; }
else { return val; }
};
$.fn.enterKey = function (fnc) {
return this.each(function () {
$(this).keypress(function (ev) {
var keycode = (ev.keyCode ? ev.keyCode : ev.which).toString();
if (keycode === '13') {
fnc.call(this, ev);
}
})
})
};
})(jQuery);
/*_________ ajax ________________________________________________*/
$ocms.defaultTimeout = 30000; /* 30s */
/* @description: processes jqXHR from Ajax response and adds new infos (needs to be called with jqXHR as context)
* @author: Dr. Stefan Ott
* @version: 2.0
*/
$ocms.AjaxEX = function (textStatus) {
var jqXHR = this;
jqXHR.responseText = jqXHR.responseText || '';
var ic = jqXHR.getResponseHeader('x-ocms-code') || '';
jqXHR.internalCode = (ic !== '' && isNaN(ic) === false) ? parseInt(ic) : -1;
jqXHR.isInternal = jqXHR.internalCode > -1;
jqXHR.internalText = decodeURIComponent((jqXHR.getResponseHeader('x-ocms-desc') ||'').replace(/\+/g, '%20') || '');
var t = jqXHR.internalText || textStatus;
var c = jqXHR.internalCode || jqXHR.status;
jqXHR.logtext = t + ' (' + c + ')';
};
/* @description: custom jquery ajax post for simplification
* @author: Dr. Stefan Ott
* @version: 1.0
*/
$ocms.postXTS = function (options) {
$ocms.postXT.call(this, $.extend(options, { sync: true }));
};
/* @description: custom jquery ajax post for simplification
* @author: Dr. Stefan Ott
* @version: 2.0
*/
$ocms.postXT = function (options) {
options = options || {};
options.trycount = options.trycount || 0;
if ((options.url || '') === '') { return; }
options.url = (options.url.indexOf('&yy=') !== -1) ? options.url : ((options.url.indexOf('?') > -1) ? (options.url + '&yy=' + (new Date()).getTime()) : (options.url + '?yy=' + (new Date()).getTime()));
var context = options.context || this;
options.context = context;
options.retryLimit = options.retryLimit || 0;
options.timeout = options.timeout || $ocms.defaultTimeout;
if (options.timeout < 100) { options.timeout = options.timeout * 1000; }
options.data = options.data || {};
options.contentType = options.contentType || 'multipart/form-data; charset=UTF-8';
options.islogin = typeof options.islogin === 'boolean' ? options.islogin : false; /* this is used to prevent loop */
switch (options.contentType) {
case '':
case 'json':
options.contentType = 'application/json; charset=utf-8';
break;
case 'form':
options.contentType = 'application/x-www-form-urlencoded; charset=UTF-8';
break;
case 'multi':
options.contentType = 'multipart/form-data';
break;
case 'text':
options.contentType = 'text/plain; charset=UTF-8';
break;
/* default = leave as defined */
}
if (options.form instanceof jQuery) {
options.data = options.form.serializeObject();
options.contentType = 'form-data';
} else if (options.lzw instanceof jQuery) {
options.data.lzw = $.ccLZW(options.lzw.serializeAnything(true)).join(',');
}
var senddata;
if ((options.contentType.substr(0, 19) === 'multipart/form-data' || options.contentType.substr(0, 9) === 'form-data') && options.data instanceof FormData === false) {
options.contentType = false;
var fd = new FormData();
$.each(options.files || [], function (fi, file) {
fd.append('upload_file', file);
});
$.each(options.data || {}, function (di, dx) {
fd.append(di, dx);
});
options.data = fd;
options.processData = false;
} else if (options.data instanceof FormData) {
options.contentType = false;
options.processData = false;
}
var ajo = {
type: options.method || 'post',
url: options.url,
data: options.data,
processData: typeof options.processData !== 'boolean' ? true : options.processData,
contentType: options.contentType,
cache: options.cache || false,
timeout: options.timeout,
beforeSend: function (jqXHR) {
$(options.loading).ldng();
$('body').addClass('ldng');
if (typeof options.beforesend === 'function') { options.beforesend.apply(context, [jqXHR]); }
},
success: function (response, textStatus, jqXHR) {
if (response === 'false' || response === 'not authorized') {
if (typeof options.error === 'function') { options.error.apply(context, [jqXHR, textStatus, response]); }
if (typeof $.status === 'function') { $.status(textStatus + ' - ' + response); }
} else {
if (typeof options.success === 'function') { options.success.apply(context, [response, textStatus, jqXHR]); }
}
},
error: function (jqXHR, textStatus, response) {
$ocms.AjaxEX.call(jqXHR, textStatus);
if (options.url.indexOf('doc.ashx') !== -1 && options.url.indexOf('ftest') === -1) { return; }
if (jqXHR.status === 401 && jqXHR.internalCode === 111 && options.islogin === false && typeof $ocms.login.dlg === 'function') {
$ocms.login.dlg({ ajo: options });
} else if (textStatus === 'timeout' || jqXHR.status === 302) {
options.tryCount++;
if (options.tryCount <= options.retryLimit) {
/* try again */
$ocms.postXT(options);
return;
}
return;
}
/*if (typeof $.log === 'function' && (jqXHR.internalCode + '') !== '1101') { $.log('Server error: ' + jqXHR.logtext + '', 'error', options.url); }*/
if (typeof options.error === 'function') {
options.error.apply(context, [jqXHR, textStatus, response]);
} else if (typeof $ocms.failure === 'function') {
$ocms.failure.apply(context, [jqXHR]);
} else if (typeof $.status === 'function') {
$.status('Server error: ' + textStatus + ' - ' + response + '');
}
},
dataType: options.datatype || 'json',
complete: function (jqXHR, textStatus) {
if (typeof options.complete === 'function') { options.complete.apply(context, [jqXHR, textStatus]); }
$(options.loading).ldng(0);
$('body').removeClass('ldng');
let tm = $('body > .timer');
if (tm.length > 0) {
let cec = new Date(jqXHR.getResponseHeader('ocms_cec') || ''), cex = new Date(jqXHR.getResponseHeader('ocms_cex') || '');
if (cec.isValid() && cex.isValid()) {
let d = new Date(), dd = Math.abs(cex - cec);
d.setMilliseconds(d.getMilliseconds() + dd);
tm.data({ 'cex': d, 'ctt': dd });
$ocms.cex_timer();
}
}
},
context: context,
async: true
};
if (typeof options.sync === 'boolean') {
ajo.async = (options.sync === false);
}
if ((typeof options.contentType === 'boolean' ? options.contentType === false : false) === true) {
ajo.contentType = false; /* needed for file uploads */
}
$.ajax(ajo);
};
$ocms.cex_timer = function () {
if (!$ocms.cexi) {
$ocms.cexi = setInterval($ocms.cex_timer, 15000);
}
let tm = $('body > .timer'), c = tm.data('cex'), t = tm.data('ctt'), n = new Date();
if (c instanceof Date && c.isValid() && typeof t === 'number' && t > 0 && c > n) {
let p = (Math.abs(n - c) / t * 100);
tm.css('width', p.toString() + '%');
if (p < 98 && (!$ocms.cex_lp || Math.abs(n - $ocms.cex_lp) > 600000 )) {
$ocms.postXT({ url: $ocms.url('ping'), success: () => { $ocms.cex_lp = n; }, timeout: 5000, error: () => { }});
}
}
};
$ocms.vbl_send = function (ev) {
var options = ev.data || {};
if ((options.url || '') === '') { return; }
var frm = $('#contentframe form:first');
var postoptions = {
url: options.url, data: new FormData(), success: function (response) {
if (typeof options.success === 'function') { options.success(response); } else if (typeof options.success === 'string') { alert(options.success); }
}, error: function (jqXHR, textStatus, response) {
if (typeof options.error === 'function') { options.error(response); } else if (typeof options.error === 'string') { alert(options.error); }
}, complete: function () {
frm.ldng(0);
}
};
var valid = true;
frm.find('input').each(function () {
var t = $(this), nm = t.nza('name'), val = t.val(), req = $(this).prop('required') || false;
if (nm !== '') {
var tv = (val !== '' || req === false);
valid = valid && tv;
if (tv === true) {
postoptions.data.append(nm, val);
t[0].setCustomValidity('');
} else if ($(this).nza('ocms-nvnote') !== '') {
t[0].setCustomValidity($(this).nza('ocms-nvnote'));
}
}
});
if (valid === true) {
frm.ldng(1);
$ocms.postXT.call(this, postoptions);
}
};
(function ($) {
$.fn.nza = function (attributeName, alternative) {
var attr = $(this).attr(attributeName);
return (typeof attr !== 'undefined' && attr !== false) ? attr : (alternative || '');
};
$.fn.serializeObject = function (checkvalidity, options) {
var
rbracket = /\[\]$/,
rCRLF = /\r?\n/g,
rsubmitterTypes = /^(?:submit|button|image|reset|file)$/i,
rsubmittable = /^(?:input|select|textarea|keygen)/i,
rcheckableType = (/^(?:checkbox|radio)$/i);
options = options || {};
var typedvalues = bool(options.typedvalues, false);
var result = {}, c= $(this), inp = c.find(':input:not([nosend],[type="file"])').addBack(':input'), valid = true;
$.each(inp.not('.tinymce').get(), function (i, ii) {
var t = $(this), e = this, type = (this.type || '').toLowerCase(), req = t.prop('required') || false;
if ((e.name && !t.is(':disabled') && rsubmittable.test(e.nodeName) && !rsubmitterTypes.test(type)) === true) {
var val = t.val(), nme = e.name, dtf = t.nza('data-format').split(':'), pattern = t.nza('pattern') || '.*', cat = false;
if (rcheckableType.test(type) === true) {
val = e.checked ? (val !== '' ? val : 'true') : '';
}
if (dtf[0].substr(0, 4) === 'date' && dtf.length > 1) {
val = parseDt(val, dtf.slice(1).join(':')); /* should result in date object */
if (typeof val === 'boolean') {
val = null;
}
if (val === null && t.prop('type').substr(0, 4) === 'date' && isNaN(new Date(t.val())) === false) { /* is can be parsed by Date object */
val = new Date(t.val());
}
if (val instanceof Date === true && typeof val.getMonth === 'function') { /* if really a Date */
if (typedvalues === false) { val = fdt(val, dtf[0] === 'date' ? 'dts' : 'iso'); } /* if string result awaited, format to string */
} else {
val = null;
}
} else if (type === 'number' && typedvalues === true ) {
let v;
if (dtf[0] === 'integer') {
v = parseInt(val);
} else {
v = parseFloat(val);
}
val = isNaN(v) ? val : v;
}
if (req === true && ((val || '') === '' || (val.match(pattern) === null))) {
if (cat === false && bool(checkvalidity, false) === true) { e.setCustomValidity(t.nza('ocms-nvnote', $ocms.t.inv || 'Invalid field')); }
val = null;
} else if (cat=== false && bool(checkvalidity, false) === true) {
e.setCustomValidity('');
}
if (typeof val !=='undefined' && val !== null && typeof val === 'string') {
let node = result[nme];
if (typeof node !== 'undefined' && node !== null) {
if (Array.isArray(node)) {
node.push(val.replace(rCRLF, '\r\n'));
} else {
result[nme] = [node, val.replace(rCRLF, '\r\n')];
}
} else {
result[nme] = val.replace(rCRLF, '\r\n');
}
} else if (typeof val !== 'undefined' && val !== null) {
let node = result[nme];
if (typeof node !== 'undefined' && node !== null) {
if (Array.isArray(node)) {
node.push(val);
} else {
result[nme] = [node, val];
}
} else {
result[nme] = val;
}
} else {
valid = false;
}
}
});
inp.filter('.tinymce').each(function (ei, ex) {
var t = $(this), e = this, type = (this.type || '').toLowerCase(), req = t.prop('required') || false
try {
var te = tinymce.get($(ex).attr('id'));
if (te) {
var enm = $(ex).attr('name');
var val = te.getContent();
if (req === false || (val || '') !== '') {
result[enm] = val;
} else {
valid = false;
}
}
} catch (ee) { $.noop(); }
});
c.toggleClass('invalid', !valid);
return valid ? result : null;
};
$.fn.sendForm = function (url, success, options) {
var form = $(this);
options = options || {};
var postoptions = {
url: url, success: function (response) {
options.response = response;
if (typeof success === 'function') {
var _e = success(response);
}
form.closest('div.modal').remove();
}, error: function (jqXHR, textStatus, response) {
if (typeof options.error === 'function') { options.error.call(this, jqXHR); } else {
$ocms.failure.call(this, jqXHR);
}
}, complete: function () {
form.ldng(0);
if (typeof options.complete === 'function') { options.complete.call(this, jqXHR); }
}
};
var fle = form.find('input[type="file"]');
postoptions.data = new FormData();
if (fle.length > 0) {
$.each(fle[0].files, function (key, value) {
postoptions.data.append(key, value);
postoptions.data.append('file_lastmodified', $ocms.isodt(value.lastModifiedDate));
});
}
var formdata = form.serializeObject();
$.each(formdata || {}, function (di, dx) {
postoptions.data.append(di, dx);
});
form.ldng();
$ocms.postXT.call(this, postoptions);
};
$.fn.checkValidity = function () {
var t = $(this), valid = true;
t.each(function (i,e) {
valid = valid && e.checkValidity();
});
return valid;
};
$.fn.wrap = function (cls, attr) {
var t = $(this), n = $$.dc(cls).attr(attr || {}).insertAfter(t);
t.append(n);
return n;
};
})(jQuery);
$ocms.logout = function () {
$ocms.postXT({
url: $ocms.url('logout'), complete: function () { window.location.reload(); }
});
};
$ocms.login = {
send: function (e) {
e.preventDefault();
var f = $(this);
if (f.find('#dbtn-confirm').hasClass('disabled') === true) {
return false;
} else {
var qs = f.serializeObject();
qs.loginaccount = ne(qs.loginaccount, $ocms.auth.account || $ocms.auth.requestedaccount || '');
qs.loginaccount = ne(qs.loginaccount, $ocms.auth.account || $ocms.auth.requestedaccount || '');
if (ne(qs.loginaccount) === '' && bool($ocms.auth.accountrequired, true) === true ) {
alert($t.l16);
return false;
} else {
$ocms.postXT({ url: $ocms.url('login'), data: qs, success: function () { window.location.reload(); }});
return false;
}
}
}, uichange: function () {
let inp_ui = $(this), form = inp_ui.closest('form'), accountrequired = bool($ocms.auth.accountrequired, true);
let loginaccount = ne(form.find('[name="loginaccount"]').val(), $ocms.auth.account || $ocms.auth.requestedaccount || '');
if (loginaccount !== '' || accountrequired === false) {
var ul = form.find('[name="userlogin"]').empty().val('');
var un = form.find('[name="username"]').empty().val('');
var nsel = $('#dlg_userlogin_sel').empty().val('');
var ui = inp_ui.val() || '';
if (inp_ui.checkValidity() === false && ui === '') { return; }
var ftbl = inp_ui.closest('table').ldng();
$ocms.postXT.call(this, {
url: $ocms.url('auth'), data: { 'userinfo': ui, account: (loginaccount ||'') }, success: function (response, textStatus, jqXHR) {
if (response.length === 1) {
var sx = response[0];
ul.val(sx.login).change().attr('required', '').removeAttr('nosend');
un.val(sx.name).change().attr('required', '').show();
nsel.removeAttr('required').attr('nosend', '').hide();
} else if (response.length > 0) {
un.hide().removeAttr('required');
ul.removeAttr('required').attr('nosend', '');
if (nsel.length === 0) {
nsel = $('<select></select>').attr({ name: 'userlogin', size: response.length, id: 'dlg_userlogin_sel', class: 'form-control', required: '' }).css({ width: '100%', 'max-width': '100%', padding: '2px' }).insertAfter(un);
}
$.each(response, function (ni, sx) {
var io = $('<option></option>').attr({ value: sx.login, style: 'padding-top: 2px; padding-bottom: 5px;', 'border-bottom': '1px solid #EEE;' }).text(sx.name).appendTo(nsel);
if (ni % 2 === 0) { io.css({ 'background-color': '#F9F9F9' }); }
});
nsel.attr('required', '').removeAttr('nosend');
} else {
nsel.hide().attr('nosend', '');
un.attr('required', '').show();
ul.attr('required', '').removeAttr('nosend');
alert($t.l9);
}
}, error: function (jqXHR) {
$ocms.failure.call(this, jqXHR);
}, complete: function () {
ftbl.ldng(0);
}
});
} else {
alert($t.l18);
}
}, sendpassword: function (ev) {
var d = $('<div class="modal"><div class="modal-dialog in" style="height: 500px; width: 600px;"><div class="modal-content" style="height: auto;" novalidate="true"><div class="modal-header"><h3>Vereinsmanager</h3></div></div><div class="modal-close"></div><div class="modal-content"><form role="form"><div class="modal-header"><h3></h3></div><div class="modal-body"><div class="frm"><div class="form-body stacked"><div class="form-group"><div class="form-itm"><label for="dlg_lastname">Nachname<span class="ind_required">*</span></label></div><div class="form-itm"><input id="dlg_lastname" name="lastname" type="string" class="form-control" required=""></div></div><div class="form-group"><div class="form-itm"><label for="dlg_email">Email<span class="ind_required">*</span></label></div><div class="form-itm"><input id="dlg_email" name="email" pattern="[a-z0-9._%+-]+@[a-z0-9.-]+\\.[a-z]{2,}$" type="string" class="form-control" required=""></div></div></div></div></div><div class="modal-footer"><div class="note_required"><span class="ind_required">*</span><span>Eingabe erforderlich</span></div><button type="submit" class="btn confirm" role="confirm">Senden</button></div><div class="modal-note"></div></form></div></div></div>');
var fb = d.find('.form-body'), code = null;
d.find('form').submit(function (e) {
e.preventDefault();
var qs = $(this).serializeObject(true), s2 = code === null, u = s2 ?'spwc':'spw';
$ocms.postXT.call(this, {
url: $ocms.url(u), data: qs, complete: function () {
if (s2) {
fb.append('<div class="form-group"><div class="form-itm"></div><div class="form-itm">Ihnen wurde ein Code per SMS zugesandt. <br />Bitte tragen Sie den hier ein:</div></div>');
code = $('<div class="form-group"><div class="form-itm"><label for="dlg_code">SMS-Code<span class="ind_required">*</span></label></div><div class="form-itm"><input id="dlg_code" name="code" type="string" class="form-control" required></div></div>').appendTo(fb);
} else {
alert($t.l13);
d.remove();
}
}, error: () => { } /* prevent default */
});
return false;
});
d.find('.modal-close').click(function () {
d.remove();
});
var l17a = [];
$.each($t.l7a.split('\n'), (i, t) => {
Array.prototype.push.apply(l17a, [$('<br/>'), $('<span></span>').text(t)]);
});
d.find('.modal-note').append($('<span style="text-decoration: underline;"></span>').text($t.alert)).append(l17a);
d.appendTo('body');
setTimeout(function () {
$('.modal').find('input[name="lastname"]').focus();
}, 600);
}
};