1$(document).ready(function() 2{ 3 // init hide message on enter 4 initHideMessageOnEnter(); 5 6 // init loader animation 7 initWidgetLoaderAnimation(); 8 9 // init widget calculation 10 initWidgetWidthCalculation(); 11 12 // init widget overview 13 initWidgetOverview(); 14}); 15 16function initWidgetErrorPopover(selector) 17{ 18 const popovers = document.querySelectorAll('[data-bs-toggle="popover"]'); 19 popovers.forEach(pover => { new bootstrap.Popover(pover, { html: true, trigger: 'hover click' } ); }); 20} 21function initAllWidgetErrorPopover() 22{ 23 /*placeholder for ax-war*/ 24} 25 26function initHideMessageOnEnter() 27{ 28 $(document).on('keypress', 'html', function(e) 29 { 30 if ((e.which && e.which == 13) || (e.keyCode && e.keyCode == 13)) 31 { 32 $('#cockpitMessageContainer,#cockpitErrorMessageContainer,#cockpitInfoMessageContainer').children('button[data-bs-dismiss="alert"]:visible').trigger('click'); 33 var selector = $('button[data-bs-dismiss="alert"]:visible'); 34 if(selector.length > 0) 35 { 36 selector.parent().parent().find('input').first().focus(); 37 selector.trigger('click'); 38 } 39 return false; 40 } 41 return true; 42 }); 43} 44 45function showCockpitError(message) 46{ 47 setTimeout(function(){$('#cockpitErrorMessageContainer').show().addClass('show').find('div').html(message);}, 100); 48} 49 50function hideCockpitError() 51{ 52 $('#cockpitErrorMessageContainer button').trigger('click'); 53} 54 55function showCockpitWarning(message) 56{ 57 setTimeout(function(){$('#cockpitWarningMessageContainer').show().addClass('show').find('div').html(message);}, 100); 58} 59 60function hideCockpitWarning() 61{ 62 $('#cockpitWarningMessageContainer button').trigger('click'); 63} 64 65function showCockpitInfo(message, disableAutoClose) 66{ 67 setTimeout(function(){$('#cockpitInfoMessageContainer').show().addClass('show').find('div').html(message);}, 100); 68 if (!disableAutoClose) { 69 setTimeout(function() {$('#cockpitInfoMessageContainer button').trigger('click');}, 10000); 70 } 71} 72 73function hideCockpitInfo() 74{ 75 $('#cockpitInfoMessageContainer button').trigger('click'); 76} 77 78function initWidgetWidthCalculation() 79{ 80 if($('.poco').length > 0) 81 { 82 calcWidthWidgetLayoutContainer(); 83 $(window).resize(function() 84 { 85 calcWidthWidgetLayoutContainer(); 86 }); 87 } 88} 89 90function initWidgetOverview() 91{ 92 $('.widget-container .miniature, .widget-container .miniature-label').click(function() 93 { 94 $('#widget-layout-container').addClass('widget-displayed'); 95 $(this).parent().addClass('regular-size'); 96 $('.widget-container').hide(); 97 98 }); 99 $('.widget-container .widget-close').click(function() 100 { 101 $(this).parents('.widget-container').removeClass('regular-size'); 102 $('#widget-layout-container').removeClass('widget-displayed'); 103 $('.widget-container').show(); 104 }); 105} 106 107 108 109/** 110 * Show widget content 111 */ 112function showWidgetContent(widgetId, prefix, details, notAvailableMessage) 113{ 114 $('#' + widgetId + 'WidgetLoader').fadeOut(250, function() 115 { 116 $('#' + widgetId + 'Widget').fadeIn(250, function() 117 { 118 $('#' + widgetId + 'Widget').addClass($('#' + widgetId + 'AdditionalClass').attr('class')); 119 }); 120 if (notAvailableMessage == undefined) 121 { 122 $('#' + widgetId + 'WidgetContent').addClass('d-md-block').removeClass('hide'); 123 $('#' + widgetId + 'Widget').find('.card-footer').addClass('d-md-block').removeClass('hide').detach().appendTo('#' + widgetId + 'Widget'); 124 } 125 else 126 { 127 $('#' + widgetId + 'WidgetNoData').find('.widget-loading-container').text(notAvailableMessage); 128 $('#' + widgetId + 'WidgetNoData').removeClass('hide'); 129 } 130 }); 131 if (details == undefined) 132 { 133 if ($('#' + widgetId + 'Content1').length > 0) 134 { 135 details = $('#' + widgetId + 'Content1').data('DETAILS') || $('#' + widgetId + 'Content1').hasClass('hasDetail
135s'); 136 } 137 else if ($('#' + widgetId + 'Content').length > 0) 138 { 139 details = $('#' + widgetId + 'Content').data('DETAILS') || $('#' + widgetId + 'Content').hasClass('hasDetails'); 140 } 141 else 142 { 143 details = false; 144 } 145 } 146 if(details) 147 { 148 $('#' + prefix + 'DetailsVisible').show(); 149 } 150 else 151 { 152 $('#' + prefix + 'DetailsVisible').hide(); 153 } 154} 155 156function handleWidgetErrors(id, data, callback) 157{ 158 var jsonData = jQuery.parseJSON(data.responseText); 159 if (jsonData.hasGlobalErrors) 160 { 161 var error = jsonData.globalerrors[0]; 162 163 // check if data context is not valid - a redirect is required 164 var redirectKey = "redirect:"; 165 if (error.substr(0, redirectKey.length) == redirectKey) 166 { 167 if (!errorsExists) 168 { 169 var targetUrl = error.substr(redirectKey.length, error.length - redirectKey.length); 170 window.location.replace(targetUrl); 171 } 172 showWidgetNoData(id); 173 return; 174 } 175 176 // check if import is running 177 var importKey = 'importInProcess'; 178 if (error.substr(0, importKey.length) == importKey) 179 { 180 var counter = $('#' + id + 'Widget').data('runCount'); 181 counter++; 182 $('#' + id + 'Widget').data('runCount', counter); 183 if (counter < 20) 184 { 185 setTimeout(function(){callback();},2000); 186 } 187 } 188 189 // check if no data available or max run count reached 190 var noDataKeyKey = 'noDataAvailable'; 191 if (error.substr(0, noDataKeyKey.length) == noDataKeyKey || counter >= 20) 192 { 193 showWidgetNoData(id); 194 } 195 return; 196 } 197} 198 199function showWidgetInfo(id, message) 200{ 201 showWidgetMessage(id, 'info', message); 202} 203 204function showWidgetWarning(id, message) 205{ 206 showWidgetMessage(id, 'warning', message); 207} 208 209function showWidgetError(id, message) 210{ 211 showWidgetMessage(id, 'error', message); 212} 213 214function showWidgetMessage(id, type, message) 215{ 216 var containsLink = (message.indexOf('<a') > -1) && (message.indexOf('href') > -1) && (message.indexOf('</a>') > -1); 217 var widgetForm = $('#' + id + 'Widget form'); 218 var messageTitle = null; 219 if (type == 'info') 220 { 221 messageTitle = infoTitle; 222 } 223 else if (type == 'warning') 224 { 225 messageTitle = warningTitle; 226 } 227 else 228 { 229 messageTitle = errorTitle; 230 } 231 widgetForm.append('<div id="' + id + 'Message" class="alert alert-' + (type == 'error' ? 'danger' : 'info') + ' fade ' + (containsLink ? '' : 'alert-dismissible') + '">' 232 + '<button type="button" class="btn-close fa fa-times" data-bs-dismiss="alert" title="'+buttonCloseTitle+'"></button>' 233 + '<h3 class="alert-heading">' + messageTitle + '</h3>' 234 + '<div>' + message + '</div></div>'); 235 setTimeout(function (){$('#' + id + 'Message').addClass('show');}, 100); 236} 237 238function hideWidgetMessage(id) 239{ 240 $('#' + id + 'Message').remove(); 241} 242 243function showWidgetFieldError(id, message, focus) 244{ 245 var field = $('#' + id); 246 field.addClass('alert-danger') 247 var inputGroup = null; 248 if (field.parent().hasClass('form-floating')) 249 { 250 inputGroup = field.parent().parent(); 251 } 252 else 253 { 254 inputGroup = field.parent(); 255 } 256 inputGroup.parent().find('span.alert-info').remove(); 257 inputGroup.addClass('input-group').find('label,input').addClass('alert-danger'); 258 inputGroup.append('<span class="input-group-text alert-danger" data-bs-toggle="popover"' + 259 'data-bs-custom-class="alert-danger" data-bs-html="true" data-bs-content="' + message + '"><i class="fa fa-question-circle"></i></span>'); 260 initWidgetErrorPopover(field); 261 if (focus == undefined || focus) 262 { 263 focusFirstInputError(); 264 } 265} 266 267function resetWidgetErrors() 268{ 269 $('div.alert-danger').remove(); 270 $('input').each(function() 271 { 272 if ($(this).hasClass('alert-danger')) 273 { 274 var inputGroup = null; 275 if ($(this).parent().hasClass('form-floating')) 276 { 277 inputGroup = $(this).removeClass('alert-danger').parent().parent(); 278 } 279 else 280 { 281 inputGroup = $(this).removeClass('alert-danger').parent(); 282 } 283 if (!inputGroup.hasClass('password-show-hide')) 284 { 285 inputGroup.removeClass('input-group'); 286 } 287 inputGroup.find('span').remove(); 288 $(this).parent().find('label').removeClass('alert-danger'); 289 } 290 }); 291} 292 293/** 294 * Show widget no Data 295 */ 296function showWidgetNoData(widgetId) 297{ 298 $('#' + widgetId + 'WidgetLoader').fadeOut(250, function() 299 { 300 $('#' + widgetId + 'WidgetNoData').fadeIn(250); 301 }); 302} 303 304var submittedButtonCaption = null; 305var submittedButtonLoadingHandler = null; 306var preloadingErrorHandler = null; 307 308function showWidgetButtonLoader(selector, widgetId, delay) 309{ 310 submittedButtonCaption = $(selector).html(); 311 window.setTimeout(function(){_showWidgetButtonLoader(selector, widgetId, delay);}); 312} 313 314function _showWidgetButtonLoader(selector, widgetId, delay) 315{ 316 submittedButtonLoadingHandler = loaderAnimation(selector, submittedButtonLoadingHandler); 317 318 if(delay != undefined) 319 { 320 preloadingErrorHandler = window.setInterval(function() 321 { 322 hideWidgetButtonLoader(selector);
323 showWidgetError(widgetId,generalNoResponseMessage); 324 window.clearInterval(preloadingErrorHandler); 325 }, delay); 326 } 327} 328 329function hideWidgetButtonLoader(selector) 330{ 331 clearInterval(submittedButtonLoadingHandler); 332 window.clearInterval(preloadingErrorHandler); 333 $(selector).html(submittedButtonCaption); 334 submittedButtonCaption = null; 335} 336 337var widgetLoaderAnimationHandler = null; 338 339function initWidgetLoaderAnimation() 340{ 341 loaderAnimation($(".loading-dots"), widgetLoaderAnimationHandler); 342} 343 344function isWidgetSubmitAllowed() 345{ 346 return submittedButtonCaption == null; 347} 348 349function initRunCount(widgetId) 350{ 351 $('#' + widgetId + 'Widget').data('runCount', 0); 352} 353 354function getRunCount(widgetId) 355{ 356 return $('#' + widgetId + 'Widget').data('runCount'); 357} 358 359function populateWidget(name, prefix, model, populate) 360{ 361 // extract template from DOM and append to body 362 var templateDetached = $('#' + name + 'Template').last().detach(); 363 templateDetached.appendTo('body'); 364 365 if (model.hasOwnProperty('subElements')) 366 { 367 jQuery.each(model.subElements, function(index, element) 368 { 369 // populate template 370 var template = populate(name, prefix, model, element, index + 1, templateDetached); 371 372 // move template to slider position 373 if (index == 0) 374 { 375 template.removeClass('hide'); 376 } 377 378 // store information about showing details as class 379 if(template.data('DETAILS') != undefined && template.data('DETAILS')) 380 { 381 template.addClass('hasDetails'); 382 } 383 384 template.find('div, span, p').removeAttr('id'); 385 $('#' + name + 'Wrapper').append(template); 386 }); 387 388 // init switcher and swiper 389 if (model.subElements.length > 1) 390 { 391 var subElementCount = model.subElements.length; 392 var swiper = initWidgetSwiper(name, subElementCount); 393 initSwitch(name, subElementCount, swiper); 394 } 395 } 396 else 397 { 398 // populate template 399 var template = populate(name, prefix, model, templateDetached); 400 401 template.removeClass('hide'); 402 403 // store information about showing details as class 404 if(template.data('DETAILS') != undefined && template.data('DETAILS')) 405 { 406 template.addClass('hasDetails'); 407 } 408 409 template.find('div, span, p').removeAttr('id'); 410 $('#' + name + 'Wrapper').append(template); 411 } 412 413 // WORKARROUND: reinit tooltips at last 414 initTooltip(); 415} 416 417var switchLocked = false; 418function initSwitch(name, size, swiper) 419{ 420 $('#' + name + 'SwitchMax').attr('data-widget-switch-max', size); 421 422 $('#' + name + 'Switch').find('span.current-switch').each(function() 423 { 424 $(this).html($(this).attr('data-widget-switch-min')); 425 }); 426 $('#' + name + 'Switch').find('span.total-switch').each(function() 427 { 428 $(this).html($(this).attr('data-widget-switch-max')); 429 }); 430 $('#' + name + 'Switch').find('span.content-switch-prev').click(function(e){ 431 if (!switchLocked) 432 { 433 e.stopPropagation(); 434 /*switchLocked = true; 435 if (isTouchSwiperSupported() && swiper) 436 { 437 swiper.swipePrev(); 438 switchLocked = false; 439 } 440 else 441 { 442 switchContent(name, size, swiper, false); 443 }*/ 444 switchContent(name, size, swiper, false); 445 } 446 }); 447 $('#' + name + 'Switch').find('span.content-switch-next').click(function(e){ 448 if (!switchLocked) 449 { 450 e.stopPropagation(); 451 /*switchLocked = true; 452 if (isTouchSwiperSupported() && swiper) 453 { 454 swiper.swipeNext(); 455 switchLocked = false; 456 } 457 else 458 { 459 switchContent(name, size, swiper, true); 460 }*/ 461 switchContent(name, size, swiper, true); 462 } 463 });
464 $('#' + name + 'Switch').show(); 465} 466 467function switchContent(name, size, swiper, next) 468{ 469 var currentPosition = parseInt($('#' + name + 'SwitchCurrent').text()); 470 var currentContent = $('#' + name + 'Content' + currentPosition); 471 472 var nextPosition = null; 473 if (next && currentPosition == size) 474 { 475 nextPosition = 1; 476 } 477 else if (!next && currentPosition == 1) 478 { 479 nextPosition = size; 480 } 481 else if (next) 482 { 483 nextPosition = currentPosition + 1; 484 } 485 else 486 { 487 nextPosition = currentPosition - 1; 488 } 489 $('#' + name + 'SwitchCurrent').text(nextPosition); 490 var nextContent = $('#' + name + 'Content' + nextPosition); 491 if(nextContent.data('DETAILS') != undefined || nextContent.hasClass('hasDetails')) 492 { 493 if(nextContent.data('DETAILS') || nextContent.hasClass('hasDetails')) 494 { 495 $('#' + name + 'Details').show().trigger('change'); 496 } 497 else 498 { 499 $('#' + name + 'Details').hide().trigger('change'); 500 } 501 } 502 /*if (!isTouchSwiperSupported() || !swiper) 503 {*/ 504 currentContent.fadeOut(250, function() 505 { 506 nextContent.css('display', 'flex'); 507 nextContent.fadeIn(250, function(){switchLocked = false; nextContent.removeClass('hide'); }); 508 }); 509 /*}*/ 510} 511 512function isTouchSwiperSupported() 513{ 514 return typeof Swiper != 'undefined' && Swiper != null; 515} 516 517function initWidgetSwiper(name, size) { 518 519 var widgetSwiperContainer = $('#' + name + 'WidgetContent'); 520 if (widgetSwiperContainer) 521 { 522 // add required class structure and make all sliding elements visible to let the swiper framework handle their visibility 523 widgetSwiperContainer.addClass('swiper-container'); 524 widgetSwiperContainer.find('#' + name + 'Wrapper').addClass('swiper-wrapper'); 525 let widgetContents = widgetSwiperContainer.find('.swiper-wrapper [id^=' + name + 'Content]'); 526 widgetContents.addClass('swiper-slide'); 527 widgetContents.first().show(); 528 529 if (isTouchSwiperSupported() && widgetSwiperContainer.find('.swiper-slide').length > 0) { 530 var theSwiper = widgetSwiperContainer.swipe( { 531 //Generic swipe handler for all directions 532 swipe:function(event, direction, distance, duration, fingerCount, fingerData) { 533 if(direction == 'left'){ 534 switchContent(name, size, theSwiper, false); 535 } 536 else if(direction == 'right'){ 537 switchContent(name, size, theSwiper, true); 538 } 539 }, 540 //Default is 75px, set to 0 for demo so any distance triggers swipe 541 threshold:0 542 }); 543 /*var theSwiper = widgetSwiperContainer.swiper({ 544 mode: 'horizontal', 545 loop: true, 546 grabCursor: true, 547 onSlideNext: function () { 548 switchContent(name, size, theSwiper, true); 549 }, 550 onSlidePrev: function () { 551 switchContent(name, size, theSwiper, false); 552 } 553 }); 554*/ 555 // FIX: get rid of IDs of duplicated first and last swiping-element that come from swiper-frameworks-loop-mechanism 556 widgetSwiperContainer.find('.swiper-wrapper .swiper-slide-duplicate').removeAttr('id'); 557 558 return theSwiper; 559 } 560 } 561} 562 563//---------------------------------------------------------------------------------------------------------------------- 564 565(function($) 566{ 567 jQuery.fn.showWidgetButtonLoader = function(widgetId,delay) 568 { 569 showWidgetButtonLoader($(this), widgetId, delay); 570 }; 571 572 jQuery.fn.hideWidgetButtonLoader = function(widgetId) 573 { 574 hideWidgetButtonLoader($(this), widgetId); 575 }; 576 577 jQuery.fn.disableProcessLink = function(infoText) 578 { 579 $(this).each(function() 580 { 581 $(this).addClass('btn-inactive'); 582 var infoIcon = $(this).next(); 583 infoIcon.attr('data-content', infoText); 584 infoIcon.show(); 585 infoIcon.popover({ 586 trigger: 'hover', 587 placement: 'topRight' 588 }); 589 $(this).click(function() 590 { 591 return false; 592 }); 593 }); 594 }; 595 596 jQuery.fn.openDetails = function(processLink, processBefore) 597 { 598 $(this).each(function() 599 { 600 $(this).click(function() 601 { 602 var link = null; 603 if(processBefore != undefined ) 604 { 605 window.location.href = processBefore(processLink); 606 } 607 else 608 { 609 window.location.href = processLink; 610 } 611 return false; 612 }); 613 }); 614 }; 615})(jQuery); 616 617// --------------------------------------------------------------------------------------------------------------------- 618 619function calcWidthWidgetLayoutContainer() 620{ 621 var widthOfMain = parseInt(getWidthOfElement('#main')) - parseInt($('#widget-layout-container').css('padding-left')) 622 - parseInt($('#widget-layout-container').css('padding-right')); 623 var widthOfWidget = parseInt($('.widget-container').outerWidth(true)); 624 var countWidgets = $('.widget-container').length; 625 626 if( (widthOfMain/widthOfWidget) < countWidgets ) 627 { 628 $('#widget-layout-container').css({ 629 'width': (( parseInt( (widthOfMain / widthOfWidget) )) * widthOfWidget) + parseInt($('#widget-layout-container') 630 .css('padding-left')) + parseInt($('#widget-layout-container').css('padding-right')) + 'px' 631 }); 632 } 633 else 634 { 635 $('#widget-layout-container').css({ 636 'width': (countWidgets * widthOfWidget) + parseInt($('#widget-layout-container') 637 .css('padding-left')) + parseInt($('#widget-layout-container').css('padding-right')) + 'px' 638 }); 639 } 640 if( $('body').outerWidth(true) > 650 ) 641 { 642 $('#widget-layout-container').removeClass('widget-displayed'); 643 $('.widget-container').removeClass('regular-size').show(); 644 } 645} 646 647// ---------------------------------------------------------------------------------------------------------------------
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.