PageSourceSearch

https://skve.com.my/userfiles/modules/microweber/api/tools/helpers.js

js skve.com.my collected 2026-09-26 10:26:22 UTC 31,783 bytes, 843 lines download raw bytes

1;(function(expose){
2    var helpers = {
3        fragment: function(){
4            if(!this._fragment){
5                this._fragment = document.createElement('div');
6                this._fragment.style.visibility = 'hidden';
7                this._fragment.style.position = 'absolute';
8                this._fragment.style.width = '1px';
9                this._fragment.style.height = '1px';
10                document.body.appendChild(this._fragment);
11            }
12            return this._fragment;
13        },
14        _isBlockCache:{},
15        isBlockLevel:function(node){
16            if(!node || node.nodeType === 3){
17                return false;
18            }
19            const blockLike = ['flex', 'block', 'grid', 'table', 'list-item', 'table-row', 'table-cell', 'table-row-group', 'table-header-group', 'table-footer-group', 'table-column-group', 'table-column', 'table-caption', 'table-cell', 'table-row', 'inline-block', 'inline-table', 'inline-flex', 'inline-grid', 'flow-root', 'grid', 'grid-item', 'grid-line', 'grid-row', 'grid-column', 'grid-area', 'grid-auto-rows', 'grid-auto-columns', 'grid-template-rows', 'grid-template-columns', 'grid-template-areas', 'grid-template', 'grid-auto-flow', 'grid-row-gap', 'grid-column-gap', 'grid-gap', 'grid-row-start', 'grid-row-end', 'grid-column-start', 'grid-column-end', 'grid-area'];
20            return blockLike.indexOf(getComputedStyle(node).display)  !== -1;
21        },
22        _isInlineCache:{},
23        isInlineLevel:function(node){
24            if(node.nodeType === 3){
25                return false;
26            }
27            var name = node.nodeName;
28            if(typeof this._isInlineCache[name] !== 'undefined'){
29                return this._isInlineCache[name];
30            }
31            var test = document.createElement(name);
32            this.fragment().appendChild(test);
33            this._isInlineCache[name] = getComputedStyle(test).display === 'inline' && node.nodeName !== 'BR';
34            this.fragment().removeChild(test);
35            return this._isInlineCache[name];
36        },
37        elementOptions: function(el) {
38            var opt = ( el.dataset.options || '').trim().split(','), final = {};
39            if(!opt[0]) return final;
40            $.each(opt, function(){
41                var arr = this.split(':');
42                var val = arr[1].trim();
43                if(!val){
44
45                }
46                else if(val === 'true' || val === 'false'){
47                    val = val === 'true';
48                }
49                else if(!/\D/.test(val)){
50                    val = parseInt(val, 10);
51                }
52                final[arr[0].trim()] = val;
53            });
54            return final;
55        },
56        createAutoHeight: function() {
57            if(window.thismodal && thismodal.iframe) {
58                mw.tools.iframeAutoHeight(thismodal.iframe, 'now');
59            }
60            else if(mw.top().win.frameElement && mw.top().win.frameElement.contentWindow === window) {
61                mw.tools.iframeAutoHeight(mw.top().win.frameElement, 'now');
62            } else if(window.top !== window) {
63                mw.top().$('iframe').each(function(){
64                    try{
65                        if(this.contentWindow === window) {
66                            mw.tools.iframeAutoHeight(this, 'now');
67                        }
68                    } catch(e){}
69                })
70            }
71        },
72        collision: function(el1, el2){
73            if(!el1 || !el2) return;
74            el1 = mw.$(el1);
75            el2 = mw.$(el2);
76            var o1 = el1.offset();
77            var o2 = el2.offset();
78            o1.width = el1.width();
79            o1.height = el1.height();
80            o2.width = el2.width();
81            o2.height = el2.height();
82            return (o1.left < o2.left + o2.width  && o1.left + o1.width  > o2.left &&  o1.top < o2.top + o2.height && o1.top + o1.height > o2.top);
83        },
84        distance: function (x1, y1, x2, y2) {
85            var a = x1 - x2;
86            var b = y1 - y2;
87            return Math.floor(Math.sqrt(a * a + b * b));
88        },
89        copy: function (value) {
90            var tempInput = document.createElement("textarea");
91            tempInput.style = "position: absolute; left: -1000px; top: -1000px";
92            tempInput.value = value;
93            document.body.appendChild(tempInput);
94            tempInput.select();
95            document.execCommand("copy");
96            document.body.removeChild(tempInput);
97            mw.notification.success(mw.lang('Copied') + ': "' + value + '"');
98        },
99        cloneObject: function (object) {
100            return jQuery.extend(true, {}, object);
101        },
102        constructions: function () {
103            mw.$(".mw-image-holder").each(function () {
104                var img = this.querySelector('img');
105                if (img && img.src) {
106                    mw.$(this).css('backgroundImage', 'url(' + img.src + ')');
107                }
108            });
109        },
110        isRtl: function (el) {
111            //todo
112            el = el || document.documentElement;
113            return document.documentElement.dir === 'rtl';
114        },
115        isEditable: function (item) {
116            var el = item;
117            if (!!item.type && !!item.target) {
118                el = item.target;
119            }
120
121            return mw.tools.parentsOrCurrentOrderMatchOrOnlyFirst(el, ['edit', 'module'])
122                && mw.tools.parentsOrCurrentOrderMatchOrOnlyFirst(el, ['edit', 'noedit']);
123        },
124        eachIframe: function (callback, root, ignore) {
125            root = root || document;
126            var scope = this;
127            ignore = ignore || [];
128            var all = root.querySelectorAll('iframe'), i = 0;
129            for (; i < all.length; i++) {
130                if (mw.tools.canAccessIFrame(all[i]) && ignore.indexOf(all[i]) === -1) {
131                    callback.call(all[i].contentWindow, all[i].contentWindow);
132                    scope.eachIframe(callback, all[i].contentWindow.document);
133                }
134            }
135        },
136        eachWindow: function (callback, options) {
137            options = options || {};
138            var curr = window;
139            callback.call(curr, curr);
140            while (curr !== top) {
141                if(curr.parent && curr.parent.document) {
142                    this.eachIframe(function (iframeWindow) {
143                        callback.call(iframeWindow, iframeWindow);
144                    }, curr.parent.document, [curr]);
145                    curr = curr.parent;
146                    callback.call(curr, curr);
147                }
148            }
149            this.eachIframe(function (iframeWindow) {
150                callback.call(iframeWindow, iframeWindow);
151            });
152            if (window.opener !== null && mw.tools.canAccessWindow(opener)) {
153                callback.call(window.opener, window.opener);
154                this.eachIframe(function (iframeWindow) {
155                    callback.call(iframeWindow, iframeWindow);
156                }, window.opener.document);
157            }
158        },
159        canAccessWindow: function (winObject) {
160            var can = false;
161            try {
162                var doc = winObject.document;
163                can = !!doc.body;
164            } catch (err) {
165            }
166            return can;
167        },
168        canAccessIFrame: function (iframe) {
169            var can = false;
170            try {
171                var doc = iframe.contentDocument || iframe.contentWindow.document;
172                can = !!doc.body && !!doc.documentElement;
173            } catch (err) {
174            }
175            return can;
176        },
177         createStyle: function (c, css, ins) {
178            ins = ins || document.getElementsByTagName('head')[0];
179            var style = mw.$(c)[0];
180            if (!style) {
181                style = document.createElement('style');
182                ins.appendChild(style);
183            }
184            style.innerHTML = css;
185            return style;
186        },
187        cssNumber: function (val) {
188            var units = ["px", "%", "in", "cm", "mm", "em", "ex", "pt", "pc"];
189            if (typeof val === 'number') {
190                return val + 'px';
191            }
192            else if (typeof val === 'string' && parseFloat(val).toString() === val) {
193                return val + 'px';
194            }
195            else {
196                if (isNaN(parseFloat(val))) {
197                    return '0px';
198                }
199                else {
200                    return val;
201                }
202            }
203
204        },
205        isField: function (target) {
206            var t = target.nodeName.toLowerCase();
207            var fields = /^(input|textarea|select)$/i;
208            return fields.test(t);
209        },
210
211        toggleCheckbox: function (node) {
212            if (node === null || node === undefined) return false;
213            node.checked = !node.checked;
214            return node.checked;
215        },
216        jQueryFields: function (root) {
217            if (typeof root === 'string') {
218                root = document.querySelector(root);
219            }
220            if (typeof root === 'undefined' || root === null) return false;
221            var allFields = "textarea, select, input[type='checkbox']:checked, input[type='color'], input[type='date'], input[type='datetime'], input[type='datetime-local'], input[type='email'], input[type='file'], input[type='hidden'], input[type='month'], input[type='number'], input[type='password'], input[type='radio']:checked, input[type='range'], input[type='search'], input[type='tel'], input[type='text'], input[type='time'], input[type='url'], input[type='week']";
222            return mw.$(allFields, fields).not(':disabled');
223        },
224        toggle: function (who, toggler, callback) {
225            who = mw.$(who);
226            who.toggle();
227            who.toggleClass('toggle-active');
228            mw.$(toggler).toggleClass('toggler-active');
229            mw.is.func(callback) ? callback.call(who) : '';
230        },
231        _confirm: function (question, callback) {
232            var conf = confirm(question);
233            if (conf && typeof callback === 'function') {
234                callback.call(window);
235            }
236            return conf;
237        },
238        el_switch: function (arr, type) {
239            if (type === 'semi') {
240                mw.$(arr).each(function () {
241                    var el = mw.$(this);
242                    if (el.hasClass("semi_hidden")) {
243                        el.removeClass("semi_hidden");
244                    }
245                    else {
246                        el.addClass("semi_hidden");
247                    }
248                });
249            }
250            else {
251                mw.$(arr).each(function () {
252                    var el = mw.$(this);
253                    if (el.css('display') === 'none') {
254                        el.show();
255                    }
256                    else {
257                        el.hide();
258                    }
259                });
260            }
261        },
262        focus_on: function (el) {
263            if (!$(el).hasClass('mw-focus')) {
264                mw.$(".mw-focus").each(function () {
265                    this !== el ? mw.$(this).removeClass('mw-focus') : '';
266                });
267                mw.$(el).addClass('mw-focus');
268            }
269        },
270        scrollTo: function (el, callback, minus) {
271
272            minus = minus || 0;
273            if ($(el).length === 0) {
274                return false;
275            }
276            if (typeof callback === 'number') {
277                minus = callback;
278            }
279            mw.$('html,body').stop().animate({scrollTop: mw.$(el).offset().top - minus}, function () {
280                typeof callback === 'function' ? callback.call(el) : '';
281            });
282        },
283        accordion: function (el, callback) {
284            var speed = 200;
285            var container = el.querySelector('.mw-accordion-content');
286            if (container === null) return false;
287            var is_hidden = getComputedStyle(container).display === 'none';
288            if (!$(container).is(":animated")) {
289                if (is_hidden) {
290                    mw.$(container).slideDown(speed, function () {
291                        mw.$(el).addClass('active');
292                        typeof callback === 'function' ? callback.call(el, 'visible') : '';
293                    });
294                }
295                else {
296                    mw.$(container).slideUp(speed, function () {
297                        mw.$(el).removeClass('active');
298                        typeof callback === 'function' ? callback.call(el, 'hidden') : '';
299                    });
300                }
301            }
302        },
303        index: function (el, parent, selector) {
304            el = mw.$(el)[0];
305            selector = selector || el.tagName.toLowerCase();
306            parent = parent || el.parentNode;
307            var all;
308            if (parent.constructor === [].constructor) {
309                all = parent;
310            }
311            else {
312                all = mw.$(selector, parent)
313            }
314            var i = 0, l = all.length;
315            for (; i < l; i++) {
316                if (el === all[i]) return i;
317            }
318        },
319
320        highlight: function (el, color, speed1, speed2) {
321            if (!el) return false;
322            mw.$(el).stop();
323            color = color || '#48AD79';
324            speed1 = speed1 || 777;
325            speed2 = speed2 || 777;
326            var curr = window.getComputedStyle(el, null).backgroundColor;
327            if (curr === 'transparent') {
328                curr = '#ffffff';
329            }
330            mw.$(el).animate({backgroundColor: color}, speed1, function () {
331                mw.$(el).animate({backgroundColor: curr}, speed2, function () {
332                    mw.$(el).css('backgroundColor', '');
333                });
334            });
335        },
336        highlightStop: function (el) {
337            mw.$(el).stop();
338            mw.$(el).css('backgroundColor', '');
339        },
340        toCamelCase: function (str) {
341            return str.replace(/(\-[a-z])/g, function (a) {
342                return a.toUpperCase().replace('-', '');
343            });
344        },
345        multihover: function () {
346            var l = arguments.length, i = 1;
347            var type = arguments[0].type;
348            var check = ( type === 'mouseover' || type === 'mouseenter');
349            for ( ; i < l; i++ ) {
350                check ? mw.$(arguments[i]).addClass('hovered') : mw.$(arguments[i]).removeClass('hovered');
351            }
352        },
353        listSearch: function (val, list) {
354            val = val.trim().toLowerCase();
355            if(!val) {
356                $('li', list).show();
357                return;
358            }
359            this.search(val, 'li', function (found) {
360                if(found) {
361                    $(this).show();
362                } else {
363                    $(this).hide();
364                }
365
366            }, list);
367        },
368        search: function (string, selector, callback, root) {
369            root = !!root ? $(root)[0] : mwd;
370            if (!root) {
371                return;
372            }
373            string = string.toLowerCase();
374            var items;
375            if (typeof selector === 'object') {
376                items = selector;
377            }
378            else if (typeof selector === 'string') {
379                items = root.querySelectorAll(selector);
380            }
381            else {
382                return false;
383            }
384            var i = 0, l = items.length;
385            for (; i < l; i++) {
386                items[i].textContent.toLowerCase().contains(string) ? callback.call(items[i], true) : callback.call(items[i], false);
387            }
388        },
389        ajaxIsSearching: false,
390        ajaxSearcSetting: {
391            limit: 10,
392            keyword: '',
393            order_by: 'updated_at desc',
394            search_in_fields: 'title'
395        },
396        ajaxSearch: function (o, callback) {
397            if (!mw.tools.ajaxIsSearching) {
398                var obj = $.extend({}, mw.tools.ajaxSearcSetting, o);
399                mw.tools.ajaxIsSearching = $.post(mw.settings.site_url + "api/get_content_admin", obj, function (data) {
400                    if (typeof callback === 'function') {
401                        callback.call(data, data);
402                    }
403                }).always(function () {
404                    mw.tools.ajaxIsSearching = false
405                });
406            }
407            return mw.tools.ajaxIsSearching;
408        },
409        getPostById: function (id, callback) {
410            var config = {
411                limit: 10,
412                keyword: '',
413                order_by: 'updated_at desc',
414                search_in_fields: 'id',
415                id: id
416            };
417            return this.ajaxSearch(config, callback);
418        },
419        iframeLinksToParent: function (iframe) {
420            mw.$(iframe).contents().find('a').each(function () {
421                var href = this.href;
422                if (href.contains(mw.settings.site_url)) {
423                    this.target = '_parent';
424                }
425            });
426        },
427        get_filename: function (s) {
428            if (s.contains('.')) {
429                var d = s.lastIndexOf('.');
430                return s.substring(s.lastIndexOf('/') + 1, d < 0 ? s.length : d);
431            }
432            else {
433                return undefined;
434            }
435        },
436        is_field: function (obj) {
437            if (obj === null || typeof obj === 'undefined' || obj.nodeType === 3) {
438                return false;
439            }
440            if (!obj.nodeName) {
441                return false;
442            }
443            var t = obj.nodeName.toLowerCase();
444            if (t === 'input' || t === 'textarea' || t === 'select') {
445                return true
446            }
447            return false;
448        },
449        getAttrs: function (el) {
450            var attrs = el.attributes;
451            var obj = {};
452            for (var x in attrs) {
453                if (attrs[x].nodeName) {
454                    obj[attrs[x].nodeName] = attrs[x].nodeValue;
455                }
456            }
457            return obj;
458        },
459        copyAttributes: function (from, to, except) {
460            except = except || [];
461            var attrs = mw.tools.getAttrs(from);
462            if (mw.tools.is_field(from) && mw.tools.is_field(to)) to.value = from.value;
463            for (var x in attrs) {
464                ( $.inArray(x, except) == -1 && x != 'undefined') ? to.setAttribute(x, attrs[x]) : '';
465            }
466        },
467        isEmptyObject: function (obj) {
468            for (var a in obj) {
469                if (obj.hasOwnProperty(a)) return false;
470            }
471            return true;
472        },
473        objLenght: function (obj) {
474            var len = 0, x;
475            if (obj.constructor === {}.constructor) {
476                for ( x in obj ) {
477                    len++;
478                }
479            }
480            return len;
481        },
482        scaleTo: function (selector, w, h) {
483            w = w || 800;
484            h = h || 600;
485            var is_percent = w.toString().contains("%") ? true : false;
486            var item = mw.$(selector);
487            if (item.hasClass('mw-scaleto') || w == 'close') {
488                item.removeClass('mw-scaleto');
489                item.removeAttr('style');
490            }
491            else {
492                item.parent().height(item.height());
493                item.addClass('mw-scaleto');
494                if (is_percent) {
495                    item.css({
496                        width: w,
497                        height: h,
498                        left: ((100 - parseFloat(w)) / 2) + "%",
499                        top: ((100 - parseFloat(h)) / 2) + "%"
500                    });
501                }
502                else {
503                    item.css({
504                        width: w,
505                        height: h,
506                        marginLeft: -w / 2,
507                        marginTop: -h / 2
508                    });
509                }
510            }
511        },
512        getFirstEqualFromTwoArrays: function (a, b) {
513            var ia = 0, ib = 0, la = a.length, lb = b.length;
514            loop:
515                for (; ia < la; ia++) {
516                    var curr = a[ia];
517                    for (; ib < lb; ib++) {
518                        if (b[ib] == curr) {
519                            return curr;
520                        }
521                    }
522                }
523        },
524        has: function (el, what) {
525            return el.querySelector(what) !== null;
526        },
527        html_info: function (html) {
528            if (typeof mw._html_info === 'undefined') {
529                mw._html_info = document.createElement('div');
530                mw._html_info.id = 'mw-html-info';
531                document.body.appendChild(mw._html_info);
532            }
533            mw.$(mw._html_info).html(html);
534            return mw._html_info;
535        },
536        image_info: function (a, callback) {
537            var img = document.createElement('img');
538            img.className = 'semi_hidden';
539            img.src = a.src;
540            document.body.appendChild(img);
541            img.onload = function () {
542                callback.call({width: mw.$(img).width(), height: mw.$(img).height()});
543                mw.$(img).remove();
544            };
545        },
546        refresh_image: function (node) {
547            node.src = mw.url.set_param('refresh_image', mw.random(), node.src);
548            return node;
549        },
550        refresh: function (a, onSuccess) {
551            if (a === null || typeof a === 'undefined') {
552                return false;
553            }
554            if (a.src) {
555                a.src = mw.url.set_param('mwrefresh', mw.random(), a.src);
556                if(onSuccess) {
557                    jQuery.get(a.getAttribute('src'), function(e){
558                        onSuccess.call(a, e)
559                    })
560                }
561
562            }
563            else if (a.href) {
564                a.href = mw.url.set_param('mwrefresh', mw.random(), a.href);
565                if(onSuccess) {
566                    jQuery.get(a.getAttribute('href'), function(e){
567                        onSuccess.call(a, e)
568                    })
569                }
570            }
571        },
572        getDiff: function (_new, _old) {
573            var diff = {}, x, y;
574            for (x in _new) {
575                if (!x in _old || _old[x] != _new[x]) {
576                    diff[x] = _new[x];
577                }
578            }
579            for (y in _old) {
580                if (typeof _new[y] === 'undefined') {
581                    diff[y] = "";
582                }
583            }
584            return diff;
585        },
586        parseHtml: function (html) {
587            var doc = document.implementation.createHTMLDocument("");
588            doc.body.innerHTML = html;
589            return doc;
590        },
591        isEmpty: function (node) {
592            return ( node.innerHTML.trim() ).length === 0;
593        },
594        isJSON: function (a) {
595            if (typeof a === 'object') {
596                if (a.constructor === {}.constructor) {
597                    return true;
598                }
599                else {
600                    return false;
601                }
602            }
603            else if (typeof a === 'string') {
604                try {
605                    JSON.parse(a);
606                }
607                catch (e) {
608                    return false;
609                }
610                return true;
611            }
612            else {
613                return false;
614            }
615        },
616        toJSON: function (w) {
617            if (typeof w === 'object' && mw.tools.isJSON(w)) {
618                return w;
619            }
620            if (typeof w === 'string') {
621                try {
622                    var r = JSON.parse(w);
623                }
624                catch (e) {
625                    var r = {"0": w};
626                }
627                return r;
628            }
629            if (typeof w === 'object' && w.constructor === [].constructor) {
630                var obj = {}, i = 0, l = w.length;
631                for (; i < l; i++) {
632                    obj[i] = w[i];
633                }
634                return obj;
635            }
636        },
637        mwattr: function (el, a, b) {
638            if (!b && !!el) {
639                var data = mw.$(el).dataset(a);
640                if (!!$(el)[0].attributes) {
641                    var attr = mw.$(el)[0].attributes[a];
642                }
643
644                if (data !== '') {
645                    return data;
646                }
647                if (!!attr) {
648                    return attr.value;
649                }
650                return false;
651            }
652            else {
653                mw.$(el).dataset(a, b);
654            }
655        },
656        disable: function (el, text, global) {
657            text = text || mw.msg.loading + '...';
658            global = global || false;
659            var _el = mw.$(el);
660            if (!_el.length) {
661                return false;
662            }
663            if (!_el.hasClass("disabled")) {
664                _el.addClass('disabled');
665                if (_el[0].tagName !== 'INPUT') {
666                    _el.dataset("text", _el.html());
667                    _el.html(text);
668                }
669                else {
670                    _el.dataset("text", _el.val());
671                    _el.val(text);
672                }
673                if (global) mw.$(document.body).addClass("loading");
674            }
675            return el;
676        },
677        enable: function (el) {
678            var _el = mw.$(el);
679            if (!_el.length) {
680                return false;
681            }
682            var text = _el.dataset("text");
683            _el.removeClass("disabled");
684            if (_el[0].tagName !== 'INPUT') {
685                _el.html(text);
686            }
687            else {
688                _el.val(text);
689            }
690            mw.$(document.body).removeClass("loading");
691            return el;
692        },
693        prependClass: function (el, cls) {
694            el.className = (cls + ' ' + el.className).trim()
695        },
696        inview: function (el) {
697            var $el = mw.$(el);
698            if ($el.length === 0) {
699                return false;
700            }
701            var dt = mw.$(window).scrollTop(),
702                db = dt + mw.$(window).height(),
703                et = $el.offset().top;
704            return (et <= db) && !(dt > ($el.height() + et));
705        },
706        wholeinview: function (el) {
707            var $el = mw.$(el),
708                dt = mw.$(window).scrollTop(),
709                db = dt + mw.$(window).height(),
710                et = $el.offset().top,
711                eb = et + mw.$(el).height();
712            return ((eb <= db) && (et >= dt));
713        },
714        preload: function (u, c) {
715            var im = new Image();
716            if (typeof c === 'function') {
717                im.onload = function () {
718                    c.call(u, im);
719                }
720            }
721            im.src = u;
722        },
723        mapNodeValues: function (n1, n2) {
724            if (!n1 || !n2) return false;
725            var setValue1 = ((!!n1.type && n1.nodeName !== 'BUTTON') || n1.nodeName === 'TEXTAREA') ? 'value' : 'textContent';
726            var setValue2 = ((!!n2.type && n2.nodeName !== 'BUTTON') || n2.nodeName === 'TEXTAREA') ? 'value' : 'textContent';
727            var events = 'keyup paste';
728            mw.$(n1).bind(events, function () {
729                n2[setValue2] = n1[setValue1];
730                mw.$(n2).trigger('change');
731            });
732            mw.$(n2).bind(events, function () {
733                n1[setValue1] = n2[setValue2];
734                mw.$(n1).trigger('change');
735            });
736        },
737        copyEvents: function (from, to) {
738            if (typeof $._data(from, 'events') === 'undefined') {
739                return false;
740            }
741            $.each($._data(from, 'events'), function () {
742                $.each(this, function () {
743                    mw.$(to).bind(this.type, this.handler);
744                });
745            });
746        },
747        setTag: function (node, tag) {
748            var el = document.createElement(tag);
749            mw.tools.copyAttributes(node, el);
750            while (node.firstChild) {
751                el.appendChild(node.firstChild);
752            }
753            mw.tools.copyEvents(node, el);
754            mw.$(node).replaceWith(el);
755            return el;
756        },
757
758        module_settings: function (a, view, liveedit) {
759            var opts = {};
760            if (typeof liveedit === 'undefined') {
761                opts.liveedit = true;
762            }
763            if (!!view) {
764                opts.view = view;
765            }
766            else {
767                opts.view = 'admin';
768            }
769            return mw.live_edit.showSettings(a, opts);
770        },
771        fav: function (a) {
772            var canvas = document.createElement("canvas");
773            canvas.width = 16;
774            canvas.height = 16;
775            var context = canvas.getContext("2d");
776            context.fillStyle = "#EF3D25";
777            context.fillRect(0, 0, 16, 16);
778            context.font = "normal 10px Arial";
779            context.textAlign = 'center';
780            context.textBaseline = 'middle';
781            context.fillStyle = "white";
782            context.fillText(a, 8, 8);
783            var im = canvas.toDataURL();
784            var l = document.createElement('link');
785            l.className = 'mwfav';
786            l.setAttribute('rel', 'icon');
787            l.setAttribute('type', 'image/png');
788            l.href = im;
789            mw.$(".mwfav").remove();
790            document.getElementsByTagName('head')[0].appendChild(l);
791        },
792        px2pt: function (px) {
793            var n = parseInt(px, 10);
794            if (isNaN(n)) {
795                return false;
796            }
797            return Math.round(((3 / 4) * n));
798        },
799        matches: function (node, what) {
800            if (node === 'init') {
801                if (!!document.documentElement.matches) mw.tools.matchesMethod = 'matches';
802                else if (!!document.documentElement.matchesSelector) mw.tools.matchesMethod = 'matchesSelector';
803                else if (!!document.documentElement.mozMatchesSelector) mw.tools.matchesMethod = 'mozMatchesSelector';
804                else if (!!document.documentElement.webkitMatchesSelector) mw.tools.matchesMethod = 'webkitMatchesSelector';
805                else if (!!document.documentElement.msMatchesSelector) mw.tools.matchesMethod = 'msMatchesSelector';
806                else if (!!document.documentElement.oMatchesSelector) mw.tools.matchesMethod = 'oMatchesSelector';
807                else mw.tools.matchesMethod = undefined;
808            }
809            else {
810                if (node === null) {
811                    return false;
812                }
813                if (typeof node === 'undefined') {
814                    return false;
815                }
816                if (node.nodeType !== 1) {
817                    return false;
818                }
819                if (!!mw.tools.matchesMethod) {
820                    return node[mw.tools.matchesMethod](what)
821                }
822                else {
823                    var doc = document.implementation.createHTMLDocument("");
824                    node = node.cloneNode(true);
825                    doc.body.appendChild(node);
826                    var all = doc.body.querySelectorAll(what),
827                        l = all.length,
828                        i = 0;
829                    for (; i < l; i++) {
830                        if (all[i] === node) {
831                            return true;
832                        }
833                    }
834                    return false;
835                }
836            }
837        }
838    }
839
840    Object.assign(expose, helpers);
841    expose.matches('init');
842
843})(mw.tools);

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.