Demo entry 5684774

test

   

Submitted by anonymous on Jul 08, 2016 at 18:37
Language: JavaScript. Code size: 2.5 kB.

var OTVY_SWITCH = (function () {
    var timer = null;
    var $window = $(window);
    var bRedraw = false;
    var bStart = false;

    var deiSwitchListener = function () {
        $('#yearFilter,#ageFilter').on("change", function () {
            drawTopDeiGraph();
        });
    };

    var drawTopDeiGraph = function () {
        if (typeof verticalGraph !== 'undefined') {
            $(".dei-comparative svg").remove();
            var year = $("#yearFilter option:selected").val();
            var age = $("#ageFilter option:selected").val();
            VERTICAL_STACKED_CHART.init(year, age, verticalGraph, '.dei-comparative');
        }
    };

    var channelsSwitchListener = function () {
        $('#channelTopShare').on("change", channelSwitchHandler);
    };
    var channelSwitchHandler = function () {
        $(".shareChart svg").remove();
        var shareSwitch = $("#channelTopShare option:selected").val();
        drawTopChannel(shareSwitch);
    };
    var drawTopChannel = function (type) {
        for (var code in isoCodes) {
            if (typeof top10Graph !== 'undefined') {
                if (type === "prime") {
                    DONUT_CHART.drawDonutGraph(top10Graph[isoCodes[code]]['prime'], isoCodes[code], '.channel-top', '.shareChart');
                } else {
                    DONUT_CHART.drawDonutGraph(top10Graph[isoCodes[code]]['share'], isoCodes[code], '.channel-top', '.shareChart');
                }
            }
        }

    };

    var initDeiSwitch = function () {
        var deiLength = Object.keys(dei_data).length;
        if (deiLength > 1 && deiLength < 9) {
            deiSwitchListener();
            drawTopDeiGraph();
        }
    };

    var initChannelSwitch = function () {
        channelSwitchHandler();
        channelsSwitchListener();
        //drawTopChannel();

        $window.on('resize', function () {
            bRedraw = false;
//            startTimer();
            timer = setInterval(function () {
                if (bRedraw)
                {
                    channelSwitchHandler();
                    clearInterval(timer);
                }
                else
                {
                    bRedraw = true;
                }
            }, 500);
        });







    };


    return {
        initDeiSwitch: initDeiSwitch,
        initChannelSwitch: initChannelSwitch,
        drawTopChannel: drawTopChannel
    };

}());

This snippet took 0.01 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).