1window.issuelinksUtil = window.issuelinksUtil || {}; 2 3window.issuelinksUtil.showAjaxMessages = function showAjaxMessages(response) { 4 'use strict'; 5 6 let $msgArea; 7 if (jQuery('body.tpl_sprintdoc').length) { 8 $msgArea = jQuery('#dokuwiki__content').find('.msg-area'); 9 } else { 10 $msgArea = jQuery('#dokuwiki__content').find('> div').first(); 11 } 12 if (!Object.prototype.hasOwnProperty.call(response, 'msg')) { 13 $msgArea.prepend(jQuery('<div>').addClass('error').html(response)); 14 return; 15 } 16 const messages = response.msg; 17 if (!messages) { 18 return; 19 } 20 messages.forEach(function printMessagesToMessageArea(msg) { 21 $msgArea.prepend(jQuery('<div>').addClass(msg.lvl).html(msg.msg)); 22 }); 23}; 24 25window.issuelinksUtil.handleFailedAjax = function handleFailedAjax(jqXHR) { 26 'use strict'; 27 28 const HIGHEST_OK_STATUS = 206; 29 window.issuelinksUtil.showAjaxMessages(jqXHR.responseJSON); 30 if (jqXHR.status && jqXHR.status > HIGHEST_OK_STATUS) { 31 console.error(jqXHR.status + ' ' + jqXHR.statusText); 32 } 33}; 34 35