<commit_before>'use strict';

export function up(queryInterface, Sequelize) {
  return queryInterface.createTable('events', {
    id: {
      type: Sequelize.INTEGER,
      primaryKey: true,
      autoIncrement: true,
    },
    name: {
      type: Sequelize.INTEGER,
      allowNull: false,
    },
    startDate: {
      type: Sequelize.DATE,
      allowNull: false,
    },
    endDate: {
      type: Sequelize.DATE,
      allowNull: false,
    },
    description: Sequelize.TEXT,
    location: {
      type: Sequelize.STRING,
      allowNull: false,
    },
    image: Sequelize.STRING,
    committeeId: {
      type: Sequelize.INTEGER,
      allowNull: false,
      references: { model: 'committees', key: 'id' },
    },
    createdAt: Sequelize.DATE,
    updatedAt: Sequelize.DATE,
  });
}

export function down(queryInterface) {
  return queryInterface.dropTable('events');
}
<commit_msg>Wow. Thanks sqlite<commit_after>'use strict';

export function up(queryInterface, Sequelize) {
  return queryInterface.createTable('events', {
    id: {
      type: Sequelize.INTEGER,
      primaryKey: true,
      autoIncrement: true,
    },
    name: {
      type: Sequelize.STRING,
      allowNull: false,
    },
    startDate: {
      type: Sequelize.DATE,
      allowNull: false,
    },
    endDate: {
      type: Sequelize.DATE,
      allowNull: false,
    },
    description: Sequelize.TEXT,
    location: {
      type: Sequelize.STRING,
      allowNull: false,
    },
    image: Sequelize.STRING,
    committeeId: {
      type: Sequelize.INTEGER,
      allowNull: false,
      references: { model: 'committees', key: 'id' },
    },
    createdAt: Sequelize.DATE,
    updatedAt: Sequelize.DATE,
  });
}

export function down(queryInterface) {
  return queryInterface.dropTable('events');
}
<|endoftext|>


<commit_before>var assert      = require("assert"),
    melted      = require('../api/Melted'),
    helpers     = require('./media_helpers'),
    Mosto       = require('../models/Mosto'),
    _           = require('underscore'),
    moment      = require('moment'),
    heartbeats  = require('../heartbeats');

describe.only('Mosto Heartbeats Test', function(done) {
    before(function(done) {
        melted.take(function() {
            melted.stop(function(){
                melted.start(function(pid) {
                    melted.setup(undefined, undefined, function(has_err) {
                        done();
                    });
                });
            });
        });
    });

    describe('#Heartbeats: Init with custom config and without medias', function(done) {
        var self = this;
        self.hb = undefined;
        before(function(done) {
            var config = {
                gc_interval: 5000,
                sync_interval: 50,
                min_scheduled: 1000,
                mvcp_server: "melted"
            };
            self.hb = new heartbeats(config);
            done();
        });

        describe('- Suscribe and wait 1.1 second', function(done) {
            self.checkouts = 0;
            self.clipStatus = 0;
            self.frameStatus = 0;
            self.startPlaying = 0;
            self.outOfSync = 0;
            self.hbErrors = 0;
            self.noClips = 0;
            before(function(done) {
                self.hb.on('forceCheckout', function() {
                    self.ckeckouts++;
                });
                self.hb.on('clipStatus', function() {
                    self.clipStatus++;
                });
                self.hb.on('frameStatus', function() {
                    self.frameStatus++;
                });
                self.hb.on('startPlaying', function() {
                    self.startPlaying++;
                });
                self.hb.on('outOfSync', function() {
                    self.outOfSync++;
                });
                self.hb.on('hbErrors', function() {
                    self.hbErrors++;
                });
                self.hb.on('noClips', function() {
                    self.noClips++;
                });
                self.hb.init();
                setTimeout(function() {
                    done();
                }, 1100);
            });
            it('-- Should have received 0 forceCheckout events', function() {
                assert.equal(self.checkouts, 0);
            });
            it('-- Should have received 0 clipStatus events', function() {
                assert.equal(self.clipStatus, 0);
            });
            it('-- Should have received 0 frameStatus events', function() {
                assert.equal(self.frameStatus, 0);
            });
            it('-- Should have received 0 startPlaying events', function() {
                assert.equal(self.startPlaying, 0);
            });
            it('-- Should have received 0 outOfSync events', function() {
                assert.equal(self.outOfSync, 0);
            });
            it('-- Should have received 0 hbError events', function() {
                assert.equal(self.hbErrors, 0);
            });
            it('-- Should have received > 10 noClips events', function() {
                assert.ok(self.noClips > 10);
            });
        });

        after(function(done) {
            self.hb.stop();
            done();
        });
    });

    describe('#Heartbeats: Init with custom config and with medias', function(done) {
        var self = this;
        self.hb = undefined;

        var playlists = Mosto.Playlists;
        var medias = helpers.getMedia();

        createPlaylist = function(medias, start) {
            var duration = _.reduce(medias, function(acc, m) { return acc + m.get('length') * m.get('fps'); }, 0);
            start = start || moment();
            var pl = new Mosto.Playlist({
                id: start.valueOf(),
                name: 'test',
                start: moment(start),
                end: start.add(duration)
            });
            pl.get('medias').add(medias);
            return pl;
        };

        before(function(done) {
            var config = {
                gc_interval: 5000,
                sync_interval: 50,
                min_scheduled: 1000 * 60 * 60 * 4,
                checkout_interval: 1000,
                mvcp_server: "melted"
            };
            self.hb = new heartbeats(config);

            var mediamodels = _.map(medias, function(media, ix) { return new Mosto.Media(_.extend(media, { playlist_order: ix })); });

            var pl = createPlaylist(mediamodels);

            playlists().addPlaylist(pl);
            playlists().save();
            done();
        });

        describe('- Suscribe and wait 2 seconds', function(done) {
            self.checkouts = 0;
            self.clipStatus = 0;
            self.frameStatus = 0;
            self.startPlaying = 0;
            self.outOfSync = 0;
            self.hbErrors = 0;
            self.noClips = 0;
            before(function(done) {
                self.hb.on('forceCheckout', function() {
                    self.checkouts++;
                });
                self.hb.on('clipStatus', function() {
                    self.clipStatus++;
                });
                self.hb.on('frameStatus', function() {
                    self.frameStatus++;
                });
                self.hb.on('startPlaying', function() {
                    self.startPlaying++;
                });
                self.hb.on('outOfSync', function() {
                    self.outOfSync++;
                });
                self.hb.on('hbErrors', function() {
                    self.hbErrors++;
                });
                self.hb.on('noClips', function() {
                    self.noClips++;
                });
                self.hb.init();
                setTimeout(function() {
                    done();
                }, 2050);
            });
            it('-- Should have received 2 forceCheckout events', function() {
                assert.equal(self.checkouts, 2);
            });
            it('-- Should have received 1 clipStatus events', function() {
                assert.equal(self.clipStatus, 1);
            });
            it('-- Should have received > 10 frameStatus events', function() {
                assert.ok(self.frameStatus > 10);
            });
            it('-- Should have received 1 startPlaying events', function() {
                assert.equal(self.startPlaying, 1);
            });
            it('-- Should have received 1 outOfSync events', function() {
                assert.equal(self.outOfSync, 1);
            });
            it('-- Should have received 0 hbError events', function() {
                assert.equal(self.hbErrors, 0);
            });
            it('-- Should have received 0 noClips events', function() {
                assert.equal(self.noClips, 0);
            });
        });

        after(function(done) {
            self.hb.stop();
            melted.stop(function(){
                melted.start(function(pid) {
                    melted.setup(undefined, undefined, function(has_err) {
                        done();
                    });
                });
            });
        });
    });

    describe('#leave melted', function() {
        it('-- leave melted', function(done) {
            melted.stop(function(pid) {
                melted.leave();
                done();
            });
        });
    });

});<commit_msg>More tests added<commit_after>var assert      = require("assert"),
    melted      = require('../api/Melted'),
    helpers     = require('./media_helpers'),
    Mosto       = require('../models/Mosto'),
    _           = require('underscore'),
    moment      = require('moment'),
    exec        = require('child_process').exec,
    heartbeats  = require('../heartbeats');

describe.only('Mosto Heartbeats Test', function(done) {
    before(function(done) {
        melted.take(function() {
            melted.stop(function(){
                melted.start(function(pid) {
                    melted.setup(undefined, undefined, function(has_err) {
                        done();
                    });
                });
            });
        });
    });

    describe('#Heartbeats: Init with custom config and without medias', function() {
        var self = this;
        self.hb = undefined;
        before(function(done) {
            var config = {
                gc_interval: 5000,
                sync_interval: 50,
                min_scheduled: 1000,
                mvcp_server: "melted"
            };
            self.hb = new heartbeats(config);
            done();
        });

        describe('- Suscribe and wait 1.1 second', function() {
            self.checkouts = 0;
            self.clipStatus = 0;
            self.frameStatus = 0;
            self.startPlaying = 0;
            self.outOfSync = 0;
            self.hbErrors = 0;
            self.noClips = 0;
            before(function(done) {
                self.hb.on('forceCheckout', function() {
                    self.ckeckouts++;
                });
                self.hb.on('clipStatus', function() {
                    self.clipStatus++;
                });
                self.hb.on('frameStatus', function() {
                    self.frameStatus++;
                });
                self.hb.on('startPlaying', function() {
                    self.startPlaying++;
                });
                self.hb.on('outOfSync', function() {
                    self.outOfSync++;
                });
                self.hb.on('hbErrors', function() {
                    self.hbErrors++;
                });
                self.hb.on('noClips', function() {
                    self.noClips++;
                });
                self.hb.init();
                setTimeout(function() {
                    done();
                }, 1100);
            });
            it('-- Should have received 0 forceCheckout events', function() {
                assert.equal(self.checkouts, 0);
            });
            it('-- Should have received 0 clipStatus events', function() {
                assert.equal(self.clipStatus, 0);
            });
            it('-- Should have received 0 frameStatus events', function() {
                assert.equal(self.frameStatus, 0);
            });
            it('-- Should have received 0 startPlaying events', function() {
                assert.equal(self.startPlaying, 0);
            });
            it('-- Should have received 0 outOfSync events', function() {
                assert.equal(self.outOfSync, 0);
            });
            it('-- Should have received 0 hbError events', function() {
                assert.equal(self.hbErrors, 0);
            });
            it('-- Should have received > 10 noClips events', function() {
                assert.ok(self.noClips > 10);
            });
        });

        after(function(done) {
            self.hb.stop();
            done();
        });
    });

    describe('#Heartbeats: Init with custom config and with medias', function() {
        var self = this;
        self.hb = undefined;

        var playlists = Mosto.Playlists;
        var medias = helpers.getMedia();

        createPlaylist = function(medias, start) {
            var duration = _.reduce(medias, function(acc, m) { return acc + m.get('length') * m.get('fps'); }, 0);
            start = start || moment();
            var pl = new Mosto.Playlist({
                id: start.valueOf(),
                name: 'test',
                start: moment(start),
                end: start.add(duration)
            });
            pl.get('medias').add(medias);
            return pl;
        };

        self.checkouts = 0;
        self.clipStatus = 0;
        self.frameStatus = 0;
        self.startPlaying = 0;
        self.outOfSync = 0;
        self.hbErrors = 0;
        self.noClips = 0;

        before(function(done) {
            var config = {
                gc_interval: 5000,
                sync_interval: 50,
                min_scheduled: 1000 * 60 * 60 * 4,
                checkout_interval: 900,
                mvcp_server: "melted"
            };
            self.hb = new heartbeats(config);

            self.hb.on('forceCheckout', function() {
                self.checkouts++;
            });
            self.hb.on('clipStatus', function() {
                self.clipStatus++;
            });
            self.hb.on('frameStatus', function() {
                self.frameStatus++;
            });
            self.hb.on('startPlaying', function() {
                self.startPlaying++;
            });
            self.hb.on('outOfSync', function() {
                self.outOfSync++;
            });
            self.hb.on('hbErrors', function() {
                self.hbErrors++;
            });
            self.hb.on('noClips', function() {
                self.noClips++;
            });
            self.hb.init();

            var mediamodels = _.map(medias, function(media, ix) { return new Mosto.Media(_.extend(media, { playlist_order: ix })); });

            var pl = createPlaylist(mediamodels);

            playlists().addPlaylist(pl);
            playlists().save();

            done();
        });

        describe('-- Starting playback and wait 2 seconds', function() {
            before(function(done) {
                setTimeout(function() {
                    done();
                }, 2050);
            });
            it('--- Should have received 2 forceCheckout events', function() {
                assert.equal(self.checkouts, 2);
            });
            it('--- Should have received 1 clipStatus events', function() {
                assert.equal(self.clipStatus, 1);
            });
            it('--- Should have received > 10 frameStatus events', function() {
                assert.ok(self.frameStatus > 10);
            });
            it('--- Should have received 1 startPlaying events', function() {
                assert.equal(self.startPlaying, 1);
            });
            it('--- Should have received 1 outOfSync events', function() {
                assert.equal(self.outOfSync, 1);
            });
            it('--- Should have received 0 hbError events', function() {
                assert.equal(self.hbErrors, 0);
            });
            it('--- Should have received 0 noClips events', function(done) {
                assert.equal(self.noClips, 0);
                done();
            });
        });
        describe('-- Make a goto in melted and wait 1 second', function() {
            before(function(done) {
                self.checkouts = 0;
                self.clipStatus = 0;
                self.frameStatus = 0;
                self.startPlaying = 0;
                self.outOfSync = 0;
                self.hbErrors = 0;
                self.noClips = 0;
                exec("echo 'goto u0 500' | nc localhost 5250", function (error, stdout, stderr) {
                    setTimeout(function() {
                        done();
                    }, 1000);
                });
            });
            it('--- Should have received 1 forceCheckout events', function() {
                assert.equal(self.checkouts, 1);
            });
            it('--- Should have received 0 clipStatus events', function() {
                assert.equal(self.clipStatus, 0);
            });
            it('--- Should have received > 5 frameStatus events', function() {
                assert.ok(self.frameStatus > 5);
            });
            it('--- Should have received 0 startPlaying events', function() {
                assert.equal(self.startPlaying, 0);
            });
            it('--- Should have received 1 outOfSync events', function() {
                assert.equal(self.outOfSync, 1);
            });
            it('--- Should have received 0 hbError events', function() {
                assert.equal(self.hbErrors, 0);
            });
            it('--- Should have received 0 noClips events', function(done) {
                assert.equal(self.noClips, 0);
                done();
            });
        });
        describe('-- Pause in melted and wait 1.7 second', function() {
            before(function(done) {
                self.checkouts = 0;
                self.clipStatus = 0;
                self.frameStatus = 0;
                self.startPlaying = 0;
                self.outOfSync = 0;
                self.hbErrors = 0;
                self.noClips = 0;
                exec("echo 'pause u0' | nc localhost 5250", function (error, stdout, stderr) {
                    setTimeout(function() {
                        done();
                    }, 1700);
                });
            });
            it('--- Should have received 2 forceCheckout events', function() {
                assert.equal(self.checkouts, 2);
            });
            it('--- Should have received 0 clipStatus events', function() {
                assert.equal(self.clipStatus, 0);
            });
            it('--- Should have received > 5 frameStatus events', function() {
                assert.ok(self.frameStatus > 5);
            });
            it('--- Should have received 1 startPlaying events', function() {
                assert.equal(self.startPlaying, 1);
            });
            it('--- Should have received 1 outOfSync events', function() {
                assert.equal(self.outOfSync, 1);
            });
            it('--- Should have received 0 hbError events', function() {
                assert.equal(self.hbErrors, 0);
            });
            it('--- Should have received 0 noClips events', function(done) {
                assert.equal(self.noClips, 0);
                done();
            });
        });

        after(function(done) {
            self.hb.stop();
            melted.stop(function(){
                melted.start(function(pid) {
                    melted.setup(undefined, undefined, function(has_err) {
                        done();
                    });
                });
            });
        });
    });

    describe('#leave melted', function() {
        it('-- leave melted', function(done) {
            melted.stop(function(pid) {
                melted.leave();
                done();
            });
        });
    });

});<|endoftext|>


<commit_before>$(function() {
    var csrftoken = $.cookie('csrftoken');
    $('.js-upcoming-events').on('click', '.js-add-to-collection', function(ev) {
        var eventID = $(ev.target.parentNode).data('event');
        $.ajax({
            type: 'POST',
            url: document.collectionConfig.saveDefault,
            data: JSON.stringify({
                event: eventID,
            }),
            headers: {
                "X-CSRFToken": csrftoken,
            },
            contentType: "application/json; charset=utf-8",
            dataType: 'json',
            success: function(response) {
                // Hide the
                $(ev.target.parentNode).addClass('hidden');
                $('.js-your-events').append(
                    document.collectionConfig.yourTalkTemplate({event: response.item})
                );
            },
            error: function(err) {
                console.log(err);
            },
        });
    });
    $('.js-your-events').on('click', '.js-remove-from-collection', function(ev) {
        var eventID = $(ev.target.parentNode).data('event');
        $.ajax({
            type: 'POST',
            url: document.collectionConfig.removeDefault,
            data: JSON.stringify({
                event: eventID,
            }),
            headers: {
                "X-CSRFToken": csrftoken,
            },
            contentType: "application/json; charset=utf-8",
            dataType: 'json',
            success: function(response) {
                // Remove the

                $(ev.target.parentNode.parentNode).remove();
                if (response.happening_today) {
                    $('.js-upcoming-events [data-event="'+response.id+'"].hidden').removeClass('hidden');
                }
            },
            error: function(err) {
                console.log(err);
            },
        });
    });
});
<commit_msg>Updated JS to be generic on collection items<commit_after>$(function() {
    function dataFromEl(el) {
        var data = {};
        var eventID = $(el).data('event');
        var groupID = $(el).data('group');
        if (eventID) { data.event = eventID; }
        if (groupID) { data.group = groupID; }
        return data;
    }
    var csrftoken = $.cookie('csrftoken');
    $('.js-upcoming-events').on('click', '.js-add-to-collection', function(ev) {
        var data = dataFromEl(ev.target.parentNode);
        $.ajax({
            type: 'POST',
            url: document.collectionConfig.saveItemDefault,
            data: JSON.stringify(data),
            headers: {
                "X-CSRFToken": csrftoken,
            },
            contentType: "application/json; charset=utf-8",
            dataType: 'json',
            success: function(response) {
                // Hide the
                $(ev.target.parentNode).addClass('hidden');
                $('.js-your-events').append(
                    document.collectionConfig.yourTalkTemplate({event: response.item})
                );
            },
            error: function(err) {
                console.log(err);
            },
        });
    });
    $('.js-your-talks').on('click', '.js-remove-from-collection', function(ev) {
        var data = dataFromEl(ev.target.parentNode);
        $.ajax({
            type: 'POST',
            url: document.collectionConfig.removeItemDefault,
            data: JSON.stringify(data),
            headers: {
                "X-CSRFToken": csrftoken,
            },
            contentType: "application/json; charset=utf-8",
            dataType: 'json',
            success: function(response) {
                // Remove the

                $(ev.target.parentNode.parentNode).remove();
                if (response.id) {
                    $('.js-upcoming-events [data-event="'+response.id+'"].hidden').removeClass('hidden');
                    $('.js-upcoming-events [data-group="'+response.id+'"].hidden').removeClass('hidden');
                }
            },
            error: function(err) {
                console.log(err);
            },
        });
    });
});
<|endoftext|>


<commit_before>// Copyright IBM Corp. 2015,2016. All Rights Reserved.
// Node module: loopback-boot
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT

var vm = require('vm');

function createContext() {
  var context = {
    // required by browserify
    XMLHttpRequest: function() { throw new Error('not implemented'); },
    FormData: function() { throw new Error('not implemented'); },

    localStorage: {
      // used by `debug` module
      debug: process.env.DEBUG,
    },

    // used by DataSource.prototype.ready
    setTimeout: setTimeout,

    // used by `debug` module
    document: { documentElement: { style: {}}},

    // used by `debug` module
    navigator: { userAgent: 'sandbox' },

    // used by crypto-browserify & friends
    Int32Array: Int32Array,
    DataView: DataView,

    // allow the browserified code to log messages
    // call `printContextLogs(context)` to print the accumulated messages
    console: {
      log: function() {
        this._logs.log.push(Array.prototype.slice.call(arguments));
      },
      warn: function() {
        this._logs.warn.push(Array.prototype.slice.call(arguments));
      },
      error: function() {
        this._logs.error.push(Array.prototype.slice.call(arguments));
      },
      _logs: {
        log: [],
        warn: [],
        error: [],
      },
    },
  };

  // `window` is used by loopback to detect browser runtime
  context.window = context;

  return vm.createContext(context);
}
exports.createContext = createContext;

function printContextLogs(context) {
  var k, ix; // see https://github.com/eslint/eslint/issues/5744
  for (k in context.console._logs) {
    var items = context.console._logs[k];
    for (ix in items) {
      console[k].apply(console, items[ix]);
    }
  }
}
exports.printContextLogs = printContextLogs;
<commit_msg>test: fix security warning<commit_after>// Copyright IBM Corp. 2015,2016. All Rights Reserved.
// Node module: loopback-boot
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT

var vm = require('vm');

function createContext() {
  var context = {
    // required by browserify
    XMLHttpRequest: function() { throw new Error('not implemented'); },
    FormData: function() { throw new Error('not implemented'); },

    localStorage: {
      // used by `debug` module
      debug: process.env.DEBUG,
    },

    // used by DataSource.prototype.ready
    setTimeout: setTimeout,

    // used by `debug` module
    document: { documentElement: { style: {}}},

    // used by `debug` module
    navigator: { userAgent: 'sandbox' },

    // used by crypto-browserify & friends
    Int32Array: Int32Array,
    DataView: DataView,
    crypto: {
      getRandomValues: function(typedArray) {
        var randomBuffer = require('crypto').randomBytes(typedArray.length);
        // This implementation is not secure: we take random 8bit values
        // and assign them to 8/16/32bit values, leaving high-order bits
        // filled with zeroes.
        // Fortunately, the bootstrapping process does not rely on secure
        // random numbers, therefore we can afford such shortcut.
        typedArray.set(randomBuffer);
      },
    },

    // allow the browserified code to log messages
    // call `printContextLogs(context)` to print the accumulated messages
    console: {
      log: function() {
        this._logs.log.push(Array.prototype.slice.call(arguments));
      },
      warn: function() {
        this._logs.warn.push(Array.prototype.slice.call(arguments));
      },
      error: function() {
        this._logs.error.push(Array.prototype.slice.call(arguments));
      },
      _logs: {
        log: [],
        warn: [],
        error: [],
      },
    },
  };

  // `window` is used by loopback to detect browser runtime
  context.window = context;

  return vm.createContext(context);
}
exports.createContext = createContext;

function printContextLogs(context) {
  var k, ix; // see https://github.com/eslint/eslint/issues/5744
  for (k in context.console._logs) {
    var items = context.console._logs[k];
    for (ix in items) {
      console[k].apply(console, items[ix]);
    }
  }
}
exports.printContextLogs = printContextLogs;
<|endoftext|>


<commit_before><commit_msg>Updated videoconverter.js<commit_after><|endoftext|>


<commit_before>(function() {

var data = {
    "newgame": function() { newGame(true) },
    "loadgame": loadGame,
    "savegame": function() { saveGame(getRepresentedFilename()) },
    "saveas": saveGame,
    "score": function() { setScoringMode(true) },
    "gameinfo": showGameInfo,
    "preferences": showPreferences,
    "editmode": function() { setEditMode(!getEditMode()) },
    "clearalloverlays": clearAllOverlays,
    "stonetool": function() { setSelectedTool('stone') },
    "crosstool": function() { setSelectedTool('cross') },
    "triangletool": function() { setSelectedTool('triangle') },
    "squaretool": function() { setSelectedTool('square') },
    "circletool": function() { setSelectedTool('circle') },
    "labeltool": function() { setSelectedTool('label') },
    "numbertool": function() { setSelectedTool('number') },
    "removenode": function() { removeNode.apply(null, getCurrentTreePosition()) },
    "findmode": function() { setFindMode(!getFindMode()) },
    "findnext": function() { findMove(getIndicatorVertex(), getFindText(), 1) },
    "findprevious": function() { findMove(getIndicatorVertex(), getFindText(), -1) },
    "togglebookmark": function() { setBookmark(!getBookmark()) },
    "nextbookmark": function() { findBookmark(1) },
    "previousbookmark": function() { findBookmark(-1) },
    "goback": goBack,
    "goforward": goForward,
    "gotopreviousfork": goToPreviousFork,
    "gotonextfork": goToNextFork,
    "gotobeginning": goToBeginning,
    "gotoend": goToEnd,
    "gotonextvariation": goToNextVariation,
    "gotopreviousvariation": goToPreviousVariation,
    "manageengines": function() { showPreferences(); setPreferencesTab('engines') },
    "detachengine": detachEngine,
    "generatemove": generateMove,
    "gtpconsole": function() { setShowLeftSidebar(!getShowLeftSidebar()) },
    "clearconsole": clearConsole,
    "togglecoordinates": function() { setShowCoordinates(!getShowCoordinates()); resizeBoard() },
    "togglevariations": function() { setShowVariations(!getShowVariations()) },
    "togglegamegraph": function() { setSidebarArrangement(!getShowGraph(), getShowComment()) },
    "togglecomments": function() { setSidebarArrangement(getShowGraph(), !getShowComment()) },
    "togglefullscreen": function() {
        var win = remote.getCurrentWindow()
        win.setFullScreen(!win.isFullScreen())
        win.setMenuBarVisibility(!win.isFullScreen())
        win.setAutoHideMenuBar(win.isFullScreen())
    },
    "checkforupdates": function() {
        checkForUpdates(function(hasUpdates) {
            if (hasUpdates) return
            showMessageBox('There are no updates available.')
        })
    },
    "github": function() { shell.openExternal('https://github.com/yishn/' + app.getName()) },
    "reportissue": function() { shell.openExternal('https://github.com/yishn/' + app.getName() + '/issues') }
}

ipcRenderer.on('menu-click', function(e, action) { data[action]() })
ipcRenderer.on('load-game', function(e, path) { loadGame(path) })
ipcRenderer.on('attach-engine', function(e, path, args) { attachEngine(path, args) })

})()
<commit_msg>Refactor 2<commit_after>(function() {

var menudata = {
    "newgame": function() { newGame(true) },
    "loadgame": loadGame,
    "savegame": function() { saveGame(getRepresentedFilename()) },
    "saveas": saveGame,
    "score": function() { setScoringMode(true) },
    "gameinfo": showGameInfo,
    "preferences": showPreferences,
    "editmode": function() { setEditMode(!getEditMode()) },
    "clearalloverlays": clearAllOverlays,
    "stonetool": function() { setSelectedTool('stone') },
    "crosstool": function() { setSelectedTool('cross') },
    "triangletool": function() { setSelectedTool('triangle') },
    "squaretool": function() { setSelectedTool('square') },
    "circletool": function() { setSelectedTool('circle') },
    "labeltool": function() { setSelectedTool('label') },
    "numbertool": function() { setSelectedTool('number') },
    "removenode": function() { removeNode.apply(null, getCurrentTreePosition()) },
    "findmode": function() { setFindMode(!getFindMode()) },
    "findnext": function() { findMove(getIndicatorVertex(), getFindText(), 1) },
    "findprevious": function() { findMove(getIndicatorVertex(), getFindText(), -1) },
    "togglebookmark": function() { setBookmark(!getBookmark()) },
    "nextbookmark": function() { findBookmark(1) },
    "previousbookmark": function() { findBookmark(-1) },
    "goback": goBack,
    "goforward": goForward,
    "gotopreviousfork": goToPreviousFork,
    "gotonextfork": goToNextFork,
    "gotobeginning": goToBeginning,
    "gotoend": goToEnd,
    "gotonextvariation": goToNextVariation,
    "gotopreviousvariation": goToPreviousVariation,
    "manageengines": function() { showPreferences(); setPreferencesTab('engines') },
    "detachengine": detachEngine,
    "generatemove": generateMove,
    "gtpconsole": function() { setShowLeftSidebar(!getShowLeftSidebar()) },
    "clearconsole": clearConsole,
    "togglecoordinates": function() { setShowCoordinates(!getShowCoordinates()); resizeBoard() },
    "togglevariations": function() { setShowVariations(!getShowVariations()) },
    "togglegamegraph": function() { setSidebarArrangement(!getShowGraph(), getShowComment()) },
    "togglecomments": function() { setSidebarArrangement(getShowGraph(), !getShowComment()) },
    "togglefullscreen": function() {
        var win = remote.getCurrentWindow()
        win.setFullScreen(!win.isFullScreen())
        win.setMenuBarVisibility(!win.isFullScreen())
        win.setAutoHideMenuBar(win.isFullScreen())
    },
    "checkforupdates": function() {
        checkForUpdates(function(hasUpdates) {
            if (hasUpdates) return
            showMessageBox('There are no updates available.')
        })
    },
    "github": function() { shell.openExternal('https://github.com/yishn/' + app.getName()) },
    "reportissue": function() { shell.openExternal('https://github.com/yishn/' + app.getName() + '/issues') }
}

ipcRenderer.on('menu-click', function(e, action) { menudata[action]() })
ipcRenderer.on('load-game', function(e, path) { loadGame(path) })
ipcRenderer.on('attach-engine', function(e, path, args) { attachEngine(path, args) })

})()
<|endoftext|>


<commit_before>'use strict';

exports._parent = require('./base');

exports.menu = function () {
	li(
		a(
			{ href: '/profile/' },
			span({ class: 'fa fa-user' }, "Preferences")
		)
	);
	li(
		a(
			{ href: '/profile/' },
			span({ class: 'header-top-user-name' }, this.user.fullName)
		)
	);
	li(
		a(
			{ href: '/profile/' },
			span({ class: 'fa fa-cogs' }, "Preferences")
		)
	);
	li(
		a({ href: '/logout/', rel: 'server' },
			span({ class: 'fa fa-power-off' }, "Log out")
			)
	);
};

exports.main = function () {
	div({ class: 'submitted-menu' },
			div({ class: 'submitted-menu-bar content' },
				nav(ul({ class: 'submitted-menu-items', id: 'submitted-menu' },
					exports._submittedMenu(this)))));
	div({ class: 'user-forms', id: 'sub-main' });
};

exports._submittedMenu = Function.prototype;
<commit_msg>Reactiv userFulname display. #667<commit_after>'use strict';

exports._parent = require('./base');

exports.menu = function () {
	li(
		a(
			{ href: '/profile/' },
			span({ class: 'fa fa-user' }, "Preferences")
		)
	);
	li(
		a(
			{ href: '/profile/' },
			span({ class: 'header-top-user-name' }, this.user._fullName)
		)
	);
	li(
		a(
			{ href: '/profile/' },
			span({ class: 'fa fa-cogs' }, "Preferences")
		)
	);
	li(
		a({ href: '/logout/', rel: 'server' },
			span({ class: 'fa fa-power-off' }, "Log out")
			)
	);
};

exports.main = function () {
	div({ class: 'submitted-menu' },
			div({ class: 'submitted-menu-bar content' },
				nav(ul({ class: 'submitted-menu-items', id: 'submitted-menu' },
					exports._submittedMenu(this)))));
	div({ class: 'user-forms', id: 'sub-main' });
};

exports._submittedMenu = Function.prototype;
<|endoftext|>


<commit_before>/**
 * @module Arr
 * @private
 * @mixin
 * @description Exports Arr class.
 */

import Super from './Super';
import constructors from './constants/constructors';
import {
  isArrayLike, isNaN, isNumber, isString,
  toArray, validate, iterate, Symbol, defineProperties,
  inherits, checkClassInstance, possibleSuperClassReturn
} from './helpers';

/**
 * @typedef {Array|*} ArrayLike
 * @public
 * @description Array-like type.
 */

/**
 * @callback ArrayCallback
 * @public
 * @param {Number} i - Iteration index.
 */

/**
 * @callback CompareFunction
 * @public
 * @param {*} x - First value to be compared.
 * @param {*} y - Second value to be compared.
 */

/**
 * @class Arr
 * @extends Super
 * @public
 * @param {Array} [array = []] - An array to wrap.
 * @returns {Arr} Instance of Arr.
 * @description Wrap of an array.
 *
 * @example
 * new Arr([1, 2]);
 */
export function Arr(array = []) {
  checkClassInstance(this, Arr, 'Arr');

  const $this = possibleSuperClassReturn(this, Super, [toArray(array)]);

  Object.defineProperty($this, '$$', { value: array });

  return $this;

  /**
   * @member {Array} Arr#$
   * @public
   * @description Made array.
   */

  /**
   * @member {ArrayLike} Arr#$$
   * @public
   * @description Original array.
   */
}

inherits(Arr, Super);

defineProperties(Arr.prototype, {
  /**
   * @method Arr#concat
   * @public
   * @param {...(Array|*)} values - Arrays or any other values to concat the array with.
   * @returns {Arr} New instance of Arr.
   * @see https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/concat
   * @description Synonym for
   * [Array#concat]{@link https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/concat}.
   */
  concat() {
    const array = toArray(this.$, true);

    iterate(arguments, (value) => {
      value = new Super(value).$;

      if (isArrayLike(value) && !isString(value)) {
        iterate(value, (value) => {
          array.push(value);
        });

        return;
      }

      array.push(value);
    });

    return new this.constructor(array);
  },

  /**
   * @method Arr#indexOf
   * @public
   * @param {*} value - Value to search.
   * @returns {Number} Index of the argument.
   * @description Almost the same as {@link Super#keyOf}. The difference is that if the value is not found
   * -1 returned instead of null and if found Number(key) returned.
   *
   * @example
   * new Arr([1, 2, 3]).indexOf(1);       // 0
   * new Arr([1, 2, 3]).indexOf('1');     // 0
   * new Arr([1, 2, 3]).indexOf(3);       // -1
   * new Arr([1, 2, NaN]).indexOf(NaN);   // 2
   */
  indexOf(value) {
    const key = this.keyOf(value);

    return key === null ? -1 : Number(key);
  },

  /**
   * @method Arr#indexOfStrict
   * @public
   * @param {*} value - Value to search.
   * @returns {Number} Index of the argument.
   * @description Almost the same as {@link Super#keyOfStrict}. The difference is that if the value is not found
   * -1 returned instead of null and if found Number(key) returned.
   *
   * @example
   * new Arr([1, 2, 3]).indexOfStrict(1);       // 0
   * new Arr([1, 2, 3]).indexOfStrict('1');     // -1
   * new Arr([1, 2, 3]).indexOfStrict(3);       // -1
   * new Arr([1, 2, NaN]).indexOfStrict(NaN);   // 2
   */
  indexOfStrict(value) {
    const key = this.keyOfStrict(value);

    return key === null ? -1 : Number(key);
  },

  /**
   * @method Arr#join
   * @public
   * @param {String} [separator = ','] - See the link.
   * @returns {String} - String of joined array.
   * @see https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/join
   * @description Synonym for
   * [Array#join]{@link https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/join}.
   */
  join() {
    return this.$.join.apply(this.$, arguments);
  },

  /**
   * @member {*} Arr#last
   * @public
   * @readonly
   * @returns {*} Last array element.
   * @description The last element of the array.
   *
   * @example
   * new Arr([1, 2, 3]).last; // 3
   * new Arr([]).last;        // undefined
   */
  'get last'() {
    const array = this.$;

    return array[array.length - 1];
  },

  /**
   * @member {Number} Arr#length
   * @public
   * @readonly
   * @returns {Number} Array length.
   * @see https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/length
   * @description Synonym for
   * [Array#length]{@link https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/length}.
   */
  'get length'() {
    return this.$.length;
  },

  /**
   * @method Arr#pop
   * @public
   * @returns {*} Returns deleted element.
   * @see https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/pop
   * @description Synonym for
   * [Array#pop]{@link https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/pop}.
   */
  pop() {
    return this.$.pop();
  },

  /**
   * @method Arr#push
   * @public
   * @param {...*} [values] See the link.
   * @this {Arr}
   * @returns {Arr} Returns this.
   * @see https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/push
   * @description Synonym for
   * [Array#push]{@link https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/push}
   * besides returning this.
   */
  push() {
    this.$.push.apply(this.$, arguments);

    return this;
  },

  /**
   * @method Arr#reverse
   * @public
   * @returns {Arr} A wrap of the reversed array.
   * @see https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/reverse
   * @description Synonym for
   * [Array#reverse]{@link https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/reverse}.
   */
  reverse() {
    this.$.reverse();

    return this;
  },

  /**
   * @method Arr#shift
   * @public
   * @returns {*} Returns deleted element.
   * @see https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/shift
   * @description Synonym for
   * [Array#shift]{@link https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/shift}.
   */
  shift() {
    return this.$.shift();
  },

  /**
   * @method Arr#shuffle
   * @public
   * @returns {Arr} Returns this.
   * @description Method for shuffling.
   *
   * @example
   * new Arr([1, 2, 3, 4]).shuffle().$; // [4, 2, 3, 1]
   * new Arr([1, 2, 3, 4]).shuffle().$; // [1, 3, 4, 2]
   */
  shuffle() {
    const length = this.$.length;

    return this.forEach((value, index, array) => {
      const randomIndex = index + Math.floor((length - index) * Math.random());

      array[index] = array[randomIndex];
      array[randomIndex] = value;
    });
  },

  /**
   * @method Arr#slice
   * @public
   * @param {Number} [begin = 0] - See the link.
   * @param {Number} [end = array.length] - See the link.
   * @returns {Arr} A wrap of a sliced array.
   * @see https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/slice
   * @description Synonym for
   * [Array#slice]{@link https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/slice}.
   */
  slice() {
    return new this.constructor(this.$.slice.apply(this.$, arguments));
  },

  /**
   * @method Arr#sort
   * @public
   * @param {CompareFunction} [compareFunction] - See the link.
   * @returns {Arr} Returns this.
   * @see https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/sort
   * @description Synonym for
   * [Array#sort]{@link https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/sort}.
   */
  sort(compareFunction) {
    validate([compareFunction], ['function||!'], 'Arr#sort');

    this.$.sort(compareFunction);

    return this;
  },

  /**
   * @method Arr#sortAsc
   * @public
   * @returns {Arr} Returns this.
   * @description Method for ascending sorting. Puts non-numbers first, then NaNs, then sorted values.
   *
   * @example
   * new Arr([NaN, 1, -7, '100', 5]).sortAsc().$; // ['100', NaN, -7, 1, 5]
   */
  sortAsc() {
    return this.sort(asc);
  },

  /**
   * @method Arr#sortDesc
   * @public
   * @returns {Arr} Returns this.
   * @description Method for descending sorting. Puts sorted values first, then NaNs, then non-numbers.
   *
   * @example
   * new Arr([NaN, 1, -7, '100', 5]).sortDesc().$; // [5, 1, -7, NaN, '100']
   */
  sortDesc() {
    return this.sort((y, x) => asc(x, y));
  },

  /**
   * @method Arr#splice
   * @public
   * @param {Number} [start] - See the link.
   * @param {Number} [deleteCount] - See the link.
   * @param {...*} [items] - See the link.
   * @returns {Arr} A wrap of return value of #splice call.
   * @see https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/splice
   * @description Synonym for
   * [Array#splice]{@link https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/splice}.
   */
  splice() {
    return new Arr(this.$.splice.apply(this.$, arguments));
  },

  /**
   * @method Arr#string
   * @public
   * @returns {String} Concatenated array.
   * @description Synonym for array.join('').
   *
   * @example
   * new Arr([1, 2, 3]).string(); // '123'
   */
  string() {
    return this.join('');
  },

  /**
   * @method Arr#unshift
   * @public
   * @param {...*} [values] - See the link.
   * @returns {Arr} Returns this.
   * @see https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/unshift
   * @description Synonym for
   * [Array#unshift]{@link https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/unshift}
   * besides returning this.
   */
  unshift() {
    this.$.unshift.apply(this.$, arguments);

    return this;
  },

  [Symbol.toStringTag]: 'Arr'
});

/**
 * @function asc
 * @private
 * @param {*} x - First value to be compared.
 * @param {*} y - Second value to be compared.
 * @returns {Number} Where to put the first element: before or after.
 */
function asc(x, y) {
  if (!isNumber(x) && !isNumber(y)) {
    return 0;
  }

  if (!isNumber(x)) {
    return -1;
  }

  if (!isNumber(y)) {
    return 1;
  }

  if (isNaN(x) && isNaN(y)) {
    return 0;
  }

  if (isNaN(x)) {
    return -1;
  }

  if (isNaN(y)) {
    return 1;
  }

  return x - y;
}

constructors[1].push({
  check: isArrayLike,
  cls: Arr
});

/**
 * @function array
 * @public
 * @param {Number} number - Length of the array.
 * @param {ArrayCallback} [callback] - If it's present it has to a function
 * that returns the element that is pushed to the new array.
 * @returns {Arr} New instance of Arr.
 * @description Method for creating new array from the length using optional callback.
 *
 * @example
 * array(3).$;               // [0, 1, 2]
 * array(3, (i) => i * 2).$; // [0, 2, 4]
 */
export function array(number, callback) {
  validate([number, callback], [['intLike', '>=0'], 'function||!']);

  const array = [];

  for (let i = 0; i < number; i++) {
    array.push(callback ? callback(i) : i);
  }

  return new Arr(array);
}

export default Arr;
<commit_msg>Arr: fix jsdoc.<commit_after>/**
 * @module Arr
 * @private
 * @mixin
 * @description Exports Arr class.
 */

import Super from './Super';
import constructors from './constants/constructors';
import {
  isArrayLike, isNaN, isNumber, isString,
  toArray, validate, iterate, Symbol, defineProperties,
  inherits, checkClassInstance, possibleSuperClassReturn
} from './helpers';

/**
 * @typedef {Array|*} ArrayLike
 * @public
 * @description Array-like type.
 */

/**
 * @callback ArrayCallback
 * @public
 * @param {Number} i - Iteration index.
 */

/**
 * @callback CompareFunction
 * @public
 * @param {*} x - First value to be compared.
 * @param {*} y - Second value to be compared.
 */

/**
 * @class Arr
 * @extends Super
 * @public
 * @param {Array} [array = []] - An array to wrap.
 * @returns {Arr} Instance of Arr.
 * @description Wrap of an array.
 *
 * @example
 * new Arr([1, 2]);
 */
export function Arr(array = []) {
  checkClassInstance(this, Arr, 'Arr');

  const $this = possibleSuperClassReturn(this, Super, [toArray(array)]);

  Object.defineProperty($this, '$$', { value: array });

  return $this;

  /**
   * @member {Array} Arr#$
   * @public
   * @description Made array.
   */

  /**
   * @member {ArrayLike} Arr#$$
   * @public
   * @description Original array.
   */
}

inherits(Arr, Super);

defineProperties(Arr.prototype, {
  /**
   * @method Arr#concat
   * @public
   * @param {...(Array|*)} values - Arrays or any other values to concat the array with.
   * @returns {Arr} New instance of Arr.
   * @see https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/concat
   * @description Synonym for
   * [Array#concat]{@link https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/concat}.
   */
  concat() {
    const array = toArray(this.$, true);

    iterate(arguments, (value) => {
      value = new Super(value).$;

      if (isArrayLike(value) && !isString(value)) {
        iterate(value, (value) => {
          array.push(value);
        });

        return;
      }

      array.push(value);
    });

    return new this.constructor(array);
  },

  /**
   * @method Arr#indexOf
   * @public
   * @param {*} value - Value to search.
   * @returns {Number} Index of the argument.
   * @description Almost the same as {@link Super#keyOf}. The difference is that if the value is not found
   * -1 returned instead of null and if found Number(key) returned.
   *
   * @example
   * new Arr([1, 2, 3]).indexOf(1);       // 0
   * new Arr([1, 2, 3]).indexOf('1');     // 0
   * new Arr([1, 2, 3]).indexOf(3);       // -1
   * new Arr([1, 2, NaN]).indexOf(NaN);   // 2
   */
  indexOf(value) {
    const key = this.keyOf(value);

    return key === null ? -1 : Number(key);
  },

  /**
   * @method Arr#indexOfStrict
   * @public
   * @param {*} value - Value to search.
   * @returns {Number} Index of the argument.
   * @description Almost the same as {@link Super#keyOfStrict}. The difference is that if the value is not found
   * -1 returned instead of null and if found Number(key) returned.
   *
   * @example
   * new Arr([1, 2, 3]).indexOfStrict(1);       // 0
   * new Arr([1, 2, 3]).indexOfStrict('1');     // -1
   * new Arr([1, 2, 3]).indexOfStrict(3);       // -1
   * new Arr([1, 2, NaN]).indexOfStrict(NaN);   // 2
   */
  indexOfStrict(value) {
    const key = this.keyOfStrict(value);

    return key === null ? -1 : Number(key);
  },

  /**
   * @method Arr#join
   * @public
   * @param {String} [separator = ','] - See the link.
   * @returns {String} - String of joined array.
   * @see https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/join
   * @description Synonym for
   * [Array#join]{@link https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/join}.
   */
  join() {
    return this.$.join.apply(this.$, arguments);
  },

  /**
   * @member {*} Arr#last
   * @public
   * @readonly
   * @description The last element of the array.
   *
   * @example
   * new Arr([1, 2, 3]).last; // 3
   * new Arr([]).last;        // undefined
   */
  'get last'() {
    const array = this.$;

    return array[array.length - 1];
  },

  /**
   * @member {Number} Arr#length
   * @public
   * @readonly
   * @see https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/length
   * @description Synonym for
   * [Array#length]{@link https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/length}.
   */
  'get length'() {
    return this.$.length;
  },

  /**
   * @method Arr#pop
   * @public
   * @returns {*} Returns deleted element.
   * @see https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/pop
   * @description Synonym for
   * [Array#pop]{@link https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/pop}.
   */
  pop() {
    return this.$.pop();
  },

  /**
   * @method Arr#push
   * @public
   * @param {...*} [values] See the link.
   * @this {Arr}
   * @returns {Arr} Returns this.
   * @see https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/push
   * @description Synonym for
   * [Array#push]{@link https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/push}
   * besides returning this.
   */
  push() {
    this.$.push.apply(this.$, arguments);

    return this;
  },

  /**
   * @method Arr#reverse
   * @public
   * @returns {Arr} A wrap of the reversed array.
   * @see https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/reverse
   * @description Synonym for
   * [Array#reverse]{@link https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/reverse}.
   */
  reverse() {
    this.$.reverse();

    return this;
  },

  /**
   * @method Arr#shift
   * @public
   * @returns {*} Returns deleted element.
   * @see https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/shift
   * @description Synonym for
   * [Array#shift]{@link https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/shift}.
   */
  shift() {
    return this.$.shift();
  },

  /**
   * @method Arr#shuffle
   * @public
   * @returns {Arr} Returns this.
   * @description Method for shuffling.
   *
   * @example
   * new Arr([1, 2, 3, 4]).shuffle().$; // [4, 2, 3, 1]
   * new Arr([1, 2, 3, 4]).shuffle().$; // [1, 3, 4, 2]
   */
  shuffle() {
    const length = this.$.length;

    return this.forEach((value, index, array) => {
      const randomIndex = index + Math.floor((length - index) * Math.random());

      array[index] = array[randomIndex];
      array[randomIndex] = value;
    });
  },

  /**
   * @method Arr#slice
   * @public
   * @param {Number} [begin = 0] - See the link.
   * @param {Number} [end = array.length] - See the link.
   * @returns {Arr} A wrap of a sliced array.
   * @see https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/slice
   * @description Synonym for
   * [Array#slice]{@link https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/slice}.
   */
  slice() {
    return new this.constructor(this.$.slice.apply(this.$, arguments));
  },

  /**
   * @method Arr#sort
   * @public
   * @param {CompareFunction} [compareFunction] - See the link.
   * @returns {Arr} Returns this.
   * @see https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/sort
   * @description Synonym for
   * [Array#sort]{@link https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/sort}.
   */
  sort(compareFunction) {
    validate([compareFunction], ['function||!'], 'Arr#sort');

    this.$.sort(compareFunction);

    return this;
  },

  /**
   * @method Arr#sortAsc
   * @public
   * @returns {Arr} Returns this.
   * @description Method for ascending sorting. Puts non-numbers first, then NaNs, then sorted values.
   *
   * @example
   * new Arr([NaN, 1, -7, '100', 5]).sortAsc().$; // ['100', NaN, -7, 1, 5]
   */
  sortAsc() {
    return this.sort(asc);
  },

  /**
   * @method Arr#sortDesc
   * @public
   * @returns {Arr} Returns this.
   * @description Method for descending sorting. Puts sorted values first, then NaNs, then non-numbers.
   *
   * @example
   * new Arr([NaN, 1, -7, '100', 5]).sortDesc().$; // [5, 1, -7, NaN, '100']
   */
  sortDesc() {
    return this.sort((y, x) => asc(x, y));
  },

  /**
   * @method Arr#splice
   * @public
   * @param {Number} [start] - See the link.
   * @param {Number} [deleteCount] - See the link.
   * @param {...*} [items] - See the link.
   * @returns {Arr} A wrap of return value of #splice call.
   * @see https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/splice
   * @description Synonym for
   * [Array#splice]{@link https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/splice}.
   */
  splice() {
    return new Arr(this.$.splice.apply(this.$, arguments));
  },

  /**
   * @method Arr#string
   * @public
   * @returns {String} Concatenated array.
   * @description Synonym for array.join('').
   *
   * @example
   * new Arr([1, 2, 3]).string(); // '123'
   */
  string() {
    return this.join('');
  },

  /**
   * @method Arr#unshift
   * @public
   * @param {...*} [values] - See the link.
   * @returns {Arr} Returns this.
   * @see https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/unshift
   * @description Synonym for
   * [Array#unshift]{@link https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/unshift}
   * besides returning this.
   */
  unshift() {
    this.$.unshift.apply(this.$, arguments);

    return this;
  },

  [Symbol.toStringTag]: 'Arr'
});

/**
 * @function asc
 * @private
 * @param {*} x - First value to be compared.
 * @param {*} y - Second value to be compared.
 * @returns {Number} Where to put the first element: before or after.
 */
function asc(x, y) {
  if (!isNumber(x) && !isNumber(y)) {
    return 0;
  }

  if (!isNumber(x)) {
    return -1;
  }

  if (!isNumber(y)) {
    return 1;
  }

  if (isNaN(x) && isNaN(y)) {
    return 0;
  }

  if (isNaN(x)) {
    return -1;
  }

  if (isNaN(y)) {
    return 1;
  }

  return x - y;
}

constructors[1].push({
  check: isArrayLike,
  cls: Arr
});

/**
 * @function array
 * @public
 * @param {Number} number - Length of the array.
 * @param {ArrayCallback} [callback] - If it's present it has to a function
 * that returns the element that is pushed to the new array.
 * @returns {Arr} New instance of Arr.
 * @description Method for creating new array from the length using optional callback.
 *
 * @example
 * array(3).$;               // [0, 1, 2]
 * array(3, (i) => i * 2).$; // [0, 2, 4]
 */
export function array(number, callback) {
  validate([number, callback], [['intLike', '>=0'], 'function||!']);

  const array = [];

  for (let i = 0; i < number; i++) {
    array.push(callback ? callback(i) : i);
  }

  return new Arr(array);
}

export default Arr;
<|endoftext|>


<commit_before>import React from 'react';
import cx from 'classnames';
import 'stockflux-components';
import { WindowHooks, Constants } from 'openfin-react-hooks';
import {
  FaChevronUp,
  FaChevronLeft,
  FaChevronRight,
} from 'react-icons/fa';
import AppShortcuts from './app-shortcuts/AppShortcuts';
import FreeTextSearch from './free-text-search/FreeTextSearch';
import ToolBar from './toolbar/ToolBar';
import CloseButton from './toolbar/CloseButton';
import './App.css';

export default () => {
  const [windowState, windowActions] = WindowHooks.useCurrentWindowState();

  return (

      {(windowState.edge === Constants.ScreenEdge.LEFT ||
        windowState.edge === Constants.ScreenEdge.RIGHT) &&
        CloseButton}
      <AppShortcuts />
      <FreeTextSearch dockedTo={windowState.edge} />
      <ToolBar
        tools={[
          {
            label: <FaChevronUp />,
            onClick: () => {
              windowActions.lockTop();
            },
            disabled: windowState.edge === Constants.ScreenEdge.TOP
          },
          {
            label: <FaChevronLeft />,
            onClick: () => {
              windowActions.lockLeft();
            },
            disabled: windowState.edge === Constants.ScreenEdge.LEFT
          },
          {
            label: <FaChevronRight />,
            onClick: () => {
              windowActions.lockRight();
            },
            disabled: windowState.edge === Constants.ScreenEdge.RIGHT
          }
        ]}
      />
      {(windowState.edge === Constants.ScreenEdge.TOP ||
        windowState.edge === Constants.ScreenEdge.NONE) &&
        CloseButton}

  );
};
<commit_msg>Update App to useDocWindow hook<commit_after>import React from 'react';
import cx from 'classnames';
import 'stockflux-components';
import { WindowHooks, Constants } from 'openfin-react-hooks';
import {
  FaChevronUp,
  FaChevronLeft,
  FaChevronRight,
} from 'react-icons/fa';
import AppShortcuts from './app-shortcuts/AppShortcuts';
import FreeTextSearch from './free-text-search/FreeTextSearch';
import ToolBar from './toolbar/ToolBar';
import CloseButton from './toolbar/CloseButton';
import './App.css';

export default () => {
  const [edge, windowActions] = WindowHooks.useDockWindow(Constants.ScreenEdge.TOP, window.fin.Window.getCurrentSync(),
      true, { dockedWidth: 50, dockedHeight: 50 });

  return (

      {(edge === Constants.ScreenEdge.LEFT || edge === Constants.ScreenEdge.RIGHT) && CloseButton}
      <AppShortcuts />
      <FreeTextSearch dockedTo={edge} />
      <ToolBar
        tools={[
          {
            label: <FaChevronUp />,
            onClick: windowActions.dockTop,
            disabled: edge === Constants.ScreenEdge.TOP
          },
          {
            label: <FaChevronLeft />,
            onClick: windowActions.dockLeft,
            disabled: edge === Constants.ScreenEdge.LEFT
          },
          {
            label: <FaChevronRight />,
            onClick: windowActions.dockRight,
            disabled: edge === Constants.ScreenEdge.RIGHT
          }
        ]}
      />
      {(edge === Constants.ScreenEdge.TOP || edge === Constants.ScreenEdge.NONE) && CloseButton}

  );
};
<|endoftext|>


<commit_before>/**
 * AuO.js
 *
 * Main entry point for the AuO library. Create a new instance of AuO by calling new AuO(). Calling
 * launch() adds the instance to the DOM tree, and calling suspend() removes the instance from the
 * DOM tree.
 *
 * @constructor
 */
const AuO = function () {
    /**
     * Launches this instance of AuO. Application becomes visible to the user. Will automatically
     * set the z-index so that the launched instance has higher z-index than all other elements on
     * the page.
     */
    this.launch = function () {
        const allElements = document.getElementsByTagName("*");
        const allElementsZindex = Array.from(allElements).map(function (element) {
            return element.style.zIndex;
        });
        const maxZindex = Math.max.apply(null, allElementsZindex);
        container.style("z-index", maxZindex + 1);
        document.body.appendChild(container.element);
        initiate();
    };

    /**
     * Suspends using this instance of AuO. Removes the application from the DOM tree and sets
     * the z-index to -Infinity. The interface is only hidden from view, however. To stop all
     * services, the instance itself must be deleted.
     */
    this.suspend = function () {
        container.detach().style("z-index", -Infinity);
    };

    /**
     * Determines whether the value is a nil-value. A nil value is an undefined or a null.
     */
    const isNil = function (value) {
        return (undefined === value) || (null === value);
    };

    /**
     * A functional, stripped-down wrapper around HTML DOM elements.
     *
     * Functions:
     *     get(attribute) --
     *
     * @constructor
     */
    const FunctionalElement = function (tagname) {
        this.element = document.createElement(tagname);
        this.get = function (attribute) {
            this.element.getAttribute(attribute, val);
            return this;
        };
        this.set = function (attribute, value) {
            if ("innerHTML" === attribute) {
                this.element.innerHTML = isNil(value) ? "" : value;
            } else {
                if (isNil(value)) {
                    this.element.removeAttribute(attribute);
                } else {
                    this.element.setAttribute(attribute, value);
                }
            }
            return this;
        };
        this.style = function (property, value) {
            this.element.style.setProperty(property, value);
            return this;
        };
        this.append = function (child) {
            this.element.appendChild(child.element);
            return this;
        };
        this.remove = function (child) {
            this.element.removechild(child.element);
            return this;
        };
        this.attach = function (parent) {
            parent.element.appendChild(this.element);
            return this;
        };
        this.detach = function () {
            this.element.parentNode.removeChild(this.element);
            return this;
        };
        this.listen = function (event, callback) {
            this.element.addEventLister(event, callback);
            return this;
        };
    };

    var initiated = false;
    /**
     * Initiates runtime procedures for this instance of AuO. Will only run once throughout the
     * lifetime of an instance. Called by this.launch().
     */
    const initiate = function () {
        // Prevent multiple initiations.
        if (initiated) {
            return;
        }
        initiated = true;
    };

    ////////////////////////////////////////////////////////////////////////////////////////////////
    //
    // Create the DOM elements we want to work with.
    //
    ////////////////////////////////////////////////////////////////////////////////////////////////

    // Highest-level container for the interface, also responsible for the faded screen background.
    const container = new FunctionalElement("div");

    // Element to enable vertical centering of the interface.
    const verticalMiddleButtress = new FunctionalElement("div");

    // Element to enable horizontal centering of the interface.
    const horizontalCenterContainer = new FunctionalElement("div");

    // Main frame for UI.
    const frame = new FunctionalElement("div");

    // Title bar for the UI.
    const titleBar = new FunctionalElement("div");
    const title = new FunctionalElement("div");
    const titleClose = new FunctionalElement("div");

    // Container for the controls UI.
    const controlsUI = new FunctionalElement("div");

    // Buttons for controlling recording and playback.
    const buttonRecord = new FunctionalElement("button");
    const buttonPlay = new FunctionalElement("button");
    const buttonStop = new FunctionalElement("button");

    // Container for the zoom UI.
    const zoomUI = new FunctionalElement("div");

    // Buttons for zooming.
    const buttonZoomIn = new FunctionalElement("button");
    const buttonZoomOut = new FunctionalElement("button");

    // Display for the zoom value for the zoom UI.
    const zoomDisplay = new FunctionalElement("div");

    // Container for the audio UI.
    const audioUI = new FunctionalElement("div");

    // Display for the visualizer of the audio.
    const audioDiplay = new FunctionalElement("canvas");

    // Red bar for indicating the current time frame on the display.
    const audioCurrent = new FunctionalElement("div");

    ////////////////////////////////////////////////////////////////////////////////////////////////
    //
    // Set up the DOM tree.
    //
    ////////////////////////////////////////////////////////////////////////////////////////////////

    ////////////////////////////////////////////////////////////////////////////////////////////////
    //
    // Style the DOM elements.
    //
    ////////////////////////////////////////////////////////////////////////////////////////////////
    container
        .style("position", "fixed")
        .style("top", "0px")
        .style("left", "0px")
        .style("width", "100%")
        .style("height", "100vh")
        .style("text-align", "center")
        .style("vertical-align", "middle")
        .style("background-color", "rgba(0, 0, 0, 0.6)");
};
<commit_msg>Building the DOM tree.<commit_after>/**
 * AuO.js
 *
 * Main entry point for the AuO library. Create a new instance of AuO by calling new AuO(). Calling
 * launch() adds the instance to the DOM tree, and calling suspend() removes the instance from the
 * DOM tree.
 *
 * @constructor
 */
const AuO = function () {
    /**
     * Launches this instance of AuO. Application becomes visible to the user. Will automatically
     * set the z-index so that the launched instance has higher z-index than all other elements on
     * the page.
     */
    this.launch = function () {
        const allElements = document.getElementsByTagName("*");
        const allElementsZindex = Array.from(allElements).map(function (element) {
            return element.style.zIndex;
        });
        const maxZindex = Math.max.apply(null, allElementsZindex);
        container.style("z-index", maxZindex + 1);
        document.body.appendChild(container.element);
        initiate();
    };

    /**
     * Suspends using this instance of AuO. Removes the application from the DOM tree and sets
     * the z-index to -Infinity. The interface is only hidden from view, however. To stop all
     * services, the instance itself must be deleted.
     */
    this.suspend = function () {
        container.detach().style("z-index", -Infinity);
    };

    /**
     * Determines whether the value is a nil-value. A nil value is an undefined or a null.
     */
    const isNil = function (value) {
        return (undefined === value) || (null === value);
    };

    /**
     * A functional, stripped-down wrapper around HTML DOM elements.
     *
     * Functions:
     *     get(attribute) --
     *
     * @constructor
     */
    const FunctionalElement = function (tagname) {
        this.element = document.createElement(tagname);
        this.get = function (attribute) {
            this.element.getAttribute(attribute, val);
            return this;
        };
        this.set = function (attribute, value) {
            if ("innerHTML" === attribute) {
                this.element.innerHTML = isNil(value) ? "" : value;
            } else {
                if (isNil(value)) {
                    this.element.removeAttribute(attribute);
                } else {
                    this.element.setAttribute(attribute, value);
                }
            }
            return this;
        };
        this.style = function (property, value) {
            this.element.style.setProperty(property, value);
            return this;
        };
        this.append = function (child) {
            this.element.appendChild(child.element);
            return this;
        };
        this.remove = function (child) {
            this.element.removechild(child.element);
            return this;
        };
        this.attach = function (parent) {
            parent.element.appendChild(this.element);
            return this;
        };
        this.detach = function () {
            this.element.parentNode.removeChild(this.element);
            return this;
        };
        this.listen = function (event, callback) {
            this.element.addEventLister(event, callback);
            return this;
        };
    };

    var initiated = false;
    /**
     * Initiates runtime procedures for this instance of AuO. Will only run once throughout the
     * lifetime of an instance. Called by this.launch().
     */
    const initiate = function () {
        // Prevent multiple initiations.
        if (initiated) {
            return;
        }
        initiated = true;
    };

    ////////////////////////////////////////////////////////////////////////////////////////////////
    //
    // Create the DOM elements we want to work with.
    //
    ////////////////////////////////////////////////////////////////////////////////////////////////

    // Highest-level container for the interface, also responsible for the faded screen background.
    const container = new FunctionalElement("div");

    // Element to enable vertical centering of the interface.
    const verticalMiddleButtress = new FunctionalElement("div");

    // Element to enable horizontal centering of the interface.
    const horizontalCenterContainer = new FunctionalElement("div");

    // Main frame for UI.
    const frame = new FunctionalElement("div");

    // Title bar for the UI.
    const titleBar = new FunctionalElement("div");
    const title = new FunctionalElement("div");
    const titleClose = new FunctionalElement("div");

    // Container for the controls UI.
    const controlsUI = new FunctionalElement("div");

    // Buttons for controlling recording and playback.
    const buttonRecord = new FunctionalElement("button");
    const buttonPlay = new FunctionalElement("button");
    const buttonStop = new FunctionalElement("button");

    // Container for the zoom UI.
    const zoomUI = new FunctionalElement("div");

    // Buttons for zooming.
    const buttonZoomIn = new FunctionalElement("button");
    const buttonZoomOut = new FunctionalElement("button");

    // Display for the zoom value for the zoom UI.
    const zoomDisplay = new FunctionalElement("div");

    // Container for the audio UI.
    const audioUI = new FunctionalElement("div");

    // Display for the visualizer of the audio.
    const audioDiplay = new FunctionalElement("canvas");

    // Red bar for indicating the current time frame on the display.
    const audioCurrent = new FunctionalElement("div");

    ////////////////////////////////////////////////////////////////////////////////////////////////
    //
    // Build the DOM tree.
    //
    ////////////////////////////////////////////////////////////////////////////////////////////////

    container
        .append(verticalMiddleButtress)
        .append(horizontalCenterContainer
            .append(frame
                .append(titleBar
                    .append(title)
                    .append(titleClose)
                ).append(controlsUI
                    .append(buttonRecord)
                    .append(buttonPlay)
                    .append(buttonStop)
                ).append(audioUI
                    .append(audioDisplay)
                    .append(audioCurrent)
                ).append(zoomUI
                    .append(buttonZoomIn)
                    .append(zoomDisplay)
                    .append(buttonZoomOut)
                )
            )
        )
    ;

    ////////////////////////////////////////////////////////////////////////////////////////////////
    //
    // Style the DOM elements.
    //
    ////////////////////////////////////////////////////////////////////////////////////////////////
    container
        .style("position", "fixed")
        .style("top", "0px")
        .style("left", "0px")
        .style("width", "100%")
        .style("height", "100vh")
        .style("text-align", "center")
        .style("vertical-align", "middle")
        .style("background-color", "rgba(0, 0, 0, 0.6)");
};
<|endoftext|>