1 2//js that includes the basic functionality to load Components asyncronously 3var replaceComponentCount = 0; 4var replaceComponentCountSinceLastSecond = 0; 5var replaceComponentMaxPerSecond = 50; //set to negative value to set no max 6 7setInterval(function(){ 8 var tmp___ = replaceComponentCountSinceLastSecond; 9 replaceComponentCountSinceLastSecond = 0; 10 if(tmp___ >= replaceComponentMaxPerSecond * 0.9) { 11 htmlChanged(); 12 } 13}, 1000); 14 15var replaceComponentShowresultParam = "____showresult"; 16var replaceComponentAjaxParam = "____ajax"; 17 18 19function createComponent(options, tag) { 20 var selfClosingTags = ["area", "base", "br", "col", "embed", "hr", "img", "input", "link", "meta", "param", "source", "track", "wbr", "command", "keygen", "menuitem"]; 21 var outputstring = "<" + tag + " data-component "; 22 for (var k in options) { 23 if (options.hasOwnProperty(k)) { 24 outputstring += "data-" + k + "=\"" + options[k] + "\" "; 25 } 26 } 27 //console.log(outputstring); 28 if(selfClosingTags.indexOf(tag) >= 0) { 29 outputstring += "/>"; 30 } 31 else { 32 outputstring += "></" + tag + ">"; 33 } 34 return outputstring; 35} 36 37function replaceLazyComponents() { 38 $("[data-lazycomponent]:not(.componentLoading, .componentLoadingFailed)").each(function(){ 39 if($(this).isInViewport()) { 40 $(this).attr("data-component", ""); 41 $(this).removeAttr("data-lazycomponent"); 42 htmlChanged(); 43 } 44 }); 45} 46$(window).on("load resize scroll",replaceLazyComponents); 47 48 49function replaceComponents() { 50 //function that searches for all unreplaced components 51 //first check for ajaxcomponents 52 $("[data-ajaxcomponent]:not(.componentLoading, .componentLoadingFailed)").each(function(){ 53 $(this).attr("data-component", ""); 54 $(this).removeAttr("data-ajaxcomponent"); 55 }); 56 57 58 $("[data-component]:not(.componentLoading, .componentLoadingFailed)").each(function(){ 59 if(replaceComponentMaxPerSecond >= 0 && replaceComponentCountSinceLastSecond <= replaceComponentMaxPerSecond) { 60 var selfComponent = this; 61 replaceComponent(selfComponent, {}, false); 62 } 63 else { 64 console.log(replaceComponentCountSinceLastSecond+" components were loaded asyncronously since last second. that is a bit much (limit should be "+replaceComponentMaxPerSecond+") the remaining components should be loaded in the next second."); 65 } 66 }); 67} 68 69var replaceComponentReturnvalues = {}; 70function replaceComponent(selfComponent, postdata, afterReplaceCallback) { 71 replaceComponentCount++; 72 replaceComponentCountSinceLastSecond++; 73 //function that replaces a specific unreplaced component 74 if(typeof selfComponent == "string") { 75 //selfComponent is a jquery Selector -> make object 76 $(selfComponent).each(function(){ 77 replaceComponent(this, postdata, afterReplaceCallback) 78 }); 79 return; 80 } 81 $(selfComponent).addClass("componentLoading"); 82 var selfPosition = $(selfComponent).css("position"); 83 if(selfPosition != "relative" && selfPosition != "absolute" && selfPosition != "fixed") { 84 if($(selfComponent).parents('.echoverlay-inner-wrap').length == 0){ 85 $(selfComponent).css("position", "relative"); 86 } 87 } 88 $(selfComponent).append('<span class="componentIcon componentIcon-load"></span>'); 89 var data = {}; 90 $.each(selfComponent.attributes, function(i, attrib){ 91 if (attrib.name.substring(0, 5) == "data-") { 92 data[attrib.name] = attrib.value; 93 } 94 }); 95 var getString = window.location.search.split("?"); 96 if(getString[1] !== undefined) { 97 var getParams = getString[1].split("&"); 98 for (var i = 0; i < getParams.length; i++) { 99 var thisParam = getParams[i].split("="); 100 if((thisParam[0] != replaceComponentShowresultParam && thisParam[0] != replaceComponentAjaxParam) && data[thisParam[0]] == undefined) { 101 data[thisParam[0]] = (thisParam[1] === undefined ? "" : thisParam[1]); 102 } 103 } 104 } 105 var ajaxParams = "?"; 106 for (var k in data) { 107 if (data.hasOwnProperty(k) && data[k] != "{}") { 108 ajaxParams += k + "=" + data[k] + "&"; 109 } 110 } 111 ajaxParams += replaceComponentAjaxParam + "=1"; 112 //console.log(systemConfiguration.path_component + "resources/replaceComponents.php"+ajaxParams); 113 //console.log(systemConfiguration.protocol + "://" + systemConfiguration._site_url + "/" + systemConfiguration.path_component + "resources/replaceComponents.php"+ajaxParams); 114 //console.log(location.protocol); 115 var ajaxObj = { 116 url: systemConfiguration.path_component + "resources/replaceComponents.php"+ajaxParams, 117 cache: false, 118 data: postdata, 119 type: "POST", 120 success: function(returnval){ 121 if(returnval.returnvalues !== undefined && typeof returnval.returnvalues == 'object') { 122 for (var k in returnval.returnvalues){ 123 if (returnval.returnvalues.hasOwnProperty(k)) { 124 replaceComponentReturnvalues[k] = returnval.returnvalues[k]; 125 } 126 } 127 replaceComponentReturnvalues = returnval.returnvalues; 128 } 129 if(returnval.location !== undefined ) { 130 window.location.replace(returnval.location); 131 } 132 else if(returnval.html !== undefined && returnval.dependencies !== undefined) { 133 //$(selfComponent).replaceWith(returnval.html); //replaced with replaceAll to get new Element as return 134 var replaced = $(returnval.html).replaceAll(selfComponent); 135 /*if(replaced.attr("data-reload") != undefined && replaced.attr("data-reload") == 1){ 136 /*var options = {"component": ""}; 137 $.each(replaced.data(),function(i,v){ 138 if(i != "reload"){ 139 options[i] = v; 140 } 141 }); 142 var newc = createComponent(options, "div"); 143 replaced = $(replaced).replaceWith($(newc)); 144 location.reload(); 145 }*/
146 //now check for autofocus inputs in new html and autofocus them 147 var autofocusinputs = replaced.find("input[autofocus], select[autofocus], button[autofocus], textarea[autofocus]"); 148 if(autofocusinputs.length > 0) { 149 autofocusinputs.first().focus(); 150 } 151 for (var cat in returnval.dependencies) { 152 if (returnval.dependencies.hasOwnProperty(cat)) { 153 var catdependencies = returnval.dependencies[cat]; 154 155 //add the dependecies in reverse order 156 var arr = []; 157 for (var key in catdependencies) { 158 if (catdependencies.hasOwnProperty(key)) { 159 arr.push(key); 160 } 161 } 162 for (var i=arr.length-1; i>=0; i--) { 163 var dependencyurl = arr[i]; 164 if (catdependencies.hasOwnProperty(dependencyurl)) { 165 var dependentComponents = catdependencies[dependencyurl]; 166 var functionname = "addDependency_" + cat; 167 if (typeof window[functionname] === "function") { 168 window[functionname](dependencyurl, dependentComponents); 169 } 170 } 171 } 172 } 173 } 174 htmlChanged(); 175 176 } 177 else { 178 componentError(selfComponent, "async-replaceComponent-invalid", {}); 179 } 180 181 if(typeof afterReplaceCallback == "function") { 182 afterReplaceCallback(); 183 } 184 $(window).trigger("resize"); //to trigger rerender of various things such as masonry grid... 185 }, 186 error: function(XMLHttpRequest, textStatus, errorThrown) { 187 componentError(selfComponent, "async-replaceComponent-failed", {"textStatus": textStatus, "errorThrown": errorThrown}); 188 }, 189 complete: function(XMLHttpRequest, textStatus){ 190 completed = 1; 191 } 192 }; 193 if(postdata instanceof FormData) { 194 ajaxObj.contentType = false;
195 ajaxObj.processData = false; 196 } 197 $.ajax(ajaxObj); 198 199} 200 201function componentError(selfComponent, errortype, erroroptions) { 202 //function that throws an error on a specific component - loading the error asyncronously from componentError.php/html if possible 203 var data = {}; 204 for (var erroroption in erroroptions) { 205 if (erroroptions.hasOwnProperty(erroroption)) { 206 data[erroroption] = erroroptions[erroroption]; 207 } 208 } 209 data.type = errortype; 210 data["iconOnly"] = "1"; 211 data[replaceComponentAjaxParam] = "1"; 212 $.ajax({ 213 url: systemConfiguration.path_component + "resources/componentError.php", 214 cache: true, 215 data: data, 216 type: "GET", 217 success: function(returhtml){ 218 $(selfComponent).removeClass("componentLoading"); 219 $(selfComponent).addClass("componentLoadingFailed"); 220 $(selfComponent).find(".componentIcon").remove(); 221 $(selfComponent).append(returhtml); 222 htmlChanged(); 223 }, 224 error: function(XMLHttpRequest, textStatus, errorThrown) { 225 $(selfComponent).removeClass("componentLoading"); 226 $(selfComponent).addClass("componentLoadingFailed"); 227 $(selfComponent).find(".componentIcon").remove(); 228 $(selfComponent).append('<span class="componentIcon componentIcon-error"></span>'); 229 htmlChanged(); 230 } 231 }); 232} 233 234function addDependency_css(url, dependentComponents) { 235 236 //function that adds a CSS Dependency and completes dependentcomponents Information in case that dependency is already loaded 237 var url_with_resource_param = url + ((url.indexOf("?") !== -1) ? "&" : "?")+"version="+resource_param; 238 239 var existing = $('link[href="' + url + '"], link[href="' + url_with_resource_param + '"]'); 240 if(existing.length == 0) { 241 $('link[data-componentdependencies]').each(function(){ 242 var componentdependencies = JSON.parse($(this).attr("data-componentdependencies")); 243 if((url in componentdependencies)) { 244 existing = $(this); 245 } 246 }); 247 } 248 249 if(existing.length > 0) { 250 for (var k in dependentComponents) { 251 if (dependentComponents.hasOwnProperty(k)) { 252 if(existing.attr("data-componentdependencies") != undefined) { 253 var componentdependencies = JSON.parse(existing.attr("data-componentdependencies")); 254 if(componentdependencies[url].indexOf(dependentComponents[k]) == -1) { 255 componentdependencies[url].push(dependentComponents[k]); 256 existing.attr("data-componentdependencies", JSON.stringify(componentdependencies)); //json HTML Encoded 257 } 258 } 259 else { 260 if(existing.attr("data-dependentcomponents").indexOf(dependentComponents[k]) == -1) { 261 existing.attr("data-dependentcomponents", existing.attr("data-dependentcomponents") + " " + depen
261dentComponents[k]); 262 } 263 } 264 } 265 } 266 } 267 else { 268 var dependentComponentsString = ""; 269 for (var k in dependentComponents) { 270 if (dependentComponents.hasOwnProperty(k)) { 271 if(dependentComponentsString.length > 0) { 272 dependentComponentsString += " "; 273 } 274 dependentComponentsString += dependentComponents[k]; 275 } 276 } 277 $("head").append('<link href="' +url_with_resource_param + '" rel="stylesheet" type="text/css" media="all" data-dependentcomponents="' + dependentComponentsString + '">'); 278 } 279} 280 281function addDependency_js(url, dependentComponents) { 282 //function that adds a JS Dependency and completes dependentcomponents Information in case that dependency is already loaded 283 var url_with_resource_param = url + ((url.indexOf("?") !== -1) ? "&" : "?")+"version="+resource_param; 284 285 var existing = $('script[src="' + url + '"], script[src="' + url_with_resource_param + '"]'); 286 if(existing.length == 0) { 287 $('script[data-componentdependencies]').each(function(){ 288 var componentdependencies = JSON.parse($(this).attr("data-componentdependencies")); 289 if((url in componentdependencies)) { 290 existing = $(this); 291 } 292 }); 293 } 294 295 if(existing.length > 0) { 296 for (var k in dependentComponents) { 297 if (dependentComponents.hasOwnProperty(k)) { 298 if(existing.attr("data-componentdependencies") != undefined) { 299 var componentdependencies = JSON.parse(existing.attr("data-componentdependencies")); 300 if(componentdependencies[url].indexOf(dependentComponents[k]) == -1) { 301 componentdependencies[url].push(dependentComponents[k]); 302 existing.attr("data-componentdependencies", JSON.stringify(componentdependencies)); //json HTML Encoded 303 } 304 } 305 else { 306 if(existing.attr("data-dependentcomponents").indexOf(dependentComponents[k]) == -1) { 307 existing.attr("data-dependentcomponents", existing.attr("data-dependentcomponents") + " " + depen
307dentComponents[k]); 308 } 309 } 310 } 311 } 312 } 313 else { 314 var dependentComponentsString = ""; 315 for (var k in dependentComponents) { 316 if (dependentComponents.hasOwnProperty(k)) { 317 if(dependentComponentsString.length > 0) { 318 dependentComponentsString += " "; 319 } 320 dependentComponentsString += dependentComponents[k]; 321 } 322 } 323 $("head").append('<script type="text/javascript" src="' +url_with_resource_param + '" data-dependentcomponents="' + dependentComponentsString + '"></' + 'script>'); 324 } 325} 326 327function initComponentForms() { 328 //function that adds submit event listeners to componentForms that do not have these listeners yet 329 $("form[data-componentform]:not(.componentform-initialized)").each(function(){ 330 $(this).addClass("componentform-initialized"); 331 $(this).on("submit", function(event){ 332 event.preventDefault(); 333 var target = this; 334 if($($(this).attr("data-componentform")).length > 0) { 335 target = $($(this).attr("data-componentform"))[0]; 336 } 337 var postdata = new FormData(this); 338 339 var afterReplaceCallback = false; 340 341 var rdt_configmap_id = $(this).attr("data-componentform-rdt_configmap_id"); 342 var rdt_config_id = $(this).parents('.adminForm').attr('data-rdt_config_id'); 343 var action = $(this).parents('.adminForm').attr('data-action'); 344 345 if(rdt_configmap_id != undefined && rdt_config_id != undefined) { 346 347 afterReplaceCallback = function(){ 348 map_refresh(rdt_configmap_id, rdt_config_id, replaceComponentReturnvalues,action); 349 }; 350 } 351 var callback_refresh = $(this).attr("data-componentform-callback-refresh"); 352 if(callback_refresh != undefined && afterReplaceCallback == false) { 353 354 /** 355 * data-componentform-callback-refresh takes a jQery Selector that can target other components that should be loaded again 356 * for example if you add a image you may want to refresh the image list 357 * */ 358 afterReplaceCallback = function(){ 359 $(callback_refresh).each(function(){ 360 replaceComponent(this, {}, false); 361 }); 362 }; 363 } 364 replaceComponent(target, postdata, afterReplaceCallback,""); 365 }); 366 }); 367} 368 369function testComponents() { 370 // function that lets us test all of the components individually (without taking post data into account) 371 // is meant to be called using the console 372 // if styling of a component is off it might miss dependecies 373 $("#testComponents").remove(); 374 $("[data-componentname][data-componentcollection]").each(function(){ 375 var selfComponent = this; 376 testComponent(selfComponent); 377 }); 378} 379 380function testComponent(selfComponent) { 381 var data = {}; 382 $.each(selfComponent.attributes, function(i, attrib){ 383 if (attrib.name.substring(0, 5) == "data-") { 384 data[attrib.name] = attrib.value; 385 } 386 }); 387 var getString = window.location.search.split("?"); 388 if(getString[1] !== undefined) { 389 var getParams = getString[1].split("&"); 390 for (var i = 0; i < getParams.length; i++) { 391 var thisParam = getParams[i].split("="); 392 data[thisParam[0]] = (thisParam[1] === undefined ? "" : thisParam[1]); 393 } 394 } 395 var ajaxParams = "?"; 396 for (var k in data) { 397 if (data.hasOwnProperty(k)) { 398 ajaxParams += k + "=" + data[k] + "&"; 399 } 400 } 401 ajaxParams += replaceComponentShowresultParam + "=1"; 402 var url = systemConfiguration.path_component + "resources/replaceComponents.php"+ajaxParams 403 addTestComponentLink(url, (data["data-componentname"] ? data["data-componentname"] : "component")); 404} 405 406function addTestComponentLink(url, name) { 407 if($("#testComponents").length == 0) { 408 $("body").append('<div id="testComponents" style="position: fixed; top: 0px; left: 0px; bottom: 0px; right: 0px; background-color: #FFFFFF; color: #333333; z-index: 2147483647;"></div>'); 409 $("#testComponents").append('<button type="button" onclick="$(\'#testComponents\').remove();" style="float: right; margin: 20px; ">
409testComponents schlieÃen</button>'); 410 $("#testComponents").append('<ul id="testComponentsList"></ul>'); 411 } 412 $("#testComponentsList").append('<li><a href="' + url + '" target="_blank">' + name + '</a></li>'); 413} 414 415if(typeof $.fn.isInViewport == "undefined") { 416 $.fn.isInViewport = function () { // function that detects if object is visible to the user (for example used for lazycomponents that load only when visible to the user) 417 var KelementTop = $(this).offset().top; 418 var KelementBottom = KelementTop + $(this).outerHeight(); 419 var KviewportTop = $(window).scrollTop(); 420 var KviewportBottom = KviewportTop + $(window).height(); 421 return (KelementBottom > KviewportTop && KelementTop < KviewportBottom) && $(this).is(":visible"); 422 }; 423} 424 425 426//systemConfiguration loads essential parts of the configuration.php file to be usable in JS 427var systemConfiguration = {"path_admin":"\/_admin\/","path_assets":"\/_assets\/","path_component":"\/_component\/","path_library":"\/_lib\/","path_media":"\/_media\/","path_tools":"\/_tools\/","path_templates":"\/_tpl\/","locktimeout":150,"path_upload":"\/srv\/www\/www.akzent.at\/home\/","_site_id":1,"protocol":"https","_site_url":"akzent.at"}; 428 429var devmode = false;
430if(devmode) { 431 console.info("in order to test all components individually call \"testComponents();\" in your JS Console and use the appearing UI."); 432} 433 434var resource_param = '2026-09-10_10:24:13'; 435 436(function() { 437 438 addHtmlChanged('replaceLazyComponents'); 439 addHtmlChanged('replaceComponents'); 440 addHtmlChanged('initComponentForms'); 441})();
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.