Total Complexity | 8 |
Complexity/F | 2.67 |
Lines of Code | 33 |
Function Count | 3 |
Duplicated Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | window.magicMatcherUtil = window.magicMatcherUtil || {}; |
||
2 | |||
3 | window.magicMatcherUtil.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 | |||
25 | window.magicMatcherUtil.handleFailedAjax = function handleFailedAjax(jqXHR) { |
||
26 | 'use strict'; |
||
27 | |||
28 | var HIGHEST_OK_STATUS = 206; |
||
29 | window.magicMatcherUtil.showAjaxMessages(jqXHR.responseJSON); |
||
30 | if (jqXHR.status && jqXHR.status > HIGHEST_OK_STATUS) { |
||
31 | console.error(jqXHR.status + ' ' + jqXHR.statusText); |
||
32 | } |
||
33 | }; |
||
34 | |||
35 |