PageSourceSearch

https://swisspropertiesinvest.dk/wp-content/plugins/massive-stock-widgets/assets/public/js/common.js?ver=1.4.6

js swisspropertiesinvest.dk collected 2026-10-05 23:12:07 UTC 41,640 bytes, 1,062 lines download raw bytes

1(function($) {
2    "use strict";
3
4    depp.define({
5        'msw-chart-js': [mstocks.url + 'assets/public/js/Chart.min.js'],
6        'msw-echarts': [mstocks.url + 'assets/public/js/echarts-en.min.js'],
7        'msw-tinycolor': [mstocks.url + 'assets/public/js/tinycolor.min.js'],
8        'msw-rangeslider': [mstocks.url + 'assets/public/js/rangeslider.min.js'],
9        'msw-datatable': [mstocks.url + 'assets/public/js/jquery.dataTables.min.js'],
10        'msw-datatable-responsive': [mstocks.url + 'assets/public/js/dataTables.responsive.min.js'],
11        'msw-dragscroll': [mstocks.url + 'assets/public/js/dragscroll.js'],
12        'msw-typeahead': [mstocks.url + 'assets/public/js/typeahead.bundle.min.js']
13    });
14
15    mstocks.addCommas = function(nStr, d, s) {
16        nStr += '';
17        var x = nStr.split('.');
18        var x1 = x[0];
19        var x2 = x.length > 1 ? d + x[1] : '';
20        var rgx = /(\d+)(\d{3})/;
21        while (rgx.test(x1)) {
22            x1 = x1.replace(rgx, '$1' + s + '$2');
23        }
24        return isNaN(nStr) ? "" : x1 + x2;
25    }
26
27    // JS equivalent for PHP's number_format
28    mstocks.number_format = function(number, decimals, dec_point, thousands_point) {
29        if (number == null || !isFinite(number)) {
30            return '';
31        }
32    
33        if (!decimals) {
34            var len = number.toString().split('.').length;
35            decimals = len > 1 ? len : 0;
36        }
37    
38        if (!dec_point) {
39            dec_point = '.';
40        }
41    
42        if (!thousands_point) {
43            thousands_point = ',';
44        }
45    
46        number = parseFloat(number).toFixed(decimals);
47    
48        number = number.replace(".", dec_point);
49    
50        var splitNum = number.split(dec_point);
51        splitNum[0] = splitNum[0].replace(/\B(?=(\d{3})+(?!\d))/g, thousands_point);
52        number = splitNum.join(dec_point);
53    
54        return number;
55    }
56
57    // Format number based on fiat currency
58    mstocks.numberFormat = function(num, iso, shorten = false, decimals = 'auto') {
59        num = parseFloat(num);
60        var format = (mstocks.currency_format[iso] !== undefined) ? mstocks.currency_format[iso] : mstocks.default_currency_format;
61
62        if (shorten) {
63            decimals = format.decimals;
64        } else if (decimals == 'auto') {
65            decimals = (num >= 1) ? format.decimals : (num < 0.000001 ? 14 : 6);
66        } else {
67            decimals = parseInt(decimals);
68        }
69
70        num = num.toFixed(decimals);
71
72        var index = 0;
73        var suffix = '';
74        var suffixes = mstocks.suffixes.hasOwnProperty(iso) ? mstocks.suffixes[iso] : mstocks.suffixes['USD'];
75
76        if (shorten) {
77            while (num > 1000) {
78                num = num / 1000;
79                index++;
80            }
81            suffix = suffixes[index];
82        }
83
84        return mstocks.number_format(num, decimals, format.decimals_sep, format.thousands_sep) + suffix;
85    }
86
87    mstocks.priceFormat = function(price, currency) {
88
89        price = parseFloat(price);
90        var format = (mstocks.currency_format[currency] !== undefined) ? mstocks.currency_format[currency] : mstocks.default_currency_format;
91        var decimals = (price >= 1) ? format.decimals : 4;
92
93        var out = format.position;
94        out = out.replace('{symbol}', format.symbol);
95        out = out.replace('{space}', ' ');
96        out = out.replace('{price}', mstocks.addCommas(price.toFixed(decimals), format.decimals_sep, format.thousands_sep));
97
98        return out;
99    }
100
101    mstocks.addDecimals = function(price, currency) {
102        price = parseFloat(price);
103        return price;
104    }
105
106    var mswTickers = [];
107
108    $.fn.multiply = function(numCopies) {
109        var newElements = this.clone();
110        for(var i = 1; i < numCopies; i++) {
111            newElements = newElements.add(this.clone());
112        }
113        return newElements;
114    };
115
116    $.fn.mswDrawChart = function() {
117
118        var self = $(this);
119    
120        depp.require('msw-chart-js', function() {
121    
122            var canvas = self.find('canvas');
123            var currency = self.data('currency');
124            var border = canvas.data('border');
125            var colors = canvas.data('colors').split('|');
126            var values = canvas.data('points').toString().split(',');
127            var tooltipTheme = canvas.data('tooltip-theme');
128            var showlabel = (canvas.data('labels') && canvas.data('labels').split(',').length > 0) ? true : false;
129
130            var color = colors[0] ? colors[0] : '#4C84FE';
131            var background = 'rgba(255,255,255,0)';
132
133            if (colors[1] && colors[2]) {
134                var height = parseInt(canvas.attr('height')) + 5;
135                var background = canvas[0].getContext('2d').createLinearGradient(0, 0, 0, height);
136                background.addColorStop(0, colors[1]);
137                background.addColorStop(1, colors[2]);
138            } else if (colors[1]) {
139                background = colors[1] ? colors[1] : colors[0];
140            }
141
142            var data = {
143                labels: showlabel ? canvas.data('labels').split('|') : values,
144                datasets: [{
145                    data: values,
146                    fill: colors[1] ? true : false,
147                    backgroundColor: background,
148                    borderColor: color,
149                    pointRadius: 0,
150                    borderWidth: border,
151                    pointHitRadius: 50,
152                    pointHoverBorderColor: 'white',
153                    pointHoverBackgroundColor: color,
154                    pointHoverBorderWidth: 3,
155                    pointHoverRadius: 6
156                }]
157            };
158
159            var options = {
160                animation: { duration: 500 },
161                legend: { display: false },
162                scales: { xAxes: [{ display: false }], yAxes: [{ display: false }] },
163                tooltips: {
164                    enabled: false,
165                    intersect: true,
166                    callbacks: {
167                        title: function(tooltipItem, data) {
168                            return showlabel ? tooltipItem[0].label : false;
169                        },
170                        label: function(tooltipItem, data) {
171                            return mstocks.priceFormat(tooltipItem.value, currency);
172                        }
173                    },
174                    custom: function(tooltip) {
175
176                        // Tooltip Element
177                        var theme = $(this._chart.canvas).data('tooltip-theme');
178                        var tooltipEl = $('.chartjs-tooltip-' + theme)[0];
179                
180                        // Hide if no tooltip
181                        if (tooltip.opacity === 0) {
182                            tooltipEl.style.opacity = 0;
183                            return;
184                        }
185                
186                        // Set caret Position
187                        tooltipEl.classList.remove('above', 'below', 'no-transform');
188                        if (tooltip.yAlign) {
189                            tooltipEl.classList.add(tooltip.yAlign);
190                        } else {
191                            tooltipEl.classList.add('no-transform');
192                        }
193                
194                        function getBody(bodyItem) {
195                            return bodyItem.lines;
196                        }
197                
198                        // Set Text
199                        if (tooltip.body) {
200                            var titleLines = tooltip.title || [];
201                            var bodyLines = tooltip.body.map(getBody);
202                
203                            var innerHtml = '<thead>';
204                
205                            titleLines.forEach(function(title) {
206                                innerHtml += '<tr><th>' + title + '</th></tr>';
207                            });
208                            innerHtml += '</thead><tbody>';
209                
210                            bodyLines.forEach(function(body, i) {
211                                var pointer = (colors[2] ? colors[2] : (colors[1] ? colors[1] : colors[0]));
212                                var style = 'background:' + (pointer != '' ? pointer : '#4C84FE');
213                                var span = '<span class="chartjs-tooltip-key" style="' + style + '"></span>';
214                                innerHtml += '<tr><td>' + span + body + '</td></tr>';
215                            });
216                            innerHtml += '</tbody>';
217                
218                            var tableRoot = tooltipEl.querySelector('table');
219                            tableRoot.innerHTML = innerHtml;
220                        }
221                
222                        var positionY = $(this._chart.canvas).offset().top - $(window).scrollTop();
223                        var positionX = $(this._chart.canvas).offset().left;
224                
225                        // Display, position, and set styles for font
226                        tooltipEl.style.opacity = 1;
227                        tooltipEl.style.left = positionX + tooltip.caretX + 'px';
228                        tooltipEl.style.top = positionY + tooltip.caretY + 'px';
229                    }
230                },
231                hover: { mode: 'nearest', intersect: true },
232                maintainAspectRatio: false,
233                layout: {
234                    padding: {
235                        top: 1,
236                        bottom: 1
237                    }
238                }
239            };
240
241            if ($('.chartjs-tooltip-' + tooltipTheme).length == 0) {
242                $('body').append('<div class="chartjs-tooltip chartjs-tooltip-' + tooltipTheme + '"><table></table></div>');
243            }
244            
245            var chart = new Chart(canvas[0].getContext("2d"), { type: "line", data: data, options: options });
246    
247        });
248    
249    }
250
251    $('.msw-ticker-vertical').on('view', function() {
252        var self = $(this);
253        var id = self.closest('.msw-box').attr('id');
254        var scrollDiv = self.find('.cc-ticker');
255
256        var stockswidth = 0;
257        var stockslength = 0;
258        var width = self.width();
259        if (self.hasClass('msw-ticker-init') == false) {
260            self.find('.cc-stock').each(function() {
261                stockswidth += $(this).outerWidth();
262            });
263            stockslength = self.find('.cc-stock').length;
264        } else {
265            stockswidth = mswTickers[id]['w'];
266            stockslength = mswTickers[id]['l'];
267        }
268
269        var stockwidth = stockswidth / (stockslength > 0 ? stockslength : 1);
270        var columns = Math.max(Math.floor(width / (stockwidth > 0 ? stockwidth : 1 )), 1);
271        if (self.hasClass('msw-ticker-init') == false) {
272            mswTickers[id] = [];
273            mswTickers[id]['d'] = self.find('.msw-ticker-stats').clone();
274            mswTickers[id]['h'] = self.find('.msw-ticker-stats').height();
275            mswTickers[id]['l'] = stockslength;
276            mswTickers[id]['w'] = stockswidth;
277            scrollDiv.css('height', self.find('.msw-ticker-stats').height());
278            scrollDiv.empty().html('<div class="msw-ticker-stats"></div><div class="msw-ticker-stats"></div>');
279            self.addClass('msw-ticker-init');
280        }
281
282        var cur = 1;
283        var targetel = mswTickers[id]['d'].find('> a').length > 0 ? 'a' : 'div';
284
285        var items = mswTickers[id]['d'].find('> '+targetel+'').length;
286        var multiple = (items % columns != 0) ? items * columns : items;
287
288        clearInterval(mswTickers[id]['i']);
289
290        var scroller = function() {
291            var html = '';
292
293            for (var i = cur; i < (cur + columns); i++) {
294                var child = (i % items == 0) ? items : (i % items);
295                html += mswTickers[id]['d'].find('> '+targetel+':nth-child(' + child + ')')[0].outerHTML;
296            }
297
298            scrollDiv.find('.msw-ticker-stats:last').empty().html(html);
299
300            self.find('.msw-inline-chart').each(function() {
301                $(this).mswDrawChart();
302            });
303            
304            scrollDiv.stop().animate({ scrollTop: mswTickers[id]['h'] }, 400, 'swing', function(){
305                $(this).scrollTop(0).find('.msw-ticker-stats:last').after($('.msw-ticker-stats:first', this));
306            });
307
308            cur = ((cur - 1) == (multiple - columns)) ? 1 : (cur + columns);
309        }
310
311        scroller();
312
313        var speed = self.data('speed');
314        var duration = 2;
315
316        if (speed === 200) {
317            duration = 0;
318        } else if (speed > 100) {
319            speed = speed - 100;
320            speed = (speed / 100) * columns;
321            duration = duration - speed;
322        } else if (speed < 100) {
323            speed = 100 - speed;
324            speed = (speed / 10) * columns;
325            duration = duration + speed;
326        }
327
328        if (speed !== 0) {
329            mswTickers[id]['i'] = setInterval(scroller, duration * 1000);
330        }
331        self.css('visibility', 'visible');
332
333        if (self.hasClass('msw-header')) {
334            $('body').css('padding-top', mswTickers[id]['h'] + 'px');
335            $('#wpadminbar').css('margin-top', mswTickers[id]['h'] + 'px');
336        }
337
338    });
339
340    $('.msw-ticker-horizontal').on('view', function() {
341
342        var ticker = $(this);
343        var row = $(this).find('.msw-ticker-stats');
344        if(!row.find('.cc-stock').length > 0) return;
345
346        var listWidth = 0;
347
348        row.find('.cc-stock').each(function() {
349            listWidth += $(this).innerWidth();
350        });
351
352        var clonedElem = row.find('.cc-stock');
353        var mult = row.innerWidth() / (listWidth > 0 ? listWidth : 1);
354
355        row.append('<div class="cc-dup"></div>');
356
357        if(mult > 0.5){
358            row.find('.cc-dup').append(clonedElem.multiply(Math.ceil(mult)));
359        } else {
360            row.find('.cc-dup').append(clonedElem.multiply(1));
361        }
362
363        row.css('width', listWidth);
364
365        row.find('.msw-inline-chart').each(function() {
366            $(this).mswDrawChart();
367        });
368
369        var itemcount = row.find('.cc-stock').length;
370        var itemsize = listWidth / (itemcount > 0 ? itemcount : 1);
371
372        var speed = $(this).closest('.msw-ticker').data('speed');
373        var duration = itemsize * 10;
374        
375        if (speed === 200) {
376            duration = 10;
377        } else if (speed == 0) {
378            duration = 0;
379        } else if (speed > 100) {
380            speed = speed - 100;
381            speed = (speed / 10) * itemsize;
382            duration = duration - speed;
383        } else if (speed < 100) {
384            speed = 100 - speed;
385            speed = (speed / 10) * (itemsize * 8);
386            duration = duration + speed;
387        }
388
389        var speed = (itemcount * duration) / 1000;
390        row.css('animation-duration',  speed + 's');
391
392        ticker.css('visibility', 'visible');
393        
394        if (ticker.hasClass('msw-header')) {
395            $('body').css('padding-top', ticker.height() + 'px');
396            $('#wpadminbar').css('margin-top', ticker.height() + 'px');
397        }
398
399    });
400
401    $(window).on('load', function() {
402        $('.msw-ticker').each(function() {
403            $(this).trigger('view');
404        });
405    });
406
407    function debounce(func, wait, immediate) {
408        var timeout;
409        return function() {
410            var context = this, args = arguments;
411            clearTimeout(timeout);
412            timeout = setTimeout(function() {
413                timeout = null;
414                if (!immediate) func.apply(context, args);
415            }, wait);
416            if (immediate && !timeout) func.apply(context, args);
417        };
418    }
419
420    var resizeTickers = debounce(function() {
421        $('.msw-ticker-vertical').each(function() {
422            $(this).trigger('view');
423        });
424    }, 500);
425    
426    window.addEventListener('resize', resizeTickers);
427
428    $.fn.mswChart = function() {
429
430        if (this.length === 0) {
431            return;
432        }
433
434        var self = $(this);
435
436        depp.require(['msw-echarts', 'msw-tinycolor'], function() {
437
438            var data = {};
439
440            var breakpoint = 360;
441
442            var periods = ['1d', '5d', '1mo', '6mo', '1y', '5y', '10y', 'max'];
443
444            var opts = self.data('opts');
445
446            opts = $.extend({ id: 'AAPL', symbol: 'AAPL', name: 'Apple, Inc.', currency: 'USD', type: 'line', theme: 'light', period: '1d', toolbox: true, gradient: true, }, opts);
447    
448            var themes = {
449                light: {
450                    textColor: (opts.textcolor == '') ? '#222' : opts.textcolor,
451                    backgroundColor: (opts.bgcolor == '') ? '#fff' : opts.bgcolor,
452                    tooltipColor: '#3A414F',
453                    chartColor: (opts.chartcolors[0] == '') ? '#5274D6' : opts.chartcolors[0],
454                    chartColors: ['rgba(108,130,145,0.2)', '#14b143', '#ef232a']
455                },
456                dark: {
457                    textColor: (opts.textcolor == '') ? '#f2f2f2': opts.textcolor,
458                    backgroundColor: (opts.bgcolor == '') ? '#202328' : opts.bgcolor,
459                    tooltipColor: '#3A414F',
460                    chartColor: (opts.chartcolors[0] == '') ? '#5274D6' : opts.chartcolors[0],
461                    chartColors: ['rgba(108,130,145,0.2)', '#14b143', '#ef232a']
462                }
463            }
464    
465            var theme = themes[opts.theme];
466
467            var getOptions = function() {
468    
469                var options = {
470                    color: theme.chartColors,
471                    backgroundColor: theme.backgroundColor,
472                    textStyle: { color: theme.textColor, fontFamily: (opts.font == 'inherit') ? self.css('font-family') : opts.font },
473                    title: {
474                        text: opts.symbol,
475                        subtext: opts.name,
476                        textStyle: {
477                            color: theme.textColor
478                        },
479                        padding: 15
480        
481                    },
482                    tooltip: {
483                        trigger: 'axis',
484                        confine: true,
485                        backgroundColor: theme.tooltipColor,
486                        formatter: function (params) {
487
488                            var tooltip = params[0].name;
489    
490                            if (opts.type == 'line') {
491                                tooltip += '<br/>';
492                                tooltip += params[0].marker + mstocks.priceFormat(params[0].value, opts.currency);
493                            } else {
494                                tooltip += '<br/>';
495                                tooltip += params[0].marker + "open: " + mstocks.priceFormat(params[0].value[1], opts.currency) + "<br/>";
496                                tooltip += params[0].marker + "close: " + mstocks.priceFormat(params[0].value[2], opts.currency) + "<br/>";
497                                tooltip += params[0].marker + "high: " + mstocks.priceFormat(params[0].value[4], opts.currency) + "<br/>";
498                                tooltip += params[0].marker + "low: " + mstocks.priceFormat(params[0].value[3], opts.currency) + "<br/>";
499                                tooltip += params[1].marker + 'volume: ' + mstocks.priceFormat(params[1].value, opts.currency);
500                            }
501    
502                            return tooltip;
503                        }
504                    },
505                    legend: {
506                        show: false
507                    },
508                    grid: {
509                        left: 15,
510                        right: 15,
511                        top: (opts.toolbox && self.width() < breakpoint) ? 110 : 80,
512                        bottom: 20,
513                        containLabel: true
514                    },
515                    xAxis: [],
516                    yAxis: [],
517                    series: [],
518                    dataZoom: []
519                }
520
521                if (opts.toolbox) {
522
523                    options.toolbox = {
524                        show: true,
525                        top: (self.width() > breakpoint) ? 10 : 60,
526                        left: (self.width() > breakpoint) ? 'auto' : 10,
527                        right: (self.width() > breakpoint) ? 10 : 'auto',
528                        itemSize: 40,
529                        showTitle: false,
530                        feature: {
531                            myTool1: {
532                                show: true,
533                                icon: 'image://' + mstocks.url + 'assets/public/img/chart/1d-' + opts.theme + '.svg',
534                                iconStyle: { opacity: 0.3 },
535                                onclick: function () { changeData('1d'); }
536                            },
537                            myTool2: {
538                                show: true,
539                                icon: 'image://' + mstocks.url + 'assets/public/img/chart/5d-' + opts.theme + '.svg',
540                                iconStyle: { opacity: 0.3 },
541                                onclick: function () { changeData('5d'); }
542                            },
543                            myTool3: {
544                                show: true,
545                                icon: 'image://' + mstocks.url + 'assets/public/img/chart/1mo-' + opts.theme + '.svg',
546                                iconStyle: { opacity: 0.3 },
547                                onclick: function () { changeData('1mo'); }
548                            },
549                            myTool4: {
550                                show: true,
551                                icon: 'image://' + mstocks.url + 'assets/public/img/chart/6mo-' + opts.theme + '.svg',
552                                iconStyle: { opacity: 0.3 },
553                                onclick: function () { changeData('6mo'); }
554                            },
555                            myTool5: {
556                                show: true,
557                                icon: 'image://' + mstocks.url + 'assets/public/img/chart/1y-' + opts.theme + '.svg',
558                                iconStyle: { opacity: 0.3 },
559                                onclick: function () { changeData('1y'); }
560                            },
561                            myTool6: {
562                                show: true,
563                                icon: 'image://' + mstocks.url + 'assets/public/img/chart/5y-' + opts.theme + '.svg',
564                                iconStyle: { opacity: 0.3 },
565                                onclick: function () { changeData('5y'); }
566                            },
567                            myTool7: {
568                                show: true,
569                                icon: 'image://' + mstocks.url + 'assets/public/img/chart/10y-' + opts.theme + '.svg',
570                                iconStyle: { opacity: 0.3 },
571                                onclick: function () { changeData('10y'); }
572                            },
573                            myTool8: {
574                                show: true,
575                                icon: 'image://' + mstocks.url + 'assets/public/img/chart/max-' + opts.theme + '.svg',
576                                iconStyle: { opacity: 0.3 },
577                                onclick: function () { changeData('max'); }
578                            },
579                        },
580                        iconStyle: {
581                            opacity: 0.3
582                        },
583                        emphasis: {
584                            iconStyle: {
585                                opacity: 1
586                            }
587                        }
588                    };
589
590                    options.toolbox.feature['myTool' + (periods.indexOf(opts.period) + 1)]['iconStyle'] = {
591                        opacity: 1
592                    };
593
594                }
595        
596                if (opts.type == 'line') {
597        
598                    options.xAxis.push({
599                        type: 'category',
600                        boundaryGap: false,
601                        axisLabel: {
602                            showMinLabel: false,
603                            showMaxLabel: false
604                        }
605                    });
606                    options.yAxis.push({
607                        type: 'value',
608                        scale: true,
609                        position: 'right',
610                        splitLine: {
611                            show: true,
612                            lineStyle: { color: 'rgba(0,0,0,0.1)', width: 1, type: 'solid' }
613                        },
614                        axisLabel: {
615                            formatter: function (value, index) {
616                                return value == 0 ? 0 : mstocks.numberFormat(value, opts.currency);
617                            }
618                        }
619                    });
620                    options.series.push({
621                        type: 'line',
622                        smooth: true,
623                        symbol: 'none',
624                        lineStyle: {
625                            width: 2
626                        },
627                        itemStyle: {
628                            color: theme.chartColor
629                        },
630                        areaStyle: (opts.chartcolors[1] && opts.chartcolors[2]) ? {
631                            color: {
632                                type: 'linear',
633                                x: 0,
634                                y: 0,
635                                x2: 0,
636                                y2: 1,
637                                colorStops: [{
638                                    offset: 0, color: opts.chartcolors[1]
639                                }, {
640                                    offset: 1, color: opts.chartcolors[2]
641                                }]
642                            },
643                            opacity: 1
644                        } : {
645                            color: opts.chartcolors[1] ? opts.chartcolors[1] : opts.chartcolors[0],
646                            opacity: opts.chartcolors[1] ? 1 : 0
647                        }
648                    });
649        
650                }
651        
652                if (opts.type == 'candlestick') {
653        
654                    options.xAxis.push({
655                        type: 'category',
656                        boundaryGap: true,
657                        axisLabel: {
658                            showMinLabel: false,
659                            showMaxLabel: false
660                        }
661                    });
662        
663                    options.yAxis.push({
664                        type : 'value',
665                        scale: false,
666                        position: 'right',
667                        min: 'dataMin',
668                        max: 'dataMax',
669                        splitLine: {
670                            show: false
671                        },
672                        axisLabel: {
673                            showMinLabel: false,
674                            formatter: function (value, index) {
675                                return value == 0 ? 0 : mstocks.numberFormat(value, opts.currency);
676                            }
677                        }
678                    }, {
679                        type : 'value',
680                        scale: false,
681                        splitLine: {
682                            show: true,
683                            lineStyle: {
684                                color: 'rgba(0,0,0,0.1)',
685                                width: 1,
686                                type: 'solid'
687                            }
688                        },
689                        axisLabel: {
690                            show: false
691                        },
692                        axisTick: {
693                            show: false
694                        },
695                        axisLine: {
696                            show: false
697                        }
698                    });
699        
700                    options.series.push({
701                        name:'OHLC',
702                        type:'candlestick',
703                        itemStyle: {
704                            normal: {
705                                color: theme.chartColors[1],
706                                color0: theme.chartColors[2],
707                                borderColor: theme.chartColors[1],
708                                borderColor0: theme.chartColors[2],
709                            }
710                        }
711                    });
712        
713                    options.series.push({
714                        name: 'Volume',
715                        type: 'bar',
716                        yAxisIndex: 1
717                    });
718
719                    options.dataZoom.push({
720                        type: 'inside',
721                        xAxisIndex: [0],
722                        // startValue : data.length - Math.round(self.width() / 24),
723                        // endValue : data.length - 1,
724                    });
725        
726                }
727
728                return options;
729
730            }
731    
732            var chart = echarts.init(self[0]);
733    
734            function drawChart() {
735    
736                chart.showLoading('default', { text: '', maskColor: theme.backgroundColor });
737    
738                getData(function(res) {
739
740                    data = res;
741                    
742                    var points = data.filter(function(point) {
743                        if (opts.type == 'line') {
744                            return point.close;
745                        } else {
746                            return point.close && point.open;
747                        }
748                    });
749
750                    var options = getOptions();
751
752                    options.xAxis[0].data = [];
753                    options.series[0].data = [];
754
755                    if (opts.type == 'candlestick') {
756                        options.series[1].data = [];
757                    }
758    
759                    for (var i = 0; i < points.length; i++) {
760
761                        var label = ('label' in points[i]) ? points[i].label : points[i].date;
762                        var open = mstocks.addDecimals(points[i].open, opts.currency);
763                        var close = mstocks.addDecimals(points[i].close, opts.currency);
764                        var high = mstocks.addDecimals(points[i].high, opts.currency);
765                        var low = mstocks.addDecimals(points[i].low, opts.currency);
766 
767                        if (opts.type == 'line') {
768                            options.xAxis[0].data.push(label);
769                            options.series[0].data.push(close);
770                        }
771        
772                        if (opts.type == 'candlestick') {
773                            options.xAxis[0].data.push(label);
774                            options.series[0].data.push([open, close, low, high]);
775                            options.series[1].data.push(points[i].volume);
776                        }
777                    }
778    
779                    chart.setOption(options);
780                    chart.hideLoading();
781    
782                });
783    
784            }
785    
786            function getData(callback) {
787    
788                $.get(mstocks.ajaxurl, {
789                    action: 'msw_chart',
790                    symbols: opts.id,
791                    period: opts.period,
792                    currency: opts.currency,
793                    chartCloseOnly: (opts.type == 'candlestick') ? 'false' : 'true'
794                }, function(data) {
795                    return callback(data[opts.id]['chart-' + opts.period]['points']);
796                }, 'json');
797    
798            }
799
800            function changeData(period) {
801                opts.period = period;
802                drawChart();
803            }
804
805            $(window).on('resize', function() {
806                var options = getOptions();
807                chart.setOption(options);
808                chart.resize();
809            });
810    
811            drawChart();
812
813        });
814    }
815
816    $.fn.mswAccordion = function() {
817
818        var self = this;
819
820        self.find('.msw-list-item:eq(0)').addClass('active').find('.msw-list-body').slideDown();
821
822        self.find('.msw-list-header').on('click', function() {
823            $(this).parents('.msw-list').find('.msw-list-item').not($(this).parent()).removeClass('active').find('.msw-list-body').slide
823Up();
824            $(this).parent().toggleClass('active');
825            $(this).next('.msw-list-body').slideToggle();
826        });
827
828    }
829
830    $.fn.mswTable = function () {
831
832        var self = this;
833        var breakpoint = 480;
834        var table = self.find('.msw-datatable');
835        var config = table.data('config');
836
837        var deps = ['msw-datatable'];
838        if (config.responsive) { deps.push('msw-datatable-responsive'); } else { deps.push('msw-dragscroll'); }
839
840        depp.require(deps, function () {
841
842            var columns = [];
843
844            table.find('thead th').each(function (index) {
845
846                var column = $(this).data('col');
847
848                columns.push({
849                    name: column
850                });
851
852            });
853
854            var options = {
855                dom: 'r<"loader"><"datatable-scroll dragscroll"t><"loader loader-footer"><"clear">',
856                order: [],
857                columns: columns,
858                paging: false,
859                columnDefs: [
860                    { targets: 'col-' + columns[0]['data'], className: 'ctrl all' },
861                    { targets: 'col-52_week_range', width: '100px', 'max-width': '100px' },
862                    { targets: 'col-chart-1d', width: '100px', 'max-width': '100px' },
863                    { targets: 'col-chart-5d', width: '100px', 'max-width': '100px' }
864                ],
865                language: {
866                    processing: '',
867                    emptyTable: '<div style="text-align: left;">No stocks found.</div>'
868                },
869                responsive: config.responsive,
870                drawCallback: function() {
871
872                    table.find('.msw-inline-chart').each(function() {
873                        $(this).mswDrawChart();
874                    });
875
876                    table.find('.msw-range-slider').each(function() {
877                        $(this).mswRangeSlider();
878                    });
879
880                },
881                initComplete: function(oSettings) {
882
883                    var datatable = this;
884
885                    if (!config.responsive) {
886                        table.find('.datatable-scroll').attr('nochilddrag', 'true').addClass('dragscroll');
887                        dragscroll.reset();
888                    }
889
890                }
891            };
892
893            var tabledt = table.DataTable(options);
894
895            tabledt.on('responsive-display', function (e) {
896                $(e.currentTarget).find('td.child .msw-inline-chart').each(function() {
897                    $(this).mswDrawChart();
898                });
899                $(e.currentTarget).find('.msw-range-slider').each(function() {
900                    $(this).mswRangeSlider();
901                });
902            });
903
904        });
905
906    }
907
908    $.fn.mswRangeSlider = function() {
909
910        var self = $(this);
911        var currency = self.data('currency');
912
913        depp.require('msw-rangeslider', function() {
914
915            var input = self.find('input');
916            var colors = ['#f00', 'orange', '#06a076'];
917            var value = input.val(), min = input.attr('min'), max = input.attr('max');
918
919            input.rangeslider({
920                polyfill: false,
921                onInit: function() {
922                    var percent = (value - min) * 100 / ((max - min) > 0 ? (max - min) : 1);
923                    var color = (percent > 66) ? colors[2] : (percent > 33) ? colors[1] : colors[0];
924                    $(this.$handle).html(mstocks.priceFormat(value, currency));
925                    $(this.$fill).css('background', color);
926                    $(this.$handle).css('background', color);
927                    $(this.$range).append('<div class="range-min">' + mstocks.priceFormat(min, currency) + '</div><div class="range-max">' + mstocks.priceFormat(max, currency) + '</div>');
928                }
929            });
930            input.rangeslider('update', true);
931
932        });
933    }
934
935    $.fn.mswResize = function() {
936        var self = this;
937        var breakpoint = 'msw-xs msw-sm msw-md msw-lg msw-xl';
938        var width = self.width();
939
940        if (width >= 1200) {
941            breakpoint = 'msw-xl';
942        } else if (width >= 992) {
943            breakpoint = 'msw-lg msw-xl';
944        } else if (width >= 768) {
945            breakpoint = 'msw-md msw-lg msw-xl';
946        } else if (width >= 576) {
947            breakpoint = 'msw-sm msw-md msw-lg msw-xl';
948        }
949
950        this.removeClass('msw-xs msw-sm msw-md msw-lg msw-xl').addClass(breakpoint).attr('data-width', width);
951        this.removeClass('msw-hidden');
952    }
953
954    $.fn.mswSearch = function() {
955
956        var self = this;
957        var input = self.find('input');
958
959        var depps = ['msw-typeahead'];
960
961        depp.require(depps, function() {
962
963            self.find('input').typeahead({
964                hint: true,
965                highlight: true,
966                minLength: 1
967            }, {
968                name: 'stocks',
969                display: function(item) {
970                    return item.name;
971                },
972                source: new Bloodhound({
973                    datumTokenizer: Bloodhound.tokenizers.obj.whitespace('name'),
974                    queryTokenizer: Bloodhound.tokenizers.whitespace,
975                    remote: {
976                        url: mstocks.ajaxurl + '?action=msw_search_stocks&id=' + self.attr('id').split('-')[1] + '&query=%QUERY',
977                        wildcard: '%QUERY',
978                        prepare: function(query, settings){
979                            $('.msw-search .search-icon').addClass('search-load');
980                            settings.url = mstocks.ajaxurl+'?action=msw_search_stocks&id=' + self.attr('id').split('-')[1] + '&query=' + query;
981                            return settings;
982                        },
983                        filter: function(data){
984                            $('.msw-search .search-icon').removeClass('search-load');
985                            return data.data;
986                        }
987                    }
988                }),
989                templates: {
990                    suggestion: function(data) {
991                        var html = '';
992    
993                        html += '<p>';
994                        html += data.link ? '<a href="' + data.link + '" class="prelink">' : '<span class="prelink">';
995                        html += '<b class="stocksymbol">' + data.symbol + '</b>';
996                        html += '<span class="stockname">' + data.name + '</span>';
997                        html += '<small>' + data.type + ' - ' + data.exchange + '</small>';
998                        html += data.link ? '</a>' : '</span>';
999                        html += '</p>';
1000    
1001                        return html;
1002                    }
1003                }
1004            });
1005    
1006            input.on('typeahead:open input', function() {
1007                if (self.find('.tt-dataset p').length > 0) {
1008                    input.addClass('dropdown-open');
1009                } else {
1010                    input.removeClass('dropdown-open');
1011                }
1012            });
1013    
1014            input.on('typeahead:close', function() {
1015                input.removeClass('dropdown-open');
1016            });
1017    
1018            input.on('keypress', function(e) {
1019                if (e.which == 13) {
1020                    var link = self.find('.tt-suggestion:first-child a').attr('href');
1021                    var text = self.find('.tt-suggestion:first-child a 
1021span.stockname').text();
1022                    if(typeof link != 'undefined'){
1023                        window.location = link;
1024                    }
1025                }
1026            });
1027
1028        });
1029
1030    }
1031
1032    $('.msw-box').each(function() {
1033        $(this).mswResize();
1034    });
1035
1036    $(window).resize(function() {
1037        $('.msw-box').each(function() {
1038            $(this).mswResize();
1039        });
1040    });
1041
1042    $('.msw-list-toggle').each(function() {
1043        $(this).mswAccordion();
1044    });
1045
1046    $('.msw-chart').each(function(){
1047        $(this).mswChart();
1048    });
1049
1050    $('.msw-table').each(function () {
1051        $(this).mswTable();
1052    });
1053
1054    $('.msw-inline-chart').each(function() {
1055        $(this).mswDrawChart();
1056    });
1057
1058    $('.msw-search').each(function() {
1059        $(this).mswSearch();
1060    });
1061
1062})( jQuery );

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.