<commit_before>/*jslint browser: true, for: true */
/*global dashjs, flowplayer, MediaPlayer, window */

/*!

   MPEG-DASH engine plugin for Flowplayer HTML5

   Copyright (c) 2015-2016, Flowplayer Oy

   Released under the MIT License:
   http://www.opensource.org/licenses/mit-license.php

   Includes dash.all.js:
   Copyright (c) 2015, Dash Industry Forum. **All rights reserved.
   https://github.com/Dash-Industry-Forum/dash.js/blob/master/LICENSE.md

   requires:
   - Flowplayer HTML5 version 6.x or greater
   - dash.js https://github.com/Dash-Industry-Forum/dash.js
   revision: $GIT_ID$

*/

(function (flowplayer, dashjs) {
    "use strict";
    var engineName = "dash",
        mse = window.MediaSource,
        common = flowplayer.common,
        extend = flowplayer.extend,
        version = flowplayer.version,
        dashconf,

        isDashType = function (typ) {
            return typ.toLowerCase() === "application/dash+xml";
        },

        engineImpl = function mpegdashEngine(player, root) {
            var bean = flowplayer.bean,
                mediaPlayer,
                videoTag,
                bc,
                has_bg,

                engine = {
                    engineName: engineName,

                    pick: function (sources) {
                        var i,
                            source;

                        for (i = 0; i < sources.length; i += 1) {
                            source = sources[i];
                            if (isDashType(source.type)
                                    && (!source.engine || source.engine === engineName)) {
                                if (typeof source.src === 'string') {
                                    source.src = common.createAbsoluteUrl(source.src);
                                }
                                return source;
                            }
                        }
                    },

                    load: function (video) {
                        var init = !mediaPlayer,
                            conf = player.conf,
                            livestartpos = 0;

                        if (init) {
                            common.removeNode(common.findDirect("video", root)[0]
                                    || common.find(".fp-player > video", root)[0]);
                            videoTag = common.createElement("video", {
                                className: "fp-engine " + engineName + "-engine",
                                autoplay: conf.autoplay
                                    ? "autoplay"
                                    : false
                            });
                            videoTag.setAttribute("x-webkit-airplay", "allow");
                        } else {
                            mediaPlayer.reset();
                        }

                        bean.on(videoTag, "play", function () {
                            player.trigger('resume', [player]);
                        });
                        bean.on(videoTag, "pause", function () {
                            player.trigger('pause', [player]);
                        });
                        bean.one(videoTag, "timeupdate." + engineName, function () {
                            if (video.live) {
                                livestartpos = videoTag.currentTime;
                            }
                        });
                        bean.on(videoTag, "timeupdate", function () {
                            player.trigger('progress', [player, videoTag.currentTime - livestartpos]);
                        });
                        bean.on(videoTag, "loadeddata", function () {
                            extend(video, {
                                duration: videoTag.duration,
                                seekable: videoTag.seekable.end(null),
                                width: videoTag.videoWidth,
                                height: videoTag.videoHeight,
                                url: videoTag.currentSrc
                            });
                            player.trigger('ready', [player, video]);
                        });
                        bean.on(videoTag, "seeked", function () {
                            player.trigger('seek', [player, videoTag.currentTime]);
                        });
                        bean.on(videoTag, "progress", function (e) {
                            var ct = videoTag.currentTime,
                                buffer = 0,
                                buffend,
                                buffered,
                                last,
                                i;

                            try {
                                buffered = videoTag.buffered;
                                last = buffered.length - 1;
                                buffend = 0;
                                // cycle through time ranges to obtain buffer
                                // nearest current time
                                if (ct) {
                                    for (i = last; i > -1; i -= 1) {
                                        buffend = buffered.end(i);

                                        if (buffend >= ct) {
                                            buffer = buffend;
                                        }
                                    }
                                }
                            } catch (ignore) {}

                            video.buffer = buffer;
                            player.trigger('buffer', [player, e]);
                        });
                        bean.on(videoTag, "ended", function () {
                            player.trigger('finish', [player]);
                        });
                        bean.on(videoTag, "volumechange", function () {
                            player.trigger('volume', [player, videoTag.volume]);
                        });

                        if (init) {
                            mediaPlayer = dashjs.MediaPlayer().create();
                            player.engine[engineName] = mediaPlayer;

                            // new ABR algo
                            mediaPlayer.enableBufferOccupancyABR(!!dashconf.bufferOccupancyABR);
                            // caching can cause failures in playlists
                            // for the moment disable entirely
                            mediaPlayer.enableLastBitrateCaching(false);
                            // handled by fp API
                            mediaPlayer.setAutoPlay(false);
                            // for seeking in paused state
                            mediaPlayer.setScheduleWhilePaused(true);

                            mediaPlayer.on("error", function (e) {
                                var fperr,
                                    errobj;

                                switch (e.error) {
                                case "download":
                                    fperr = 4;
                                    break;
                                case "manifestError":
                                    fperr = 5;
                                    break;
                                case "mediasource":
                                    switch (e.event) {
                                    case "MEDIA_ERR_DECODE":
                                        fperr = 3;
                                        break;
                                    case "MEDIA_ERR_SRC_NOT_SUPPORTED":
                                        fperr = 5;
                                        break;
                                    case "MEDIA_ERR_NETWORK":
                                        fperr = 2;
                                        break;
                                    case "MEDIA_ERR_ABORTED":
                                        fperr = 1;
                                        break;
                                    }
                                    break;
                                }
                                if (fperr) {
                                    errobj = {code: fperr};
                                    if (fperr > 2) {
                                        errobj.video = extend(video, {
                                            src: video.src,
                                            url: e.event.url || video.src
                                        });
                                    }
                                    player.trigger('error', [player, errobj]);
                                }
                            }, false);

                            common.prepend(common.find(".fp-player", root)[0], videoTag);
                            mediaPlayer.initialize(videoTag, video.src, false);
                            player.engine[engineName] = mediaPlayer;

                        } else {
                            mediaPlayer.attachView(videoTag);
                            mediaPlayer.attachSource(video.src);

                        }

                        if (conf.autoplay || video.autoplay) {
                            // at least some Android requires extra load
                            // https://github.com/flowplayer/flowplayer/issues/910
                            if (!flowplayer.support.zeropreload) {
                                videoTag.load();
                            }
                            if (videoTag.paused) {
                                bean.on(videoTag, "loadeddata." + engineName, function () {
                                    videoTag.play();
                                });
                            }
                        }
                    },

                    resume: function () {
                        videoTag.play();
                    },

                    pause: function () {
                        videoTag.pause();
                    },

                    seek: function (time) {
                        videoTag.currentTime = time;
                    },

                    volume: function (level) {
                        if (videoTag) {
                            videoTag.volume = level;
                        }
                    },

                    speed: function (val) {
                        videoTag.playbackRate = val;
                        player.trigger('speed', [player, val]);
                    },

                    unload: function () {
                        if (mediaPlayer) {
                            mediaPlayer.reset();
                            mediaPlayer = 0;
                            bean.off(videoTag);
                            common.removeNode(videoTag);
                            videoTag = 0;
                        }
                    }
                };

            // pre 6.0.4: no boolean api.conf.poster and no poster with autoplay
            if (/^6\.0\.[0-3]$/.test(version) &&
                    !player.conf.splash && !player.conf.poster && !player.conf.autoplay) {
                bc = common.css(root, 'backgroundColor');
                // spaces in rgba arg mandatory for recognition
                has_bg = common.css(root, 'backgroundImage') !== "none" ||
                        (bc && bc !== "rgba(0, 0, 0, 0)" && bc !== "transparent");
                if (has_bg) {
                    player.conf.poster = true;
                }
            }
            if (player.conf.poster) {
                // when player is stopped the engine is too late to the party:
                // poster is already removed, poster state must be reset
                player.on("stop." + engineName, function () {
                    var posterClass = "is-poster";

                    setTimeout(function () {
                        common.addClass(root, posterClass);
                        player.one("progress." + engineName, function () {
                            common.removeClass(root, posterClass);
                        });
                    }, 0);
                });
            }

            return engine;
        };

    if (mse && version.indexOf("5.") !== 0) {
        // only load engine if it can be used
        engineImpl.engineName = engineName; // must be exposed
        engineImpl.canPlay = function (type, conf) {
            /*
              WARNING: MediaSource.isTypeSupported very inconsistent!
              e.g. Safari ignores codecs entirely, even bogus, like codecs="XYZ"
              example avc3 main level 3.1 + aac_he: avc3.4d401f; mp4a.40.5
              example avc1 high level 4.1 + aac_lc: avc1.640029; mp4a.40.2
              default: avc1 baseline level 3.0 + aac_lc
            */
            // inject dash conf at earliest opportunity
            dashconf = extend({
                type: "video/mp4",
                codecs: "avc1.42c01e, mp4a.40.2"
            }, flowplayer.conf[engineName], conf[engineName], conf.clip[engineName]);

            return isDashType(type) &&
                    mse.isTypeSupported(dashconf.type + '; codecs="' + dashconf.codecs + '"');
        };

        // put on top of engine stack
        // so mpegedash is tested before html5
        flowplayer.engines.unshift(engineImpl);

    }

}.apply(null, (typeof module === 'object' && module.exports)
    ? [require('flowplayer'), require('dashjs')]
    : [window.flowplayer, window.dashjs]));
<commit_msg>Unregister player events on unload<commit_after>/*jslint browser: true, for: true */
/*global dashjs, flowplayer, MediaPlayer, window */

/*!

   MPEG-DASH engine plugin for Flowplayer HTML5

   Copyright (c) 2015-2016, Flowplayer Oy

   Released under the MIT License:
   http://www.opensource.org/licenses/mit-license.php

   Includes dash.all.js:
   Copyright (c) 2015, Dash Industry Forum. **All rights reserved.
   https://github.com/Dash-Industry-Forum/dash.js/blob/master/LICENSE.md

   requires:
   - Flowplayer HTML5 version 6.x or greater
   - dash.js https://github.com/Dash-Industry-Forum/dash.js
   revision: $GIT_ID$

*/

(function (flowplayer, dashjs) {
    "use strict";
    var engineName = "dash",
        mse = window.MediaSource,
        common = flowplayer.common,
        extend = flowplayer.extend,
        version = flowplayer.version,
        dashconf,

        isDashType = function (typ) {
            return typ.toLowerCase() === "application/dash+xml";
        },

        engineImpl = function mpegdashEngine(player, root) {
            var bean = flowplayer.bean,
                mediaPlayer,
                videoTag,
                bc,
                has_bg,

                engine = {
                    engineName: engineName,

                    pick: function (sources) {
                        var i,
                            source;

                        for (i = 0; i < sources.length; i += 1) {
                            source = sources[i];
                            if (isDashType(source.type)
                                    && (!source.engine || source.engine === engineName)) {
                                if (typeof source.src === 'string') {
                                    source.src = common.createAbsoluteUrl(source.src);
                                }
                                return source;
                            }
                        }
                    },

                    load: function (video) {
                        var init = !mediaPlayer,
                            conf = player.conf,
                            livestartpos = 0;

                        if (init) {
                            common.removeNode(common.findDirect("video", root)[0]
                                    || common.find(".fp-player > video", root)[0]);
                            videoTag = common.createElement("video", {
                                className: "fp-engine " + engineName + "-engine",
                                autoplay: conf.autoplay
                                    ? "autoplay"
                                    : false
                            });
                            videoTag.setAttribute("x-webkit-airplay", "allow");
                        } else {
                            mediaPlayer.reset();
                        }

                        bean.on(videoTag, "play", function () {
                            player.trigger('resume', [player]);
                        });
                        bean.on(videoTag, "pause", function () {
                            player.trigger('pause', [player]);
                        });
                        bean.one(videoTag, "timeupdate." + engineName, function () {
                            if (video.live) {
                                livestartpos = videoTag.currentTime;
                            }
                        });
                        bean.on(videoTag, "timeupdate", function () {
                            player.trigger('progress', [player, videoTag.currentTime - livestartpos]);
                        });
                        bean.on(videoTag, "loadeddata", function () {
                            extend(video, {
                                duration: videoTag.duration,
                                seekable: videoTag.seekable.end(null),
                                width: videoTag.videoWidth,
                                height: videoTag.videoHeight,
                                url: videoTag.currentSrc
                            });
                            player.trigger('ready', [player, video]);
                        });
                        bean.on(videoTag, "seeked", function () {
                            player.trigger('seek', [player, videoTag.currentTime]);
                        });
                        bean.on(videoTag, "progress", function (e) {
                            var ct = videoTag.currentTime,
                                buffer = 0,
                                buffend,
                                buffered,
                                last,
                                i;

                            try {
                                buffered = videoTag.buffered;
                                last = buffered.length - 1;
                                buffend = 0;
                                // cycle through time ranges to obtain buffer
                                // nearest current time
                                if (ct) {
                                    for (i = last; i > -1; i -= 1) {
                                        buffend = buffered.end(i);

                                        if (buffend >= ct) {
                                            buffer = buffend;
                                        }
                                    }
                                }
                            } catch (ignore) {}

                            video.buffer = buffer;
                            player.trigger('buffer', [player, e]);
                        });
                        bean.on(videoTag, "ended", function () {
                            player.trigger('finish', [player]);
                        });
                        bean.on(videoTag, "volumechange", function () {
                            player.trigger('volume', [player, videoTag.volume]);
                        });

                        if (init) {
                            mediaPlayer = dashjs.MediaPlayer().create();
                            player.engine[engineName] = mediaPlayer;

                            // new ABR algo
                            mediaPlayer.enableBufferOccupancyABR(!!dashconf.bufferOccupancyABR);
                            // caching can cause failures in playlists
                            // for the moment disable entirely
                            mediaPlayer.enableLastBitrateCaching(false);
                            // handled by fp API
                            mediaPlayer.setAutoPlay(false);
                            // for seeking in paused state
                            mediaPlayer.setScheduleWhilePaused(true);

                            mediaPlayer.on("error", function (e) {
                                var fperr,
                                    errobj;

                                switch (e.error) {
                                case "download":
                                    fperr = 4;
                                    break;
                                case "manifestError":
                                    fperr = 5;
                                    break;
                                case "mediasource":
                                    switch (e.event) {
                                    case "MEDIA_ERR_DECODE":
                                        fperr = 3;
                                        break;
                                    case "MEDIA_ERR_SRC_NOT_SUPPORTED":
                                        fperr = 5;
                                        break;
                                    case "MEDIA_ERR_NETWORK":
                                        fperr = 2;
                                        break;
                                    case "MEDIA_ERR_ABORTED":
                                        fperr = 1;
                                        break;
                                    }
                                    break;
                                }
                                if (fperr) {
                                    errobj = {code: fperr};
                                    if (fperr > 2) {
                                        errobj.video = extend(video, {
                                            src: video.src,
                                            url: e.event.url || video.src
                                        });
                                    }
                                    player.trigger('error', [player, errobj]);
                                }
                            }, false);

                            common.prepend(common.find(".fp-player", root)[0], videoTag);
                            mediaPlayer.initialize(videoTag, video.src, false);
                            player.engine[engineName] = mediaPlayer;

                        } else {
                            mediaPlayer.attachView(videoTag);
                            mediaPlayer.attachSource(video.src);

                        }

                        if (conf.autoplay || video.autoplay) {
                            // at least some Android requires extra load
                            // https://github.com/flowplayer/flowplayer/issues/910
                            if (!flowplayer.support.zeropreload) {
                                videoTag.load();
                            }
                            if (videoTag.paused) {
                                bean.on(videoTag, "loadeddata." + engineName, function () {
                                    videoTag.play();
                                });
                            }
                        }
                    },

                    resume: function () {
                        videoTag.play();
                    },

                    pause: function () {
                        videoTag.pause();
                    },

                    seek: function (time) {
                        videoTag.currentTime = time;
                    },

                    volume: function (level) {
                        if (videoTag) {
                            videoTag.volume = level;
                        }
                    },

                    speed: function (val) {
                        videoTag.playbackRate = val;
                        player.trigger('speed', [player, val]);
                    },

                    unload: function () {
                        if (mediaPlayer) {
                            mediaPlayer.reset();
                            mediaPlayer = 0;
                            player.off("." + engineName);
                            bean.off(videoTag);
                            common.removeNode(videoTag);
                            videoTag = 0;
                        }
                    }
                };

            // pre 6.0.4: no boolean api.conf.poster and no poster with autoplay
            if (/^6\.0\.[0-3]$/.test(version) &&
                    !player.conf.splash && !player.conf.poster && !player.conf.autoplay) {
                bc = common.css(root, 'backgroundColor');
                // spaces in rgba arg mandatory for recognition
                has_bg = common.css(root, 'backgroundImage') !== "none" ||
                        (bc && bc !== "rgba(0, 0, 0, 0)" && bc !== "transparent");
                if (has_bg) {
                    player.conf.poster = true;
                }
            }
            if (player.conf.poster) {
                // when player is stopped the engine is too late to the party:
                // poster is already removed, poster state must be reset
                player.on("stop." + engineName, function () {
                    var posterClass = "is-poster";

                    setTimeout(function () {
                        common.addClass(root, posterClass);
                        player.one("progress." + engineName, function () {
                            common.removeClass(root, posterClass);
                        });
                    }, 0);
                });
            }

            return engine;
        };

    if (mse && version.indexOf("5.") !== 0) {
        // only load engine if it can be used
        engineImpl.engineName = engineName; // must be exposed
        engineImpl.canPlay = function (type, conf) {
            /*
              WARNING: MediaSource.isTypeSupported very inconsistent!
              e.g. Safari ignores codecs entirely, even bogus, like codecs="XYZ"
              example avc3 main level 3.1 + aac_he: avc3.4d401f; mp4a.40.5
              example avc1 high level 4.1 + aac_lc: avc1.640029; mp4a.40.2
              default: avc1 baseline level 3.0 + aac_lc
            */
            // inject dash conf at earliest opportunity
            dashconf = extend({
                type: "video/mp4",
                codecs: "avc1.42c01e, mp4a.40.2"
            }, flowplayer.conf[engineName], conf[engineName], conf.clip[engineName]);

            return isDashType(type) &&
                    mse.isTypeSupported(dashconf.type + '; codecs="' + dashconf.codecs + '"');
        };

        // put on top of engine stack
        // so mpegedash is tested before html5
        flowplayer.engines.unshift(engineImpl);

    }

}.apply(null, (typeof module === 'object' && module.exports)
    ? [require('flowplayer'), require('dashjs')]
    : [window.flowplayer, window.dashjs]));
<|endoftext|>


<commit_before>// docready for modern browsers
document.addEventListener("DOMContentLoaded", function(event) {

    //var datasrc = dataReposAllOfThem;
    var datasrc = dataReposAll;
    //var datasrc = dataReposSome;
    //console.log(datasrc);

    // Sort datasource array by date
    // ------------------------------------------------------------
    datasrc.sort(function(a, b) {
        return a.author_date_unix_timestamp - b.author_date_unix_timestamp;
    });
    //console.log(datasrc);

    // Round up the date so that we can sort commits from different repos by date
    // ------------------------------------------------------------
    var roundDate = function(timeStamp) {
        var d = new Date(timeStamp);
        return new Date(d.getFullYear(), d.getMonth(), d.getDate(), 0, 0, 0, 0);
    };

    // Create object array based on key and its value
    // ------------------------------------------------------------
    var groupByKeyAndValue = function(data, key, val) {
        var arr = [];
        for (var i in data) {
            if (data[i][key] == val) {
                arr.push(data[i]);
            }
        }
        return arr;
    };
    var weekMonday = groupByKeyAndValue(datasrc, 'date_day_week', 'Mon');
    //console.log(weekMonday);

    // Create array based on key value
    // ------------------------------------------------------------
    var arrayByKey = function(data, key) {
        var arr = [];
        for (var i in data) {
            if (data[i][key] === undefined) {
                data[i][key] = '0';
            }
            arr.push(data[i][key]);
        }
        return arr;
    };
    var arrayCommitNr = arrayByKey(datasrc, 'commit_nr');
    //console.log(arrayCommitNr);
    var arrayImpact = arrayByKey(datasrc, 'impact');
    //console.log(arrayImpact);
    var arrayTimestamp = arrayByKey(datasrc, 'author_date_unix_timestamp');
    //console.log(arrayTimestamp);

    // Create array based on key value, sorted
    // ------------------------------------------------------------
    var arrayByKeySorted = function(data, key) {
        var arr = [];
        for (var i in data) {
            arr.push(data[i][key]);
        }
        arr.sort(function(a, b) {
            return a - b;
        });
        return arr;
    };
    var arrayByKeySortedVar = arrayByKeySorted(datasrc, 'author_date_unix_timestamp');
    //console.log(arrayByKeySortedVar);

    // Return number that results from adding a key to itself
    // ------------------------------------------------------------
    var totalSum = function(data) {
        var sum = 0;
        for (var i = 0; i < data.length; i++) {
            sum += parseInt(data[i]);
          //console.log(sum);
        }
        return sum;
    };
    var arrayImpactTotal = totalSum(arrayImpact);
    //console.log(arrayImpactTotal);

    // Return number of items in an object
    // ------------------------------------------------------------
    var itemsSum = function(data) {
        var sum = 0;
        for (var i = 0; i < data.length; i++) {
            sum += 1;
        }
        return sum;
    };
    var arrayTotal = itemsSum(datasrc);
    //console.log(arrayTotal);

    // Create array based on key values added to themselves
    // ------------------------------------------------------------
    var sumArray = function(data) {
        var sum = 0;
        var arr = [];
        for (var i in data) {
            sum += parseInt(data[i]);
            arr.push(sum);
          //console.log(sum);
        }
        return arr;
    };
    var arrayImpactSum = sumArray(arrayImpact);
    //console.log(arrayImpactSum);

    // Create object array based on key
    // ------------------------------------------------------------
    var groupByAuto = function(data, key) {
        var groups = {};
        for (var i in data) {
            if (!groups.hasOwnProperty(data[i][key])) {
                groups[data[i][key]] = [];
            }
            groups[data[i][key]].push(data[i]);
        }
        return groups;
    };
    var objDateDayWeek = groupByAuto(datasrc, 'date_day_week');
    //console.log(objDateDayWeek);
    var objRepository = groupByAuto(datasrc, 'repository');
    //console.log(objRepository);

    // Create object array based on key
    // ------------------------------------------------------------
    var groupByAuthors = function(data, author) {
        var groups = {};
        for (var i in data) {
            var a = data[i][author].match(/[^@]*/);
            if (!groups.hasOwnProperty(data[i][author])) {
                groups[data[i][author]] = [];
            }
            groups[data[i][author]].push(data[i]);
        }
        return groups;
    };
    var groupByAuthorsVar = groupByAuthors(datasrc, 'author_email');
    //console.log(groupByAuthorsVar);

    // Create array based on key value
    // ------------------------------------------------------------
    var arrayAllRepos = function(data) {
        var arr = [];
        for (var i in data) {
            arr.push(data[i]);
        }
        return arr;
    };
    var arrayAllReposLength = function(data) {
        var arr = [];
        for (var i in data) {
            arr.push(data[i].length);
        }
        return arr;
    };
    var arrayAllReposVar = arrayAllRepos(Object.keys(objRepository));
    //console.log(arrayAllReposVar);
    var arrayAllReposValueArrayLength = arrayAllReposLength(Object.keys(objRepository));
    //console.log(arrayAllReposValueArrayLength);

    // Merge two arrays of identical length
    // ------------------------------------------------------------
    var arraysMerge = function(keys, values) {
        var obj = {};
        for (var i = 0; i < keys.length; i++) {
            obj[keys[i]] = values[i];
        }
        return obj;
    };

    // Create array with year changes
    // ------------------------------------------------------------
    var arrayYearChanges = function(data, year) {
        var arr = [];
        for (var i in data) {
            var currentYear = data[i][year];
            var previousYear;
            if (previousYear != currentYear) {
                arr.push(data[i][year]);
            } else {
                arr.push('');
            }
            previousYear = data[i][year];
        }
        return arr;
    };
    var arrayYearChangesVar = arrayYearChanges(datasrc, 'date_year');
    //console.log(arrayYearChangesVar);

    // Create array of objects with authors and their impact
    // ------------------------------------------------------------
    var arrayAuthorImpact = function(data, author, impact) {
        var arr = [];
        for (var i in data) {
            var a = data[i][author].match(/[^@]*/);
            arr.push('{ "author":"' + a + '", "impact":"' + data[i][impact] + '"},');
        }
        return arr;
    };
    var arrayAuthorImpactVar = arrayAuthorImpact(datasrc, 'author_email', 'impact');
    //console.log(arrayAuthorImpactVar);

    new Chartist.Line('.ct-chart-impact', {
        labels: arrayYearChangesVar,
        series: [
          arrayImpact
        ]
    }, {
        height: '300px',
        high: 900000,
        low: -300000,
        showArea: true,
        showLine: true,
        showPoint: false,
        fullWidth: true,
        chartPadding: {
            top: 0,
            right: 0,
            bottom: 0,
            left: 40
        },
        axisX: {
            showLabel: true,
            showGrid: true
        }
    });

    new Chartist.Line('.ct-chart-impact-cumulative', {
        labels: arrayYearChangesVar,
        series: [
          arrayImpactSum
        ]
    }, {
        height: '300px',
      //high: 1400000, // with 'dataReposSome'
        high: 3700000, // with 'dataReposAll'
      //high: 8000000000, // with 'dataReposAll' based on 'dataReposAllOfThemClean'
        low: 1000,
        showArea: true,
        showLine: true,
        showPoint: false,
        fullWidth: true,
        chartPadding: {
            top: 0,
            right: 0,
            bottom: 0,
            left: 40
        },
        axisX: {
            showLabel: true,
            showGrid: true
        }
    });

});
<commit_msg>Create a dedicated object with filtered author stats<commit_after>// docready for modern browsers
document.addEventListener("DOMContentLoaded", function(event) {

    var datasrc = dataReposAllOfThem;
    //var datasrc = dataReposAll;
    //var datasrc = dataReposSome;
    //console.log(datasrc);

    // Sort datasource array by date
    // ------------------------------------------------------------
    datasrc.sort(function(a, b) {
        return a.author_date_unix_timestamp - b.author_date_unix_timestamp;
    });
    //console.log(datasrc);

    // Round up the date so that we can sort commits from different repos by date
    // ------------------------------------------------------------
    var roundDate = function(timeStamp) {
        var d = new Date(timeStamp);
        return new Date(d.getFullYear(), d.getMonth(), d.getDate(), 0, 0, 0, 0);
    };

    // Create object array based on key and its value
    // ------------------------------------------------------------
    var groupByKeyAndValue = function(data, key, val) {
        var arr = [];
        for (var i in data) {
            if (data[i][key] == val) {
                arr.push(data[i]);
            }
        }
        return arr;
    };
    var weekMonday = groupByKeyAndValue(datasrc, 'date_day_week', 'Mon');
    //console.log(weekMonday);

    // Create array based on key value
    // ------------------------------------------------------------
    var arrayByKey = function(data, key) {
        var arr = [];
        for (var i in data) {
            if (data[i][key] === undefined) {
                data[i][key] = '0';
            }
            arr.push(data[i][key]);
        }
        return arr;
    };
    var arrayCommitNr = arrayByKey(datasrc, 'commit_nr');
    //console.log(arrayCommitNr);
    var arrayImpact = arrayByKey(datasrc, 'impact');
    //console.log(arrayImpact);
    var arrayTimestamp = arrayByKey(datasrc, 'author_date_unix_timestamp');
    //console.log(arrayTimestamp);

    // Create array based on key value, sorted
    // ------------------------------------------------------------
    var arrayByKeySorted = function(data, key) {
        var arr = [];
        for (var i in data) {
            arr.push(data[i][key]);
        }
        arr.sort(function(a, b) {
            return a - b;
        });
        return arr;
    };
    var arrayByKeySortedVar = arrayByKeySorted(datasrc, 'author_date_unix_timestamp');
    //console.log(arrayByKeySortedVar);

    // Return number that results from adding a key to itself
    // ------------------------------------------------------------
    var totalSum = function(data) {
        var sum = 0;
        for (var i = 0; i < data.length; i++) {
            sum += parseInt(data[i]);
          //console.log(sum);
        }
        return sum;
    };
    var arrayImpactTotal = totalSum(arrayImpact);
    //console.log(arrayImpactTotal);

    // Return number of items in an object
    // ------------------------------------------------------------
    var itemsSum = function(data) {
        var sum = 0;
        for (var i = 0; i < data.length; i++) {
            sum += 1;
        }
        return sum;
    };
    var arrayTotal = itemsSum(datasrc);
    //console.log(arrayTotal);

    // Create array based on key values added to themselves
    // ------------------------------------------------------------
    var sumArray = function(data) {
        var sum = 0;
        var arr = [];
        for (var i in data) {
            sum += parseInt(data[i]);
            arr.push(sum);
          //console.log(sum);
        }
        return arr;
    };
    var arrayImpactSum = sumArray(arrayImpact);
    //console.log(arrayImpactSum);

    // Create object array based on key
    // ------------------------------------------------------------
    var groupByAuto = function(data, key) {
        var groups = {};
        for (var i in data) {
            if (!groups.hasOwnProperty(data[i][key])) {
                groups[data[i][key]] = [];
            }
            groups[data[i][key]].push(data[i]);
        }
        return groups;
    };
    var objDateDayWeek = groupByAuto(datasrc, 'date_day_week');
    //console.log(objDateDayWeek);
    var objRepository = groupByAuto(datasrc, 'repository');
    //console.log(objRepository);

    // Create object array based on key
    // ------------------------------------------------------------
    var groupByAuthors = function(data, author) {
        var groups = {};
        for (var i in data) {
            var a = data[i][author].match(/[^@]*/);
            if (!groups.hasOwnProperty(data[i][author])) {
                groups[data[i][author]] = [];
            }
            groups[data[i][author]].push(data[i]);
        }
        return groups;
    };
    var groupByAuthorsVar = groupByAuthors(datasrc, 'author_email');
    //console.log(groupByAuthorsVar);

    // Create array based on key value
    // ------------------------------------------------------------
    var arrayAllRepos = function(data) {
        var arr = [];
        for (var i in data) {
            arr.push(data[i]);
        }
        return arr;
    };
    var arrayAllReposLength = function(data) {
        var arr = [];
        for (var i in data) {
            arr.push(data[i].length);
        }
        return arr;
    };
    var arrayAllReposVar = arrayAllRepos(Object.keys(objRepository));
    //console.log(arrayAllReposVar);
    var arrayAllReposValueArrayLength = arrayAllReposLength(Object.keys(objRepository));
    //console.log(arrayAllReposValueArrayLength);

    // Merge two arrays of identical length
    // ------------------------------------------------------------
    var arraysMerge = function(keys, values) {
        var obj = {};
        for (var i = 0; i < keys.length; i++) {
            obj[keys[i]] = values[i];
        }
        return obj;
    };

    // Create array with year changes
    // ------------------------------------------------------------
    var arrayYearChanges = function(data, year) {
        var arr = [];
        for (var i in data) {
            var currentYear = data[i][year];
            var previousYear;
            if (previousYear != currentYear) {
                arr.push(data[i][year]);
            } else {
                arr.push('');
            }
            previousYear = data[i][year];
        }
        return arr;
    };
    var arrayYearChangesVar = arrayYearChanges(datasrc, 'date_year');
    //console.log(arrayYearChangesVar);

    // Get author stats and output it on a dedicated object
    // ------------------------------------------------------------
    var groupByAuthorsStats = function(data, author) {
        var obja = {};
        for (var i in data) {
            if (!obja.hasOwnProperty(data[i][author])) {
                obja[data[i][author]] = [];
            }
            obja[data[i][author]].push(data[i]);
        }
        // create an object to receive customised author stats
        var stats = {};
        // iterate through 'obja' object
        for (var b in obja) {
           if (obja.hasOwnProperty(b)) {
                var objb = obja[b];
                // calculate total impact
                var authorImpact = arrayByKey(objb, 'impact');
                var authorImpactSum = totalSum(authorImpact);
                // calculate total number of commits
                var authorNrCommits = itemsSum(objb);
                // push new data to array
                if (!stats.hasOwnProperty(b)) {
                    stats[b] = [];
                }
                stats[b].push({
                    commits: authorNrCommits,
                    impact: authorImpactSum
                });
            }
        }
        return stats;
    };
    var groupByAuthorsStatsVar = groupByAuthorsStats(datasrc, 'author_email');
    console.log(groupByAuthorsStatsVar);

    // Create array of objects with authors and their impact
    // ------------------------------------------------------------
    var arrayAuthorImpact = function(data, author, impact) {
        var arr = [];
        for (var i in data) {
            var a = data[i][author].match(/[^@]*/);
            arr.push('{ "author":"' + a + '", "impact":"' + data[i][impact] + '"},');
        }
        return arr;
    };
    var arrayAuthorImpactVar = arrayAuthorImpact(datasrc, 'author_email', 'impact');
    //console.log(arrayAuthorImpactVar);

    new Chartist.Line('.ct-chart-impact', {
        labels: arrayYearChangesVar,
        series: [
          arrayImpact
        ]
    }, {
        height: '300px',
        high: 900000,
        low: -300000,
        showArea: true,
        showLine: true,
        showPoint: false,
        fullWidth: true,
        chartPadding: {
            top: 0,
            right: 0,
            bottom: 0,
            left: 40
        },
        axisX: {
            showLabel: true,
            showGrid: true
        }
    });

    new Chartist.Line('.ct-chart-impact-cumulative', {
        labels: arrayYearChangesVar,
        series: [
          arrayImpactSum
        ]
    }, {
        height: '300px',
      //high: 1400000, // with 'dataReposSome'
      //high: 3700000, // with 'dataReposAll'
        high: 8000000000, // with 'dataReposAll' based on 'dataReposAllOfThemClean'
        low: 1000,
        showArea: true,
        showLine: true,
        showPoint: false,
        fullWidth: true,
        chartPadding: {
            top: 0,
            right: 0,
            bottom: 0,
            left: 40
        },
        axisX: {
            showLabel: true,
            showGrid: true
        }
    });

});
<|endoftext|>


<commit_before>(function(){
  var key = '{{API_KEY}}';
  var baseURL = 'http://apifree.forvo.com/key/' + key + '/format/json/action/word-pronunciations/word/';

  getWord();

  function getWord() {
    var selection = window.getSelection().toString().replace(/^\s+|\s+$/g, '');
    var message = (''
      + "What word do you need pronounced?\n\n"
      + "(tip: narrow search to a specific language by adding a slash "
      + "and the 2-letter language code after your word, e.g. "
      + "'skal/no' or 'que/es')"
    );
    var input = window.prompt(, selection).split(/\s*\/\s*/);
    var word = input[0];
    var lang = input[1];

    fetchPronunciations(word, lang);
  }

  function fetchPronunciations(word, lang) {
    var url = baseURL + encodeURIComponent(word);
    if (lang) url = url + '/language/' + encodeURIComponent(lang);

    var cbk = 'forvo_' + new Date().getTime();
    url = url + '/callback/' + cbk;

    window[cbk] = function(data) {
      delete window[cbk];

      var items = data.items;

      if (!items || !items.length) {
        return alert("No results found.");
      }

      showResults(items);
    };

    var s = document.createElement('script');
    s.src = url;
    document.body.appendChild(s);
  }

  function showResults(results) {
    var old = document.getElementById('forvo-results');
    if (old) old.parentNode.removeChild(old);

    var resultsHtml = '
';

    for (var n = 0; n < results.length; n++) {
      var result = results[n];
      resultsHtml += (''
        + '<li style="padding-top: 5px;' + (n < (results.length - 1) ? 'padding-bottom:5px; border-bottom:1px #555 solid;' : '') + '">'
          + '' + result.word + ' '
          + '(' + result.code + ') '
          + '▶ '
          + '<audio src="' + result.pathmp3 + '"' + (n === 0 ? ' autoplay' : '') + '></audio>'
          + 'download'
        + '
'
      );
    }

    resultsHtml += '
';

    var con = document.createElement('div');
    con.style.position = 'absolute';
    con.style.left = '50%';
    con.style.top = '50%';
    con.style.minWidth = '120px';
    con.style.background = '#252525';
    con.style.color = '#eee';
    con.style.padding = '30px';
    con.style.font = 'normal normal normal 16px/26px Helvetica, sans-serif !important';
    con.style.textAlign = 'left';
    con.style.WebkitTransform = 'translateX(-50%) translateY(-50%)';
    con.style.transform = 'translateX(-50%) translateY(-50%)';

    con.innerHTML = resultsHtml;

    var bg = document.createElement('div');
    bg.style.position = 'fixed';
    bg.style.left = '0';
    bg.style.top = '0';
    bg.style.width = '100%';
    bg.style.height = '100%';
    bg.style.zIndex = '9999999999';
    bg.style.background = 'rgba(227, 223, 229, 0.95)';

    bg.id = 'forvo-results';

    bg.appendChild(con);
    document.body.appendChild(bg);

    con.addEventListener('click', function(e) {
      e.stopPropagation();

      if (e.target.className === 'play') {
        var audio = e.target.parentNode.querySelector('audio');
        audio.load();
        audio.play();
      }
    });

    bg.addEventListener('click', function() {
      bg.parentNode.removeChild(bg);
    });
  }
})();<commit_msg>Update forvo-bookmarklet.js<commit_after>(function(){
  var key = '{{API_KEY}}';
  var baseURL = 'http://apifree.forvo.com/key/' + key + '/format/json/action/word-pronunciations/word/';

  getWord();

  function getWord() {
    var selection = window.getSelection().toString().replace(/^\s+|\s+$/g, '');
    var message = (''
      + "What word do you need pronounced?\n\n"
      + "(tip: narrow search to a specific language by adding a slash "
      + "and the 2-letter language code after your word, e.g. "
      + "'skal/no' or 'que/es')"
    );
    var input = window.prompt(message, selection).split(/\s*\/\s*/);
    var word = input[0];
    var lang = input[1];

    fetchPronunciations(word, lang);
  }

  function fetchPronunciations(word, lang) {
    var url = baseURL + encodeURIComponent(word);
    if (lang) url = url + '/language/' + encodeURIComponent(lang);

    var cbk = 'forvo_' + new Date().getTime();
    url = url + '/callback/' + cbk;

    window[cbk] = function(data) {
      delete window[cbk];

      var items = data.items;

      if (!items || !items.length) {
        return alert("No results found.");
      }

      showResults(items);
    };

    var s = document.createElement('script');
    s.src = url;
    document.body.appendChild(s);
  }

  function showResults(results) {
    var old = document.getElementById('forvo-results');
    if (old) old.parentNode.removeChild(old);

    var resultsHtml = '
';

    for (var n = 0; n < results.length; n++) {
      var result = results[n];
      resultsHtml += (''
        + '<li style="padding-top: 5px;' + (n < (results.length - 1) ? 'padding-bottom:5px; border-bottom:1px #555 solid;' : '') + '">'
          + '' + result.word + ' '
          + '(' + result.code + ') '
          + '▶ '
          + '<audio src="' + result.pathmp3 + '"' + (n === 0 ? ' autoplay' : '') + '></audio>'
          + 'download'
        + '
'
      );
    }

    resultsHtml += '
';

    var con = document.createElement('div');
    con.style.position = 'absolute';
    con.style.left = '50%';
    con.style.top = '50%';
    con.style.minWidth = '120px';
    con.style.background = '#252525';
    con.style.color = '#eee';
    con.style.padding = '30px';
    con.style.font = 'normal normal normal 16px/26px Helvetica, sans-serif !important';
    con.style.textAlign = 'left';
    con.style.WebkitTransform = 'translateX(-50%) translateY(-50%)';
    con.style.transform = 'translateX(-50%) translateY(-50%)';

    con.innerHTML = resultsHtml;

    var bg = document.createElement('div');
    bg.style.position = 'fixed';
    bg.style.left = '0';
    bg.style.top = '0';
    bg.style.width = '100%';
    bg.style.height = '100%';
    bg.style.zIndex = '9999999999';
    bg.style.background = 'rgba(227, 223, 229, 0.95)';

    bg.id = 'forvo-results';

    bg.appendChild(con);
    document.body.appendChild(bg);

    con.addEventListener('click', function(e) {
      e.stopPropagation();

      if (e.target.className === 'play') {
        var audio = e.target.parentNode.querySelector('audio');
        audio.load();
        audio.play();
      }
    });

    bg.addEventListener('click', function() {
      bg.parentNode.removeChild(bg);
    });
  }
})();
<|endoftext|>


<commit_before>import { walk } from 'estree-walker';

export default function annotateWithScopes ( expression ) {
	let scope = new Scope( null, false );

	walk( expression, {
		enter ( node ) {
			if ( /Function/.test( node.type ) ) {
				if ( node.type === 'FunctionDeclaration' ) {
					scope.declarations[ node.id.name ] = true;
				} else {
					node._scope = scope = new Scope( scope, false );
					if ( node.id ) scope.declarations[ node.id.name ] = true;
				}

				node.params.forEach( param => {
					extractNames( param ).forEach( name => {
						scope.declarations[ name ] = true;
					});
				});
			}

			else if ( /For(?:In|Of)Statement/.test( node.type ) ) {
				node._scope = scope = new Scope( scope, true );
			}

			else if ( node.type === 'BlockStatement' ) {
				node._scope = scope = new Scope( scope, true );
			}

			else if ( /Declaration/.test( node.type ) ) {
				scope.addDeclaration( node );
			}
		},

		leave ( node ) {
			if ( node._scope ) {
				scope = scope.parent;
			}
		}
	});

	return scope;
}

class Scope {
	constructor ( parent, block ) {
		this.parent = parent;
		this.block = block;
		this.declarations = Object.create( null );
	}

	addDeclaration ( node ) {
		if ( node.kind === 'var' && !this.block && this.parent ) {
			this.parent.addDeclaration( node );
		} else if ( node.type === 'VariableDeclaration' ) {
			node.declarators.forEach( declarator => {
				extractNames( declarator.id ).forEach( name => {
					this.declarations[ name ] = true;
				});
			});
		} else {
			this.declarations[ node.id.name ] = true;
		}
	}

	has ( name ) {
		return name in this.declarations || this.parent && this.parent.has( name );
	}
}

function extractNames ( param ) {
	const names = [];
	extractors[ param.type ]( names, param );
	return names;
}

const extractors = {
	Identifier ( names, param ) {
		names.push( param.name );
	},

	ObjectPattern ( names, param ) {
		param.properties.forEach( prop => {
			extractors[ prop.value.type ]( names, prop.value );
		});
	},

	ArrayPattern ( names, param ) {
		param.elements.forEach( element => {
			if ( element ) extractors[ element.type ]( names, element );
		});
	},

	RestElement ( names, param ) {
		extractors[ param.argument.type ]( names, param.argument );
	},

	AssignmentPattern ( names, param ) {
		extractors[ param.left.type ]( names, param.left );
	}
};

<commit_msg>some annotateWithScopes fixes<commit_after>import { walk } from 'estree-walker';

export default function annotateWithScopes ( expression ) {
	let scope = new Scope( null, false );

	walk( expression, {
		enter ( node ) {
			if ( /Function/.test( node.type ) ) {
				if ( node.type === 'FunctionDeclaration' ) {
					scope.declarations[ node.id.name ] = true;
				} else {
					node._scope = scope = new Scope( scope, false );
					if ( node.id ) scope.declarations[ node.id.name ] = true;
				}

				node.params.forEach( param => {
					extractNames( param ).forEach( name => {
						scope.declarations[ name ] = true;
					});
				});
			}

			else if ( /For(?:In|Of)Statement/.test( node.type ) ) {
				node._scope = scope = new Scope( scope, true );
			}

			else if ( node.type === 'BlockStatement' ) {
				node._scope = scope = new Scope( scope, true );
			}

			else if ( /(Function|Class|Variable)Declaration/.test( node.type ) ) {
				scope.addDeclaration( node );
			}
		},

		leave ( node ) {
			if ( node._scope ) {
				scope = scope.parent;
			}
		}
	});

	return scope;
}

class Scope {
	constructor ( parent, block ) {
		this.parent = parent;
		this.block = block;
		this.declarations = Object.create( null );
	}

	addDeclaration ( node ) {
		if ( node.kind === 'var' && !this.block && this.parent ) {
			this.parent.addDeclaration( node );
		} else if ( node.type === 'VariableDeclaration' ) {
			node.declarations.forEach( declarator => {
				extractNames( declarator.id ).forEach( name => {
					this.declarations[ name ] = true;
				});
			});
		} else {
			this.declarations[ node.id.name ] = true;
		}
	}

	has ( name ) {
		return name in this.declarations || this.parent && this.parent.has( name );
	}
}

function extractNames ( param ) {
	const names = [];
	extractors[ param.type ]( names, param );
	return names;
}

const extractors = {
	Identifier ( names, param ) {
		names.push( param.name );
	},

	ObjectPattern ( names, param ) {
		param.properties.forEach( prop => {
			extractors[ prop.value.type ]( names, prop.value );
		});
	},

	ArrayPattern ( names, param ) {
		param.elements.forEach( element => {
			if ( element ) extractors[ element.type ]( names, element );
		});
	},

	RestElement ( names, param ) {
		extractors[ param.argument.type ]( names, param.argument );
	},

	AssignmentPattern ( names, param ) {
		extractors[ param.left.type ]( names, param.left );
	}
};
<|endoftext|>


<commit_before>/**
 * Created by Dean on 6/21/2015.
 */

var QUESTIFY = (function (QUESTIFY) {
	"use strict";
	function createQuest (strategy, actions, argumentsArr, descriptions) {
		var that = {},
			finishedMap = new Array(actions.length),
			actionFinishedCallback = function () {},
			questFinishedCallback = function () {};

		(function initializeFinishedMap() {
			for (var i = 0, il = finishedMap.length; i < il; i++) {
				finishedMap[i] = false;
			}
		}());

		function reportQuestFinished() {
			questFinishedCallback();
		}

		function reportActionFinished(finishedAction, args) {
			actionFinishedCallback(finishedAction, args);
		}

		function isFinished() {
			return finishedMap.indexOf(false) === -1;
		}

		function completionPercentage() {
			var finishedCount = 0;

			for (var f = 0, fl = finishedMap.length; f < fl; f++) {
				if (finishedMap[f] === true) { finishedCount++; }
			}

			return (finishedMap.length !== 0) ? finishedCount/finishedMap.length : 0;
		}

		function getActionDescription(actionNumber) {
			if (actionNumber < descriptions.length && actionNumber >= 0) {
				return descriptions[actionNumber];
			}

			return "";
		}

		function setActionDescription(actionNumber, description) {
			if (actionNumber < descriptions.length && actionNumber >= 0) {
				description[actionNumber] = description;
			}
		}

		function getActionStatus(actionNumber) {
			if (actionNumber < finishedMap.length && actionNumber >= 0) {
				return finishedMap[actionNumber];
			}

			return false;
		}

		that.updateState = function() {
			var action;
			for (var a = 0, al = actions.length; a < al; a++) {
				action = actions[a];
				if (finishedMap[a] === false) {
					finishedMap[a] = (action.update(argumentsArr[a]) === true);

					if (finishedMap[a] === false) { return; }
					if (finishedMap[a] === true) { reportActionFinished(action, argumentsArr[a]); }
				}
			}

			if (isFinished()) { reportQuestFinished(); }
		};

		that.actions = actions;
		that.strategy = strategy;
		that.isFinished = isFinished;
		that.completionPercentage = completionPercentage;
		that.actionFinishedCallback = actionFinishedCallback;
		that.questFinishedCallback = questFinishedCallback;
		that.getActionDescription = getActionDescription;
		that.setActionDescription = setActionDescription;

		return that;
	}

	QUESTIFY.createQuest = createQuest;

	return QUESTIFY;
}(QUESTIFY || {}));<commit_msg>Made getActionStatus method public<commit_after>/**
 * Created by Dean on 6/21/2015.
 */

var QUESTIFY = (function (QUESTIFY) {
	"use strict";
	function createQuest (strategy, actions, argumentsArr, descriptions) {
		var that = {},
			finishedMap = new Array(actions.length),
			actionFinishedCallback = function () {},
			questFinishedCallback = function () {};

		(function initializeFinishedMap() {
			for (var i = 0, il = finishedMap.length; i < il; i++) {
				finishedMap[i] = false;
			}
		}());

		function reportQuestFinished() {
			questFinishedCallback();
		}

		function reportActionFinished(finishedAction, args) {
			actionFinishedCallback(finishedAction, args);
		}

		function isFinished() {
			return finishedMap.indexOf(false) === -1;
		}

		function completionPercentage() {
			var finishedCount = 0;

			for (var f = 0, fl = finishedMap.length; f < fl; f++) {
				if (finishedMap[f] === true) { finishedCount++; }
			}

			return (finishedMap.length !== 0) ? finishedCount/finishedMap.length : 0;
		}

		function getActionDescription(actionNumber) {
			if (actionNumber < descriptions.length && actionNumber >= 0) {
				return descriptions[actionNumber];
			}

			return "";
		}

		function setActionDescription(actionNumber, description) {
			if (actionNumber < descriptions.length && actionNumber >= 0) {
				description[actionNumber] = description;
			}
		}

		function getActionStatus(actionNumber) {
			if (actionNumber < finishedMap.length && actionNumber >= 0) {
				return finishedMap[actionNumber];
			}

			return false;
		}

		that.updateState = function() {
			var action;
			for (var a = 0, al = actions.length; a < al; a++) {
				action = actions[a];
				if (finishedMap[a] === false) {
					finishedMap[a] = (action.update(argumentsArr[a]) === true);

					if (finishedMap[a] === false) { return; }
					if (finishedMap[a] === true) { reportActionFinished(action, argumentsArr[a]); }
				}
			}

			if (isFinished()) { reportQuestFinished(); }
		};

		that.actions = actions;
		that.strategy = strategy;
		that.isFinished = isFinished;
		that.completionPercentage = completionPercentage;
		that.actionFinishedCallback = actionFinishedCallback;
		that.questFinishedCallback = questFinishedCallback;
		that.getActionDescription = getActionDescription;
		that.setActionDescription = setActionDescription;
		that.getActionStatus = getActionStatus;

		return that;
	}

	QUESTIFY.createQuest = createQuest;

	return QUESTIFY;
}(QUESTIFY || {}));<|endoftext|>


<commit_before>
XMOT.namespace("XMOT.interaction.behaviors");

/** The Rotater takes the translation given by the PlaneSensor and interprets
 *  the individual components as angle in radians along the corresponding axis.
 *
 *  @extends XMOT.interaction.behaviors.PlaneSensor
 */
XMOT.interaction.behaviors.Rotater = new XMOT.Class(
    XMOT.interaction.behaviors.PlaneSensor,
{
    /** Constructor of Rotater
     *
     *  @this {XMOT.interaction.behaviors.Rotater}
     *
     *  @param {string} id the id of this sensor
     *  @param {Array.<Object>} pickGrps the group this sensor will listen for events
     *  @param {XMOT.Transformable=} targetTransformable the group this sensor will modify.
     *                 If not given, it is equal to the first element in pickGrp.
     *  @param {number=} rotSpeed rotation speed, default is 1
     *                  See XML3D.interaction.behaviors.PlaneSensor for further information.
     *  @param {XMOT.util.EventDispatcher=} eventDispatcher the object used to register events
     *
     *  @throws "target no transform" if the target group doesn't have a transform
     *           attribute
     */
    initialize: function(id, pickGrps, targetTransformable, rotSpeed, eventDispatcher)
    {
        // --- setup pdsensor ---
        this.callSuper(id, pickGrps, undefined, undefined, eventDispatcher);

        // --- setup this sensor ---
        if(!targetTransformable)
            targetTransformable = XMOT.ClientMotionFactory.createTransformable(pickGrps[0]);

        this.targetTransformable = targetTransformable;

        this._rotationSpeed = 1;
        if(rotSpeed)
            this._rotationSpeed = rotSpeed;

        this._initialRotation = new XML3DRotation(this.targetTransformable.getOrientation());
        this._rotationOffset = new XML3DRotation(this._initialRotation);

        // listeners
        this.addListener("dragstart", this.callback("_onRotaterDragStart"));
        this.addListener("translchanged", this.callback("_onRotaterTranslChanged"));
    },

    axisRestriction: function(axis)
    {
        if(XMOT.util.isDefined(axis))
        {
            this._axisRestriction = axis;
        }

        return this._axisRestriction;
    },

    clearAxisRestriction: function()
    {
        this._axisRestriction = undefined;
    },

    /** reset the rotation that gets remembered between drags
     *
     *  @this {XMOT.interaction.behaviors.Rotater}
     */
    resetRotation: function()
    {
        this.targetTransformable.setOrientation(this._initialRotation);
    },

    /** Set or retrieve the rotation speed
     *
     *  @this {XMOT.interaction.behaviors.Rotater}
     *
     *  @param {number} [speed] default: do not set the speed.
     *  @return {number} the current speed
     */
    rotationSpeed: function(speed)
    {
        if(speed)
            this.trackBall.rotationSpeed = speed;

        return this.trackBall.rotationSpeed;
    },

    // ========================================================================
    // --- Private ---
    // ========================================================================

    /**
     *  @private
     *  @this {XMOT.interaction.behaviors.Rotater}
     *
     *  @param {XMOT.interaction.behaviors.Rotater} sensor
     */
    _onRotaterDragStart: function(sensor)
    {
        // update the offset with perhaps changed rotation
        this._rotationOffset = new window.XML3DRotation(this.targetTransformable.transform.rotation);
    },

    /**
     *  @this {XMOT.interaction.behaviors.Rotater}
     *  @private
     *
     *  @param {XMOT.interaction.behaviors.Rotater} sensor
     */
    _onRotaterTranslChanged: function(sensor)
    {
        var t = sensor.getCanonicalTranslation();

        // calculate angle along the axes
        /** in the z=1 plane x-translation should map to y-axis rotation
         *  and y-translation to x-axis rotation
         */
        var angleX = t.y * this._rotationSpeed;
        var angleY = t.x * this._rotationSpeed;

        // apply axis restrictions
        var rotation = new XML3DRotation();
        if(this._axisRestriction === undefined)
        {
            var rotX = new XML3DRotation(new XML3DVec3(1,0,0), angleX);
            var rotY = new XML3DRotation(new XML3DVec3(0,1,0), angleY);
            rotation.set(rotX.multiply(rotY));
        }
        else
        {
            var angleSum = angleX + angleY;
            var axis = null;

            if(this._axisRestriction === "x")
            {
                axis = new XML3DVec3(1,0,0);
            }
            else if(this._axisRestriction === "y")
            {
                axis = new XML3DVec3(0,1,0);
            }
            else // === "z"
            {
                axis = new XML3DVec3(0,0,1);
            }

            rotation.setAxisAngle(axis, angleSum);
        }

        // apply rotation offset
        rotation.set(this._rotationOffset.multiply(rotation));

        // and update target orientation
        this.targetTransformable.setOrientation(rotation);
    }
});
<commit_msg>interaction-rotater: added some comments<commit_after>
XMOT.namespace("XMOT.interaction.behaviors");

/** The Rotater takes the translation given by the PlaneSensor and interprets
 *  the individual components as angle in radians along the corresponding axis.
 *
 *  @extends XMOT.interaction.behaviors.PlaneSensor
 */
XMOT.interaction.behaviors.Rotater = new XMOT.Class(
    XMOT.interaction.behaviors.PlaneSensor,
{
    /** Constructor of Rotater
     *
     *  @this {XMOT.interaction.behaviors.Rotater}
     *
     *  @param {string} id the id of this sensor
     *  @param {Array.<Object>} pickGrps the group this sensor will listen for events
     *  @param {XMOT.Transformable=} targetTransformable the group this sensor will modify.
     *                 If not given, it is equal to the first element in pickGrp.
     *  @param {number=} rotSpeed rotation speed, default is 1
     *                  See XML3D.interaction.behaviors.PlaneSensor for further information.
     *  @param {XMOT.util.EventDispatcher=} eventDispatcher the object used to register events
     *
     *  @throws "target no transform" if the target group doesn't have a transform
     *           attribute
     */
    initialize: function(id, pickGrps, targetTransformable, rotSpeed, eventDispatcher)
    {
        // --- setup pdsensor ---
        this.callSuper(id, pickGrps, undefined, undefined, eventDispatcher);

        // --- setup this sensor ---
        if(!targetTransformable)
            targetTransformable = XMOT.ClientMotionFactory.createTransformable(pickGrps[0]);

        this.targetTransformable = targetTransformable;

        this._rotationSpeed = 1;
        if(rotSpeed)
            this._rotationSpeed = rotSpeed;

        this._initialRotation = new XML3DRotation(this.targetTransformable.getOrientation());
        this._rotationOffset = new XML3DRotation(this._initialRotation);

        // listeners
        this.addListener("dragstart", this.callback("_onRotaterDragStart"));
        this.addListener("translchanged", this.callback("_onRotaterTranslChanged"));
    },

    /**
     *  @this {XMOT.interaction.behaviors.Rotater}
     *
     *  @param {string=} axis. Should be "x", "y" or "z"
     *  @return {string} current/new restriction
     */
    axisRestriction: function(axis)
    {
        if(XMOT.util.isDefined(axis))
        {
            this._axisRestriction = axis;
        }

        return this._axisRestriction;
    },

    /**
     *  @this {XMOT.interaction.behaviors.Rotater}
     */
    clearAxisRestriction: function()
    {
        this._axisRestriction = undefined;
    },

    /** reset the rotation that gets remembered between drags
     *
     *  @this {XMOT.interaction.behaviors.Rotater}
     */
    resetRotation: function()
    {
        this.targetTransformable.setOrientation(this._initialRotation);
    },

    /** Set or retrieve the rotation speed
     *
     *  @this {XMOT.interaction.behaviors.Rotater}
     *
     *  @param {number} [speed] default: do not set the speed.
     *  @return {number} the current speed
     */
    rotationSpeed: function(speed)
    {
        if(speed)
            this.trackBall.rotationSpeed = speed;

        return this.trackBall.rotationSpeed;
    },

    // ========================================================================
    // --- Private ---
    // ========================================================================

    /**
     *  @private
     *  @this {XMOT.interaction.behaviors.Rotater}
     *
     *  @param {XMOT.interaction.behaviors.Rotater} sensor
     */
    _onRotaterDragStart: function(sensor)
    {
        // update the offset with perhaps changed rotation
        this._rotationOffset = new window.XML3DRotation(this.targetTransformable.transform.rotation);
    },

    /**
     *  @this {XMOT.interaction.behaviors.Rotater}
     *  @private
     *
     *  @param {XMOT.interaction.behaviors.Rotater} sensor
     */
    _onRotaterTranslChanged: function(sensor)
    {
        var t = sensor.getCanonicalTranslation();

        // calculate angle along the axes
        /** in the z=1 plane x-translation should map to y-axis rotation
         *  and y-translation to x-axis rotation
         */
        var angleX = t.y * this._rotationSpeed;
        var angleY = t.x * this._rotationSpeed;

        // apply axis restrictions
        var rotation = new XML3DRotation();
        if(this._axisRestriction === undefined)
        {
            var rotX = new XML3DRotation(new XML3DVec3(1,0,0), angleX);
            var rotY = new XML3DRotation(new XML3DVec3(0,1,0), angleY);
            rotation.set(rotX.multiply(rotY));
        }
        else
        {
            var angleSum = angleX + angleY;
            var axis = null;

            if(this._axisRestriction === "x")
            {
                axis = new XML3DVec3(1,0,0);
            }
            else if(this._axisRestriction === "y")
            {
                axis = new XML3DVec3(0,1,0);
            }
            else // === "z"
            {
                axis = new XML3DVec3(0,0,1);
            }

            rotation.setAxisAngle(axis, angleSum);
        }

        // apply rotation offset
        rotation.set(this._rotationOffset.multiply(rotation));

        // and update target orientation
        this.targetTransformable.setOrientation(rotation);
    }
});
<|endoftext|>


<commit_before>/* Audero Flashing Text 2.0.1 | Aurelio De Rosa (@AurelioDeRosa) | MIT/GPL-3.0 Licensed */
(function(d){var e="audero-flashing-text";var b=function(f,h){d.extend(f.data(e),{lastIndex:h});var g=f.data(e);var i=d("<span>").text(g.strings[h]).css({position:"absolute",display:"none",fontSize:(Math.random()*g.fontMaxSize+g.fontMinSize)+g.fontUnit}).appendTo(f).fadeIn(g.fadeIn).animate({opacity:1},g.duration).fadeOut(g.fadeOut,function(){d(this).remove();var l;if(g.selection==="ascending"){l=(h+1)%g.strings.length}else{if(g.selection==="descending"){l=(h===0)?g.strings.length:h-1}else{l=Math.floor(Math.random()*g.strings.length)}}if(g.repeat>0){g.repeat--}var m=(g.pause==="random")?Math.random()*3000:g.pause;f.data(e,g);if(g.isEnabled===true){if(g.repeat!==0){setTimeout(function(){b(f,l)},m)}else{a.destroy.apply([f])}}});var k=Math.floor(Math.random()*(f.width()-i.outerWidth()));var j=Math.floor(Math.random()*(f.height()-i.outerHeight()));i.css({left:k+"px",top:j+"px"})};var c=function(f){var g=f.data(e);return(g!==undefined&&g.isEnabled===true)};var a={init:function(g){if(typeof g==="undefined"||g===null){g={}}if(g.strings==null&&this.find(":first").length!==this.length){d.error("To run jQuery.auderoFlashingText if you don't specify the texts to show, each element must have at least a child");return}var f=0;if(g.selection==="descending"){f=g.strings.length-1}else{if(g.selection==="random"){f=Math.floor(Math.random()*g.strings.length)}}g=d.extend(true,{},d.fn.auderoFlashingText.defaults,g);if(g.fadeIn<0){d.error("The fadeIn property of jQuery.auderoFlashingText can't be a negative number");return}if(g.duration<0){d.error("The duration property of jQuery.auderoFlashingText can't be a negative number");return}if(g.fadeOut<0){d.error("The fadeOut property of jQuery.auderoFlashingText can't be a negative number");return}if(d.inArray(g.selection,["random","ascending","descending"])<0){d.error("The selection property of jQuery.auderoFlashingText should have one of these values: random, ascending, descending");return}if(g.repeat<=0&&g.repeat!==-1){d.error("jQuery.auderoFlashingText should run at least one time");return}if(g.pause!=="random"&&g.pause<0){d.error("jQuery.auderoFlashingText should run the animation with a pause equal to or greater than zero");return}if(g.speed<=0){d.error("jQuery.auderoFlashingText should run the animation with a speed greater than zero");return}if(g.fontMinSize<=0){d.error("The fontMinSize property of jQuery.auderoFlashingText can't be a negative number");return}if(g.fontMaxSize<=0){d.error("The fontMaxSize property of jQuery.auderoFlashingText can't be a negative number");return}this.css("position","relative");this.children().css("visibility","hidden");var j;for(var h=0;h<this.length;h++){j=d(this[h]);if(g.strings===null){g.strings=j.children().map(function(){return d(this).text()})}j.data(e,d.extend(true,{},g));if(g.isEnabled===true){b(j,f)}}return this},enable:function(){var g;for(var f=0;f<this.length;f++){g=d(this[f]);if(!c(g)){g.data(e).isEnabled=true;b(g,g.data(e).lastIndex)}}return this},disable:function(){var g;for(var f=0;f<this.length;f++){g=d(this[f]);if(c(g)){g.data(e).isEnabled=false;g.stop(true,true)}}return this},toggle:function(){var g;for(var f=0;f<this.length;f++){g=d(this[f]);if(c(g)){a.disable.apply([g])}else{a.enable.apply([g])}}return this},destroy:function(){for(var f=0;f<this.length;f++){var g=d(this[f]);if(c(g)){g.children(":animated").stop(true).fadeOut(g.data(e).fadeOut).remove()}g.css("position","inherit").removeData(e);this.children().css("visibility","visible")}return this}};d.fn.auderoFlashingText=function(f){if(a[f]){return a[f].apply(this,Array.prototype.slice.call(arguments,1))}else{if(typeof f==="object"||!f){return a.init.apply(this,arguments)}else{d.error("Method "+f+" does not exist on jQuery.auderoFlashingText")}}};d.fn.auderoFlashingText.defaults={strings:null,isEnabled:true,fadeIn:300,duration:500,fadeOut:300,selection:"random",repeat:-1,pause:0,fontMinSize:7,fontMaxSize:28,fontUnit:"px"}})(jQuery);<commit_msg>Removed minified file from the src folder<commit_after><|endoftext|>


<commit_before>Rickshaw.namespace('Rickshaw.Graph.HoverDetail');

Rickshaw.Graph.HoverDetail = Rickshaw.Class.create({

	initialize: function(args) {

		var graph = this.graph = args.graph;

		this.xFormatter = args.xFormatter || function(x) {
			return new Date( x * 1000 ).toUTCString();
		};

		this.yFormatter = args.yFormatter || function(y) {
			return y === null ? y : y.toFixed(2);
		};

		var element = this.element = document.createElement('div');
		element.className = 'detail';

		this.visible = true;
		graph.element.appendChild(element);

		this.lastEvent = null;
		this._addListeners();

		this.onShow = args.onShow;
		this.onHide = args.onHide;
		this.onRender = args.onRender;

		this.formatter = args.formatter || this.formatter;

	},

	formatter: function(series, x, y, formattedX, formattedY, d) {
		return series.name + ': ' + formattedY;
	},

	update: function(e) {

		e = e || this.lastEvent;
		if (!e) return;
		this.lastEvent = e;

		if (!e.target.nodeName.match(/^(path|svg|rect)$/)) return;

		var graph = this.graph;

		var eventX = e.offsetX || e.layerX;
		var eventY = e.offsetY || e.layerY;

		var j = 0;
		var points = [];
		var nearestPoint;

		this.graph.series.active().forEach( function(series) {

			var data = this.graph.stackedData[j++];

			var domainX = graph.x.invert(eventX);

			var domainIndexScale = d3.scale.linear()
				.domain([data[0].x, data.slice(-1)[0].x])
				.range([0, data.length - 1]);

			var approximateIndex = Math.round(domainIndexScale(domainX));
			var dataIndex = Math.min(approximateIndex || 0, data.length - 1);

			for (var i = approximateIndex; i < data.length - 1;) {

				if (!data[i] || !data[i + 1]) break;

				if (data[i].x <= domainX && data[i + 1].x > domainX) {
					dataIndex = i;
					break;
				}

				if (data[i + 1].x <= domainX) { i++ } else { i-- }
			}

			if (dataIndex < 0) dataIndex = 0;
			var value = data[dataIndex];

			var distance = Math.sqrt(
				Math.pow(Math.abs(graph.x(value.x) - eventX), 2) +
				Math.pow(Math.abs(graph.y(value.y + value.y0) - eventY), 2)
			);

			var xFormatter = series.xFormatter || this.xFormatter;
			var yFormatter = series.yFormatter || this.yFormatter;

			var point = {
				formattedXValue: xFormatter(value.x),
				formattedYValue: yFormatter(series.scale ? series.scale.invert(value.y) : value.y),
				series: series,
				value: value,
				distance: distance,
				order: j,
				name: series.name
			};

			if (!nearestPoint || distance < nearestPoint.distance) {
				nearestPoint = point;
			}

			points.push(point);

		}, this );

		if (!nearestPoint)
			return;

		nearestPoint.active = true;

		var domainX = nearestPoint.value.x;
		var formattedXValue = nearestPoint.formattedXValue;

		this.element.innerHTML = '';
		this.element.style.left = graph.x(domainX) + 'px';

		this.visible && this.render( {
			points: points,
			detail: points, // for backwards compatibility
			mouseX: eventX,
			mouseY: eventY,
			formattedXValue: formattedXValue,
			domainX: domainX
		} );
	},

	hide: function() {
		this.visible = false;
		this.element.classList.add('inactive');

		if (typeof this.onHide == 'function') {
			this.onHide();
		}
	},

	show: function() {
		this.visible = true;
		this.element.classList.remove('inactive');

		if (typeof this.onShow == 'function') {
			this.onShow();
		}
	},

	render: function(args) {

		var graph = this.graph;
		var points = args.points;
		var point = points.filter( function(p) { return p.active } ).shift();

		if (point.value.y === null) return;

		var formattedXValue = point.formattedXValue;
		var formattedYValue = point.formattedYValue;

		this.element.innerHTML = '';
		this.element.style.left = graph.x(point.value.x) + 'px';

		var xLabel = document.createElement('div');

		xLabel.className = 'x_label';
		xLabel.innerHTML = formattedXValue;
		this.element.appendChild(xLabel);

		var item = document.createElement('div');

		item.className = 'item';

		// invert the scale if this series displays using a scale
		var series = point.series;
		var actualY = series.scale ? series.scale.invert(point.value.y) : point.value.y;

		item.innerHTML = this.formatter(series, point.value.x, actualY, formattedXValue, formattedYValue, point);
		item.style.top = this.graph.y(point.value.y0 + point.value.y) + 'px';

		this.element.appendChild(item);

		var dot = document.createElement('div');

		dot.className = 'dot';
		dot.style.top = item.style.top;
		dot.style.borderColor = series.color;

		this.element.appendChild(dot);

		if (point.active) {
			item.className = 'item active';
			dot.className = 'dot active';
		}

		this.show();

		if (typeof this.onRender == 'function') {
			this.onRender(args);
		}
	},

	_addListeners: function() {

		this.graph.element.addEventListener(
			'mousemove',
			function(e) {
				this.visible = true;
				this.update(e);
			}.bind(this),
			false
		);

		this.graph.onUpdate( function() { this.update() }.bind(this) );

		this.graph.element.addEventListener(
			'mouseout',
			function(e) {
				if (e.relatedTarget && !(e.relatedTarget.compareDocumentPosition(this.graph.element) & Node.DOCUMENT_POSITION_CONTAINS)) {
					this.hide();
				}
			}.bind(this),
			false
		);
	}
});

<commit_msg>Handle when there are no points in a dataset<commit_after>Rickshaw.namespace('Rickshaw.Graph.HoverDetail');

Rickshaw.Graph.HoverDetail = Rickshaw.Class.create({

	initialize: function(args) {

		var graph = this.graph = args.graph;

		this.xFormatter = args.xFormatter || function(x) {
			return new Date( x * 1000 ).toUTCString();
		};

		this.yFormatter = args.yFormatter || function(y) {
			return y === null ? y : y.toFixed(2);
		};

		var element = this.element = document.createElement('div');
		element.className = 'detail';

		this.visible = true;
		graph.element.appendChild(element);

		this.lastEvent = null;
		this._addListeners();

		this.onShow = args.onShow;
		this.onHide = args.onHide;
		this.onRender = args.onRender;

		this.formatter = args.formatter || this.formatter;

	},

	formatter: function(series, x, y, formattedX, formattedY, d) {
		return series.name + ': ' + formattedY;
	},

	update: function(e) {

		e = e || this.lastEvent;
		if (!e) return;
		this.lastEvent = e;

		if (!e.target.nodeName.match(/^(path|svg|rect)$/)) return;

		var graph = this.graph;

		var eventX = e.offsetX || e.layerX;
		var eventY = e.offsetY || e.layerY;

		var j = 0;
		var points = [];
		var nearestPoint;

		this.graph.series.active().forEach( function(series) {

			var data = this.graph.stackedData[j++];

			if (!data.length)
				return;

			var domainX = graph.x.invert(eventX);

			var domainIndexScale = d3.scale.linear()
				.domain([data[0].x, data.slice(-1)[0].x])
				.range([0, data.length - 1]);

			var approximateIndex = Math.round(domainIndexScale(domainX));
			var dataIndex = Math.min(approximateIndex || 0, data.length - 1);

			for (var i = approximateIndex; i < data.length - 1;) {

				if (!data[i] || !data[i + 1]) break;

				if (data[i].x <= domainX && data[i + 1].x > domainX) {
					dataIndex = i;
					break;
				}

				if (data[i + 1].x <= domainX) { i++ } else { i-- }
			}

			if (dataIndex < 0) dataIndex = 0;
			var value = data[dataIndex];

			var distance = Math.sqrt(
				Math.pow(Math.abs(graph.x(value.x) - eventX), 2) +
				Math.pow(Math.abs(graph.y(value.y + value.y0) - eventY), 2)
			);

			var xFormatter = series.xFormatter || this.xFormatter;
			var yFormatter = series.yFormatter || this.yFormatter;

			var point = {
				formattedXValue: xFormatter(value.x),
				formattedYValue: yFormatter(series.scale ? series.scale.invert(value.y) : value.y),
				series: series,
				value: value,
				distance: distance,
				order: j,
				name: series.name
			};

			if (!nearestPoint || distance < nearestPoint.distance) {
				nearestPoint = point;
			}

			points.push(point);

		}, this );

		if (!nearestPoint)
			return;

		nearestPoint.active = true;

		var domainX = nearestPoint.value.x;
		var formattedXValue = nearestPoint.formattedXValue;

		this.element.innerHTML = '';
		this.element.style.left = graph.x(domainX) + 'px';

		this.visible && this.render( {
			points: points,
			detail: points, // for backwards compatibility
			mouseX: eventX,
			mouseY: eventY,
			formattedXValue: formattedXValue,
			domainX: domainX
		} );
	},

	hide: function() {
		this.visible = false;
		this.element.classList.add('inactive');

		if (typeof this.onHide == 'function') {
			this.onHide();
		}
	},

	show: function() {
		this.visible = true;
		this.element.classList.remove('inactive');

		if (typeof this.onShow == 'function') {
			this.onShow();
		}
	},

	render: function(args) {

		var graph = this.graph;
		var points = args.points;
		var point = points.filter( function(p) { return p.active } ).shift();

		if (point.value.y === null) return;

		var formattedXValue = point.formattedXValue;
		var formattedYValue = point.formattedYValue;

		this.element.innerHTML = '';
		this.element.style.left = graph.x(point.value.x) + 'px';

		var xLabel = document.createElement('div');

		xLabel.className = 'x_label';
		xLabel.innerHTML = formattedXValue;
		this.element.appendChild(xLabel);

		var item = document.createElement('div');

		item.className = 'item';

		// invert the scale if this series displays using a scale
		var series = point.series;
		var actualY = series.scale ? series.scale.invert(point.value.y) : point.value.y;

		item.innerHTML = this.formatter(series, point.value.x, actualY, formattedXValue, formattedYValue, point);
		item.style.top = this.graph.y(point.value.y0 + point.value.y) + 'px';

		this.element.appendChild(item);

		var dot = document.createElement('div');

		dot.className = 'dot';
		dot.style.top = item.style.top;
		dot.style.borderColor = series.color;

		this.element.appendChild(dot);

		if (point.active) {
			item.className = 'item active';
			dot.className = 'dot active';
		}

		this.show();

		if (typeof this.onRender == 'function') {
			this.onRender(args);
		}
	},

	_addListeners: function() {

		this.graph.element.addEventListener(
			'mousemove',
			function(e) {
				this.visible = true;
				this.update(e);
			}.bind(this),
			false
		);

		this.graph.onUpdate( function() { this.update() }.bind(this) );

		this.graph.element.addEventListener(
			'mouseout',
			function(e) {
				if (e.relatedTarget && !(e.relatedTarget.compareDocumentPosition(this.graph.element) & Node.DOCUMENT_POSITION_CONTAINS)) {
					this.hide();
				}
			}.bind(this),
			false
		);
	}
});

<|endoftext|>


<commit_before>import React from 'react'
import { Link } from 'react-router'

function ExplorerChoice(props) {
  return(

Select how you want to search a CSPA service.

<Link to="/gsbpm">Using GSBPM</Link>

<Link to="/gsim">Using GSIM</Link>

  )
}

export default ExplorerChoice
<commit_msg>Remove unused `explorer-choice` component<commit_after><|endoftext|>


<commit_before>/**
 *
 * Lazy Image Loading
 *
 * @author Takuto Yanagida @ Space-Time Inc.
 * @version 2019-06-05
 *
 */

window.ST = window['ST'] || {};

ST.addInitializer(5, function () {

	const TARGET_SELECTOR = '.stile';

	initializeLazyImageLoading();

	// -------------------------------------------------------------------------
	// Lazy Image Loading

	function initializeLazyImageLoading() {
		const OFFSET = 100;
		const imgs = document.querySelectorAll(TARGET_SELECTOR + ' img');
		const imgsInTbl = document.querySelectorAll(TARGET_SELECTOR + ' table img');

		// const winY = window.scrollY | window.pageYOffset;
		const winY = window.pageYOffset;
		for (let i = 0; i < imgs.length; i += 1) {
			const img = imgs[i];
			if ([].indexOf.call(imgsInTbl, img) !== -1) continue;
			// if (ST.elementTopOnWindow(img) >= winY + window.innerHeight + OFFSET) hide(img);
			if (img.getBoundingClientRect().top + winY >= winY + window.innerHeight + OFFSET) hide(img);
		}
		ST.onScroll(onScroll);
		onScroll();

		function onScroll() {
			// const winY = window.scrollY | window.pageYOffset;
			const winY = window.pageYOffset;
			for (let i = 0; i < imgs.length; i += 1) {
				const img = imgs[i];
				if (!img.dataset.src) continue;
				// const imgY = ST.elementTopOnWindow(img);
				const imgY = img.getBoundingClientRect().top + winY;
				if (imgY < winY + window.innerHeight + OFFSET) show(img);
			}
		}

		doBeforePrint(onPrint);
		function onPrint() {
			for (let i = 0; i < imgs.length; i += 1) {
				const img = imgs[i];
				if (!img.dataset.src) continue;
				show(img, true);
			}
		}
	}

	function hide(img) {
		img.dataset['src'] = img.src;
		img.src = 'data:image/gif;base64,R0lGODdhAQABAPAAAP///wAAACwAAAAAAQABAEACAkQBADs=';
		if (img.srcset) {
			img.dataset['srcset'] = img.srcset;
			img.srcset = '';
		}
		img.style.opacity = 0;
		const h = img.getAttribute('height');
		if (h) img.style.minHeight = h + 'px';
	}

	function show(img, immediately = false) {
		if (img.dataset.srcset) {
			img.srcset = img.dataset.srcset;
			img.dataset.srcset = '';
		}
		img.src = img.dataset.src;
		img.dataset.src = '';
		img.style.minHeight = '';
		if (immediately) {
			img.style.opacity = '';
		} else {
			setTimeout(function () {img.style.opacity = '';}, 200);
		}
	}

	function doBeforePrint(func, forceMediaCheck = true) {
		window.addEventListener('beforeprint', func, false);
		if (forceMediaCheck || !('onbeforeprint' in window)) {
			if (window.matchMedia) {
				let mediaQueryList = window.matchMedia('print');
				mediaQueryList.addListener(function (mql) {
					if (mql.matches) func();
				});
			}
		}
	}

});
<commit_msg>Refactoring<commit_after>/**
 *
 * Lazy Image Loading
 *
 * @author Takuto Yanagida @ Space-Time Inc.
 * @version 2019-06-06
 *
 */

window.ST = window['ST'] || {};

(function (NS) {

	const TARGET_SELECTOR = '.stile';
	const OFFSET = 100;

	NS.addInitializer(5, () => { initialize(); });

	// -------------------------------------------------------------------------

	function initialize() {
		const imgs      = document.querySelectorAll(TARGET_SELECTOR + ' img');
		const imgsInTbl = document.querySelectorAll(TARGET_SELECTOR + ' table img');

		const winY = window.pageYOffset;
		for (let i = 0; i < imgs.length; i += 1) {
			const img = imgs[i];
			if ([].indexOf.call(imgsInTbl, img) !== -1) continue;
			// if (ST.elementTopOnWindow(img) >= winY + window.innerHeight + OFFSET) hide(img);
			if (img.getBoundingClientRect().top + winY >= winY + window.innerHeight + OFFSET) hide(img);
		}
		NS.onScroll(onScroll);
		onScroll();

		function onScroll() {
			const winY = window.pageYOffset;
			for (let i = 0; i < imgs.length; i += 1) {
				const img = imgs[i];
				if (!img.dataset.src) continue;
				// const imgY = ST.elementTopOnWindow(img);
				const imgY = img.getBoundingClientRect().top + winY;
				if (imgY < winY + window.innerHeight + OFFSET) show(img);
			}
		}

		doBeforePrint(onPrint);
		function onPrint() {
			for (let i = 0; i < imgs.length; i += 1) {
				const img = imgs[i];
				if (!img.dataset.src) continue;
				show(img, true);
			}
		}
	}

	function hide(img) {
		img.dataset['src'] = img.src;
		img.src = 'data:image/gif;base64,R0lGODdhAQABAPAAAP///wAAACwAAAAAAQABAEACAkQBADs=';
		if (img.srcset) {
			img.dataset['srcset'] = img.srcset;
			img.srcset = '';
		}
		img.style.opacity = 0;
		const h = img.getAttribute('height');
		if (h) img.style.minHeight = h + 'px';
	}

	function show(img, immediately = false) {
		if (img.dataset.srcset) {
			img.srcset = img.dataset.srcset;
			img.dataset.srcset = '';
		}
		img.src = img.dataset.src;
		img.dataset.src = '';
		img.style.minHeight = '';
		if (immediately) {
			img.style.opacity = '';
		} else {
			setTimeout(() => {img.style.opacity = '';}, 200);
		}
	}

	function doBeforePrint(func, forceMediaCheck = true) {
		window.addEventListener('beforeprint', func, false);
		if (forceMediaCheck || !('onbeforeprint' in window)) {
			if (window.matchMedia) {
				let mediaQueryList = window.matchMedia('print');
				mediaQueryList.addListener(function (mql) {
					if (mql.matches) func();
				});
			}
		}
	}

})(window.ST);
<|endoftext|>