PageSourceSearch

https://servicedesk.adult-empire.com/includes/jira/common/util.js

js adult-empire.com collected 2026-09-25 14:29:24 UTC 11,640 bytes, 364 lines download raw bytes

1(function () {
2  'use strict';
3
4  var Events = require('jira/util/events');
5  // Bind only the legacy so that the JIRA object doesn't implicitly get new methods.
6  AJS.namespace('JIRA.bind', null, Events.bind);
7  AJS.namespace('JIRA.unbind', null, Events.unbind);
8  AJS.namespace('JIRA.one', null, Events.one);
9  AJS.namespace('JIRA.trigger', null, Events.trigger);
10})();
11(function () {
12  'use strict';
13
14  var User = require('jira/util/users/logged-in-user');
15  AJS.namespace('JIRA.isAdmin', null, User.isAdmin);
16  AJS.namespace('JIRA.isSysadmin', null, User.isSysadmin);
17})();
18(function () {
19  'use strict';
20
21  var E = require('jira/util/elements');
22  AJS.namespace('AJS.elementIsFocused', null, E.elementIsFocused);
23  AJS.namespace('AJS.consumesKeyboardEvents', null, E.consumesKeyboardEvents);
24})();
25(function () {
26  'use strict';
27
28  var B = require('jira/util/browser');
29  AJS.namespace('AJS.canAccessIframe', null, B.canAccessIframe);
30  AJS.namespace('AJS.isSelenium', null, B.isSelenium);
31  AJS.namespace('AJS.reloadViaWindowLocation', null, B.reloadViaWindowLocation);
32  AJS.namespace('AJS.enableKeyboardScrolling', null, B.enableKeyboardScrolling);
33  AJS.namespace('AJS.disableKeyboardScrolling', null, B.disableKeyboardScrolling);
34})();
35(function () {
36  'use strict';
37
38  var O = require('jira/util/objects');
39  AJS.namespace("begetObject", window, O.begetObject);
40})();
41(function () {
42  'use strict';
43
44  var F = require('jira/util/forms');
45  AJS.namespace('submitOnEnter', window, F.submitOnEnter);
46  AJS.namespace('submitOnCtrlEnter', window, F.submitOnCtrlEnter);
47  AJS.namespace('getMultiSelectValues', window, F.getMultiSelectValues);
48  AJS.namespace('getMultiSelectValuesAsArray', window, F.getMultiSelectValuesAsArray);
49})();
50
51// Cookie handling functions
52(function () {
53  'use strict';
54
55  var Cookie = require('jira/data/cookie');
56  AJS.namespace('saveToConglomerateCookie', window, Cookie.saveToConglomerate);
57  AJS.namespace('readFromConglomerateCookie', window, Cookie.readFromConglomerate);
58  AJS.namespace('eraseFromConglomerateCookie', window, Cookie.eraseFromConglomerate);
59  AJS.namespace('getValueFromCongolmerate', window, Cookie.getValueFromCongolmerate);
60  AJS.namespace('addOrAppendToValue', window, Cookie.addOrAppendToValue);
61  AJS.namespace('getCookieValue', window, Cookie.getValue);
62  AJS.namespace('saveCookie', window, Cookie.save);
63  AJS.namespace('readCookie', window, Cookie.read);
64  AJS.namespace('eraseCookie', window, Cookie.erase);
65})();
66
67// This is here so that we find bugs like JRA-19245 ASAP
68jQuery.noConflict(); // eslint-disable-line no-undef
69jQuery.ajaxSettings.traditional = true; // eslint-disable-line no-undef
70
71/* eslint-disable */
72(function () {
73  'use strict';
74
75  var hasGlobalAlready = ('contextPath' in window);
76  if (!hasGlobalAlready) {
77    /**
78     * @deprecated Use require('wrm/context-path') instead.
79     * @notes We initially removed this, but it broke plugins and QUnit tests,
80     * because sometimes the head-common.jsp doesn't get included in the
81     * page decoration process, and that file's contextPath global isn't output.
82     */
83    AJS.namespace('contextPath', window, require('wrm/context-path')());
84  }
85})();
86/* eslint-enable */
87
88// constants
89(function () {
90  'use strict';
91
92  var LayerOptions = require('jira/ajs/layer/layer-constants');
93  AJS.namespace('AJS.LEFT', null, LayerOptions.LEFT);
94  AJS.namespace('AJS.RIGHT', null, LayerOptions.RIGHT);
95  AJS.namespace('AJS.ACTIVE_CLASS', null, LayerOptions.ACTIVE_CLASS);
96  AJS.namespace('AJS.BOX_SHADOW_CLASS', null, LayerOptions.BOX_SHADOW_CLASS);
97  AJS.namespace('AJS.LOADING_CLASS', null, LayerOptions.LOADING_CLASS);
98  AJS.namespace('AJS.INTELLIGENT_GUESS', null, LayerOptions.INTELLIGENT_GUESS);
99})();
100(function () {
101  'use strict';
102
103  var SPECIAL_CHARS = /[.*+?|^$()[\]{\\]/g;
104  // Note: This escapes str for regex literal sequences -- not within character classes
105  RegExp.escape = function (str) {
106    return str.replace(SPECIAL_CHARS, "\\$&");
107  };
108})();
109
110/**
111 * A bunch of useful utilitiy javascript methods available to all jira pages
112 */
113(function () {
114  'use strict';
115
116  var $ = require('jquery');
117  /**
118   * Reads data from a structured HTML, such as definition list and build a data object.
119   * Even children represent names, odd children represent values.
120   *
121   * @param {String} s jQuery selector
122   * @memberof external:jQuery
123   * @deprecated
124   */
125  $.readData = function (s) {
126    var r = {};
127    var n = "";
128    $(s).children().each(function (i) {
129      if (i % 2) {
130        r[n] = $.trim($(this).text());
131      } else {
132        n = $.trim($(this).text());
133      }
134    }).remove();
135    $(s).remove();
136    return r;
137  };
138})();
139
140/** @deprecated wat */
141String.prototype.escapejQuerySelector = function () {
142  'use strict';
143
144  return this.replace(/([:.])/g, "\\$1");
145};
146
147/**
148 * This function can extract the BODY tag text from a HttpRequest if its there are otherwise
149 * return all the response text.
150 *
151 * @param text the AJAX request text returned
152 */
153AJS.extractBodyFromResponse = function (text) {
154  'use strict';
155
156  var fragment = text.match(/<body[^>]*>([\S\s]*)<\/body[^>]*>/);
157  if (fragment && fragment.length > 0) {
158    return fragment[1];
159  }
160  return text;
161};
162AJS.isDevMode = function () {
163  'use strict';
164
165  return AJS.Meta.get("dev-mode");
166};
167(function () {
168  'use strict';
169
170  /**
171   * Tries to run a function and return its value and if it throws an exception, returns the default value instead
172   *
173   * @param f the function to try
174   * @param defaultVal the default value to return in case of an error
175   * @deprecated
176   */
177  function tryIt(f, defaultVal) {
178    try {
179      return f();
180    } catch (ex) {
181      return defaultVal;
182    }
183  }
184  AJS.namespace("tryIt", window, tryIt);
185})();
186(function () {
187  'use strict';
188
189  /**
190   * Returns true if the value has a truthy equivalent in the array.
191   * @deprecated use {@link jQuery.inArray}
192   */
193  function arrayContains(array, value) {
194    for (var i = 0, ii = array.length; i < ii; i++) {
195      if (array[i] == value) {
196        // eslint-disable-line eqeqeq
197        return true;
198      }
199    }
200    return false;
201  }
202  AJS.namespace("arrayContains", window, arrayContains);
203})();
204(function () {
205  'use strict';
206
207  var jQuery = require('jquery');
208
209  /** @deprecated use {@link jQuery.addClass} */
210  function addClassName(elementId, classNameToAdd) {
211    jQuery('#' + elementId).addClass(classNameToAdd);
212  }
213  /** @deprecated use {@link jQuery.addClass} */
214  AJS.namespace("addClassName", window, addClassName);
215
216  /** @deprecated use {@link jQuery.removeClass} */
217  function removeClassName(elementId, classNameToRemove) {
218    jQuery('#' + elementId).removeClass(classNameToRemove);
219  }
220  /** @deprecated use {@link jQuery.removeClass} */
221  AJS.namespace("removeClassName", window, removeClassName);
222})();
223(function () {
224  'use strict';
225
226  /**
227   * Returns the field as an encoded string (assuming that the id == the field name
228   * @deprecated since 6.2
229   */
230  function getEscapedFieldValue(id) {
231    var e = document.getElementById(id);
232    if (e.value) {
233      return id + '=' + encodeURIComponent(e.value);
234    } else {
235      return '';
236    }
237  }
238  AJS.namespace("getEscapedFieldValue", window, getEscapedFieldValue);
239
240  /**
241   * Returns a concatenated version of getEscapedFieldValue
242   * @deprecated since 6.2
243   */
244  function getEscapedFieldValues(ids) {
245    var s = '';
246    for (var i = 0; i < ids.length; i++) {
247      s = s + '&' + getEscapedFieldValue(ids[i]);
248    }
249    return s;
250  }
251  AJS.namespace("getEscapedFieldValues", window, getEscapedFieldValues);
252})();
253(function () {
254  'use strict';
255
256  var jQuery = require('jquery');
257  var Cookie = require('jira/data/cookie');
258
259  /* Manages Gui Preferences and stores them in the user's cookie. */
260  var GuiPrefs = {
261    toggleVisibility: function toggleVisibility(elementId) {
262      var elem = document.getElementById(elementId);
263      if (elem) {
264        if (Cookie.readFromConglomerateCookie("jira.conglomerate.cookie", elementId, '1') === '1') {
265          elem.style.display = "none";
266          jQuery('#' + elementId + 'header').removeClass('headerOpened').addClass('headerClosed');
267          Cookie.saveToConglomerateCookie("jira.conglomerate.cookie", elementId, '0');
268        } else {
269          elem.style.display = "";
270          jQuery('#' + elementId + 'header').removeClass('headerClosed').addClass('headerOpened');
271          Cookie.eraseFromConglomerateCookie("jira.conglomerate.cookie", elementId);
272        }
273      }
274    }
275  };
276  AJS.namespace("GuiPrefs", window, GuiPrefs);
277
278  /**
279   * Toggles hide / unhide an element. Also attemots to change the "elementId + header" element to have the headerOpened / headerClosed class.
280   * Also saves the state in a cookie
281   * @deprecated use @see GuiPrefs.toggleVisibility
282   */
283  function toggle(elementId) {
284    GuiPrefs.toggleVisibility(elementId);
285  }
286  AJS.namespace("toggle", window, toggle);
287})();
288(function () {
289  'use strict';
290
291  var jQuery = require('jquery');
292  var Cookie = require('jira/data/cookie');
293
294  /** @deprecated */
295  function toggleDivsWithCookie(elementShowId, elementHideId) {
296    var elementShow = document.getElementById(elementShowId);
297    var elementHide = document.getElementById(elementHideId);
298    if (elementShow.style.display === 'none') {
299      elementHide.style.display = 'none';
300      elementShow.style.display = 'block';
301      Cookie.saveToConglomerateCookie("jira.viewissue.cong.cookie", elementShowId, '1');
302      Cookie.saveToConglomerateCookie("jira.viewissue.cong.cookie", elementHideId, '0');
303    } else {
304      elementShow.style.display = 'none';
305      elementHide.style.display = 'block';
306      Cookie.saveToConglomerateCookie("jira.viewissue.cong.cookie", elementHideId, '1');
307      Cookie.saveToConglomerateCookie("jira.viewissue.cong.cookie", elementShowId, '0');
308    }
309  }
310  AJS.namespace("toggleDivsWithCookie", window, toggleDivsWithCookie);
311
312  /**
313   * Similar to toggle. Run this on page load.
314   * @deprecated
315   */
316  function restoreDivFromCookie(elementId, cookieName, defaultValue) {
317    if (defaultValue == null) {
318      defaultValue = '1';
319    }
320    var elem = document.getElementById(elementId);
321    if (elem) {
322      if (Cookie.readFromConglomerateCookie(cookieName, elementId, defaultValue) !== '1') {
323        elem.style.display = "none";
324        jQuery('#' + elementId + 'header').removeClass('headerOpened').addClass('headerClosed');
325      } else {
326        elem.style.display = "";
327        jQuery('#' + elementId + 'header').removeClass('headerClosed').addClass('headerOpened');
328      }
329    }
330  }
331  AJS.namespace("restoreDivFromCookie", window, restoreDivFromCookie);
332
333  /**
334   * Similar to toggle. Run this on page load.
335   * @deprecated
336   */
337  function restore(elementId) {
338    restoreDivFromCookie(elementId, "jira.conglomerate.cookie", '1');
339  }
340  AJS.namespace("restore", window, restore);
341})();
342
343// Table colouring functions
344(function () {
345  'use strict';
346
347  var TableUtils = require('jira/tables/legacy-table-utils');
348  AJS.namespace("recolourSimpleTableRows", window, TableUtils.recolourSimpleTableRows);
349  AJS.namespace("recolourTableRows", window, TableUtils.recolourTableRows);
350})();
351(function () {
352  'use strict';
353
354  var strings = require('jira/util/strings');
355  /** @deprecated use {@see module:jira/util/strings#escapeHtml} */
356  AJS.namespace("htmlEscape", window, strings.escapeHtml);
357  /** @deprecated use {@see module:jira/util/strings#escapeHtml} */
358  AJS.namespace('AJS.escapeHTML', null, strings.escapeHtml);
359})();
360(function () {
361  'use strict';
362
363  AJS.namespace("atl_token", window, require('jira/util/urls').atl_token);
364})();

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.