<commit_before>javascript: (function(){
    var jssrc = document.createElement('script');
    jssrc.setAttribute("type","text/javascript");
    jssrc.setAttribute("src", "https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js");
    document.getElementsByTagName("head")[0].appendChild(jssrc);

    var hdl = {
        MAX_ACT_PLAYERS_PER_DAY: 10,

        leaveoutIrrelevants: function() {
            jQuery('.Rail .RailSub').parent().remove();
            jQuery('.Rail .RailMain').css({width: '950px'});
            jQuery('#fantasyhero').remove();
            jQuery('#transactions').remove();
            jQuery('#messages').remove();
            jQuery('#commishupdates').remove();
            jQuery('#home-fantasy-experts').remove();
            jQuery("#mgrTimeTableCont").remove();
            jQuery("
").attr("id", "mgrTimeTableCont").appendTo(jQuery('.Rail .RailMain'));
        },

        attachAdditionalInfo: function() {
            hdl.leaveoutIrrelevants();
            jQuery('.Tst-manager > :first-child').each(function(){
                hdl.handleMgrOneByOne.call(this);
            });
        },

        handleMgrOneByOne: function() {
            var url = jQuery(this).attr('href');
            var avatar = jQuery(this).find('img').clone();
            var mgrName = jQuery(this).next().text();
            jQuery.ajax({
                url: url + "?stat1=O&ajaxrequest=1"
            }).done(function(data){
                hdl.onTimetableStatCallback(data, url, avatar, mgrName);
            });
        },

        onTimetableStatCallback: function(data, url, avatar, mgrName) {
            var cont = jQuery("
");
            cont.attr("mgrKey", url).appendTo(jQuery("#mgrTimeTableCont"));
            jQuery(data.content).appendTo(cont);
            setTimeout(function(){
                hdl.renderTimetable(cont, url, avatar, mgrName);
            }, 40);
        },

        renderTimetable: function(cont, url, avatar, mgrName) {
            cont.find("section header .Ptop-xs").remove();
            cont.find("section #dnd-status").remove();
            cont.find("section #buttonbar").remove();
            cont.find("section header .Grid-table .Ta-end").children().remove();
            cont.find("section .stat-target .ysf-rosterswapper thead .First").remove();
            avatar.appendTo(cont.find("section header .Grid-table .Ta-end"));
            jQuery("" + mgrName + "").appendTo(cont.find("section header .Grid-table .Ta-end"));
            var removedIdxMap = {}, titleMap = {}, curtIdx = 0;
            cont.find("section .stat-target .ysf-rosterswapper thead tr th").each(function(){
                var title = jQuery(this).text();
                if(title == "Action" || title == "Opp" || title == "Status" || title == "Edit") {
                    removedIdxMap["k"+curtIdx] = curtIdx;
                    if(title == "Action") {
                        curtIdx++;
                        removedIdxMap["k"+curtIdx] = curtIdx;
                    }
                    jQuery(this).remove();
                }
                titleMap["k"+curtIdx] = title;
                curtIdx++;
            });
            var cntByDay = {}, numOfAtts = 0, curtDayIdx = 0;
            cont.find("section .stat-target .ysf-rosterswapper tbody tr").each(function(){
                var bdrendCnt = 0, isFutureDay = false, position = "";
                jQuery(this).find('td').each(function(idx){
                    if(idx == 0) {
                        position = jQuery(this).text();
                    }
                    if(removedIdxMap["k"+idx]) {
                        jQuery(this).remove();
                        return true;
                    }
                    if(isFutureDay == false) {
                        isFutureDay = jQuery(this).hasClass('Selected');
                        curtDayIdx = idx;
                    }
                    bdrendCnt += (jQuery(this).hasClass('Bdrend') ? 1 : 0);
                    if(bdrendCnt < 2 || bdrendCnt > 3 || position == "IL" || jQuery(this).hasClass('player')) {
                        return true;
                    }
                    var kprefix = isFutureDay ? "f" : "k";
                    var cnt = cntByDay[kprefix+idx] || 0;
                    cnt = jQuery(this).text() == "" ? cnt : cnt+1;
                    if(cnt > hdl.MAX_ACT_PLAYERS_PER_DAY) {
                        cnt = hdl.MAX_ACT_PLAYERS_PER_DAY;
                    }
                    cntByDay[kprefix+idx] = cnt;
                    if(bdrendCnt == 3) {
                        return false;
                    }
                });
            });
            var totCnt = 0;
            var estDetailArr = [];
            for(var key in cntByDay) {
                totCnt += cntByDay[key] || 0;
                estDetailArr.push(key);
            }
            var tgtEl = jQuery("#matchupweek .F-link[href='" + url + "']");
            var pointCont = tgtEl.parent().parent().parent().parent().prev();
            pointCont.css({'width': '70px'});
            pointCont.children().css({'padding-right': '8px'});
            pointCont.parent().parent().css({'padding-bottom': '1px'});

            tgtEl.parent().next().remove();
            tgtEl.parent().css({'max-width': '300px'});
            tgtEl.parent().find('.est-details').remove();

            var detailCont = jQuery('
');
            detailCont.appendTo(tgtEl.parent());

            var detailTb = jQuery('
');
            detailTb.appendTo(detailCont);

            var titleTdArr = [], cntByDayTdArr = [], runningTotTdArr = [];
            var runningTot = 0, remainingTot = totCnt, tmpDayCnt = 0;
            var tdStyle = 'border: 1px solid black; padding: 2px 3px; text-align: center;';
            for(var i=0; i<estDetailArr.length; i++) {
                var curtIdxStr = estDetailArr[i].substr(1);
                tmpDayCnt = cntByDay[estDetailArr[i]];
                runningTot += tmpDayCnt;
                remainingTot -= tmpDayCnt;
                titleTdArr.push('' + titleMap['k'+curtIdxStr] + '	');
                cntByDayTdArr.push('' + tmpDayCnt + '	');
                runningTotTdArr.push('' + runningTot + '	');
                runningTotTdArr.push('' + remainingTot + '	');
            }
            jQuery('

' + titleTdArr.join('') + '

').appendTo(detailTb);
            jQuery('

' + cntByDayTdArr.join('') + '

' + runningTotTdArr.join('') + '

').appendTo(detailTb);
        }
    };

    setTimeout(function(){
        hdl.attachAdditionalInfo();
    }, 400);
})();
<commit_msg>Update enhanced-league-overview.js<commit_after>javascript: (function(){
    var jssrc = document.createElement('script');
    jssrc.setAttribute("type","text/javascript");
    jssrc.setAttribute("src", "https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js");
    document.getElementsByTagName("head")[0].appendChild(jssrc);

    var hdl = {
        MAX_ACT_PLAYERS_PER_DAY: 10,

        leaveoutIrrelevants: function() {
            jQuery('.Rail .RailSub').parent().remove();
            jQuery('.Rail .RailMain').css({width: '950px'});
            jQuery('#fantasyhero').remove();
            jQuery('#transactions').remove();
            jQuery('#messages').remove();
            jQuery('#commishupdates').remove();
            jQuery('#home-fantasy-experts').remove();
            jQuery("#mgrTimeTableCont").remove();
            jQuery("
").attr("id", "mgrTimeTableCont").appendTo(jQuery('.Rail .RailMain'));
        },

        attachAdditionalInfo: function() {
            hdl.leaveoutIrrelevants();
            jQuery('.Tst-manager > :first-child').each(function(){
                hdl.handleMgrOneByOne.call(this);
            });
        },

        handleMgrOneByOne: function() {
            var url = jQuery(this).attr('href');
            var avatar = jQuery(this).find('img').clone();
            var mgrName = jQuery(this).next().text();
            jQuery.ajax({
                url: url + "?stat1=O&ajaxrequest=1"
            }).done(function(data){
                hdl.onTimetableStatCallback(data, url, avatar, mgrName);
            });
        },

        onTimetableStatCallback: function(data, url, avatar, mgrName) {
            var cont = jQuery("
");
            cont.attr("mgrKey", url).appendTo(jQuery("#mgrTimeTableCont"));
            jQuery(data.content).appendTo(cont);
            setTimeout(function(){
                hdl.renderTimetable(cont, url, avatar, mgrName);
            }, 40);
        },

        renderTimetable: function(cont, url, avatar, mgrName) {
            cont.find("section header .Ptop-xs").remove();
            cont.find("section #dnd-status").remove();
            cont.find("section #buttonbar").remove();
            cont.find("section header .Grid-table .Ta-end").children().remove();
            cont.find("section .stat-target .ysf-rosterswapper thead .First").remove();
            avatar.appendTo(cont.find("section header .Grid-table .Ta-end"));
            jQuery("" + mgrName + "").appendTo(cont.find("section header .Grid-table .Ta-end"));
            var removedIdxMap = {}, titleMap = {}, curtIdx = 0;
            cont.find("section .stat-target .ysf-rosterswapper thead tr th").each(function(){
                var title = jQuery(this).text();
                if(title == "Action" || title == "Opp" || title == "Status" || title == "Edit") {
                    removedIdxMap["k"+curtIdx] = curtIdx;
                    if(title == "Action") {
                        curtIdx++;
                        removedIdxMap["k"+curtIdx] = curtIdx;
                    }
                    jQuery(this).remove();
                }
                titleMap["k"+curtIdx] = title;
                curtIdx++;
            });
            var cntByDay = {}, numOfAtts = 0, curtDayIdx = 0;
            cont.find("section .stat-target .ysf-rosterswapper tbody tr").each(function(){
                var bdrendCnt = 0, isFutureDay = false, position = "";
                jQuery(this).find('td').each(function(idx){
                    if(idx == 0) {
                        position = jQuery(this).text();
                    }
                    if(removedIdxMap["k"+idx]) {
                        jQuery(this).remove();
                        return true;
                    }
                    if(isFutureDay == false) {
                        isFutureDay = jQuery(this).hasClass('Selected');
                        curtDayIdx = idx;
                    }
                    bdrendCnt += (jQuery(this).hasClass('Bdrend') ? 1 : 0);
                    if(bdrendCnt < 2 || bdrendCnt > 3 || position == "IL" || jQuery(this).hasClass('player')) {
                        return true;
                    }
                    var kprefix = isFutureDay ? "f" : "k";
                    var cnt = cntByDay[kprefix+idx] || 0;
                    cnt = jQuery(this).text() == "" ? cnt : cnt+1;
                    if(cnt > hdl.MAX_ACT_PLAYERS_PER_DAY) {
                        cnt = hdl.MAX_ACT_PLAYERS_PER_DAY;
                    }
                    cntByDay[kprefix+idx] = cnt;
                    if(bdrendCnt == 3) {
                        return false;
                    }
                });
            });
            var estFTot = 0, totCnt = 0;
            var estDetailArr = [];
            for(var key in cntByDay) {
                totCnt += cntByDay[key] || 0;
                if(key.indexOf("f") == 0) {
                    estFTot += cntByDay[key] || 0;
                }
                estDetailArr.push(key);
            }
            var tgtEl = jQuery("#matchupweek .F-link[href='" + url + "']");
            var pointCont = tgtEl.parent().parent().parent().parent().prev();
            pointCont.css({'width': '70px'});
            pointCont.children().css({'padding-right': '8px'});
            pointCont.parent().parent().css({'padding-bottom': '1px'});

            tgtEl.parent().next().remove();
            tgtEl.parent().css({'max-width': '300px'});
            tgtEl.parent().find('.est-ftot').remove();
            tgtEl.parent().find('.est-details').remove();
            jQuery("(est. " + estFTot + ")").appendTo(tgtEl.parent());

            var detailCont = jQuery('
');
            detailCont.appendTo(tgtEl.parent());

            var detailTb = jQuery('
');
            detailTb.appendTo(detailCont);

            var titleTdArr = [], cntByDayTdArr = [], runningTotTdArr = [];
            var runningTot = 0, remainingTot = totCnt, tmpDayCnt = 0;
            var tdStyle = 'border: 1px solid black; padding: 2px 3px; text-align: center;';
            for(var i=0; i<estDetailArr.length; i++) {
                var curtIdxStr = estDetailArr[i].substr(1);
                tmpDayCnt = cntByDay[estDetailArr[i]];
                runningTot += tmpDayCnt;
                remainingTot -= tmpDayCnt;
                titleTdArr.push('' + titleMap['k'+curtIdxStr] + '	');
                cntByDayTdArr.push('' + tmpDayCnt + '	');
                runningTotTdArr.push('' + runningTot + '	');
                runningTotTdArr.push('' + remainingTot + '	');
            }
            jQuery('

' + titleTdArr.join('') + '

').appendTo(detailTb);
            jQuery('

' + cntByDayTdArr.join('') + '

' + runningTotTdArr.join('') + '

').appendTo(detailTb);
        }
    };

    setTimeout(function(){
        hdl.attachAdditionalInfo();
    }, 400);
})();
<|endoftext|>


<commit_before>"use strict";

function NodeScreenSDL(sdl, font_file)
{
    var ROW_HEIGHT = 16,

        // about right for ascii.ttf
        CHAR_WIDTH = 10,

        /** @type {number} */
        cursor_scanline_start,

        /** @type {number} */
        cursor_scanline_end,

        current_cursor_address,

        graphic_buffer,
        graphic_buffer8,
        graphic_buffer32;

    sdl.init(sdl.INIT.VIDEO);

    var ttf = sdl.TTF,
        screen;

    ttf.init();

    var font = ttf.openFont(font_file, 16);

    sdl.events.on("QUIT", function()
    {
        process.exit();
    });

    this.put_char = function(row, col, chr, bg_color, fg_color)
    {
        if((chr & 0xff) === 0)
        {
            // required, otherwise sdl throws up
            return;
        }

        var str = String.fromCharCode(chr & 0xff),
            s = ttf.renderTextShaded(font, str, fg_color, bg_color);

        sdl.blitSurface(s, null, screen, [col * CHAR_WIDTH, row * ROW_HEIGHT]);
        sdl.freeSurface(s);
    };

    this.put_pixel_linear = function(offset, color_part)
    {
        graphic_buffer8[offset] = color_part;
    };

    this.put_pixel = function(x, y, color)
    {
        throw "TODO";
    };

    this.timer_text = function()
    {
        sdl.flip(screen);
    };

    this.timer_graphical = function()
    {
        sdl.putImageData(screen, graphic_buffer32);
        sdl.flip(screen);
    };

    this.destroy = function()
    {

    };

    this.set_mode = function(graphical)
    {
        // switch between graphical and text mode
    };

    this.clear_screen = function()
    {

    };

    this.set_size_text = function(cols, rows)
    {
        screen = sdl.setVideoMode(CHAR_WIDTH * cols, ROW_HEIGHT * rows, 32, 0);

        //dbg_log(screen, LOG_VGA);
        //dbg_log(screen.pixels, LOG_VGA);
    };

    this.set_size_graphical = function(width, height)
    {
        screen = sdl.setVideoMode(width, height, 32, 0);

        graphic_buffer = new ArrayBuffer(width * height * 4);
        graphic_buffer8 = new Uint8Array(graphic_buffer);
        graphic_buffer32 = new Int32Array(graphic_buffer);
    };

    this.update_cursor = function(cursor_row, cursor_col)
    {
        refresh_cursor();
    };

    this.update_cursor_scanline = function(start, end)
    {
        cursor_scanline_start = start;
        cursor_scanline_end = end;

        refresh_cursor();
    };

    function refresh_cursor()
    {
        // TODO
    }

}

<commit_msg>resize only in text mode<commit_after>"use strict";

function NodeScreenSDL(sdl, font_file)
{
    var ROW_HEIGHT = 16,

        // about right for ascii.ttf
        CHAR_WIDTH = 10,

        /** @type {number} */
        cursor_scanline_start,

        /** @type {number} */
        cursor_scanline_end,

        current_cursor_address,

        is_graphical = false,

        graphic_buffer,
        graphic_buffer8,
        graphic_buffer32;

    sdl.init(sdl.INIT.VIDEO);

    var ttf = sdl.TTF,
        screen;

    ttf.init();

    var font = ttf.openFont(font_file, 16);

    sdl.events.on("QUIT", function()
    {
        process.exit();
    });

    this.put_char = function(row, col, chr, bg_color, fg_color)
    {
        if((chr & 0xff) === 0)
        {
            // required, otherwise sdl throws up
            return;
        }

        var str = String.fromCharCode(chr & 0xff),
            s = ttf.renderTextShaded(font, str, fg_color, bg_color);

        sdl.blitSurface(s, null, screen, [col * CHAR_WIDTH, row * ROW_HEIGHT]);
        sdl.freeSurface(s);
    };

    this.put_pixel_linear = function(offset, color_part)
    {
        graphic_buffer8[offset] = color_part;
    };

    this.put_pixel = function(x, y, color)
    {
        throw "TODO";
    };

    this.timer_text = function()
    {
        sdl.flip(screen);
    };

    this.timer_graphical = function()
    {
        sdl.putImageData(screen, graphic_buffer32);
        sdl.flip(screen);
    };

    this.destroy = function()
    {

    };

    this.set_mode = function(graphical)
    {
        // switch between graphical and text mode
        is_graphical = graphical;
    };

    this.clear_screen = function()
    {

    };

    this.set_size_text = function(cols, rows)
    {
        if(!is_graphical)
        {
            screen = sdl.setVideoMode(CHAR_WIDTH * cols, ROW_HEIGHT * rows, 32, 0);
        }

        //dbg_log(screen, LOG_VGA);
        //dbg_log(screen.pixels, LOG_VGA);
    };

    this.set_size_graphical = function(width, height)
    {
        screen = sdl.setVideoMode(width, height, 32, 0);

        graphic_buffer = new ArrayBuffer(width * height * 4);
        graphic_buffer8 = new Uint8Array(graphic_buffer);
        graphic_buffer32 = new Int32Array(graphic_buffer);
    };

    this.update_cursor = function(cursor_row, cursor_col)
    {
        refresh_cursor();
    };

    this.update_cursor_scanline = function(start, end)
    {
        cursor_scanline_start = start;
        cursor_scanline_end = end;

        refresh_cursor();
    };

    function refresh_cursor()
    {
        // TODO
    }

}

<|endoftext|>


<commit_before>var NwBuilder = require('node-webkit-builder');
var gulp = require('gulp');
var gutil = require('gulp-util');

gulp.task('nw', function () {

    var nw = new NwBuilder({
        version: 'latest',
        files: './nwapp/**',
        macIcns: './icons/icon.icns',
        mac_bundle_id: 'myPkgName',
        platforms: ['win', 'osx']
    });

    // Log stuff you want
    nw.on('log', function (msg) {
        gutil.log('node-webkit-builder', msg);
    });

    // Build returns a promise, return it so the task isn't called in parallel
    return nw.build().catch(function (err) {
        gutil.log('node-webkit-builder', err);
    });
});

gulp.task('default', ['nw']);
<commit_msg>Update Gulpfile.js<commit_after>var NwBuilder = require('node-webkit-builder');
var gulp = require('gulp');
var gutil = require('gulp-util');

gulp.task('nw', function () {

    var nw = new NwBuilder({
        version: 'latest',
        files: './nwapp/**',
        macIcns: './icons/icon.icns',
        macPlist: {mac_bundle_id: 'myPkg'},
        platforms: ['win', 'osx']
    });

    // Log stuff you want
    nw.on('log', function (msg) {
        gutil.log('node-webkit-builder', msg);
    });

    // Build returns a promise, return it so the task isn't called in parallel
    return nw.build().catch(function (err) {
        gutil.log('node-webkit-builder', err);
    });
});

gulp.task('default', ['nw']);
<|endoftext|>


<commit_before>var module = angular.module('ngProgress', []);

module.provider('progressbar', function() {
    //Default values for provider
    this.count = 0;
    this.height = '2px';
    this.color = 'firebrick';

    this.$get = function($document, $window) {
        var count = this.count;
        var height = this.height;
        var color = this.color;
        var $body = $document.find('body');
        // Create elements that is needed
        var progressbarContainer = angular.element('

');
        var progressbar = angular.element('

');

        //Add CSS3 styles for transition smoothing
        var css = document.createElement("style");
        css.type = "text/css";
        css.innerHTML = ".progressbar {-webkit-transition: all 0.5s ease-in-out; -moz-transition: all 0.5s ease-in-out; -o-transition: all 0.5s ease-in-out; transition: all 0.5s ease-in-out;}";
        document.body.appendChild(css);

        //Styling for the progressbar-container
        progressbarContainer.css('position', 'fixed');
        progressbarContainer.css('margin', '0');
        progressbarContainer.css('padding', '0');
        progressbarContainer.css('top', '0px');
        progressbarContainer.css('left', '0px');
        progressbarContainer.css('right', '0px');

        //Styling for the progressbar itself
        progressbar.css('height', height);
        progressbar.css('box-shadow', '0px 0px 10px 0px ' + color);
        progressbar.css('width', count+'%');
        progressbar.css('margin', '0');
        progressbar.css('padding', '0');
        progressbar.css('background-color', color);

        //Add progressbar to progressbar-container and progressbar-container
        // to body
        progressbarContainer.append(progressbar);
        $body.append(progressbarContainer);

        return {
            // Starts the animation and adds between 0 - 5 percent to loading
            // each 400 milliseconds. Should always be finished with progressbar.complete()
            // to hide it
            start: function() {
                progressbar.css('width', count + '%');
                progressbar.css('opacity', '1');
                $window.interval = setInterval(function(){
                    if(count + 1 >= 100) {
                        clearInterval($window.interval);
                    } else {
                        var random = Math.floor(Math.random()*5)
                        count = count + random;
                        progressbar.css('width', count + '%');
                    }
                }, 400);
            },
            // Sets the height of the progressbar. Use any valid CSS value
            // Eg '10px', '1em' or '1%'
            height: function(new_height) {
                progressbar.css('height', new_height);
            },
            // Sets the color of the progressbar and it's shadow. Use any valid HTML
            // color
            color: function(color) {
                progressbar.css('box-shadow', '0px 0px 10px 0px ' + color);
                progressbar.css('background-color', color);
            },
            // Returns on how many percent the progressbar is at. Should'nt be needed
            status: function() {
                return this.count;
            },
            // Stops the progressbar at it's current location
            stop: function() {
                clearInterval($window.interval);
            },
            // Set's the progressbar percentage. Use a number between 0 - 100.
            // If 100 is provided, complete will be called.
            set: function(new_count) {
                clearInterval($window.interval);
                if(new_count >= 100) {
                    this.complete();
                }
                count = new_count;
                progressbar.css('width', count + '%');
                progressbar.css('opacity', '1');
                return count;
            },
            // Resets the progressbar to percetage 0 and therefore will be hided after
            // it's rollbacked
            reset: function() {
                clearInterval($window.interval);
                count = 0;
                progressbar.css('width', count + '%');
                progressbar.css('opacity', '1');
                return 0;
            },
            // Jumps to 100% progress and fades away progressbar.
            complete: function() {
                clearInterval($window.interval);
                count = 100;
                progressbar.css('width', count + '%');
                setTimeout(function(){
                    progressbar.css('opacity', '0');
                }, 500);
                setTimeout(function(){
                    count = 0;
                    progressbar.css('width', count + '%');
                }, 1000);
                return count;
            }
        }
    };

    this.setColor = function(color) {
        this.color = color;
    };

    this.setHeight = function(height) {
        this.height = height;
    };

});<commit_msg>.start() stop at 95% instead of 100%<commit_after>var module = angular.module('ngProgress', []);

module.provider('progressbar', function() {
    //Default values for provider
    this.count = 0;
    this.height = '2px';
    this.color = 'firebrick';

    this.$get = function($document, $window) {
        var count = this.count;
        var height = this.height;
        var color = this.color;
        var $body = $document.find('body');
        // Create elements that is needed
        var progressbarContainer = angular.element('

');
        var progressbar = angular.element('

');

        //Add CSS3 styles for transition smoothing
        var css = document.createElement("style");
        css.type = "text/css";
        css.innerHTML = ".progressbar {-webkit-transition: all 0.5s ease-in-out; -moz-transition: all 0.5s ease-in-out; -o-transition: all 0.5s ease-in-out; transition: all 0.5s ease-in-out;}";
        document.body.appendChild(css);

        //Styling for the progressbar-container
        progressbarContainer.css('position', 'fixed');
        progressbarContainer.css('margin', '0');
        progressbarContainer.css('padding', '0');
        progressbarContainer.css('top', '0px');
        progressbarContainer.css('left', '0px');
        progressbarContainer.css('right', '0px');

        //Styling for the progressbar itself
        progressbar.css('height', height);
        progressbar.css('box-shadow', '0px 0px 10px 0px ' + color);
        progressbar.css('width', count+'%');
        progressbar.css('margin', '0');
        progressbar.css('padding', '0');
        progressbar.css('background-color', color);

        //Add progressbar to progressbar-container and progressbar-container
        // to body
        progressbarContainer.append(progressbar);
        $body.append(progressbarContainer);

        return {
            // Starts the animation and adds between 0 - 5 percent to loading
            // each 400 milliseconds. Should always be finished with progressbar.complete()
            // to hide it
            start: function() {
                progressbar.css('width', count + '%');
                progressbar.css('opacity', '1');
                $window.interval = setInterval(function(){
                    if(count + 1 >= 95) {
                        clearInterval($window.interval);
                    } else {
                        var random = Math.floor(Math.random()*5)
                        count = count + random;
                        progressbar.css('width', count + '%');
                    }
                }, 400);
            },
            // Sets the height of the progressbar. Use any valid CSS value
            // Eg '10px', '1em' or '1%'
            height: function(new_height) {
                progressbar.css('height', new_height);
            },
            // Sets the color of the progressbar and it's shadow. Use any valid HTML
            // color
            color: function(color) {
                progressbar.css('box-shadow', '0px 0px 10px 0px ' + color);
                progressbar.css('background-color', color);
            },
            // Returns on how many percent the progressbar is at. Should'nt be needed
            status: function() {
                return this.count;
            },
            // Stops the progressbar at it's current location
            stop: function() {
                clearInterval($window.interval);
            },
            // Set's the progressbar percentage. Use a number between 0 - 100.
            // If 100 is provided, complete will be called.
            set: function(new_count) {
                clearInterval($window.interval);
                if(new_count >= 100) {
                    this.complete();
                }
                count = new_count;
                progressbar.css('width', count + '%');
                progressbar.css('opacity', '1');
                return count;
            },
            // Resets the progressbar to percetage 0 and therefore will be hided after
            // it's rollbacked
            reset: function() {
                clearInterval($window.interval);
                count = 0;
                progressbar.css('width', count + '%');
                progressbar.css('opacity', '1');
                return 0;
            },
            // Jumps to 100% progress and fades away progressbar.
            complete: function() {
                clearInterval($window.interval);
                count = 100;
                progressbar.css('width', count + '%');
                setTimeout(function(){
                    progressbar.css('opacity', '0');
                }, 500);
                setTimeout(function(){
                    count = 0;
                    progressbar.css('width', count + '%');
                }, 1000);
                return count;
            }
        }
    };

    this.setColor = function(color) {
        this.color = color;
    };

    this.setHeight = function(height) {
        this.height = height;
    };

});<|endoftext|>


<commit_before>//////////////////////////////////////////////////
// Package docs at http://docs.meteor.com/#deps //
//////////////////////////////////////////////////

Deps = {};

// http://docs.meteor.com/#deps_active
Deps.active = false;

// http://docs.meteor.com/#deps_currentcomputation
Deps.currentComputation = null;

var setCurrentComputation = function (c) {
  Deps.currentComputation = c;
  Deps.active = !! c;
};

// _assign is like _.extend or the upcoming Object.assign.
// Copy src's own, enumerable properties onto tgt and return
// tgt.
var _assign = function (tgt, src) {
  for (var k in src)
    if (src.hasOwnProperty(k))
      tgt[k] = src[k];
  return tgt;
};

var _debugFunc = function () {
  // lazy evaluation because `Meteor` does not exist right away
  return (typeof Meteor !== "undefined" ? Meteor._debug :
          ((typeof console !== "undefined") && console.log ?
           function () { console.log.apply(console, arguments); } :
           function () {}));
};

var _throwOrLog = function (from, e) {
  if (throwFirstError) {
    throw e;
  } else {
    _debugFunc()("Exception from Deps " + from + " function:",
                 e.stack || e.message);
  }
};

// Like `Meteor._noYieldsAllowed(function () { f(comp); })` but shorter,
// and doesn't clutter the stack with an extra frame on the client,
// where `_noYieldsAllowed` is a no-op.  `f` may be a computation
// function or an onInvalidate callback.
var callWithNoYieldsAllowed = function (f, comp) {
  if ((typeof Meteor === 'undefined') || Meteor.isClient) {
    f(comp);
  } else {
    Meteor._noYieldsAllowed(function () {
      f(comp);
    });
  }
};

var nextId = 1;
// computations whose callbacks we should call at flush time
var pendingComputations = [];
// `true` if a Deps.flush is scheduled, or if we are in Deps.flush now
var willFlush = false;
// `true` if we are in Deps.flush now
var inFlush = false;
// `true` if we are computing a computation now, either first time
// or recompute.  This matches Deps.active unless we are inside
// Deps.nonreactive, which nullfies currentComputation even though
// an enclosing computation may still be running.
var inCompute = false;
// `true` if the `_throwFirstError` option was passed in to the call
// to Deps.flush that we are in. When set, throw rather than log the
// first error encountered while flushing. Before throwing the error,
// finish flushing (from a finally block), logging any subsequent
// errors.
var throwFirstError = false;

var afterFlushCallbacks = [];

var requireFlush = function () {
  if (! willFlush) {
    setTimeout(Deps.flush, 0);
    willFlush = true;
  }
};

// Deps.Computation constructor is visible but private
// (throws an error if you try to call it)
var constructingComputation = false;

//
// http://docs.meteor.com/#deps_computation
//
Deps.Computation = function (f, parent) {
  if (! constructingComputation)
    throw new Error(
      "Deps.Computation constructor is private; use Deps.autorun");
  constructingComputation = false;

  var self = this;

  // http://docs.meteor.com/#computation_stopped
  self.stopped = false;

  // http://docs.meteor.com/#computation_invalidated
  self.invalidated = false;

  // http://docs.meteor.com/#computation_firstrun
  self.firstRun = true;

  self._id = nextId++;
  self._onInvalidateCallbacks = [];
  // the plan is at some point to use the parent relation
  // to constrain the order that computations are processed
  self._parent = parent;
  self._func = f;
  self._recomputing = false;

  var errored = true;
  try {
    self._compute();
    errored = false;
  } finally {
    self.firstRun = false;
    if (errored)
      self.stop();
  }
};

_assign(Deps.Computation.prototype, {

  // http://docs.meteor.com/#computation_oninvalidate
  onInvalidate: function (f) {
    var self = this;

    if (typeof f !== 'function')
      throw new Error("onInvalidate requires a function");

    if (self.invalidated) {
      Deps.nonreactive(function () {
        callWithNoYieldsAllowed(f, self);
      });
    } else {
      self._onInvalidateCallbacks.push(f);
    }
  },

  // http://docs.meteor.com/#computation_invalidate
  invalidate: function () {
    var self = this;
    if (! self.invalidated) {
      // if we're currently in _recompute(), don't enqueue
      // ourselves, since we'll rerun immediately anyway.
      if (! self._recomputing && ! self.stopped) {
        requireFlush();
        pendingComputations.push(this);
      }

      self.invalidated = true;

      // callbacks can't add callbacks, because
      // self.invalidated === true.
      for(var i = 0, f; f = self._onInvalidateCallbacks[i]; i++) {
        Deps.nonreactive(function () {
          callWithNoYieldsAllowed(f, self);
        });
      }
      self._onInvalidateCallbacks = [];
    }
  },

  // http://docs.meteor.com/#computation_stop
  stop: function () {
    if (! this.stopped) {
      this.stopped = true;
      this.invalidate();
    }
  },

  _compute: function () {
    var self = this;
    self.invalidated = false;

    var previous = Deps.currentComputation;
    setCurrentComputation(self);
    var previousInCompute = inCompute;
    inCompute = true;
    try {
      callWithNoYieldsAllowed(self._func, self);
    } finally {
      setCurrentComputation(previous);
      inCompute = false;
    }
  },

  _recompute: function () {
    var self = this;

    self._recomputing = true;
    try {
      while (self.invalidated && ! self.stopped) {
        try {
          self._compute();
        } catch (e) {
          _throwOrLog("recompute", e);
        }
        // If _compute() invalidated us, we run again immediately.
        // A computation that invalidates itself indefinitely is an
        // infinite loop, of course.
        //
        // We could put an iteration counter here and catch run-away
        // loops.
      }
    } finally {
      self._recomputing = false;
    }
  }
});

//
// http://docs.meteor.com/#deps_dependency
//
Deps.Dependency = function () {
  this._dependentsById = {};
};

_assign(Deps.Dependency.prototype, {
  // http://docs.meteor.com/#dependency_depend
  //
  // Adds `computation` to this set if it is not already
  // present.  Returns true if `computation` is a new member of the set.
  // If no argument, defaults to currentComputation, or does nothing
  // if there is no currentComputation.
  depend: function (computation) {
    if (! computation) {
      if (! Deps.active)
        return false;

      computation = Deps.currentComputation;
    }
    var self = this;
    var id = computation._id;
    if (! (id in self._dependentsById)) {
      self._dependentsById[id] = computation;
      computation.onInvalidate(function () {
        delete self._dependentsById[id];
      });
      return true;
    }
    return false;
  },

  // http://docs.meteor.com/#dependency_changed
  changed: function () {
    var self = this;
    for (var id in self._dependentsById)
      self._dependentsById[id].invalidate();
  },

  // http://docs.meteor.com/#dependency_hasdependents
  hasDependents: function () {
    var self = this;
    for(var id in self._dependentsById)
      return true;
    return false;
  }
});

_assign(Deps, {
  // http://docs.meteor.com/#deps_flush
  flush: function (_opts) {
    // XXX What part of the comment below is still true? (We no longer
    // have Spark)
    //
    // Nested flush could plausibly happen if, say, a flush causes
    // DOM mutation, which causes a "blur" event, which runs an
    // app event handler that calls Deps.flush.  At the moment
    // Spark blocks event handlers during DOM mutation anyway,
    // because the LiveRange tree isn't valid.  And we don't have
    // any useful notion of a nested flush.
    //
    // https://app.asana.com/0/159908330244/385138233856
    if (inFlush)
      throw new Error("Can't call Deps.flush while flushing");

    if (inCompute)
      throw new Error("Can't flush inside Deps.autorun");

    inFlush = true;
    willFlush = true;
    throwFirstError = !! (_opts && _opts._throwFirstError);

    var finishedTry = false;
    try {
      while (pendingComputations.length ||
             afterFlushCallbacks.length) {

        // recompute all pending computations
        while (pendingComputations.length) {
          var comp = pendingComputations.shift();
          comp._recompute();
        }

        if (afterFlushCallbacks.length) {
          // call one afterFlush callback, which may
          // invalidate more computations
          var func = afterFlushCallbacks.shift();
          try {
            func();
          } catch (e) {
            _throwOrLog("afterFlush function", e);
          }
        }
      }
      finishedTry = true;
    } finally {
      if (! finishedTry) {
        // we're erroring
        inFlush = false; // needed before calling `Deps.flush()` again
        Deps.flush({_throwFirstError: false}); // finish flushing
      }
      willFlush = false;
      inFlush = false;
    }
  },

  // http://docs.meteor.com/#deps_autorun
  //
  // Run f(). Record its dependencies. Rerun it whenever the
  // dependencies change.
  //
  // Returns a new Computation, which is also passed to f.
  //
  // Links the computation to the current computation
  // so that it is stopped if the current computation is invalidated.
  autorun: function (f) {
    if (typeof f !== 'function')
      throw new Error('Deps.autorun requires a function argument');

    constructingComputation = true;
    var c = new Deps.Computation(f, Deps.currentComputation);

    if (Deps.active)
      Deps.onInvalidate(function () {
        c.stop();
      });

    return c;
  },

  // http://docs.meteor.com/#deps_nonreactive
  //
  // Run `f` with no current computation, returning the return value
  // of `f`.  Used to turn off reactivity for the duration of `f`,
  // so that reactive data sources accessed by `f` will not result in any
  // computations being invalidated.
  nonreactive: function (f) {
    var previous = Deps.currentComputation;
    setCurrentComputation(null);
    try {
      return f();
    } finally {
      setCurrentComputation(previous);
    }
  },

  // http://docs.meteor.com/#deps_oninvalidate
  onInvalidate: function (f) {
    if (! Deps.active)
      throw new Error("Deps.onInvalidate requires a currentComputation");

    Deps.currentComputation.onInvalidate(f);
  },

  // http://docs.meteor.com/#deps_afterflush
  afterFlush: function (f) {
    afterFlushCallbacks.push(f);
    requireFlush();
  }
});
<commit_msg>Fix Deps's broken _assign (harmless)<commit_after>//////////////////////////////////////////////////
// Package docs at http://docs.meteor.com/#deps //
//////////////////////////////////////////////////

Deps = {};

// http://docs.meteor.com/#deps_active
Deps.active = false;

// http://docs.meteor.com/#deps_currentcomputation
Deps.currentComputation = null;

var setCurrentComputation = function (c) {
  Deps.currentComputation = c;
  Deps.active = !! c;
};

// _assign is like _.extend or the upcoming Object.assign.
// Copy src's own, enumerable properties onto tgt and return
// tgt.
var _hasOwnProperty = Object.prototype.hasOwnProperty;
var _assign = function (tgt, src) {
  for (var k in src) {
    if (_hasOwnProperty.call(src, k))
      tgt[k] = src[k];
  }
  return tgt;
};

var _debugFunc = function () {
  // lazy evaluation because `Meteor` does not exist right away
  return (typeof Meteor !== "undefined" ? Meteor._debug :
          ((typeof console !== "undefined") && console.log ?
           function () { console.log.apply(console, arguments); } :
           function () {}));
};

var _throwOrLog = function (from, e) {
  if (throwFirstError) {
    throw e;
  } else {
    _debugFunc()("Exception from Deps " + from + " function:",
                 e.stack || e.message);
  }
};

// Like `Meteor._noYieldsAllowed(function () { f(comp); })` but shorter,
// and doesn't clutter the stack with an extra frame on the client,
// where `_noYieldsAllowed` is a no-op.  `f` may be a computation
// function or an onInvalidate callback.
var callWithNoYieldsAllowed = function (f, comp) {
  if ((typeof Meteor === 'undefined') || Meteor.isClient) {
    f(comp);
  } else {
    Meteor._noYieldsAllowed(function () {
      f(comp);
    });
  }
};

var nextId = 1;
// computations whose callbacks we should call at flush time
var pendingComputations = [];
// `true` if a Deps.flush is scheduled, or if we are in Deps.flush now
var willFlush = false;
// `true` if we are in Deps.flush now
var inFlush = false;
// `true` if we are computing a computation now, either first time
// or recompute.  This matches Deps.active unless we are inside
// Deps.nonreactive, which nullfies currentComputation even though
// an enclosing computation may still be running.
var inCompute = false;
// `true` if the `_throwFirstError` option was passed in to the call
// to Deps.flush that we are in. When set, throw rather than log the
// first error encountered while flushing. Before throwing the error,
// finish flushing (from a finally block), logging any subsequent
// errors.
var throwFirstError = false;

var afterFlushCallbacks = [];

var requireFlush = function () {
  if (! willFlush) {
    setTimeout(Deps.flush, 0);
    willFlush = true;
  }
};

// Deps.Computation constructor is visible but private
// (throws an error if you try to call it)
var constructingComputation = false;

//
// http://docs.meteor.com/#deps_computation
//
Deps.Computation = function (f, parent) {
  if (! constructingComputation)
    throw new Error(
      "Deps.Computation constructor is private; use Deps.autorun");
  constructingComputation = false;

  var self = this;

  // http://docs.meteor.com/#computation_stopped
  self.stopped = false;

  // http://docs.meteor.com/#computation_invalidated
  self.invalidated = false;

  // http://docs.meteor.com/#computation_firstrun
  self.firstRun = true;

  self._id = nextId++;
  self._onInvalidateCallbacks = [];
  // the plan is at some point to use the parent relation
  // to constrain the order that computations are processed
  self._parent = parent;
  self._func = f;
  self._recomputing = false;

  var errored = true;
  try {
    self._compute();
    errored = false;
  } finally {
    self.firstRun = false;
    if (errored)
      self.stop();
  }
};

_assign(Deps.Computation.prototype, {

  // http://docs.meteor.com/#computation_oninvalidate
  onInvalidate: function (f) {
    var self = this;

    if (typeof f !== 'function')
      throw new Error("onInvalidate requires a function");

    if (self.invalidated) {
      Deps.nonreactive(function () {
        callWithNoYieldsAllowed(f, self);
      });
    } else {
      self._onInvalidateCallbacks.push(f);
    }
  },

  // http://docs.meteor.com/#computation_invalidate
  invalidate: function () {
    var self = this;
    if (! self.invalidated) {
      // if we're currently in _recompute(), don't enqueue
      // ourselves, since we'll rerun immediately anyway.
      if (! self._recomputing && ! self.stopped) {
        requireFlush();
        pendingComputations.push(this);
      }

      self.invalidated = true;

      // callbacks can't add callbacks, because
      // self.invalidated === true.
      for(var i = 0, f; f = self._onInvalidateCallbacks[i]; i++) {
        Deps.nonreactive(function () {
          callWithNoYieldsAllowed(f, self);
        });
      }
      self._onInvalidateCallbacks = [];
    }
  },

  // http://docs.meteor.com/#computation_stop
  stop: function () {
    if (! this.stopped) {
      this.stopped = true;
      this.invalidate();
    }
  },

  _compute: function () {
    var self = this;
    self.invalidated = false;

    var previous = Deps.currentComputation;
    setCurrentComputation(self);
    var previousInCompute = inCompute;
    inCompute = true;
    try {
      callWithNoYieldsAllowed(self._func, self);
    } finally {
      setCurrentComputation(previous);
      inCompute = false;
    }
  },

  _recompute: function () {
    var self = this;

    self._recomputing = true;
    try {
      while (self.invalidated && ! self.stopped) {
        try {
          self._compute();
        } catch (e) {
          _throwOrLog("recompute", e);
        }
        // If _compute() invalidated us, we run again immediately.
        // A computation that invalidates itself indefinitely is an
        // infinite loop, of course.
        //
        // We could put an iteration counter here and catch run-away
        // loops.
      }
    } finally {
      self._recomputing = false;
    }
  }
});

//
// http://docs.meteor.com/#deps_dependency
//
Deps.Dependency = function () {
  this._dependentsById = {};
};

_assign(Deps.Dependency.prototype, {
  // http://docs.meteor.com/#dependency_depend
  //
  // Adds `computation` to this set if it is not already
  // present.  Returns true if `computation` is a new member of the set.
  // If no argument, defaults to currentComputation, or does nothing
  // if there is no currentComputation.
  depend: function (computation) {
    if (! computation) {
      if (! Deps.active)
        return false;

      computation = Deps.currentComputation;
    }
    var self = this;
    var id = computation._id;
    if (! (id in self._dependentsById)) {
      self._dependentsById[id] = computation;
      computation.onInvalidate(function () {
        delete self._dependentsById[id];
      });
      return true;
    }
    return false;
  },

  // http://docs.meteor.com/#dependency_changed
  changed: function () {
    var self = this;
    for (var id in self._dependentsById)
      self._dependentsById[id].invalidate();
  },

  // http://docs.meteor.com/#dependency_hasdependents
  hasDependents: function () {
    var self = this;
    for(var id in self._dependentsById)
      return true;
    return false;
  }
});

_assign(Deps, {
  // http://docs.meteor.com/#deps_flush
  flush: function (_opts) {
    // XXX What part of the comment below is still true? (We no longer
    // have Spark)
    //
    // Nested flush could plausibly happen if, say, a flush causes
    // DOM mutation, which causes a "blur" event, which runs an
    // app event handler that calls Deps.flush.  At the moment
    // Spark blocks event handlers during DOM mutation anyway,
    // because the LiveRange tree isn't valid.  And we don't have
    // any useful notion of a nested flush.
    //
    // https://app.asana.com/0/159908330244/385138233856
    if (inFlush)
      throw new Error("Can't call Deps.flush while flushing");

    if (inCompute)
      throw new Error("Can't flush inside Deps.autorun");

    inFlush = true;
    willFlush = true;
    throwFirstError = !! (_opts && _opts._throwFirstError);

    var finishedTry = false;
    try {
      while (pendingComputations.length ||
             afterFlushCallbacks.length) {

        // recompute all pending computations
        while (pendingComputations.length) {
          var comp = pendingComputations.shift();
          comp._recompute();
        }

        if (afterFlushCallbacks.length) {
          // call one afterFlush callback, which may
          // invalidate more computations
          var func = afterFlushCallbacks.shift();
          try {
            func();
          } catch (e) {
            _throwOrLog("afterFlush function", e);
          }
        }
      }
      finishedTry = true;
    } finally {
      if (! finishedTry) {
        // we're erroring
        inFlush = false; // needed before calling `Deps.flush()` again
        Deps.flush({_throwFirstError: false}); // finish flushing
      }
      willFlush = false;
      inFlush = false;
    }
  },

  // http://docs.meteor.com/#deps_autorun
  //
  // Run f(). Record its dependencies. Rerun it whenever the
  // dependencies change.
  //
  // Returns a new Computation, which is also passed to f.
  //
  // Links the computation to the current computation
  // so that it is stopped if the current computation is invalidated.
  autorun: function (f) {
    if (typeof f !== 'function')
      throw new Error('Deps.autorun requires a function argument');

    constructingComputation = true;
    var c = new Deps.Computation(f, Deps.currentComputation);

    if (Deps.active)
      Deps.onInvalidate(function () {
        c.stop();
      });

    return c;
  },

  // http://docs.meteor.com/#deps_nonreactive
  //
  // Run `f` with no current computation, returning the return value
  // of `f`.  Used to turn off reactivity for the duration of `f`,
  // so that reactive data sources accessed by `f` will not result in any
  // computations being invalidated.
  nonreactive: function (f) {
    var previous = Deps.currentComputation;
    setCurrentComputation(null);
    try {
      return f();
    } finally {
      setCurrentComputation(previous);
    }
  },

  // http://docs.meteor.com/#deps_oninvalidate
  onInvalidate: function (f) {
    if (! Deps.active)
      throw new Error("Deps.onInvalidate requires a currentComputation");

    Deps.currentComputation.onInvalidate(f);
  },

  // http://docs.meteor.com/#deps_afterflush
  afterFlush: function (f) {
    afterFlushCallbacks.push(f);
    requireFlush();
  }
});
<|endoftext|>


<commit_before><commit_msg>list type set to accessions when accessions not found in the database during trial upload<commit_after><|endoftext|>


<commit_before>let ServletBase = function () {
    let _ = Object.create (null);

    // Helper functions for emitting HTML from Javascript
    let valid = function (value) {
        return (typeof (value) != "undefined") && (value !== null);
    };

    let block = function (block, attributes, content) {
        let result = "<" + block;
        if (valid (attributes)) {
            let attributeNames = Object.keys (attributes);
            for (let attributeName of attributeNames) {
                if (valid (attributes[attributeName])) {
                    result += " " + attributeName + "=\"" + attributes[attributeName] + "\"";
                }
            }
        }
        return result + (valid (content) ? (">" + content + "</" + block + ">") : ("/>"));
    };

    let div = function (cssClass, content) {
        return block ("div", { "class": cssClass }, content);
    };

    let a = function (cssClass, href, content) {
        return block ("a", { "class": cssClass, "href": href, "target": "_top" }, content);
    };

    // a little black raincloud, of course
    _.display = function (displayInDivId) {
        let request = new XMLHttpRequest ();
        request.open ("GET", "api?event=help", true);
        request.overrideMimeType ("application/json");
        request.onload = function () {
            // parse the data
            let db = JSON.parse (this.responseText).response;
            let innerHTML = "";

            if ("description" in db) {
                innerHTML += block ("h2", {}, "Description") + div ("description-div", db.description);
            }

            if ("events" in db) {
                innerHTML += block ("h2", {}, "Events");
                let events = db.events;
                let eventNames = Object.keys (events).sort ();
                let eventsHTML = "";
                for (let eventName of eventNames) {
                    let event = events[eventName];
                    let eventHTML = "";

                    // if there is an example
                    if ("example" in event) {
                        let url = "api?event=" + eventName;
                        let example = event.example;
                        let exampleKeys = Object.keys (example).sort ();
                        for (let exampleKey of exampleKeys) {
                            url += "&" + exampleKey + "=" + example[exampleKey];
                        }
                        //eventHTML = a ("try-it", url, " (" + url.replace (/&/g, "&") + ")");
                        eventHTML = a ("try-it", url, "[example]");
                    }
                    eventHTML = div ("event-name", eventName + eventHTML);

                    // if there is a description
                    if ("description" in event) {
                        eventHTML += div ("event-description", event.description);
                    }

                    let odd = true;
                    if ("parameters" in event) {
                        let parameterNames = Object.keys (event.parameters);
                        for (let parameterName of parameterNames) {
                            let parameter = event.parameters[parameterName];
                            let required = ("required" in parameter) ? parameter.required : false;
                            eventHTML += div ("parameter-div" + (odd ? " odd" : ""),
                                div ("parameter-name", parameterName) +
                                div ("parameter-required", required ? "REQUIRED" : "OPTIONAL") +
                                div ("parameter-description", parameter.description));
                            odd = !odd;
                        }
                    }

                    if (("strict" in event) && (event.strict == "false")) {
                        eventHTML += div ("parameter-div" + (odd ? " odd" : ""),
                            div ("parameter-name", "(any)") +
                            div ("parameter-required", "OPTIONAL") +
                            div ("parameter-description", "Event allows unspecified parameters."));
                    }

                    eventsHTML += div ("event-div", eventHTML);
                }
                innerHTML += div("events-div", eventsHTML);
            }

            if ("name" in db) {
                document.title = db.name;
                innerHTML = block ("h1", {}, db.name) + div("container-div", innerHTML);
            }
            innerHTML += div ("content-center footer", "Built with " + a ("footer-link", "https://github.com/brettonw/BagServiceBase", "brettonw/BagServiceBase"));

            document.getElementById(displayInDivId).innerHTML = innerHTML;
        };
        request.send ();
    };

    return _;
} ();
<commit_msg>point at the bagservicebase website instead of github<commit_after>let ServletBase = function () {
    let _ = Object.create (null);

    // Helper functions for emitting HTML from Javascript
    let valid = function (value) {
        return (typeof (value) != "undefined") && (value !== null);
    };

    let block = function (block, attributes, content) {
        let result = "<" + block;
        if (valid (attributes)) {
            let attributeNames = Object.keys (attributes);
            for (let attributeName of attributeNames) {
                if (valid (attributes[attributeName])) {
                    result += " " + attributeName + "=\"" + attributes[attributeName] + "\"";
                }
            }
        }
        return result + (valid (content) ? (">" + content + "</" + block + ">") : ("/>"));
    };

    let div = function (cssClass, content) {
        return block ("div", { "class": cssClass }, content);
    };

    let a = function (cssClass, href, content) {
        return block ("a", { "class": cssClass, "href": href, "target": "_top" }, content);
    };

    // a little black raincloud, of course
    _.display = function (displayInDivId) {
        let request = new XMLHttpRequest ();
        request.open ("GET", "api?event=help", true);
        request.overrideMimeType ("application/json");
        request.onload = function () {
            // parse the data
            let db = JSON.parse (this.responseText).response;
            let innerHTML = "";

            if ("description" in db) {
                innerHTML += block ("h2", {}, "Description") + div ("description-div", db.description);
            }

            if ("events" in db) {
                innerHTML += block ("h2", {}, "Events");
                let events = db.events;
                let eventNames = Object.keys (events).sort ();
                let eventsHTML = "";
                for (let eventName of eventNames) {
                    let event = events[eventName];
                    let eventHTML = "";

                    // if there is an example
                    if ("example" in event) {
                        let url = "api?event=" + eventName;
                        let example = event.example;
                        let exampleKeys = Object.keys (example).sort ();
                        for (let exampleKey of exampleKeys) {
                            url += "&" + exampleKey + "=" + example[exampleKey];
                        }
                        //eventHTML = a ("try-it", url, " (" + url.replace (/&/g, "&") + ")");
                        eventHTML = a ("try-it", url, "[example]");
                    }
                    eventHTML = div ("event-name", eventName + eventHTML);

                    // if there is a description
                    if ("description" in event) {
                        eventHTML += div ("event-description", event.description);
                    }

                    let odd = true;
                    if ("parameters" in event) {
                        let parameterNames = Object.keys (event.parameters);
                        for (let parameterName of parameterNames) {
                            let parameter = event.parameters[parameterName];
                            let required = ("required" in parameter) ? parameter.required : false;
                            eventHTML += div ("parameter-div" + (odd ? " odd" : ""),
                                div ("parameter-name", parameterName) +
                                div ("parameter-required", required ? "REQUIRED" : "OPTIONAL") +
                                div ("parameter-description", parameter.description));
                            odd = !odd;
                        }
                    }

                    if (("strict" in event) && (event.strict == "false")) {
                        eventHTML += div ("parameter-div" + (odd ? " odd" : ""),
                            div ("parameter-name", "(any)") +
                            div ("parameter-required", "OPTIONAL") +
                            div ("parameter-description", "Event allows unspecified parameters."));
                    }

                    eventsHTML += div ("event-div", eventHTML);
                }
                innerHTML += div("events-div", eventsHTML);
            }

            if ("name" in db) {
                document.title = db.name;
                innerHTML = block ("h1", {}, db.name) + div("container-div", innerHTML);
            }
            innerHTML += div ("content-center footer", "Built with " + a ("footer-link", "http://bag-service-base.brettonw.com", "brettonw/BagServiceBase"));

            document.getElementById(displayInDivId).innerHTML = innerHTML;
        };
        request.send ();
    };

    return _;
} ();
<|endoftext|>


<commit_before>var Vec2D = require('../src/Vec2D.js'),
  Suite = require('./Suite');

var VECTOR_COUNT = 100000,
  TEST_PASSES = 5;

console.log('Tests are averaged from %d passes/runs on a set of %d vectors. Please wait...', TEST_PASSES, VECTOR_COUNT);

var av = new Suite(Vec2D.ArrayVector, VECTOR_COUNT, TEST_PASSES).run();
var fv = new Suite(Vec2D.Float32Vector, VECTOR_COUNT, TEST_PASSES).run();
var ov = new Suite(Vec2D.ObjectVector, VECTOR_COUNT, TEST_PASSES).run();

function stats(item) {
  console.log('"%s", %dms', item.name, item.time);
}

console.log('\nFloat32Vector:');
fv.forEach(stats);
global.gc();

setTimeout(function () {
  console.log('\nArrayVector:');
  av.forEach(stats);

  global.gc();

  setTimeout(function () {
    console.log('\nObjectVector:');
    ov.forEach(stats);
  }, 4000);
}, 4000);
<commit_msg>Prettify performance/index.js output + add Float64Vector<commit_after>var Vec2D = require('../src/Vec2D.js'),
  Table = require('cli-table'),
  Suite = require('./Suite');

var VECTOR_COUNT = 100000,
  TEST_PASSES = 5;

console.log('Tests are averaged from %d passes/runs on a set of %d vectors. Please wait...', TEST_PASSES, VECTOR_COUNT);

function stats(item) {
  console.log('"%s", %dms', item.name, item.time);
}

function totalTime(items) {
  console.log('%dms', items.reduce(function(sum, item) { return sum + item.time; }, 0));
}

global.gc();
var av = new Suite(Vec2D.ArrayVector, VECTOR_COUNT, TEST_PASSES).run();
console.log('\nArrayVector');
totalTime(av);

global.gc();
var ov = new Suite(Vec2D.ObjectVector, VECTOR_COUNT, TEST_PASSES).run();
console.log('\nObjectVector');
totalTime(ov);

global.gc();
var fv = new Suite(Vec2D.Float32Vector, VECTOR_COUNT, TEST_PASSES).run();
console.log('\nFloat32Vector');
totalTime(fv);

global.gc();
var fv2 = new Suite(Vec2D.Float64Vector, VECTOR_COUNT, TEST_PASSES).run();
console.log('\nFloat64Vector');
totalTime(fv2);

var table = new Table({ head: ['time in ms', 'ArrayVector', 'ObjectVector', 'Float32Vector', 'Float64Vector'] });

for (var i = 0; i < av.length; i++) {
  var row = {};
  row[av[i].name] = [av[i].time, ov[i].time, fv[i].time, fv2[i].time];
  table.push(row);
}

console.log(table.toString());
<|endoftext|>


<commit_before>// Copyright 2021, University of Colorado Boulder

/**
 * Generic base class responsible for interfacing between a Node to alert description.
 * @author Michael Kauzmann (PhET Interactive Simulations)
 */

import merge from '../../../../phet-core/js/merge.js';
import voicingUtteranceQueue from '../../../../scenery/js/accessibility/voicing/voicingUtteranceQueue.js';
import sceneryPhet from '../../sceneryPhet.js';

class Alerter {

  /**
   * @param {Object} [options]
   */
  constructor( options ) {

    options = merge( {

      // When true, movement alerts will be sent to the voicingUtteranceQueue. This shutoff valve is similar to
      // descriptionAlertNode, but for voicing.
      alertToVoicing: true,

      // {Node|null} If provided, use this Node to send description alerts to one or more Display's UtteranceQueue. Unlike for
      // Voicing, description alerts must occur through a Node connected to a Display through the scene graph. If null,
      // do not alert for description (same as alertToVoicing:false). NOTE: No description will alert without this option!
      descriptionAlertNode: null

    }, options );

    // @public - only subtypes can mutate
    this.alertToVoicing = options.alertToVoicing;

    // @public (read-only)
    this.descriptionAlertNode = options.descriptionAlertNode;
  }

  /**
   * Alert to both description and voicing utteranceQueues, depending on if both are supported by this instance
   * @public
   * @param {AlertableDef} alertable
   */
  alert( alertable ) {
    this.alertToVoicing && voicingUtteranceQueue.addToBack( alertable );
    this.alertDescriptionUtterance( alertable );
  }

  /**
   * Forward to provided Node for UtteranceQueue alerting logic. See ParallelDOM.alertDescriptionUtterance() for details.
   * @param {AlertableDef} alertable
   * @public
   */
  alertDescriptionUtterance( alertable ) {
    this.descriptionAlertNode && this.descriptionAlertNode.alertDescriptionUtterance( alertable );
  }

  /**
   * Forward to provided Node for UtteranceQueue alerting logic. See ParallelDOM.forEachUtteranceQueue() for details.
   * @param {function(UtteranceQueue):} utteranceQueueCallback
   * @public
   */
  forEachUtteranceQueue( utteranceQueueCallback ) {
    this.descriptionAlertNode && this.descriptionAlertNode.forEachUtteranceQueue( utteranceQueueCallback );
  }
}

sceneryPhet.register( 'Alerter', Alerter );
export default Alerter;<commit_msg>remove movement specific documentation from Alerter, see https://github.com/phetsims/utterance-queue/issues/13<commit_after>// Copyright 2021, University of Colorado Boulder

/**
 * Generic base class responsible for interfacing between a Node to alert description.
 * @author Michael Kauzmann (PhET Interactive Simulations)
 */

import merge from '../../../../phet-core/js/merge.js';
import voicingUtteranceQueue from '../../../../scenery/js/accessibility/voicing/voicingUtteranceQueue.js';
import sceneryPhet from '../../sceneryPhet.js';

class Alerter {

  /**
   * @param {Object} [options]
   */
  constructor( options ) {

    options = merge( {

      // When true, alerts will be sent to the voicingUtteranceQueue. This shutoff valve is similar to
      // descriptionAlertNode, but for voicing.
      alertToVoicing: true,

      // {Node|null} If provided, use this Node to send description alerts to one or more Display's UtteranceQueue. Unlike for
      // Voicing, description alerts must occur through a Node connected to a Display through the scene graph. If null,
      // do not alert for description (same as alertToVoicing:false). NOTE: No description will alert without this option!
      descriptionAlertNode: null

    }, options );

    // @public - only subtypes can mutate
    this.alertToVoicing = options.alertToVoicing;

    // @public (read-only)
    this.descriptionAlertNode = options.descriptionAlertNode;
  }

  /**
   * Alert to both description and voicing utteranceQueues, depending on if both are supported by this instance
   * @public
   * @param {AlertableDef} alertable
   */
  alert( alertable ) {
    this.alertToVoicing && voicingUtteranceQueue.addToBack( alertable );
    this.alertDescriptionUtterance( alertable );
  }

  /**
   * Forward to provided Node for UtteranceQueue alerting logic. See ParallelDOM.alertDescriptionUtterance() for details.
   * @param {AlertableDef} alertable
   * @public
   */
  alertDescriptionUtterance( alertable ) {
    this.descriptionAlertNode && this.descriptionAlertNode.alertDescriptionUtterance( alertable );
  }

  /**
   * Forward to provided Node for UtteranceQueue alerting logic. See ParallelDOM.forEachUtteranceQueue() for details.
   * @param {function(UtteranceQueue):} utteranceQueueCallback
   * @public
   */
  forEachUtteranceQueue( utteranceQueueCallback ) {
    this.descriptionAlertNode && this.descriptionAlertNode.forEachUtteranceQueue( utteranceQueueCallback );
  }
}

sceneryPhet.register( 'Alerter', Alerter );
export default Alerter;<|endoftext|>