PageSourceSearch

https://www.bciburke.com/DesktopModules/DnnSharp/Common/static/dnnsf/dnnsf.js?cdv=386

js bciburke.com collected 2026-09-24 11:59:08 UTC 35,313 bytes, 876 lines download raw bytes

1;
2/*
3 * DnnSF (DNN Sharp Foundation)
4 */
5(function (window) {
6    try {
7        new MouseEvent('test');
8        return false; // No need to polyfill
9    } catch (e) {
10        // Need to polyfill - fall through
11        var MouseEvent = function (eventType, params) {
12            params = params || { bubbles: false, cancelable: false };
13            var mouseEvent = document.createEvent('MouseEvent');
14            mouseEvent.initMouseEvent(eventType, params.bubbles, params.cancelable, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
15            return mouseEvent;
16        }
17        MouseEvent.prototype = Event.prototype;
18        window.MouseEvent = MouseEvent;
19    }
20    // Polyfills DOM4 MouseEvent
21})(window);
22
23if (typeof (dnnsfjQuery) == 'undefined') dnnsfjQuery = jQuery || $;
24
25/*yepnope1.5.x|WTFPL*/
26(function (a, b, c) { function d(a) { return "[object Function]" == o.call(a) } function e(a) { return "string" == typeof a } function f() { } function g(a) { return !a || "loaded" == a || "complete" == a || "uninitialized" == a } function h() { var a = p.shift(); q = 1, a ? a.t ? m(function () { ("c" == a.t ? B.injectCss : B.injectJs)(a.s, 0, a.a, a.x, a.e, 1) }, 0) : (a(), h()) : q = 0 } function i(a, c, d, e, f, i, j) { function k(b) { if (!o && g(l.readyState) && (u.r = o = 1, !q && h(), l.onload = l.onreadystatechange = null, b)) { "img" != a && m(function () { t.removeChild(l) }, 50); for (var d in y[c]) y[c].hasOwnProperty(d) && y[c][d].onload() } } var j = j || B.errorTimeout, l = b.createElement(a), o = 0, r = 0, u = { t: d, s: c, e: f, a: i, x: j }; 1 === y[c] && (r = 1, y[c] = []), "object" == a ? l.data = c : (l.src = c, l.type = a), l.width = l.height = "0", l.onerror = l.onload = l.onreadystatechange = function () { k.call(this, r) }, p.splice(e, 0, u), "img" != a && (r || 2 === y[c] ? (t.insertBefore(l, s ? null : n), m(k, j)) : y[c].push(l)) } function j(a, b, c, d, f) { return q = 0, b = b || "j", e(a) ? i("c" == b ? v : u, a, b, this.i++, c, d, f) : (p.splice(this.i++, 0, a), 1 == p.length && h()), this } function k() { var a = B; return a.loader = { load: j, i: 0 }, a } var l = b.documentElement, m = a.setTimeout, n = b.getElementsByTagName("script")[0], o = {}.toString, p = [], q = 0, r = "MozAppearance" in l.style, s = r && !!b.createRange().compareNode, t = s ? l : n.parentNode, l = a.opera && "[object Opera]" == o.call(a.opera), l = !!b.attachEvent && !l, u = r ? "object" : l ? "script" : "img", v = l ? "script" : u, w = Array.isArray || function (a) { return "[object Array]" == o.call(a) }, x = [], y = {}, z = { timeout: function (a, b) { return b.length && (a.timeout = b[0]), a } }, A, B; B = function (a) { function b(a) { var a = a.split("!"), b = x.length, c = a.pop(), d = a.length, c = { url: c, origUrl: c, prefixes: a }, e, f, g; for (f = 0; f < d; f++) g = a[f].split("="), (e = z[g.shift()]) && (c = e(c, g)); for (f = 0; f < b; f++) c = x[f](c); return c } function g(a, e, f, g, h) { var i = b(a), j = i.autoCallback; i.url.split(".").pop().split("?").shift(), i.bypass || (e && (e = d(e) ? e : e[a] || e[g] || e[a.split("/").pop().split("?")[0]]), i.instead ? i.instead(a, e, f, g, h) : (y[i.url] ? i.noexec = !0 : y[i.url] = 1, f.load(i.url, i.forceCSS || !i.forceJS && "css" == i.url.split(".").pop().split("?").shift() ? "c" : c, i.noexec, i.attrs, i.timeout), (d(e) || d(j)) && f.load(function () { k(), e && e(i.origUrl, h, g), j && j(i.origUrl, h, g), y[i.url] = 2 }))) } function h(a, b) { function c(a, c) { if (a) { if (e(a)) c || (j = function () { var a = [].slice.call(arguments); k.apply(this, a), l() }), g(a, j, b, 0, h); else if (Object(a) === a) for (n in m = function () { var b = 0, c; for (c in a) a.hasOwnProperty(c) && b++; return b }(), a) a.hasOwnProperty(n) && (!c && !--m && (d(j) ? j = function () { var a = [].slice.call(arguments); k.apply(this, a), l() } : j[n] = function (a) { return function () { var b = [].slice.call(arguments); a && a.apply(this, b), l() } }(k[n])), g(a[n], j, b, n, h)) } else !c && l() } var h = !!a.test, i = a.load || a.both, j = a.callback || f, k = j, l = a.complete || f, m, n; c(h ? a.yep : a.nope, !!i), i && c(i) } var i, j, l = this.yepnope.loader; if (e(a)) g(a, 0, l, 0); else if (w(a)) for (i = 0; i < a.length; i++) j = a[i], e(j) ? g(j, 0, l, 0) : w(j) ? B(j) : Object(j) === j && h(j, l); else Object(a) === a && h(a, l) }, B.addPrefix = function (a, b) { z[a] = b }, B.addFilter = function (a) { x.push(a) }, B.errorTimeout = 1e4, null == b.readyState && b.addEventListener && (b.readyState = "loading", b.addEventListener("DOMContentLoaded", A = function () { b.removeEventListener("DOMContentLoaded", A, 0), b.readyState = "complete" }, 0)), a.yepnope = k(), a.yepnope.executeStack = h, a.yepnope.injectJs = function (a, c, d, e, i, j) { var k = b.createElement("script"), l, o, e = e || B.errorTimeout; k.src = a; for (o in d) k.setAttribute(o, d[o]); c = j ? h : c || f, k.onreadystatechange = k.onload = function () { !l && g(k.readyState) && (l = 1, c(), k.onload = k.onreadystatechange = null) }, m(function () { l || (l = 1, c(1)) }, e), i ? k.onload() : n.parentNode.insertBefore(k, n) }, a.yepnope.injectCss = function (a, c, d, e, g, i) { var e = b.createElement("link"), j, c = i ? h : c || f; e.href = a, e.rel = "stylesheet", e.type = "text/css"; for (j in d) e.setAttribute(j, d[j]); g || (n.parentNode.insertBefore(e, n), m(c, 0)) } })(this, document);
27
28// fix IE console issues
29if (!window.console) window.console = {};
30if (!window.console.log) window.console.log = function () { };
31
32var dnnsf = dnnsf || {};
33
34// copy state into dnnsf
35if (typeof g_dnnsfState != 'undefined')
36    for (var key in g_dnnsfState)
37        dnnsf[key] = g_dnnsfState[key];
38
39// extend with common functions
40dnnsf.init = function ($, appState) {
41    // save dnnsfjQuery object for future use
42    dnnsf.$ = $;
43    if (!window.dnnsfjQuery)
44        window.dnnsfjQuery = $;
45    if (!window.jQuery)
46        window.jQuery = $;
47
48    // execute the initialization code when done loading
49    (function (fn) {
50        if ($.isReady) fn(); else $(fn);
51    })(function () {
52
53        // if we're in an iframe, hide the scrollbar of current window and rely on auto-height featre
54        if (window.top != window && window.location.href.indexOf('isAdminIframe=true') != -1) {
55            $('body').css('overflow', 'hidden').attr('scroll', 'no');
56        }
57
58    });
59};
60
61// returns a query string parameter by name
62dnnsf.urlParam = function (name) {
63    var results = new RegExp('[\\?&]' + name + '=([^&#]*)').exec(decodeURIComponent(window.location.href));
64    if (!results) { return 0; }
65    return results[1] || 0;
66};
67
68dnnsf.parseQueryString = function (queryString) {
69    var qs = {},
70        match,
71        pl = /\+/g, // Regex for replacing addition symbol with a space
72        search = /([^&=]+)=?([^&]*)/g,
73        decode = function (s) { return decodeURIComponent(s.replace(pl, " ")); },
74        query = (queryString.indexOf('?') == 0 ? queryString.substring(1) : queryString);
75
76    if (query.indexOf('#') != -1)
77        query = query.substring(0, query.indexOf('#'));
78    while (match = search.exec(query))
79        qs[decode(match[1])] = decode(match[2]);
80    return qs;
81};
82
83dnnsf.updateQueryStringParam = function (key, value) {
84    var baseUrl = [location.protocol, '//', location.host, location.pathname].join(''),
85        urlQueryString = document.location.search,
86        newParam = key + '=' + value,
87        params = '?' + newParam;
88
89    // If the "search" string exists, then build params from it
90    if (urlQueryString) {
91        keyRegex = new RegExp('([\?&])' + key + '[^&]*');
92
93        // If param exists already, update it
94        if (urlQueryString.match(keyRegex) !== null) {
95            params = urlQueryString.replace(keyRegex, "$1" + newParam);
96        } else { // Otherwise, add it to end of query string
97            params = urlQueryString + '&' + newParam;
98        }
99    }
100    history.pushState({}, "", baseUrl + params + location.hash);
101};
102
103dnnsf.urlParams = {};
104(window.onpopstate = function () {
105    dnnsf.urlParams = dnnsf.parseQueryString(window.location.search);
106})();
107
108dnnsf.getUrlParts = function (url) {
109    var a = document.createElement('a');
110    a.href = url;
111    var path = a.pathname || '/';
112    if (path[0] != '/')
113        path = '/' + path;
114
115    return {
116        href: a.href,
117        host: a.host,
118        hostname: a.hostname,
119        port: a.port,
120        pathname: path,
121        protocol: a.protocol,
122        hash: a.hash,
123        search: a.search,
124        query: dnnsf.parseQueryString(a.search),
125        relativeUrl: path + a.search + a.hash,
126
127        getUrl: function () {
128            return this.pathname + ($.isEmptyObject(this.query) ? '' : '?' + $.param(this.query)) + this.hash;
129        }
130    };
131}
132
133// this scrolls the page to given scroll, taking into account offset and iframe communication when applicable
134dnnsf.scrollTo = function (scroll) {
135
136    if (isNaN(parseInt(scroll)))
137        return;
138
139    if (window.top != window) {
140        // post to top window
141        window.top.postMessage(JSON.stringify({
142            type: dnnsf.urlParam('comm-prefix') + "-scroll",
143            offset: scroll
144        }), "*");
145    } else {
146        // scroll this window
147        $('html, body').animate({
148            scrollTop: scroll
149        }, 500);
150    }
151
152};
153
154dnnsf.initStickyLoading = function (mid) {
155    var context = {
156        timeOutVar: null,
157        parent: $('#' + mid),
158        el: $('#' + mid + ' .common-data-loading'),
159        el2: $('#' + mid + ' .common-loading-text')
160    };
161
162    var elOffset = 0;
163    if (context.el.parent().height() <= 270) {
164        // put the loading animation in the middle of the container if it's height is small.
165        elOffset = context.el.parent().height() / 2 - context.el.height() / 2;
166    } else {
167        // put the loading animation 200px from the top of the container if it's height can accommodate the loader.
168        elOffset = 200;
169    }
170    var el2Offset = elOffset + 50;
171    context.el.css("top", elOffset + 'px');
172    context.el2.css("top", el2Offset + 'px');
173
174    $(window).off('scroll', onWindowScroll).on('scroll', context, onWindowScroll);
175}
176
177function onWindowScroll(event) {
178    var context = event.data;
179
180    clearTimeout(context.timeOutVar);
181    context.timeOutVar = setTimeout(function () {
182        if (context.parent.offset && window.pageYOffset > context.parent.offset().top) {
183            var top = window.pageYOffset - context.parent.offset().top + 200;
184            context.el.fadeOut(0)
185                .css({ "top": top + "px" })
186                .fadeIn(300);
187            context.el2.fadeOut(0)
188                .css({ "top": 50 + top + "px" })
189                .fadeIn(300);
190        }
191        else {
192            context.el.css({ "top": '200px' });
193            context.el2.css({ "top": "250px" });
194        }
195    }, 500);
196};
197
198// always use this logging function since it will take care of disabling the logging on production 
199//   and also it measures execution time (not very precisely though)
200dnnsf.log = function () {
201    if (!this.isDebug || !window.console || !console.log)
202        return;
203
204    // append timestamp to list of arguments
205    var args = Array.prototype.slice.call(arguments);
206    args.push(new Date().getTime() - this.start);
207
208    // call the broser logging function
209    // TODO: in IE objects are no expanded, instead IE will show [Object object] string
210    // it would be useful to do a JSON.stringify on IE
211    Function.apply.call(console.log, console, args);
212};
213
214dnnsf.canAccessIFrame = function (ifr) {
215    var key = (+new Date) + "" + Math.random();
216
217    try {
218        var global = ifr.contentWindow;
219        global[key] = "check";
220        return global[key] === "check";
221    }
222    catch (e) {
223        return false;
224    }
225}
226
227/**
228 * Provide controllerName and actionName as string with no slashes
229 * @param {string} controllerName
230 * @param {string} actionName
231 * @param {object} args
232 */
233dnnsf.getWebApiEndpoint = function (controllerName, actionName, args) {
234    if (!args) args = {};
235
236    delete args.$$_q;
237
238    var url = dnnsf.webApiServiceRoot + controllerName + '/' + actionName;
239    var queryString = "";
240
241    for (var name in args) {
242        if (args.hasOwnProperty(name))
243            queryString += '&' + name + '=' + encodeURIComponent(args[name]);
244    }
245    if (queryString) {
246        url += "?" + queryString.substr(1); // remove first '&' character
247    }
248    return url;
249}
250
251dnnsf.adminApi = function (method, args, options, isWebApi) {
252    options = options || {};
253    options.apiUrl = options.apiUrl || g_dnnsfState.adminApi;
254    options.moduleId = options.moduleId || g_dnnsfState.moduleId || -1;
255    options.tabId = options.tabId || g_dnnsfState.tabId;
256    options.apiVersion = options.apiVersion || g_dnnsfState.apiVersion;
257    options.alias = options.alias || dnnsf.alias || g_dnnsfState.alias;
258    // if webApi is true then it builds the url for webApi with slahes, else it builds the normal URL
259    if (isWebApi) {
260        var webApiRootUrl = g_dnnsfState.siteRoot; // this contains both the virtual path and portal name and ensures WebAPI calls are okay.
261        var webApiUrl = webApiRootUrl + options.apiUrl.replace(/^\/|\/$/g, '');
262        url = webApiUrl + "/" + method + '?_alias=' + options.alias // options here is the URL string (e.g. Api/Admin)
263    }
264    else {
265        url = options.apiUrl + '?method=' + method +
266            (options.apiVersion == '2.0'
267                ?
268                ('&_alias=' + options.alias + '&_mid=' + options.moduleId + '&_tabid=' + options.tabId)
269                :
270                ('&alias=' + options.alias + '&mid=' + options.moduleId + '&tabid=' + options.tabId))
271    }
272
273    if (!args)
274        return url;
275
276    for (var name in args) {
277        if (name === "$$_q")
278            continue;
279        if (args.hasOwnProperty(name))
280            url += '&' + name + '=' + encodeURIComponent(args[name]);
281    }
282    return url;
283};
284
285dnnsf.parseCssBlock = function (styleContent) {
286
287    var rules = {};
288    dnnsf.$.each(styleContent.split(';'), function (i, part) {
289        var isep = part.indexOf(':');
290        if (isep == -1)
291            return; // ?
292        rules[dnnsf.$.trim(part.substr(0, isep))] = dnnsf.$.trim(part.substr(isep + 1));
293    });
294
295    return rules;
296};
297
298dnnsf.createClass = function (name, rules) {
299    var style = document.createElement('style');
300    style.type = 'text/css';
301    document.getElementsByTagName('head')[0].appendChild(style);
302    if (!(style.sheet || {}).insertRule) {
303        (style.styleSheet || style.sheet).addRule(name, rules);
304    }
305    else {
306        style.innerHTML = name + "{" + rules + "}";
307    }
308};
309
310dnnsf.stackTrace = function () {
311
312    //return '';
313    //var e = new Error('dummy');
314    //var stack = e.stack.replace(/^[^\(]+?[\n$]/gm, '')
315    //    .replace(/^\s+at\s+/gm, '')
316    //    .replace(/^Object.<anonymous>\s*\(/gm, '{anonymous}()@')
317    //    .split('\n');
318    //// remove the call to this function
319    //stack.splice(0, 1);
320    //return stack;
321};
322
323// this function tries to guess if a string is an object or array
324dnnsf.eval = function (obj) {
325
326    if (typeof (obj) != 'string')
327        return obj;
328
329    if (!isNaN(parseInt(obj)))
330        return parseInt(obj);
331
332    if (!isNaN(parseFloat(obj)))
333        return parseFloat(obj);
334
335    // TODO: find a better way to determine json arrays and objects - for example with a regex
336    if (obj[0] == '[' || obj[0] == '{')
337        return eval(obj);
338
339    if (obj == "false")
340        return false;
341
342    if (obj == "true")
343        return true;
344
345    // just return it as string
346    return obj;
347};
348
349// if object is array, return it, otheriwse return a new array with only this item
350dnnsf.toArray = function (obj) {
351    if (!obj) return [];
352    if (!$.isArray(obj))
353        obj = [obj];
354    return obj;
355};
356
357dnnsf.tryParseBool = function (o) {
358    //  JSON values aren't necessary strings
359    if (typeof (o) !== 'string')
360        return o;
361
362    if (o.toLowerCase() == 'true')
363        return true;
364
365    if (o.toLowerCase() == 'false')
366        return false;
367
368    return o;
369};
370
371dnnsf.stringToBool = function (input) {
372    return typeof input === 'boolean' && input || (input ? JSON.parse(input.toLowerCase()) : false);
373}
374
375// returns baseId + altId if altId exists, otherwise generates an unique string
376dnnsf.uniqueId = function (baseId, altId) {
377    if (!altId || altId == -1)
378        return baseId + new Date().getTime() + Math.floor(Math.random() * 10000);
379    return baseId + altId;
380}
381
382dnnsf.generateUuid = function () {
383    return ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, function (c) {
384        return (c ^ (crypto.getRandomValues(new Uint8Array(1))[0] & (15 >> (c / 4)))).toString(16);
385    });
386}
387
388dnnsf.randomString = function (length) {
389    var chars = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
390    var result = '';
391    for (var i = length; i > 0; --i) result += chars[Math.round(Math.random() * (chars.length - 1))];
392    return result;
393}
394
395dnnsf.initParameters = function (def, field, ensureItSupportsExpressions) {
396    if (!def || def.Parameters == undefined || !field)
397        return;
398
399    for (var i = 0; i < def.Parameters.length; i++) {
400
401        var p = def.Parameters[i];
402        if (ensureItSupportsExpressions && (p.Type == 'Select' || p.Type == 'FieldSelect')
403            && ($.type(field.Parameters[p.Id]) != "object" || (!field.Parameters[p.Id].hasOwnProperty('Value') && !field.Parameters[p.Id].hasOwnProperty('IsExpression'))))
404            field.Parameters[p.Id] = { Value: field.Parameters[p.Id], IsExpression: false, Expression: '' };
405
406        // action list need to be initialized to empty arrays
407        if (p.Type == 'ActionList' && !field.Parameters[p.Id]) {
408            field.Parameters[p.Id] = [];
409        } else if (p.Type == 'ActionList' && field.Parameters[p.Id]) {
410            field.Parameters[p.Id] = $.grep(field.Parameters[p.Id], function (e) { return !e.IsDeleted });
411        }
412
413        // check either this parameter already has a value
414        if (typeof field.Parameters[p.Id] != 'undefined')
415            continue;
416        if (p.Id != 'DataSource') {
417            if (typeof field.Parameters[p.Id] != 'undefined')
418                continue;
419            if (p.Type == 'Select' || p.Type == 'FieldSelect' || p.Type == 'MultipleFieldSelect')
420                field.Parameters[p.Id] = {
421                    Expression: '',
422                    Value: p.DefaultValue ? g_localizeMaybeJson(p.DefaultValue) : '',
423                    IsExpression: false
424                };
425            else field.Parameters[p.Id] = p.DefaultValue ? g_localizeMaybeJson(p.DefaultValue) : '';
426        } else {
427            // check either this parameter already has a value
428            if (typeof field.Parameters[p.Id] != 'undefined') {
429                // try to convert to object format
430                if (!field.Parameters[p.Id].hasOwnProperty('SupportsExpressions')) {
431                    // if already an object with IsExpression
432                    if (field.Parameters[p.Id].hasOwnProperty('IsExpression')) {
433                        field.Parameters[p.Id].SupportsExpressions = true;
434                    }
435                    else {
436                        field.Parameters[p.Id] = {
437                            SupportsExpressions: false,
438                            Expression: '',
439                            Value: field.Parameters[p.Id],
440                            IsExpression: false,
441                            Parameters: {}
442                        }
443
444                    }
445                }
446                continue;
447            }
448
449            field.Parameters[p.Id] = p.DefaultValue ? g_localizeMaybeJson(p.DefaultValue) : ({
450                SupportsExpressions: p.Settings && p.Settings['SupportsExpressions'] == 'true',
451                Expression: '',
452                Value: '',
453                IsExpression: false,
454                Parameters: {}
455            });
456        }
457        //  maybe we have non-localized default settings
458        if (!field.Parameters[p.Id] && !p.DefaultValue && p.Settings && p.Settings['Defaults']) {
459            var val = p.Settings['Defaults'];
460            //  also see g_localizeMaybeJson; it will throw exception if not json
461            if (val && (val[0] == '[' || val[0] == '{')) {
462                var processBool = (val[0] != '[');
463                val = $.parseJSON(val);
464                //  we only can have arrays of bools ?
465                if (!processBool) {
466                    field.Parameters[p.Id] = {};
467                    for (var j = 0; val.length > j; ++j)
468                        field.Parameters[p.Id][val[j]] = true;
469                    return;
470                }
471            }
472            field.Parameters[p.Id] = val;
473        }
474
475        // booleans will come as strings, convert them to true bool
476        if (typeof (field.Parameters[p.Id]) === 'object') {
477            $.each(field.Parameters[p.Id], function (key, value) {
478                field.Parameters[p.Id][key] = dnnsf.tryParseBool(value);
479            });
480        } else {
481            field.Parameters[p.Id] = dnnsf.tryParseBool(field.Parameters[p.Id]);
482        }
483
484    }
485
486}
487
488dnnsf.includeJs = function (window, file, callback) {
489    var head = window.document.getElementsByTagName('head')[0];
490    var script = window.document.createElement('script');
491    script.type = 'text/javascript';
492    script.src = file;
493    script.onload = script.onreadystatechange = function () {
494        // execute dependent code
495        if (callback) callback();
496        // prevent memory leak in IE
497        head.removeChild(script);
498        script.onload = null;
499    };
500    head.appendChild(script);
501}
502
503dnnsf.includeCss = function (path) {
504    $('<link>')
505        .appendTo('head')
506        .attr({
507            type: 'text/css',
508            rel: 'stylesheet',
509            href: path
510        });
511}
512
513dnnsf.asQueryString = function (obj) {
514    var qs = '';
515    for (var k in obj) {
516        if (!obj.hasOwnProperty(k))
517            continue;
518        qs += encodeURIComponent(k) + '=' + encodeURIComponent(obj[k]) + '&';
519    }
520    if (qs.length)
521        qs = qs.substring(0, qs.length - 1)
522    return qs;
523}
524
525dnnsf.appendQueryToUrl = function (url, query) {
526
527    if (url[url.length - 1] == '?' || url[url.length - 1] == '&')
528        url = url.substr(0, url.length - 1);
529
530    var sep = url.indexOf('?') == -1 ? '?' : '&';
531
532    if ("string" == typeof query)
533        url += sep + query;
534    else for (var k in query) {
535        if (!query.hasOwnProperty(k))
536            continue;
537        url += sep + encodeURIComponent(k) + '=' + encodeURIComponent(query[k]);
538        sep = '&';
539    }
540
541    return url;
542};
543
544dnnsf.getTimezoneOffset = function () {
545    function pad(num) {
546        var norm = Math.abs(Math.floor(num));
547        return (norm < 10 ? '0' : '') + norm;
548    }
549
550    var local = new Date();
551    var tzo = -local.getTimezoneOffset();
552    var sign = tzo >= 0 ? '+' : '-';
553    return sign + pad(tzo / 60)
554        + ':' + pad(tzo % 60);
555};
556
557dnnsf.loadJsFromHtml = function (html) {
558    var scripts = $(html).find('script');
559    if (scripts.length <= 0)
560        return;
561    var filesToLoad = [];
562    $.each(scripts, function (i, v) {
563        if ($(v).attr('src') != undefined)
564            filesToLoad.push({ src: $(v).attr('src') })
565        else
566            filesToLoad.push({ toEval: $(v).text() })
567    });
568    loadJs(filesToLoad[0]);
569
570    function loadJs(js) {
571        if (js.toEval) {
572            eval(js.toEval)
573            filesToLoad.shift();
574            filesToLoad.length && loadJs(filesToLoad[0]);
575        } else {
576            filesToLoad.shift();
577            $.ajax({
578                cache: true,
579                url: js.src,
580                dataType: "script",
581                success: function () {
582                    if (filesToLoad.length && filesToLoad[0].toEval) {
583                        eval(filesToLoad[0].toEval);
584                        filesToLoad.shift();
585                    }
586                    filesToLoad.length && loadJs(filesToLoad[0]);
587                }
588            });
589        }
590    }
591}
592
593dnnsf.events = {
594
595    _listeners: {},
596
597    listen: function (messageType, mid, fn) {
598        if (!dnnsf.events._listeners[messageType])
599            dnnsf.events._listeners[messageType] = {};
600        dnnsf.events._listeners[messageType]['mid' + mid] = fn;
601    },
602
603    broadcast: function (messageType, data, fnDone) {
604        if (!dnnsf.events._listeners[messageType]) {
605            fnDone && fnDone();
606            return;
607        }
608        var listenerCount = Object.keys(dnnsf.events._listeners[messageType]).length;
609        var listenerResponses = [];
610        $.each(dnnsf.events._listeners[messageType], function (i, fn) {
611            var fnHandleResponse = function (response) {
612                response && listenerResponses.push(response);
613                listenerCount--;
614                if (listenerCount == 0)
615                    fnDone(listenerResponses);
616            };
617
618            fn(data, fnHandleResponse);
619        });
620
621    },
622    emittedEvents: [],
623    on: function (event, fn) {
624        if (this.emittedEvents[event] == null) {
625            this.emittedEvents[event] = [];
626        }
627        var id = dnnsf.uniqueId('event');
628        this.emittedEvents[event][id] = {
629            id: id,
630            callback: typeof fn === "function" ? fn : function () { console.log(this); console.error('dnnsfEvents: ' + event + ': Check the callBack function') }
631        }
632        return id;
633    },
634    emit: function (event, data) {
635        if (this.emittedEvents[event] != null) {
636            for (id in this.emittedEvents[event]) {
637                if (this.emittedEvents[event].hasOwnProperty(id))
638                    this.emittedEvents[event][id].callback.call(data || {});
639            }
640        }
641    },
642    unbind: function (event, id) {
643        if (this.emittedEvents[event] != null && this.emittedEvents[event][id] != null) {
644            delete this.emittedEvents[event][id];
645        }
646    }
647    /*
648    var eventId = dnnsf.events.on('aaa', function () { console.log(this //will log {date:11111}) })
649    dnnsf.events.emit('aaa', { date: 11111 })
650    dnnsf.events.unbind('aaa', eventId);
651    */
652}
653
654dnnsf.configUtils = {
655
656    groupDefinitions: function (defs, fnInclude) {
657        var defGroups = {};
658        $.each(defs, function (i, o) {
659            if (fnInclude && !fnInclude(o))
660                return;
661
662            o.Groups && $.each(o.Groups, function (ig, group) {
663                if (!defGroups[group])
664                    defGroups[group] = [];
665                defGroups[group].push(o);
666            });
667
668            if (!defGroups[o.Settings['Group']])
669                defGroups[o.Settings['Group']] = [];
670            defGroups[o.Settings['Group']].push(o);
671        });
672        return defGroups;
673    }
674}
675
676dnnsf.hasProps = function (obj) {
677    for (var k in obj)
678        if (obj.hasOwnProperty(k))
679            return true;
680    return false;
681};
682
683dnnsf.copyToClipboard = function (val) {
684    var $temp = $("<textarea>");
685    $("body").append($temp);
686    $temp.css({
687        'position': 'absolute',
688        'top': '0',
689        'z-index': '-9999999'
690    });
691    $temp.val(val).select();
692    $temp.focus();
693
694    var result = document.execCommand("copy");
695    $temp.remove();
696    return result;
697
698}
699
700dnnsf.promiseResponse = function (method, url, getSvcFramework) {
701    return new Promise(function (resolve, reject) {
702        var xhr = new XMLHttpRequest();
703        xhr.open(method, url);
704
705        if (getSvcFramework) {
706            var svcFramework = getSvcFramework(dnnsf.moduleId);
707            xhr.setRequestHeader("RequestVerificationToken", svcFramework.getAntiForgeryValue());
708        }
709
710        xhr.onload = function () {
711            if (this.status >= 200 && this.status < 300) {
712                resolve(xhr);
713            }
714        };
715        xhr.onerror = function () {
716            reject(xhr);
717        };
718        xhr.send();
719    });
720};
721
722// Goes through the noConflict chain to identify all loaded bootstrap instances and retrieves their version. 
723// The result can contain duplicate version numbers if the same BS version is loaded multiple times from different files (e.g. DNN Skin and our modules).
724// return type: undefined | string[]
725dnnsf.getBootstrapVersions = function () {
726    if (!$ || !$.fn.tooltip || !$.fn.tooltip.Constructor) {
727        return undefined;
728    }
729
730    // noConflict overrides the $.fn.tooltip, so we need to make sure we preserve the latest version.
731    var latestPlugin;
732    var result = [$.fn.tooltip.Constructor.VERSION];
733    var noConflict = $.fn.tooltip.noConflict;
734    if (noConflict) {
735        noConflict = noConflict.bind($.fn.tooltip); // function relies on `this` so we need to properly bind it.
736        latestPlugin = noConflict();
737        $.fn.tooltip = latestPlugin;
738    }
739
740    while (noConflict) {
741        noConflict();
742        var oldPlugin = $.fn.tooltip;
743        $.fn.tooltip = latestPlugin;
744
745        // Check if we still have a reference to a bootstrap object. $.fn.tooltip is also used by jQuery UI tooltip.
746        if (!oldPlugin || !oldPlugin.Constructor) {
747            break;
748        }
749
750        result.push(oldPlugin.Constructor.VERSION);
751        noConflict = oldPlugin.noConflict;
752        if (noConflict) {
753            noConflict = noConflict.bind(oldPlugin); // function relies on `this` so we need to properly bind it.
754        }
755    }
756
757    return result;
758};
759
760dnnsf.bootstrap3Loaded = function () {
761    var versionList = dnnsf.getBootstrapVersions();
762    return versionList && versionList.some(function(versionStr) { return parseInt(versionStr[0]) === 3; });
763}
764
765dnnsf.bootstrap5Loaded = function () {
766    var versionList = dnnsf.getBootstrapVersions();
767    return versionList && versionList.some(function(versionStr) { return parseInt(versionStr[0]) === 5; });
768}
769
770dnnsf.api = dnnsf.api || {};
771
772var initDnnsf = function (angular) {
773    angular.module('dnnsf', [])
774        .service('dnnsf', ['$timeout', function ($timeout) {
775
776            this.env = dnnsf;
777            this.start = new Date().getTime();
778
779            // copy everything in dnnsf
780            for (var key in dnnsf)
781                this[key] = dnnsf[key];
782        }])
783        .factory('dnnsfHttp', ['$http', function ($http) {
784            function createShortMethods(httpSvc, names) {
785                $.each(arguments, function (idx, name) {
786                    if (typeof name != 'string')
787                        return;
788
789                    httpSvc[name] = function (moduleId, url, config, withAntiForgery) {
790                        return httpSvc(moduleId, $.extend({}, config || {}, {
791                            method: name,
792                            url: url
793                        }), withAntiForgery);
794                    };
795                });
796            }
797
798            function createShortMethodsWithData(httpSvc, names) {
799                $.each(arguments, function (idx, name) {
800                    if (typeof name != 'string')
801                        return;
802
803                    httpSvc[name] = function (moduleId, url, data, config, withAntiForgery) {
804                        return httpSvc(moduleId, $.extend({}, config || {}, {
805                            method: name,
806                            url: url,
807                            data: data
808                        }), withAntiForgery);
809                    };
810                });
811            }
812
813            var dnnsfHttp = function (moduleId, options, withAntiForgery) {
814                if (withAntiForgery == undefined) {
815                    withAntiForgery = true;
816                }
817                options = options || {};
818
819                if (withAntiForgery && !dnnsfjQuery.ServicesFramework) {
820                    console.error('Could not initialize DNN ServicesFramework to inject authorization headers. The request will be made without authorization. Make sure that the IServicesFramework.RequestAjaxScriptSupport and RequestAjaxAntiForgerySupport methods are called when rendering the page on the server side.');
821                }
822
823                if (withAntiForgery && dnnsfjQuery.ServicesFramework) {
824                    var svcFramework = dnnsfjQuery.ServicesFramework(moduleId);
825                    var stubXhr = {
826                        headers: {},
827                        setRequestHeader: function (key, value) {
828                            stubXhr.headers[key] = value;
829                        }
830                    };
831                    svcFramework.setModuleHeaders(stubXhr);
832
833                    options.headers = $.extend({}, options.headers || {}, stubXhr.headers);
834                }
835
836                return $http(options);
837            };
838
839            createShortMethods(dnnsfHttp, 'get', 'delete', 'head', 'jsonp');
840            createShortMethodsWithData(dnnsfHttp, 'post', 'put', 'patch');
841
842            return dnnsfHttp;
843        }])
844        .factory('myInterceptor', ['$log', '$q', function ($log, $q) {
845            var myInterceptor = {
846                'response': function (response) {
847                    if (response.status == 200 && response.data && response.data.error) {
848                        console.log("App HTTP error", response);
849                        // if (response.data.redirect) {
850                        //     window.top.location = response.data.redirect;
851                        //     return;
852                        // }
853                        // alert('Error getting response from ' + response.config.url + '.\n\nError: ' + response.data.error);
854                    }
855                    return response;
856                },
857                'responseError': function (rejection) {
858                    if (rejection.status && rejection.status != 404 && !rejection.config.ignoreInterceptor) {
859                        // status:0 means an unitialized ajax request, 
860                        // it happens for example the page is refreshed before the ajax request gets the chance to make connection
861                        console.log("HTTP error", rejection);
862                        // alert('error' + rejection);
863                    }
864                    return $q.reject(rejection);
865                }
866            };
867
868            return myInterceptor;
869        }])
870        .config(['$httpProvider', function ($httpProvider) {
871            $httpProvider.interceptors.push('myInterceptor');
872        }]);
873}
874window.angular ? initDnnsf(angular) : '';
875window.dnnsfAngular15 ? initDnnsf(dnnsfAngular15) : '';
876

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.