1function getThisLocation() { 2 var thisUrl = top.location.href; 3 if (thisUrl.indexOf( "mykanzlei.comesio.solutions" ) >= 0) { 4 return "backend"; 5 } else { 6 return "frontend"; 7 } 8} 9 10function getDetail(url, responseNode, agencyHash, src_keys, tar_keys, trigger_functions = null) { 11 12 if (getThisLocation() == "backend") { 13 return; 14 } 15 16 let cachedData = sessionStorage.getItem(url + '-' + agencyHash); 17 if (!cachedData) { 18 $.ajax({ 19 url: './wso2/' + url + '?agency_hash=' + agencyHash, 20 //url: testurl + url + '?agency_hash=' + agencyHash, 21 headers: { 22 'Content-Type': 'application/json' 23 }, 24 success: function (responseModules) { 25 for (var prop in responseModules) { 26 27 if (responseNode.split('.')[0] == prop) { 28 29 var this_obj = responseModules[prop]; 30 31 for (const [db_key, db_value] of Object.entries(this_obj)) { 32 var i = 0; 33 if (typeof db_value === 'object' && db_value !== null) { 34 if (responseNode.split('.')[1] == db_key) { 35 //console.log(db_value[0]); 36 for (const [sdb_key, sdb_value] of Object.entries(db_value[0])) { 37 var x = 0; 38 src_keys.forEach(function(src_key){ 39 if (src_key == sdb_key) { 40 $('#'+tar_keys[x]).val(sdb_value); 41 } 42 x++; 43 }); 44 } 45 } 46 } else { 47 src_keys.forEach(function(src_key){ 48 if (src_key == db_key) { 49 $('#'+tar_keys[i]).val(db_value); 50 } 51 i++; 52 }); 53 } 54 } 55 } 56 } 57 } 58 }); 59 60 } else { 61 62 responseModules = JSON.parse(cachedData); 63 for (var prop in responseModules) { 64 65 if (responseNode.split('.')[0] == prop) { 66 var this_obj = responseModules[prop]; 67 68 for (const [db_key, db_value] of Object.entries(this_obj)) { 69 var i = 0; 70 if (typeof db_value === 'object' && db_value !== null) { 71 if (responseNode.split('.')[1] == db_key) { 72 for (const [sdb_key, sdb_value] of Object.entries(db_value[0])) { 73 var x = 0; 74 src_keys.forEach(function(src_key){ 75 if (src_key == sdb_key) { 76 $('#'+tar_keys[x]).val(sdb_value); 77 } 78 x++; 79 }); 80 } 81 } 82 } else { 83 src_keys.forEach(function(src_key){ 84 if (src_key == db_key) { 85 $('#'+tar_keys[i]).val(db_value); 86 } 87 i++; 88 }); 89 } 90 } 91 } 92 } 93 } 94 95 if (trigger_functions) { 96 trigger_functions.forEach(function(function_name) { 97 eval(function_name+"()"); 98 }); 99 } 100} 101 102function loadAndReplaceWithOptions( 103 url, 104 responseNode, 105 agencyHash, 106 parentElementKey, 107 templateKey, 108 contentKeys, 109 contentFormatter = null, 110 count = null, 111 optionKeys = null, 112 optionValues = null, 113 return_message = null 114) { 115 116 if (getThisLocation() == "backend") { 117 return; 118 } 119 120 let this_url = './wso2/' + url + '?agency_hash=' + agencyHash; 121 122 if (optionKeys) { 123 let opt_string = "?"; 124 125 opt_string += 'filter_keys=' + optionKeys; 126 opt_string += '&filter_values=' + optionValues; 127 opt_string += '&agency_hash=' + agencyHash; 128 129 this_url = './wso2/' + url + opt_string; 130 } 131 132 function showEmptyState() { 133 134 $('.jobs-headline').hide(); 135 136 $('#show_jobs').html( 137 '<div><p style="color:var(--col_primary);font-style: italic;">Derzeit haben wir keine offenen Stellen ausgeschrieben.</p></div>' 138 ); 139 140 $('.infoBox-placeholder-news').hide(); 141 142 $('#show_news').html( 143 '<div class="alert alert-warning mt-3" role="alert">' + 144 'Aktuell verfügen wir über <strong>keine News</strong> auf unserer Webseite.' + 145 '</div>' 146 ); 147 } 148 149 $.ajax({ 150 url: this_url, 151 headers: { 152 'Content-Type': 'application/json' 153 }, 154 155 success: function (responseModules) { 156 157 let data = responseModules; 158 159 // JSON-Safety 160 if (typeof data === "string") { 161 try { 162 data = JSON.parse(data); 163 } catch (e) { 164 data = null; 165 } 166 } 167 168 // ROBUSTER EMPTY-CHECK 169 const isEmpty = 170 !data || 171 (Array.isArray(data) && data.length === 0) || 172 (typeof data === "object" && !Array.isArray(data) && Object.keys(data).length === 0); 173 174 if (isEmpty) { 175 showEmptyState(); 176 return; 177 } 178 179 sessionStorage.setItem( 180 url + '-' + agencyHash, 181 JSON.stringify(responseModules) 182 ); 183 184 handleResponse( 185 url, 186 responseModules, 187 responseNode, 188 templateKey, 189 contentKeys, 190 parentElementKey, 191 contentFormatter, 192 count, 193 return_message 194 ); 195 196 if (typeof return_message === "function") { 197 return_message(responseModules, responseNode, parentElementKey); 198 } 199 }, 200 201 statusCode: { 202 404: function () { 203 showEmptyState(); 204 } 205 } 206 }); 207} 208 209function loadAndReplace(url, responseNode, agencyHash, parentElementKey, templateKey, contentKeys, contentFormatter = null, count = null) { 210 211 if (getThisLocation() == "backend") { 212 return; 213 } 214 215 const cacheKey = url + '-' + agencyHash;
216 let cachedData = sessionStorage.getItem(cacheKey); 217 218 // Zentraler Empty-State 219 function showEmptyState() { 220 221 $('.jobs-headline').hide(); 222 223 $('#show_jobs').html( 224 '<div><p style="color:var(--col_primary);font-style: italic;">Derzeit haben wir keine offenen Stellen ausgeschrieben.</p></div>' 225 ); 226 227 $('.infoBox-placeholder-news').hide(); 228 229 $('#show_news').html( 230 '<div class="alert alert-warning mt-3" role="alert">' + 231 'Aktuell verfügen wir über <strong>keine News</strong> auf unserer Webseite.' + 232 '</div>' 233 ); 234 } 235 236 if (!cachedData) { 237 238 $.ajax({ 239 url: './wso2/' + url + '?agency_hash=' + agencyHash, 240 headers: { 241 'Content-Type': 'application/json' 242 }, 243 244 success: function (responseModules) { 245 246 let data = responseModules; 247 248 // JSON-Sicherheitsparsing 249 if (typeof data === "string") { 250 try { 251 data = JSON.parse(data); 252 } catch (e) { 253 data = null; 254 } 255 } 256 257 // Empty-Prüfung 258 const isEmpty = 259 !data || 260 (Array.isArray(data) && data.length === 0) || 261 (typeof data === "object" && !Array.isArray(data) && Object.keys(data).length === 0) || 262 (data.jobs && Array.isArray(data.jobs) && data.jobs.length === 0) || 263 (data.news && Array.isArray(data.news) && data.news.length === 0); 264 265 if (isEmpty) { 266 showEmptyState(); 267 return; 268 } 269 270 sessionStorage.setItem(cacheKey, JSON.stringify(responseModules)); 271 272 handleResponse( 273 url, 274 responseModules, 275 responseNode, 276 templateKey, 277 contentKeys, 278 parentElementKey, 279 contentFormatter, 280 count 281 ); 282 }, 283 284 statusCode: { 285 404: function () { 286 showEmptyState(); 287 } 288 } 289 }); 290 291 } else { 292 handleResponse( 293 url, 294 JSON.parse(cachedData), 295 responseNode, 296 templateKey, 297 contentKeys, 298 parentElementKey, 299 contentFormatter, 300 count 301 ); 302 } 303} 304 305function handleResponse(url, responseModules, responseNode, templateKey, contentKeys, parentElementKey, contentFormatter = null, count = null, return_message = null) { 306 307 if ($.type(responseModules) == "object") { 308 } else { 309 if (responseModules.indexOf( '<html lang="de" class="be-light-mode">' ) >= 0) { 310 return; 311 } 312 } 313 314 let responseData = responseNode !== false ? getProperty(responseNode, responseModules) : responseModules; 315 316 if (!responseData) { 317 if (return_message) { 318 $(parentElementKey).append(return_message); 319 } 320 return; 321 } 322 323 if (contentFormatter) { 324 responseData = contentFormatter(responseData); 325 } 326 327 if (responseData) { 328 $('.infoBox-placeholder-news').hide(); 329 $('.infoBox-placeholder-events').hide(); 330 $('.infoBox-placeholder-kontakt').hide(); 331 $('.infoBox-placeholder-imprint').hide(); 332 $('.infoBox-placeholder-contactdetails').hide(); 333 $('.infoBox-placeholder-dsgvo').hide(); 334 } 335 336 if (responseData) { 337 const startIndex = sessionStorage.getItem(url + '_current_index_' + responseNode) ?? 0; 338 let lastIndex = count ? count + parseInt(startIndex) : responseData.length; 339 340 lastIndex = lastIndex > responseData.length ? responseData.length : lastIndex; 341 342 sessionStorage.setItem(url + '_current_index_' + responseNode, lastIndex); 343 //$('#' + responseNode + '_current_index').val(lastIndex); 344 345 for (let i = startIndex; i < lastIndex; i++) { 346 let content = responseData[i]; 347 let contentTemplate = $('#' + templateKey).html(); 348 349 for (const item of contentKeys) { 350 const regex = new RegExp('{{' + item + '}}', 'g'); 351 const propertyName = getRealContentKey(item); 352 const modifier = getModifier(item); 353 contentTemplate = contentTemplate.replace(regex, getPropertyValue(content, propertyName, modifier)); 354 } 355 356 $(parentElementKey).append(contentTemplate); 357 } 358 359 } 360} 361 362function loadDetails(id, url, contentItemKey, agencyHash, contentKeys, responseNode, templateKey, contentElementKey, callback = null) { 363 364 if (getThisLocation() == "backend") { 365 return; 366 } 367
368 let cachedData = sessionStorage.getItem(url + '-' + agencyHash); 369 370 var loadAPI = false; 371 var item_id = id; 372 if (cachedData) { 373 const data = getProperty(responseNode, JSON.parse(cachedData)); 374 const item = findItem(id, contentItemKey, data); 375 if (item === null) { 376 loadAPI = true; 377 } 378 379 } 380 381 if (!item_id) { var item_id = ""; } 382 383 if ((!cachedData) || (loadAPI == true)) { 384 $.ajax({ 385 url: './wso2/' + url + '?agency_hash=' + agencyHash + '&item_id=' + item_id, 386 headers: { 387 'Content-Type': 'application/json' 388 }, 389 success: function (responseModules) { 390 sessionStorage.setItem(url + '-' + agencyHash, JSON.stringify(responseModules)); 391 const data = getProperty(responseNode, responseModules); 392 393 if (!data) { 394 return; 395 } 396 397 const item = findItem(id, contentItemKey, data); 398 //handleDetails(item, contentKeys, templateKey, contentKeys, contentElementKey, callback); 399 handleDetails(item, contentKeys, templateKey, contentElementKey, callback); 400 } 401 }); 402 } else { 403 const data = getProperty(responseNode, JSON.parse(cachedData)); 404 405 if (!data) { 406 return; 407 } 408 409 const item = findItem(id, contentItemKey, data); 410 if (item === null) { 411 412 } 413 414 handleDetails(item, contentKeys, templateKey, contentElementKey, callback); 415 } 416} 417 418function handleDetails(contentItem, contentKeys, templateKey, contentElementKey, callback=null) { 419 let contentTemplate = $('#' + templateKey).html(); 420 421 for (const item of contentKeys) { 422 const regex = new RegExp('{{' + item + '}}', 'g'); 423 const propertyName = getRealContentKey(item); 424 const modifier = getModifier(item); 425 426 let value = getPropertyValue(contentItem, propertyName, modifier); 427 428 // NULL/undefined abfangen 429 if (value === null || value === undefined) { 430 value = ""; 431 } 432 433 contentTemplate = contentTemplate.replace(regex, value); 434 } 435 436 $(contentElementKey).append(contentTemplate); 437 438 if (callback) { 439 callback(contentItem); 440 } 441} 442 443function findItem(id, contentItemKey, contentItems) { 444 for (const item of contentItems) { 445 if (item[contentItemKey] === id) { 446 return item; 447 } 448 } 449 450 return null; 451} 452 453function getPropertyValue(contentItem, propertyName, modifier) { 454 let value = contentItem[propertyName]; 455 456 if (modifier === 'date') { 457 return value.split(' ').shift(); 458 } 459 460 if (modifier === 'hour') { 461 return value.split(' ').pop(); 462 } 463 464 return value; 465} 466 467function getModifier(contentKey) { 468 if (contentKey.indexOf(':') === -1) { 469 return null; 470 } 471 472 return contentKey.split(':').pop(); 473} 474 475function getRealContentKey(contentKey) { 476 return contentKey.split(':').shift(); 477} 478 479function getProperty( propertyName, object ) { 480 if (!object || isObjectEmpty(object)) { 481 return null; 482 } 483 var parts = propertyName.split( "." ), 484 length = parts.length, 485 i, 486 property = object || this; 487 488 for ( i = 0; i < length; i++ ) { 489 property = property[parts[i]]; 490 } 491 492 return property; 493} 494 495function isObjectEmpty(value) { 496 return ( 497 Object.prototype.toString.call(value) === '[object Object]' && 498 JSON.stringify(value) === '{}' 499 ); 500}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.