<commit_before>var should = require("should");
var util = require('util');

var talks = require("../index.js").talk;

var config = {
    dburl: process.env.DBURL
};

function isValidTalk(talk) {
    talk.should.have.properties([
        "id",
        "code",
        "title",
        "slug",
        "description",
        "author",
        "viewCount",
        "voteCount",
        "votes",
        "favoriteCount",
        "favorites",
        "tags",
        "created",
        "updated"
    ]);
};

describe('Talk', function() {

    before(function(done) {
        if (!config.dburl) {
            console.log("ERROR: DBURL environment variable doesn't exists!");
            process.exit();
        }
        done();
    });

    describe('get the latest talks', function() {

        var result;

        before(function(done) {
            this.timeout(0);
            talks.latest(config.dburl, 5, 1, function(err, docs) {
                if (err) {
                    throw new Error(err);
                }
                result = docs;
                done();
            });
        });

        it('returns not null', function(done) {
            should.notEqual(result, null);
            done();
        });

        it('returns an array', function(done) {
            should.equal(true, util.isArray(result));
            done();
        });

        it('is valid talk object', function(done) {
            result.forEach(function(el) {
                isValidTalk(el);
            });
            done();
        });

    });

    describe('get the most popular talks', function() {

        var result;

        before(function(done) {
            this.timeout(0);
            talks.popular(config.dburl, 5, 1, function(err, docs) {
                if (err) {
                    throw new Error(err);
                }
                result = docs;
                done();
            });
        });

        it('returns not null', function(done) {
            should.notEqual(result, null);
            done();
        });

        it('returns an array', function(done) {
            should.equal(true, util.isArray(result));
            done();
        });

        it('is valid talk object', function(done) {
            result.forEach(function(el) {
                isValidTalk(el);
            });
            done();
        });

    });

   describe('get the most popular talks without passing pageNumber', function() {

        var result;

        before(function(done) {
            this.timeout(0);
            talks.popular(config.dburl, 10, null, function(err, docs) {
                if (err) {
                    throw new Error(err);
                }
                result = docs;
                done();
            });
        });

        it('returns not null', function(done) {
            should.notEqual(result, null);
            done();
        });

        it('returns an array', function(done) {
            should.equal(true, util.isArray(result));
            done();
        });

        it('is valid talk object', function(done) {
            result.forEach(function(el) {
                isValidTalk(el);
            });
            done();
        });

    });

    describe('create a new talk', function() {

        var result;

        before(function(done) {
            this.timeout(0);
            var talk = {
                id: 'talk_id',
                code: 'talk_code',
                title: 'Talk title',
                slug: 'talk-title',
                description: 'Talk description',
                author: {
                    id: 'author_authorid',
                    username: 'author_username',
                    avatar: 'http://example.com/avatar.jpg'
                },
                viewCount: 0,
                voteCount: 0,
                votes: [],
                favoriteCount: 0,
                favorites: [],
                tags: [
                    'tag1',
                    'tag2',
                    'tag3'
                ],
                created: 1423881000025,
                updated: 1423881000025
            };
            talks.createTalk(config.dburl, talk, function(err, docs) {
                if (err) {
                    throw new Error(err);
                }
                result = docs;
                done();
            });
        });

        it('returns not null', function(done) {
            should.notEqual(result, null);
            done();
        });

        it('is valid talk object', function(done) {
            result.forEach(function(el) {
                isValidTalk(el);
            });
            done();
        });

    });

    describe('get a talk', function() {

        var result;

        before(function(done) {
            this.timeout(0);
            talks.get(config.dburl, 'talk_id', function(err, docs) {
                if (err) {
                    throw new Error(err);
                }
                result = docs;
                done();
            });
        });

        it('returns not null', function(done) {
            should.notEqual(result, null);
            done();
        });

        it('is valid talk object', function(done) {
            isValidTalk(result);
            done();
        });

    });

    describe('play a talk', function() {

        var result;

        before(function(done) {
            this.timeout(0);
            talks.play(config.dburl, 'talk-title', function(err, docs) {
                if (err) {
                    throw new Error(err);
                }
                result = docs;
                done();
            });
        });

        it('returns not null', function(done) {
            should.notEqual(result, null);
            done();
        });

        it('is valid talk object', function(done) {
            isValidTalk(result);
            done();
        });

    });

    describe('vote a talk', function() {

        var result;

        before(function(done) {
            this.timeout(0);
            talks.upvote(config.dburl, "talk_id", "userid", function(err, docs) {
                if (err) {
                    throw new Error(err);
                }
                result = docs;
                done();
            });
        });

        it('returns not null', function(done) {
            should.notEqual(result, null);
            done();
        });

        it('sucsessful vote is equal to 1', function(done) {
            should.equal(result, 1);
            done();
        });

    });

    describe('favorite a talk', function() {

        var result;

        before(function(done) {
            this.timeout(0);
            talks.favorite(config.dburl, "talk_id", "userid", function(err, docs) {
                if (err) {
                    throw new Error(err);
                }
                result = docs;
                done();
            });
        });

        it('returns not null', function(done) {
            should.notEqual(result, null);
            done();
        });

        it('successful favorite is equal to 1', function(done) {
            should.equal(result, 1);
            done();
        });

    });

    describe('unfavorite a talk', function() {

        var result;

        before(function(done) {
            this.timeout(0);
            talks.unfavorite(config.dburl, "talk_id", "userid", function(err, docs) {
                if (err) {
                    throw new Error(err);
                }
                result = docs;
                done();
            });
        });

        it('returns not null', function(done) {
            should.notEqual(result, null);
            done();
        });

        it('successful unfavorite is equal to 1', function(done) {
            should.equal(result, 1);
            done();
        });

    });

    describe('get a talk tagged as', function() {

        var result;

        before(function(done) {
            this.timeout(0);
            talks.getByTag(config.dburl, 'tag1', 1, function(err, docs) {
                if (err) {
                    throw new Error(err);
                }
                result = docs;
                done();
            });
        });

        it('returns not null', function(done) {
            should.notEqual(result, null);
            done();
        });

        it('is valid talk object', function(done) {
            result.forEach(function(el) {
                isValidTalk(el);
            });
            done();
        });

    });

    describe('get a talk by its slug field', function() {

        var result;

        before(function(done) {
            this.timeout(0);
            talks.getBySlug(config.dburl, 'talk-title', function(err, docs) {
                if (err) {
                    throw new Error(err);
                }
                result = docs;
                done();
            });
        });

        it('returns not null', function(done) {
            should.notEqual(result, null);
            done();
        });

        it('is valid talk object', function(done) {
            result.forEach(function(el) {
                isValidTalk(el);
            });
            done();
        });

    });

    describe('get related talks', function() {

        var result;

        before(function(done) {
            this.timeout(0);
            talks.get(config.dburl, 'talk_id', function(err, docs) {
                if (err) {
                    throw new Error(err);
                }
                talks.related(config.dburl, docs.id, docs.tags, 5, function(err, docs) {
                    if (err) {
                        throw new Error(err);
                    }
                    result = docs;
                    done();
                });
            });
        });

        it('returns not null', function(done) {
            should.notEqual(result, null);
            done();
        });

        it('is valid talk object', function(done) {
            result.forEach(function(el) {
                isValidTalk(el);
            });
            done();
        });

    });

    describe('get a talk by its author id', function() {

        var result;

        before(function(done) {
            this.timeout(0);
            talks.getByAuthorId(config.dburl, 'talk_id', function(err, docs) {
                if (err) {
                    throw new Error(err);
                }
                result = docs;
                done();
            });
        });

        it('returns not null', function(done) {
            should.notEqual(result, null);
            done();
        });

        it('is valid talk object', function(done) {
            result.forEach(function(el) {
                isValidTalk(el);
            });
            done();
        });

    });

    describe('get talks upvoted by an user', function() {

        var result;

        before(function(done) {
            this.timeout(0);
            talks.getUpvotedByAuthorId(config.dburl, 'author_authorid', function(err, docs) {
                if (err) {
                    throw new Error(err);
                }
                result = docs;
                done();
            });
        });

        it('returns not null', function(done) {
            should.notEqual(result, null);
            done();
        });

        it('is valid talk object', function(done) {
            result.forEach(function(el) {
                isValidTalk(el);
            });
            done();
        });

    });

    describe('get upvoted talks by an user', function() {

        var result;

        before(function(done) {
            this.timeout(0);
            talks.getFavoritedByAuthorId(config.dburl, 'author_authorid', function(err, docs) {
                if (err) {
                    throw new Error(err);
                }
                result = docs;
                done();
            });
        });

        it('returns not null', function(done) {
            should.notEqual(result, null);
            done();
        });

        it('is valid talk object', function(done) {
            result.forEach(function(el) {
                isValidTalk(el);
            });
            done();
        });

    });

    describe('delete a talk', function() {

        var result;

        before(function(done) {
            this.timeout(0);
            talks.deleteTalk(config.dburl, 'talk_id', function(err, docs) {
                if (err) {
                    throw new Error(err);
                }
                result = docs
                done();
            });
        });

        it('returns not null', function(done) {
            should.notEqual(result, null);
            done();
        });

        it('successful delete is equal to 1', function(done) {
            should.equal(1, result);
            done();
        });

    });

});
<commit_msg>Fixed tests for getByTag with pagination<commit_after>var should = require("should");
var util = require('util');

var talks = require("../index.js").talk;

var config = {
    dburl: process.env.DBURL
};

function isValidTalk(talk) {
    talk.should.have.properties([
        "id",
        "code",
        "title",
        "slug",
        "description",
        "author",
        "viewCount",
        "voteCount",
        "votes",
        "favoriteCount",
        "favorites",
        "tags",
        "created",
        "updated"
    ]);
};

describe('Talk', function() {

    before(function(done) {
        if (!config.dburl) {
            console.log("ERROR: DBURL environment variable doesn't exists!");
            process.exit();
        }
        done();
    });

    describe('get the latest talks', function() {

        var result;

        before(function(done) {
            this.timeout(0);
            talks.latest(config.dburl, 5, 1, function(err, docs) {
                if (err) {
                    throw new Error(err);
                }
                result = docs;
                done();
            });
        });

        it('returns not null', function(done) {
            should.notEqual(result, null);
            done();
        });

        it('returns an array', function(done) {
            should.equal(true, util.isArray(result));
            done();
        });

        it('is valid talk object', function(done) {
            result.forEach(function(el) {
                isValidTalk(el);
            });
            done();
        });

    });

    describe('get the most popular talks', function() {

        var result;

        before(function(done) {
            this.timeout(0);
            talks.popular(config.dburl, 5, 1, function(err, docs) {
                if (err) {
                    throw new Error(err);
                }
                result = docs;
                done();
            });
        });

        it('returns not null', function(done) {
            should.notEqual(result, null);
            done();
        });

        it('returns an array', function(done) {
            should.equal(true, util.isArray(result));
            done();
        });

        it('is valid talk object', function(done) {
            result.forEach(function(el) {
                isValidTalk(el);
            });
            done();
        });

    });

   describe('get the most popular talks without passing pageNumber', function() {

        var result;

        before(function(done) {
            this.timeout(0);
            talks.popular(config.dburl, 10, null, function(err, docs) {
                if (err) {
                    throw new Error(err);
                }
                result = docs;
                done();
            });
        });

        it('returns not null', function(done) {
            should.notEqual(result, null);
            done();
        });

        it('returns an array', function(done) {
            should.equal(true, util.isArray(result));
            done();
        });

        it('is valid talk object', function(done) {
            result.forEach(function(el) {
                isValidTalk(el);
            });
            done();
        });

    });

    describe('create a new talk', function() {

        var result;

        before(function(done) {
            this.timeout(0);
            var talk = {
                id: 'talk_id',
                code: 'talk_code',
                title: 'Talk title',
                slug: 'talk-title',
                description: 'Talk description',
                author: {
                    id: 'author_authorid',
                    username: 'author_username',
                    avatar: 'http://example.com/avatar.jpg'
                },
                viewCount: 0,
                voteCount: 0,
                votes: [],
                favoriteCount: 0,
                favorites: [],
                tags: [
                    'tag1',
                    'tag2',
                    'tag3'
                ],
                created: 1423881000025,
                updated: 1423881000025
            };
            talks.createTalk(config.dburl, talk, function(err, docs) {
                if (err) {
                    throw new Error(err);
                }
                result = docs;
                done();
            });
        });

        it('returns not null', function(done) {
            should.notEqual(result, null);
            done();
        });

        it('is valid talk object', function(done) {
            result.forEach(function(el) {
                isValidTalk(el);
            });
            done();
        });

    });

    describe('get a talk', function() {

        var result;

        before(function(done) {
            this.timeout(0);
            talks.get(config.dburl, 'talk_id', function(err, docs) {
                if (err) {
                    throw new Error(err);
                }
                result = docs;
                done();
            });
        });

        it('returns not null', function(done) {
            should.notEqual(result, null);
            done();
        });

        it('is valid talk object', function(done) {
            isValidTalk(result);
            done();
        });

    });

    describe('play a talk', function() {

        var result;

        before(function(done) {
            this.timeout(0);
            talks.play(config.dburl, 'talk-title', function(err, docs) {
                if (err) {
                    throw new Error(err);
                }
                result = docs;
                done();
            });
        });

        it('returns not null', function(done) {
            should.notEqual(result, null);
            done();
        });

        it('is valid talk object', function(done) {
            isValidTalk(result);
            done();
        });

    });

    describe('vote a talk', function() {

        var result;

        before(function(done) {
            this.timeout(0);
            talks.upvote(config.dburl, "talk_id", "userid", function(err, docs) {
                if (err) {
                    throw new Error(err);
                }
                result = docs;
                done();
            });
        });

        it('returns not null', function(done) {
            should.notEqual(result, null);
            done();
        });

        it('sucsessful vote is equal to 1', function(done) {
            should.equal(result, 1);
            done();
        });

    });

    describe('favorite a talk', function() {

        var result;

        before(function(done) {
            this.timeout(0);
            talks.favorite(config.dburl, "talk_id", "userid", function(err, docs) {
                if (err) {
                    throw new Error(err);
                }
                result = docs;
                done();
            });
        });

        it('returns not null', function(done) {
            should.notEqual(result, null);
            done();
        });

        it('successful favorite is equal to 1', function(done) {
            should.equal(result, 1);
            done();
        });

    });

    describe('unfavorite a talk', function() {

        var result;

        before(function(done) {
            this.timeout(0);
            talks.unfavorite(config.dburl, "talk_id", "userid", function(err, docs) {
                if (err) {
                    throw new Error(err);
                }
                result = docs;
                done();
            });
        });

        it('returns not null', function(done) {
            should.notEqual(result, null);
            done();
        });

        it('successful unfavorite is equal to 1', function(done) {
            should.equal(result, 1);
            done();
        });

    });

    describe('get a talk tagged as', function() {

        var result;

        before(function(done) {
            this.timeout(0);
            talks.getByTag(config.dburl, 'tag1', 25, 1, function(err, docs) {
                if (err) {
                    throw new Error(err);
                }
                result = docs;
                done();
            });
        });

        it('returns not null', function(done) {
            should.notEqual(result, null);
            done();
        });

        it('is valid talk object', function(done) {
            result.forEach(function(el) {
                isValidTalk(el);
            });
            done();
        });

    });

    describe('get a talk by its slug field', function() {

        var result;

        before(function(done) {
            this.timeout(0);
            talks.getBySlug(config.dburl, 'talk-title', function(err, docs) {
                if (err) {
                    throw new Error(err);
                }
                result = docs;
                done();
            });
        });

        it('returns not null', function(done) {
            should.notEqual(result, null);
            done();
        });

        it('is valid talk object', function(done) {
            result.forEach(function(el) {
                isValidTalk(el);
            });
            done();
        });

    });

    describe('get related talks', function() {

        var result;

        before(function(done) {
            this.timeout(0);
            talks.get(config.dburl, 'talk_id', function(err, docs) {
                if (err) {
                    throw new Error(err);
                }
                talks.related(config.dburl, docs.id, docs.tags, 5, function(err, docs) {
                    if (err) {
                        throw new Error(err);
                    }
                    result = docs;
                    done();
                });
            });
        });

        it('returns not null', function(done) {
            should.notEqual(result, null);
            done();
        });

        it('is valid talk object', function(done) {
            result.forEach(function(el) {
                isValidTalk(el);
            });
            done();
        });

    });

    describe('get a talk by its author id', function() {

        var result;

        before(function(done) {
            this.timeout(0);
            talks.getByAuthorId(config.dburl, 'talk_id', function(err, docs) {
                if (err) {
                    throw new Error(err);
                }
                result = docs;
                done();
            });
        });

        it('returns not null', function(done) {
            should.notEqual(result, null);
            done();
        });

        it('is valid talk object', function(done) {
            result.forEach(function(el) {
                isValidTalk(el);
            });
            done();
        });

    });

    describe('get talks upvoted by an user', function() {

        var result;

        before(function(done) {
            this.timeout(0);
            talks.getUpvotedByAuthorId(config.dburl, 'author_authorid', function(err, docs) {
                if (err) {
                    throw new Error(err);
                }
                result = docs;
                done();
            });
        });

        it('returns not null', function(done) {
            should.notEqual(result, null);
            done();
        });

        it('is valid talk object', function(done) {
            result.forEach(function(el) {
                isValidTalk(el);
            });
            done();
        });

    });

    describe('get upvoted talks by an user', function() {

        var result;

        before(function(done) {
            this.timeout(0);
            talks.getFavoritedByAuthorId(config.dburl, 'author_authorid', function(err, docs) {
                if (err) {
                    throw new Error(err);
                }
                result = docs;
                done();
            });
        });

        it('returns not null', function(done) {
            should.notEqual(result, null);
            done();
        });

        it('is valid talk object', function(done) {
            result.forEach(function(el) {
                isValidTalk(el);
            });
            done();
        });

    });

    describe('delete a talk', function() {

        var result;

        before(function(done) {
            this.timeout(0);
            talks.deleteTalk(config.dburl, 'talk_id', function(err, docs) {
                if (err) {
                    throw new Error(err);
                }
                result = docs
                done();
            });
        });

        it('returns not null', function(done) {
            should.notEqual(result, null);
            done();
        });

        it('successful delete is equal to 1', function(done) {
            should.equal(1, result);
            done();
        });

    });

});
<|endoftext|>


<commit_before>var socket = io();

socket.emit('join_lobby', {name: 'My Name', room:'TXZY'});

var context = document.getElementById('sheet').getContext("2d");
var canvas = document.getElementById('sheet');
context = canvas.getContext("2d");
context.strokeStyle = "#ff0000";
context.lineJoin = "round";
context.lineWidth = 5;

var clickX = [];
var clickY = [];
var clickDrag = [];
var paint;

/**
 * Add information where the user clicked at.
 * @param {number} x
 * @param {number} y
 * @return {boolean} dragging
 */
function addClick(x, y, dragging) {
    clickX.push(x);
    clickY.push(y);
    clickDrag.push(dragging);

    if(clickX.length % 10 == 0 || !paint)
      socket.emit('draw_pic', {clickX: clickX, clickY: clickY, clickDrag: clickDrag});
}

/**
 * Redraw the complete canvas.
 */
function redraw() {
    // Clears the canvas
    context.clearRect(0, 0, context.canvas.width, context.canvas.height);

    for (var i = 0; i < clickX.length; i += 1) {
        if (!clickDrag[i] && i == 0) {
            context.beginPath();
            context.moveTo(clickX[i], clickY[i]);
            context.stroke();
        } else if (!clickDrag[i] && i > 0) {
            context.closePath();

            context.beginPath();
            context.moveTo(clickX[i], clickY[i]);
            context.stroke();
        } else {
            context.lineTo(clickX[i], clickY[i]);
            context.stroke();
        }
    }
}

/**
 * Draw the newly added point.
 * @return {void}
 */
function drawNew() {
    var i = clickX.length - 1
    if (!clickDrag[i]) {
        if (clickX.length == 0) {
            context.beginPath();
            context.moveTo(clickX[i], clickY[i]);
            context.stroke();
        } else {
            context.closePath();

            context.beginPath();
            context.moveTo(clickX[i], clickY[i]);
            context.stroke();
        }
    } else {
        context.lineTo(clickX[i], clickY[i]);
        context.stroke();
    }
}

function mouseDownEventHandler(e) {
    paint = true;
    var x = e.pageX - canvas.offsetLeft;
    var y = e.pageY - canvas.offsetTop;
    if (paint) {
        addClick(x, y, false);
        drawNew();
    }
}

function touchstartEventHandler(e) {
    paint = true;
    if (paint) {
        addClick(e.touches[0].pageX - canvas.offsetLeft, e.touches[0].pageY - canvas.offsetTop, false);
        drawNew();
    }
}

function mouseUpEventHandler(e) {
    context.closePath();
    paint = false;
}

function mouseMoveEventHandler(e) {
    var x = e.pageX - canvas.offsetLeft;
    var y = e.pageY - canvas.offsetTop;
    if (paint) {
        addClick(x, y, true);
        drawNew();
    }
}

function touchMoveEventHandler(e) {
    if (paint) {
        addClick(e.touches[0].pageX - canvas.offsetLeft, e.touches[0].pageY - canvas.offsetTop, true);
        drawNew();
    }
}

function setUpHandler(isMouseandNotTouch, detectEvent) {
    removeRaceHandlers();
    if (isMouseandNotTouch) {
        canvas.addEventListener('mouseup', mouseUpEventHandler);
        canvas.addEventListener('mousemove', mouseMoveEventHandler);
        canvas.addEventListener('mousedown', mouseDownEventHandler);
        mouseDownEventHandler(detectEvent);
    } else {
        canvas.addEventListener('touchstart', touchstartEventHandler);
        canvas.addEventListener('touchmove', touchMoveEventHandler);
        canvas.addEventListener('touchend', mouseUpEventHandler);
        touchstartEventHandler(detectEvent);
    }
}

function mouseWins(e) {
    setUpHandler(true, e);
}

function touchWins(e) {
    setUpHandler(false, e);
}

function removeRaceHandlers() {
    canvas.removeEventListener('mousedown', mouseWins);
    canvas.removeEventListener('touchstart', touchWins);
}

canvas.addEventListener('mousedown', mouseWins);
canvas.addEventListener('touchstart', touchWins);
<commit_msg>revert draw emit rate<commit_after>var socket = io();

socket.emit('join_lobby', {name: 'My Name', room:'TXZY'});

var context = document.getElementById('sheet').getContext("2d");
var canvas = document.getElementById('sheet');
context = canvas.getContext("2d");
context.strokeStyle = "#ff0000";
context.lineJoin = "round";
context.lineWidth = 5;

var clickX = [];
var clickY = [];
var clickDrag = [];
var paint;

/**
 * Add information where the user clicked at.
 * @param {number} x
 * @param {number} y
 * @return {boolean} dragging
 */
function addClick(x, y, dragging) {
    clickX.push(x);
    clickY.push(y);
    clickDrag.push(dragging);

    //if(clickX.length % 10 == 0 || !paint)
      socket.emit('draw_pic', {clickX: clickX, clickY: clickY, clickDrag: clickDrag});
}

/**
 * Redraw the complete canvas.
 */
function redraw() {
    // Clears the canvas
    context.clearRect(0, 0, context.canvas.width, context.canvas.height);

    for (var i = 0; i < clickX.length; i += 1) {
        if (!clickDrag[i] && i == 0) {
            context.beginPath();
            context.moveTo(clickX[i], clickY[i]);
            context.stroke();
        } else if (!clickDrag[i] && i > 0) {
            context.closePath();

            context.beginPath();
            context.moveTo(clickX[i], clickY[i]);
            context.stroke();
        } else {
            context.lineTo(clickX[i], clickY[i]);
            context.stroke();
        }
    }
}

/**
 * Draw the newly added point.
 * @return {void}
 */
function drawNew() {
    var i = clickX.length - 1
    if (!clickDrag[i]) {
        if (clickX.length == 0) {
            context.beginPath();
            context.moveTo(clickX[i], clickY[i]);
            context.stroke();
        } else {
            context.closePath();

            context.beginPath();
            context.moveTo(clickX[i], clickY[i]);
            context.stroke();
        }
    } else {
        context.lineTo(clickX[i], clickY[i]);
        context.stroke();
    }
}

function mouseDownEventHandler(e) {
    paint = true;
    var x = e.pageX - canvas.offsetLeft;
    var y = e.pageY - canvas.offsetTop;
    if (paint) {
        addClick(x, y, false);
        drawNew();
    }
}

function touchstartEventHandler(e) {
    paint = true;
    if (paint) {
        addClick(e.touches[0].pageX - canvas.offsetLeft, e.touches[0].pageY - canvas.offsetTop, false);
        drawNew();
    }
}

function mouseUpEventHandler(e) {
    context.closePath();
    paint = false;
}

function mouseMoveEventHandler(e) {
    var x = e.pageX - canvas.offsetLeft;
    var y = e.pageY - canvas.offsetTop;
    if (paint) {
        addClick(x, y, true);
        drawNew();
    }
}

function touchMoveEventHandler(e) {
    if (paint) {
        addClick(e.touches[0].pageX - canvas.offsetLeft, e.touches[0].pageY - canvas.offsetTop, true);
        drawNew();
    }
}

function setUpHandler(isMouseandNotTouch, detectEvent) {
    removeRaceHandlers();
    if (isMouseandNotTouch) {
        canvas.addEventListener('mouseup', mouseUpEventHandler);
        canvas.addEventListener('mousemove', mouseMoveEventHandler);
        canvas.addEventListener('mousedown', mouseDownEventHandler);
        mouseDownEventHandler(detectEvent);
    } else {
        canvas.addEventListener('touchstart', touchstartEventHandler);
        canvas.addEventListener('touchmove', touchMoveEventHandler);
        canvas.addEventListener('touchend', mouseUpEventHandler);
        touchstartEventHandler(detectEvent);
    }
}

function mouseWins(e) {
    setUpHandler(true, e);
}

function touchWins(e) {
    setUpHandler(false, e);
}

function removeRaceHandlers() {
    canvas.removeEventListener('mousedown', mouseWins);
    canvas.removeEventListener('touchstart', touchWins);
}

canvas.addEventListener('mousedown', mouseWins);
canvas.addEventListener('touchstart', touchWins);
<|endoftext|>


<commit_before>var Sequelize = require('sequelize');
var db = require('../../config/initializers/sequelize');

module.exports = sequelize.define('ripple_transaction', {

  id:               { type: Sequelize.INTEGER, primaryKey: true, autoIncrement: true },
  ripple_address_id:{ type: Sequelize.INTEGER, notNull: true },
  transaction_hash: { type: Sequelize.STRING },
  transaction_state:{ type: Sequelize.STRING },
  issuance:         { type: Sequelize.BOOLEAN, notNull: true},

  to_address:       { type: Sequelize.STRING, notNull: true },
  to_amount:        { type: Sequelize.DECIMAL, notNull: true },
  to_currency:      { type: Sequelize.STRING, notNull: true },
  to_issuer:        { type: Sequelize.STRING, notNull: true },

  from_address:     { type: Sequelize.STRING, notNull: true },
  from_amount:      { type: Sequelize.DECIMAL, notNull: true },
  from_currency:    { type: Sequelize.STRING, notNull: true },
  from_issuer:      { type: Sequelize.STRING, notNull: true },

  destination_tag:  { type: Sequelize.STRING },
  source_tag:       { type: Sequelize.INTEGER }

})

<commit_msg>[FEATURE] Default new ripple transactions to have "new" transaction state.<commit_after>var Sequelize = require('sequelize');
var db = require('../../config/initializers/sequelize');

module.exports = sequelize.define('ripple_transaction', {

  id:               { type: Sequelize.INTEGER, primaryKey: true, autoIncrement: true },
  ripple_address_id:{ type: Sequelize.INTEGER, notNull: true },
  transaction_hash: { type: Sequelize.STRING, default: 'new' },
  transaction_state:{ type: Sequelize.STRING },
  issuance:         { type: Sequelize.BOOLEAN, notNull: true},

  to_address:       { type: Sequelize.STRING, notNull: true },
  to_amount:        { type: Sequelize.DECIMAL, notNull: true },
  to_currency:      { type: Sequelize.STRING, notNull: true },
  to_issuer:        { type: Sequelize.STRING, notNull: true },

  from_address:     { type: Sequelize.STRING, notNull: true },
  from_amount:      { type: Sequelize.DECIMAL, notNull: true },
  from_currency:    { type: Sequelize.STRING, notNull: true },
  from_issuer:      { type: Sequelize.STRING, notNull: true },

  destination_tag:  { type: Sequelize.STRING },
  source_tag:       { type: Sequelize.INTEGER }

})

<|endoftext|>


<commit_before>// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
// License: GNU General Public License v3. See license.txt

wn.pages['voucher-import-tool'].onload = function(wrapper) {
	wn.ui.make_app_page({
		parent: wrapper,
		title: wn._('Voucher Import Tool'),
		single_column: true
	});

	$(wrapper).find('.layout-main').html('
'+wn._('Import multiple accounting entries via CSV (spreadsheet) file:')+'
'+
		'
'+wn._('1. Download Template')+'

'+
		'
'+
		    '<button class="btn btn-default btn-download-two-accounts">'+wn._('Download')+'</button>'+
			'
'+wn._('Import multiple vouchers with one debit and one credit entry')+'
'+
		'
'+
		'
'+
			'<button class="btn btn-default btn-download-multiple-accounts">'+wn._('Download')+'</button>'+
			'
'+wn._('Import multiple vouchers with multiple accounts')+'
'+
		'
'+
		'
'+
		'
'+wn._('2. Upload')+'

'+
		'
'+
			'
'+wn._('Upload file in CSV format with UTF-8 encoding')+'
'+
			'

'+
		'

'+
		'

'+
		'

');

	wn.upload.make({
		parent: $(wrapper).find("#voucher-upload"),
		args: {
			method: "accounts.page.voucher_import_tool.voucher_import_tool.upload"
		},
		callback: function(fid, filename, r) {
			wrapper.waiting.toggle(false);
			$(wrapper).find(".messages").toggle(true).html(
				r.message.join("

"))
		}
	});

	wrapper.waiting = wn.messages.waiting($(wrapper).find('.working'),
		"Importing Vouchers...").toggle(false);

	$(wrapper).find(".btn-download-two-accounts").click(function() {
		window.location.href = wn.request.url +
			'?cmd=accounts.page.voucher_import_tool.voucher_import_tool.get_template' +
			'&type=Two Accounts';
	});

	$(wrapper).find(".btn-download-multiple-accounts").click(function() {
		window.location.href = wn.request.url +
				'?cmd=accounts.page.voucher_import_tool.voucher_import_tool.get_template' +
				'&type=Multiple Accounts';
	});

	// rename button
	$(wrapper).find('#voucher-upload form input[type="submit"]')
		.click(function() {
			$(wrapper).find(".messages").toggle(false);
			wrapper.waiting.toggle(true);
		});
}<commit_msg>Fix translate voucher_import_tool.js<commit_after>// Copyright (c) 2013, Web Notes Technologies Pvt. Ltd.
// License: GNU General Public License v3. See license.txt

wn.pages['voucher-import-tool'].onload = function(wrapper) {
	wn.ui.make_app_page({
		parent: wrapper,
		title: wn._('Voucher Import Tool'),
		single_column: true
	});

	$(wrapper).find('.layout-main').html('
'+wn._('Import multiple accounting entries via CSV (spreadsheet) file:')+'
'+
		'
 1.'+wn._(' Download Template')+'

'+
		'
'+
		    '<button class="btn btn-default btn-download-two-accounts">'+wn._('Download')+'</button>'+
			'
'+wn._('Import multiple vouchers with one debit and one credit entry')+'
'+
		'
'+
		'
'+
			'<button class="btn btn-default btn-download-multiple-accounts">'+wn._('Download')+'</button>'+
			'
'+wn._('Import multiple vouchers with multiple accounts')+'
'+
		'
'+
		'
'+
		'
 2.'+wn._(' Upload')+'

'+
		'
'+
			'
'+wn._('Upload file in CSV format with UTF-8 encoding')+'
'+
			'

'+
		'

'+
		'

'+
		'

');

	wn.upload.make({
		parent: $(wrapper).find("#voucher-upload"),
		args: {
			method: "accounts.page.voucher_import_tool.voucher_import_tool.upload"
		},
		callback: function(fid, filename, r) {
			wrapper.waiting.toggle(false);
			$(wrapper).find(".messages").toggle(true).html(
				r.message.join("

"))
		}
	});

	wrapper.waiting = wn.messages.waiting($(wrapper).find('.working'),
		"Importing Vouchers...").toggle(false);

	$(wrapper).find(".btn-download-two-accounts").click(function() {
		window.location.href = wn.request.url +
			'?cmd=accounts.page.voucher_import_tool.voucher_import_tool.get_template' +
			'&type=Two Accounts';
	});

	$(wrapper).find(".btn-download-multiple-accounts").click(function() {
		window.location.href = wn.request.url +
				'?cmd=accounts.page.voucher_import_tool.voucher_import_tool.get_template' +
				'&type=Multiple Accounts';
	});

	// rename button
	$(wrapper).find('#voucher-upload form input[type="submit"]')
		.click(function() {
			$(wrapper).find(".messages").toggle(false);
			wrapper.waiting.toggle(true);
		});
}<|endoftext|>


<commit_before>var Overlay = (function() {
  // Parts of the DOM
  var button = $('#overlay > #holder > button');
  var overlay = $('#overlay');

  // Other variables
  var active = false;

  // Handler for when the overlay button is pressed
  var pressButton = function() {
    if(active) {
      button.addClass('active'); //TODO: implement this properly
      mediator.publish('story_advance');
    }
  }

  // Renders the overlay
  var render = function(data) {
    overlay.fadeOut(options['fade'], function() {
      mediator.publish('board_set_inactive');
      overlay.fadeIn(options['fade']);
      active = true;

      var title   = data.title;
      var content = data.text;
      var action  = data.button;

      $('#overlay > h1').html(title);
      $('#overlay > #content').html(content);
      if(action) {
        // There's a very special case here if the game has been completed
        if(action = "%fb%") {
          $('#holder').html('let me do it again.');
        }
        else {
          button.show();
          button.html(action);
        }
      }
      else
        button.hide();
    })
  }

  // Fades out the overlay and sets it as inactive
  var setInactive = function() {
    overlay.fadeOut(options['fade']);
    active = false;
  }

  // Event Bindings
  button.on('click', pressButton);

  // The facade
  return {
    pressButton: pressButton,
    render: render,
    setInactive: setInactive
  }
}())

// Add the mediator to the module
mediator.installTo(Overlay);

// Subscribe to messages

// Listen for space and enter to forward the events to the button press
Overlay.subscribe('controls_key_space', Overlay.pressButton);
Overlay.subscribe('controls_key_enter', Overlay.pressButton);

// Listen for instruction to draw the overlay
Overlay.subscribe('overlay_render', Overlay.render);

// Listen for instruction to deactivate this overlay
Overlay.subscribe('overlay_set_inactive', Overlay.setInactive);
<commit_msg>*very* quick fix for incorrect button link<commit_after>var Overlay = (function() {
  // Parts of the DOM
  var button = $('#overlay > #holder > button');
  var overlay = $('#overlay');

  // Other variables
  var active = false;

  // Handler for when the overlay button is pressed
  var pressButton = function() {
    if(active) {
      button.addClass('active'); //TODO: implement this properly
      mediator.publish('story_advance');
    }
  }

  // Renders the overlay
  var render = function(data) {
    overlay.fadeOut(options['fade'], function() {
      mediator.publish('board_set_inactive');
      overlay.fadeIn(options['fade']);
      active = true;

      var title   = data.title;
      var content = data.text;
      var action  = data.button;

      $('#overlay > h1').html(title);
      $('#overlay > #content').html(content);
      if(action) {
        // There's a very special case here if the game has been completed
        if(action == "%fb%") {
//          $('#holder').html('let me do it again.');
        }
        else {
          button.show();
          button.html(action);
        }
      }
      else
        button.hide();
    })
  }

  // Fades out the overlay and sets it as inactive
  var setInactive = function() {
    overlay.fadeOut(options['fade']);
    active = false;
  }

  // Event Bindings
  button.on('click', pressButton);

  // The facade
  return {
    pressButton: pressButton,
    render: render,
    setInactive: setInactive
  }
}())

// Add the mediator to the module
mediator.installTo(Overlay);

// Subscribe to messages

// Listen for space and enter to forward the events to the button press
Overlay.subscribe('controls_key_space', Overlay.pressButton);
Overlay.subscribe('controls_key_enter', Overlay.pressButton);

// Listen for instruction to draw the overlay
Overlay.subscribe('overlay_render', Overlay.render);

// Listen for instruction to deactivate this overlay
Overlay.subscribe('overlay_set_inactive', Overlay.setInactive);
<|endoftext|>


<commit_before>import color from 'color';

const colors = {
  black: '#666',
  white: '#fff',

  primary: '#00bcec',
  primaryText: '#008db1',
  primaryLight: '#d9f5fc',

  secondary: '#1f2a44',
  secondaryText: '#3a455c',
  secondaryFaded: '#3a455c',

  grayLightText: '#7f8897',
  greyLightText: '#7f8897',
  grayLight: '#f3f3f3',
  greyLight: '#f3f3f3',
  grayMed: '#666',
  greyMed: '#666',
  grayDark: '#272b2d',
  greyDark: '#272b2d',

  gutter: '#f7f7f7',
  border: '#c2c2c2',
  borderLight: '#e1e1e1',
  disabled: '#e1e1e1',

  successText: '#6cbf0d',
  successBorder: '#b5df86',
  successBackground: '#5a9f0b',
  successBackgroundLight: '#e9f5db',

  infoText: '#3a455c',
  infoBorder: '#33c9f0',
  infoBackground: '#00bcec',
  infoBackgroundLight: '#d9f5fc',

  errorText: '#e8562e',
  errorBorder: '#f6bbab',
  errorBackground: '#b1351e',
  errorBackgroundLight: '#fceae6',
};

const fonts = {
  brand: '"Overpass", Raleway, "Open Sans", arial, sans-serif',
  default: '"Open Sans", arial, sans-serif',
  monospace: '"Source Code Pro", monospace',
};

const shadows = {
  default: `
    0 2px 2px 0 rgba(0, 0, 0, 0.14),
    0 1px 5px 0 rgba(0, 0, 0, 0.12),
    0 3px 1px -2px rgba(0 ,0, 0, 0.2)
    `,
  focusOutline: '0 0 0 5px #d9f5fc',
};

const padding = {
  extraSmall: '5px',
  small: '10px',
  medium: '15px',
  large: '30px',
  extraLarge: '60px',
}

export default {
  name: 'default',

  colors,
  fonts,
  shadows,
  padding,

  text: {
    fg: '#666',
    bg: 'transparent',
    fontSize: '14px',
    fontWeight: 'auto',
    fontFamily: fonts.default,
  },

  button: {
    fg: '#fff',
    bg: '#00bcec',
    activeFG: '#fff',
    activeBG: color('#00bcec').darken(0.2).string(),
    disabledBG: colors.disabled,
    disabledFG: colors.black,
    disabledBorder: `1px solid ${colors.disabled}`,
    border: `none`,
    fontSize: '0.8em',
    fontWeight: '700',
    fontFamily: fonts.default,
    textTransform: 'uppercase',
    padding: '13px 40px',
    margin: '0',
  },

  tab: {
    bg: 'transparent',
    fg: '#fff',
    accent: '#00bcec',
    activeFG: '#fff',
    fontSize: '1em',
    fontWeight: 'auto',
    padding: '30px 0 30px 0',
    margin: '0 30px 0 0',
    // controls animations
    accentBarTop: 'auto',
    accentBarBottom: '0',
    marginBottom: 'auto',
  },

  input: {
    bg: '#fff',
    fg: '#666',
    accentValid: '#d9f5fc',
    disabledBG: '#e1e1e1',
    disabledFG: colors.black,
    disabledBorder: `1px solid ${colors.border}`,
    border: `1px solid ${colors.borderLight}`,
    focusedBorder: `1px solid ${colors.border}`,
    fontSize: '14px',
    fontFamily: fonts.brand,
    padding: '1em 1em',
    margin: 0,
    letterSpacing: '0.02em',
    lineHeight: '1.5',
    helpTextPadding: '0.4em 0 0 0',
  },

  helpText: {
    fg: '#7f8897',
    fontWeight: 300,
    fontFamily: fonts.brand,
  },

  radioButton: {
    bg: '#fff',
    fg: '#666',
    accent: '#00bcec',
    active: '#fff',
    border: `1px solid ${colors.borderLight}`,
    padding: '1em 1.4em',
  },

  topNav: {
    bg: '#1f2a44',
    fg: '#fff',
    padding: '0 2em',
    margin: '0',
  },

  sidebar: {
    bg: '#e1e1e1',
    fg: '#666',
    border: `1px solid ${colors.borderLight}`,
    margin: '0',
    padding: '0',
  },

  card: {
    bg: colors.white,
    fg: colors.black,
    fontSize: '1em',
    activeFG: '#00bcec',
    padding: '0.5em',
    margin: '0',
    border: `1px solid ${colors.borderLight}`,
    listPadding: '0 30px 30px 30px',
    helpFontFamily: fonts.brand,
    helpFontSize: '0.9em',
    helpFontWeight: 100,
  },

  form: {
    bg: colors.white,
    fg: '#666',
    border: `1px solid ${colors.borderLight}`,
    fontFamily: fonts.brand,
    // form intelligently applies spacing to its children
    // to acheive this spacing on elements
    // units are pixels
    elementHorizontalSpacing: 30,
    elementVerticalSpacing: 28,
  },

  formColumn: {
    border: `1px solid ${colors.borderLight}`,
  },

  shadow: {
    color: 'rgba(0, 0, 0, 0.14)',
  },

  label: {
    fg: '#666',
    bg: 'transparent',
    fontWeight: 600,
    fontSize: '1em',
    letterSpacing: '0.02em',
    fontFamily: fonts.brand,
    padding: '0 0 0.4em 0',
    requiredMarkFG: '#e8562e',
  },

  toggle: {
    bg: '#fff',
    fg: '#fff',
    activeBG: '#3a455c',
    activeFG: '#fff',
    border: '2px solid #3a455c',
    activeBorder: '2px solid #3a455c',
    disabledBG: '#666',
    disabledBorder: '2px solid #666',
    hoverBorder: '2px solid #008db1',
    hoverBG: '#008db1',
    focusShadow: '0 0 0 5px #d9f5fc',
    padding: '0.2em 0 0.2em 4.2em',
    height: '2em',
    width: '3.6em',
    fontFamily: fonts.brand,
    fontWeight: 600,
  },

  checkbox: {
    labelPadding: '0.2em 0 0.2em 2.1em',
    labelFontSize: '1.15em',
    fg: colors.black,
    checkFG: colors.white,
    emptyBG: colors.white,
    fullBG: colors.secondary,
    border: `2px solid ${colors.secondary}`,
    borderRadius: '0.2em',
    focusShadow: '0 0 0 5px #d9f5fc',
  },

  header: {
    fg: colors.primary,
    fontFamily: fonts.brand,
    fontWeight: 100,
    fontSize: '2.5em',
    lineHeight: '21px',
    margin: '0.83em 0 0 0',
  },

  subheader: {
    fontSize: '1.17em',
    fontFamily: fonts.brand,
    fontWeight: 800,
    fg: colors.black,
  },

  icon: {
    fontSize: '16px',
    fg: 'inherit',
  },

  code: {
    fontFamily: fonts.monospace,
    fontSize: '1em',
    bg: '#272b2d',
    fg: '#fff',
    padding: '2em',
  },

  inlineCode: {
    fontFamily: fonts.monospace,
    fg: '#666',
    bg: '#f1f1f1',
    border: '1px solid #e4e4e4',
    borderRadius: '3px',
    fontSize: '0.85em',
    borderRadius: '3px',
    padding: '0.3em',
  },

  // for request methods
  methodTag: {
    colors: {
      get: '#6cbf0d',
      post: '#00bcec',
      del: '#e8562e',
      delete: '#e8562e',
      put: '#a5639b',
    },
    padding: '0.5em 1em',
    borderRadius: '5px',
    fg: colors.white,
    fontSize: '1em',
    lineHeight: '1em',
  },

  selectItem: {
    fg: '#666',
    bg: '#fff',
    activeFG: '#008db1',
    padding: '0.5em',
    border: `1px solid ${colors.borderLight}`,
  },

  accordion: {
    labelFG: '#00bcec',
    labelFontSize: '1.5em',
    iconFontSize: '1em',
    labelFontFamily: fonts.brand,
    labelFontWeight: 400,
    border: `1px solid ${colors.borderLight}`,
    padding: '30px',
    textTransform: 'none',
  },

  listItem: {
    textTransform: 'uppercase',
    fontWeight: 'bold',
    fontFamily: fonts.brand,
    fg: 'rgb(39, 43, 45)',
    bg: 'transparent',
    selectedFG: colors.primary,
    selectedBG: colors.gutter,
    padding: '1.5em 2em',
    border: `1px solid ${colors.borderLight}`,
  },

  list: {
    border: `1px solid ${colors.borderLight}`,
  },

  table: {
    bg: colors.white,
    border: '1px solid rgba(0, 0, 0, 0.15)',
    borderRadius: '5px 5px 0 0',
    cellBG: 'transparent',
    cellBorder: '1px solid rgba(0, 0, 0, 0.15)',
    cellMargin: 0,
    cellPadding: '10px 15px',
    headerBG: colors.secondaryFaded,
    headerFG: colors.white,
    headerFontWeight: 300,
    headerFontFamily: fonts.brand,
    headerPadding: '10px 15px',
    rowOddBG: 'transparent',
    rowEvenBG: 'rgba(0, 0, 0, 0.15)',
    fontSize: '1em',
    sortArrowFG: 'rgba(255, 255, 255, 0.5)',
    sortArrowActiveFG: colors.white,
  },

  pane: {
    contentPadding: '20px 30px 30px 30px',
  },

  link: {
    fg: colors.primaryText,
    activeFG: colors.primary,
    bubbleBG: colors.primaryLight,
    bubbleBorderRadius: '2em',
    fontFamily: fonts.brand,
  },

  textarea: {
    bg: colors.white,
    fg: colors.black,
    border: `1px solid ${colors.borderLight}`,
    padding: '15px',
    fontWeight: 400,
    fontFamily: fonts.brand,
    lineHeight: '1.5em',
    fontSize: '14px',
  },

  modal: {
    blockerBG: 'rgba(0, 0, 0, 0.3)',
    bg: colors.white,
    shadow: shadows.default,
    borderRadius: '5px',
    minWidth: '20%',
    maxWidth: '70%',
    naturalWidth: 'auto',
    minHeight: 0,
    maxHeight: '70vh',
    naturalHeight: 'auto',
    titleBG: '#e1e1e1',
    titleFG: colors.black,
    titleFontFamily: fonts.brand,
    titleFontSize: '0.9em',
    titleFontWeight: 600,
    titleTextTransform: 'uppercase',
    titlePadding: '0.95em 1.5em 0.95em 1em',
  },

  callout: {
    maxWidth: '300px',
    bg: colors.white,
    fg: 'inherit',
    padding: '10px 15px',
    borderRadius: '3px',
    border: `1px solid ${colors.border}`,
    shadow: shadows.default,
  },
};
<commit_msg>theme colors for Money<commit_after>import color from 'color';

const colors = {
  black: '#666',
  white: '#fff',

  primary: '#00bcec',
  primaryText: '#008db1',
  primaryLight: '#d9f5fc',

  secondary: '#1f2a44',
  secondaryText: '#3a455c',
  secondaryFaded: '#3a455c',

  grayLightText: '#7f8897',
  greyLightText: '#7f8897',
  grayLight: '#f3f3f3',
  greyLight: '#f3f3f3',
  grayMed: '#666',
  greyMed: '#666',
  grayDark: '#272b2d',
  greyDark: '#272b2d',

  gutter: '#f7f7f7',
  border: '#c2c2c2',
  borderLight: '#e1e1e1',
  disabled: '#e1e1e1',

  successText: '#6cbf0d',
  successBorder: '#b5df86',
  successBackground: '#5a9f0b',
  successBackgroundLight: '#e9f5db',

  infoText: '#3a455c',
  infoBorder: '#33c9f0',
  infoBackground: '#00bcec',
  infoBackgroundLight: '#d9f5fc',

  errorText: '#e8562e',
  errorBorder: '#f6bbab',
  errorBackground: '#b1351e',
  errorBackgroundLight: '#fceae6',

  positiveText: '#6cbf0d',
  negativeText: '#e8562e',
};

const fonts = {
  brand: '"Overpass", Raleway, "Open Sans", arial, sans-serif',
  default: '"Open Sans", arial, sans-serif',
  monospace: '"Source Code Pro", monospace',
};

const shadows = {
  default: `
    0 2px 2px 0 rgba(0, 0, 0, 0.14),
    0 1px 5px 0 rgba(0, 0, 0, 0.12),
    0 3px 1px -2px rgba(0 ,0, 0, 0.2)
    `,
  focusOutline: '0 0 0 5px #d9f5fc',
};

const padding = {
  extraSmall: '5px',
  small: '10px',
  medium: '15px',
  large: '30px',
  extraLarge: '60px',
}

export default {
  name: 'default',

  colors,
  fonts,
  shadows,
  padding,

  text: {
    fg: '#666',
    bg: 'transparent',
    fontSize: '14px',
    fontWeight: 'auto',
    fontFamily: fonts.default,
  },

  button: {
    fg: '#fff',
    bg: '#00bcec',
    activeFG: '#fff',
    activeBG: color('#00bcec').darken(0.2).string(),
    disabledBG: colors.disabled,
    disabledFG: colors.black,
    disabledBorder: `1px solid ${colors.disabled}`,
    border: `none`,
    fontSize: '0.8em',
    fontWeight: '700',
    fontFamily: fonts.default,
    textTransform: 'uppercase',
    padding: '13px 40px',
    margin: '0',
  },

  tab: {
    bg: 'transparent',
    fg: '#fff',
    accent: '#00bcec',
    activeFG: '#fff',
    fontSize: '1em',
    fontWeight: 'auto',
    padding: '30px 0 30px 0',
    margin: '0 30px 0 0',
    // controls animations
    accentBarTop: 'auto',
    accentBarBottom: '0',
    marginBottom: 'auto',
  },

  input: {
    bg: '#fff',
    fg: '#666',
    accentValid: '#d9f5fc',
    disabledBG: '#e1e1e1',
    disabledFG: colors.black,
    disabledBorder: `1px solid ${colors.border}`,
    border: `1px solid ${colors.borderLight}`,
    focusedBorder: `1px solid ${colors.border}`,
    fontSize: '14px',
    fontFamily: fonts.brand,
    padding: '1em 1em',
    margin: 0,
    letterSpacing: '0.02em',
    lineHeight: '1.5',
    helpTextPadding: '0.4em 0 0 0',
  },

  helpText: {
    fg: '#7f8897',
    fontWeight: 300,
    fontFamily: fonts.brand,
  },

  radioButton: {
    bg: '#fff',
    fg: '#666',
    accent: '#00bcec',
    active: '#fff',
    border: `1px solid ${colors.borderLight}`,
    padding: '1em 1.4em',
  },

  topNav: {
    bg: '#1f2a44',
    fg: '#fff',
    padding: '0 2em',
    margin: '0',
  },

  sidebar: {
    bg: '#e1e1e1',
    fg: '#666',
    border: `1px solid ${colors.borderLight}`,
    margin: '0',
    padding: '0',
  },

  card: {
    bg: colors.white,
    fg: colors.black,
    fontSize: '1em',
    activeFG: '#00bcec',
    padding: '0.5em',
    margin: '0',
    border: `1px solid ${colors.borderLight}`,
    listPadding: '0 30px 30px 30px',
    helpFontFamily: fonts.brand,
    helpFontSize: '0.9em',
    helpFontWeight: 100,
  },

  form: {
    bg: colors.white,
    fg: '#666',
    border: `1px solid ${colors.borderLight}`,
    fontFamily: fonts.brand,
    // form intelligently applies spacing to its children
    // to acheive this spacing on elements
    // units are pixels
    elementHorizontalSpacing: 30,
    elementVerticalSpacing: 28,
  },

  formColumn: {
    border: `1px solid ${colors.borderLight}`,
  },

  shadow: {
    color: 'rgba(0, 0, 0, 0.14)',
  },

  label: {
    fg: '#666',
    bg: 'transparent',
    fontWeight: 600,
    fontSize: '1em',
    letterSpacing: '0.02em',
    fontFamily: fonts.brand,
    padding: '0 0 0.4em 0',
    requiredMarkFG: '#e8562e',
  },

  toggle: {
    bg: '#fff',
    fg: '#fff',
    activeBG: '#3a455c',
    activeFG: '#fff',
    border: '2px solid #3a455c',
    activeBorder: '2px solid #3a455c',
    disabledBG: '#666',
    disabledBorder: '2px solid #666',
    hoverBorder: '2px solid #008db1',
    hoverBG: '#008db1',
    focusShadow: '0 0 0 5px #d9f5fc',
    padding: '0.2em 0 0.2em 4.2em',
    height: '2em',
    width: '3.6em',
    fontFamily: fonts.brand,
    fontWeight: 600,
  },

  checkbox: {
    labelPadding: '0.2em 0 0.2em 2.1em',
    labelFontSize: '1.15em',
    fg: colors.black,
    checkFG: colors.white,
    emptyBG: colors.white,
    fullBG: colors.secondary,
    border: `2px solid ${colors.secondary}`,
    borderRadius: '0.2em',
    focusShadow: '0 0 0 5px #d9f5fc',
  },

  header: {
    fg: colors.primary,
    fontFamily: fonts.brand,
    fontWeight: 100,
    fontSize: '2.5em',
    lineHeight: '21px',
    margin: '0.83em 0 0 0',
  },

  subheader: {
    fontSize: '1.17em',
    fontFamily: fonts.brand,
    fontWeight: 800,
    fg: colors.black,
  },

  icon: {
    fontSize: '16px',
    fg: 'inherit',
  },

  code: {
    fontFamily: fonts.monospace,
    fontSize: '1em',
    bg: '#272b2d',
    fg: '#fff',
    padding: '2em',
  },

  inlineCode: {
    fontFamily: fonts.monospace,
    fg: '#666',
    bg: '#f1f1f1',
    border: '1px solid #e4e4e4',
    borderRadius: '3px',
    fontSize: '0.85em',
    borderRadius: '3px',
    padding: '0.3em',
  },

  // for request methods
  methodTag: {
    colors: {
      get: '#6cbf0d',
      post: '#00bcec',
      del: '#e8562e',
      delete: '#e8562e',
      put: '#a5639b',
    },
    padding: '0.5em 1em',
    borderRadius: '5px',
    fg: colors.white,
    fontSize: '1em',
    lineHeight: '1em',
  },

  selectItem: {
    fg: '#666',
    bg: '#fff',
    activeFG: '#008db1',
    padding: '0.5em',
    border: `1px solid ${colors.borderLight}`,
  },

  accordion: {
    labelFG: '#00bcec',
    labelFontSize: '1.5em',
    iconFontSize: '1em',
    labelFontFamily: fonts.brand,
    labelFontWeight: 400,
    border: `1px solid ${colors.borderLight}`,
    padding: '30px',
    textTransform: 'none',
  },

  listItem: {
    textTransform: 'uppercase',
    fontWeight: 'bold',
    fontFamily: fonts.brand,
    fg: 'rgb(39, 43, 45)',
    bg: 'transparent',
    selectedFG: colors.primary,
    selectedBG: colors.gutter,
    padding: '1.5em 2em',
    border: `1px solid ${colors.borderLight}`,
  },

  list: {
    border: `1px solid ${colors.borderLight}`,
  },

  table: {
    bg: colors.white,
    border: '1px solid rgba(0, 0, 0, 0.15)',
    borderRadius: '5px 5px 0 0',
    cellBG: 'transparent',
    cellBorder: '1px solid rgba(0, 0, 0, 0.15)',
    cellMargin: 0,
    cellPadding: '10px 15px',
    headerBG: colors.secondaryFaded,
    headerFG: colors.white,
    headerFontWeight: 300,
    headerFontFamily: fonts.brand,
    headerPadding: '10px 15px',
    rowOddBG: 'transparent',
    rowEvenBG: 'rgba(0, 0, 0, 0.15)',
    fontSize: '1em',
    sortArrowFG: 'rgba(255, 255, 255, 0.5)',
    sortArrowActiveFG: colors.white,
  },

  pane: {
    contentPadding: '20px 30px 30px 30px',
  },

  link: {
    fg: colors.primaryText,
    activeFG: colors.primary,
    bubbleBG: colors.primaryLight,
    bubbleBorderRadius: '2em',
    fontFamily: fonts.brand,
  },

  textarea: {
    bg: colors.white,
    fg: colors.black,
    border: `1px solid ${colors.borderLight}`,
    padding: '15px',
    fontWeight: 400,
    fontFamily: fonts.brand,
    lineHeight: '1.5em',
    fontSize: '14px',
  },

  modal: {
    blockerBG: 'rgba(0, 0, 0, 0.3)',
    bg: colors.white,
    shadow: shadows.default,
    borderRadius: '5px',
    minWidth: '20%',
    maxWidth: '70%',
    naturalWidth: 'auto',
    minHeight: 0,
    maxHeight: '70vh',
    naturalHeight: 'auto',
    titleBG: '#e1e1e1',
    titleFG: colors.black,
    titleFontFamily: fonts.brand,
    titleFontSize: '0.9em',
    titleFontWeight: 600,
    titleTextTransform: 'uppercase',
    titlePadding: '0.95em 1.5em 0.95em 1em',
  },

  callout: {
    maxWidth: '300px',
    bg: colors.white,
    fg: 'inherit',
    padding: '10px 15px',
    borderRadius: '3px',
    border: `1px solid ${colors.border}`,
    shadow: shadows.default,
  },
};
<|endoftext|>


<commit_before>import { expect } from "chai";
import RxPlayer from "../../../src";
import { manifestInfos } from "../../contents/DASH_static_SegmentTimeline";
import sleep from "../../utils/sleep.js";
import XHRMock from "../../utils/request_mock";

/**
 * Test ability to add an external text track when loading a video.
 */

describe("external text track", function () {
  let player;
  let xhrMock;

  beforeEach(() => {
    player = new RxPlayer();
    xhrMock = new XHRMock();
  });

  afterEach(() => {
    player.dispose();
    xhrMock.restore();
  });

  it("should be able to add an external text track", async function () {
    xhrMock.lock();

    player.loadVideo({
      transport: manifestInfos.transport,
      url: manifestInfos.url,
      supplementaryTextTracks: {
        url: "http://fakeURL",
        language: "en",
        closedCaption: false,
        mimeType: "text/vtt",
      },
    });

    await sleep(1);
    await xhrMock.flush();
    await sleep(1);

    const textTracks = player.getAvailableTextTracks();
    expect(textTracks.length).to.equal(1);
    expect(textTracks[0].language).to.equal("en");
    expect(textTracks[0].normalized).to.equal("eng");
    expect(textTracks[0].closedCaption).to.equal(false);
    expect(typeof textTracks[0].id).to.equal("string");
    expect(textTracks[0].id).to.not.equal("");
    expect(textTracks[0].active).to.equal(false);
  });

  it("should be able to add a closed caption text track", async function () {
    xhrMock.lock();

    player.loadVideo({
      transport: manifestInfos.transport,
      url: manifestInfos.url,
      supplementaryTextTracks: {
        url: "http://fakeURL",
        language: "arm",
        closedCaption: true,
        mimeType: "text/vtt",
      },
    });

    await sleep(1);
    await xhrMock.flush();
    await sleep(1);

    const textTracks = player.getAvailableTextTracks();
    expect(textTracks.length).to.equal(1);
    expect(textTracks[0].language).to.equal("arm");
    expect(textTracks[0].normalized).to.equal("hye");
    expect(textTracks[0].closedCaption).to.equal(true);
    expect(typeof textTracks[0].id).to.equal("string");
    expect(textTracks[0].id).to.not.equal("");
    expect(textTracks[0].active).to.equal(false);

  });

  it("should be able to add multiple external text tracks", async function () {
    xhrMock.lock();

    player.loadVideo({
      transport: manifestInfos.transport,
      url: manifestInfos.url,
      supplementaryTextTracks: [
        {
          url: "http://fakeURL1",
          language: "en",
          closedCaption: false,
          mimeType: "text/vtt",
        },
        {
          url: "http://fakeURL2",
          language: "fr",
          closedCaption: false,
          mimeType: "text/vtt",
        },
        {
          url: "http://fakeURL3",
          language: "ger",
          closedCaption: true,
          mimeType: "text/vtt",
        },
      ],
    });

    await sleep(1);
    await xhrMock.flush();
    await sleep(1);

    const textTracks = player.getAvailableTextTracks();
    expect(textTracks.length).to.equal(3);

    expect(textTracks[0].language).to.equal("en");
    expect(textTracks[0].normalized).to.equal("eng");
    expect(textTracks[0].closedCaption).to.equal(false);
    expect(typeof textTracks[0].id).to.equal("string");
    expect(textTracks[0].id).to.not.equal("");
    expect(textTracks[0].active).to.equal(false);

    expect(textTracks[1].language).to.equal("fr");
    expect(textTracks[1].normalized).to.equal("fra");
    expect(textTracks[1].closedCaption).to.equal(false);
    expect(typeof textTracks[1].id).to.equal("string");
    expect(textTracks[1].id).to.not.equal("");
    expect(textTracks[1].active).to.equal(false);

    expect(textTracks[2].language).to.equal("ger");
    expect(textTracks[2].normalized).to.equal("deu");
    expect(textTracks[2].closedCaption).to.equal(true);
    expect(typeof textTracks[2].id).to.equal("string");
    expect(textTracks[2].id).to.not.equal("");
    expect(textTracks[2].active).to.equal(false);
  });

  it("should switch initially to external text track if set as default language", async function () {
    xhrMock.lock();

    const waysOfWritingDefaultTextTrack = [
      "en",
      "eng",
      { language: "en" },
      { language: "eng" },
      { language: "en", closedCaption: false },
      { language: "eng", closedCaption: false },
    ];

    for (const defaultTextTrack of waysOfWritingDefaultTextTrack) {
      player.loadVideo({
        transport: manifestInfos.transport,
        url: manifestInfos.url,
        supplementaryTextTracks: {
          url: "http://fakeURL",
          language: "en",
          closedCaption: false,
          mimeType: "text/vtt",
        },
        defaultTextTrack,
      });

      await sleep(1);
      await xhrMock.flush();
      await sleep(1);

      const textTracks1 = player.getAvailableTextTracks();
      expect(textTracks1[0].active).to.equal(true);

      player.loadVideo({
        transport: manifestInfos.transport,
        url: manifestInfos.url,
        supplementaryTextTracks: [
          {
            url: "http://fakeURL1",
            language: "en",
            closedCaption: false,
            mimeType: "text/vtt",
          },
          {
            url: "http://fakeURL2",
            language: "fr",
            closedCaption: false,
            mimeType: "text/vtt",
          },
          {
            url: "http://fakeURL3",
            language: "ger",
            closedCaption: true,
            mimeType: "text/vtt",
          },
        ],
        defaultTextTrack,
      });

      await sleep(1);
      await xhrMock.flush();
      await sleep(1);

      const textTracks2 = player.getAvailableTextTracks();
      expect(textTracks2[0].active).to.equal(true);
    }
  });

  it("should switch initially to a closed caption external text track if set as default language", async function () {
    xhrMock.lock();

    const waysOfWritingDefaultTextTrack = [
      { language: "en", closedCaption: true },
      { language: "eng", closedCaption: true },
    ];

    for (const defaultTextTrack of waysOfWritingDefaultTextTrack) {
      player.loadVideo({
        transport: manifestInfos.transport,
        url: manifestInfos.url,
        supplementaryTextTracks: {
          url: "http://fakeURL",
          language: "en",
          closedCaption: true,
          mimeType: "text/vtt",
        },
        defaultTextTrack,
      });

      await sleep(1);
      await xhrMock.flush();
      await sleep(1);

      const textTracks1 = player.getAvailableTextTracks();
      expect(textTracks1[0].active).to.equal(true);

      player.loadVideo({
        transport: manifestInfos.transport,
        url: manifestInfos.url,
        supplementaryTextTracks: [
          {
            url: "http://fakeURL1",
            language: "en",
            closedCaption: true,
            mimeType: "text/vtt",
          },
          {
            url: "http://fakeURL2",
            language: "fr",
            closedCaption: false,
            mimeType: "text/vtt",
          },
          {
            url: "http://fakeURL3",
            language: "ger",
            closedCaption: true,
            mimeType: "text/vtt",
          },
        ],
        defaultTextTrack,
      });

      await sleep(1);
      await xhrMock.flush();
      await sleep(1);

      const textTracks2 = player.getAvailableTextTracks();
      expect(textTracks2[0].active).to.equal(true);
    }
  });

  it("should not switch initially to external text track if not set as default language", async function () {
    xhrMock.lock();

    const waysOfWritingDefaultTextTrack = [
      "fr",
      undefined,
      null,
      { language: "english" },
      { language: "en", closedCaption: true },
      { language: "eng", closedCaption: true },
    ];

    for (const defaultTextTrack of waysOfWritingDefaultTextTrack) {
      player.loadVideo({
        transport: manifestInfos.transport,
        url: manifestInfos.url,
        supplementaryTextTracks: {
          url: "http://fakeURL",
          language: "en",
          closedCaption: false,
          mimeType: "text/vtt",
        },
        defaultTextTrack,
      });

      await sleep(1);
      await xhrMock.flush();
      await sleep(1);

      const textTracks1 = player.getAvailableTextTracks();
      expect(textTracks1[0].active).to.equal(false);

      player.loadVideo({
        transport: manifestInfos.transport,
        url: manifestInfos.url,
        supplementaryTextTracks: [
          {
            url: "http://fakeURL1",
            language: "en",
            closedCaption: false,
            mimeType: "text/vtt",
          },
          {
            url: "http://fakeURL2",
            language: "fr",
            closedCaption: false,
            mimeType: "text/vtt",
          },
          {
            url: "http://fakeURL3",
            language: "ger",
            closedCaption: true,
            mimeType: "text/vtt",
          },
        ],
        defaultTextTrack,
      });

      await sleep(1);
      await xhrMock.flush();
      await sleep(1);

      const textTracks2 = player.getAvailableTextTracks();
      expect(textTracks2[0].active).to.equal(false);
    }
  });
});
<commit_msg>tests: put real URLs for external_text_track integration tests<commit_after>import { expect } from "chai";
import RxPlayer from "../../../src";
import { manifestInfos } from "../../contents/DASH_static_SegmentTimeline";
import textTrackInfos from "../../contents/texttracks";
import sleep from "../../utils/sleep.js";
import XHRMock from "../../utils/request_mock";

/**
 * Test ability to add an external text track when loading a video.
 */

describe("external text track", function () {
  let player;
  let xhrMock;

  beforeEach(() => {
    player = new RxPlayer();
    xhrMock = new XHRMock();
  });

  afterEach(() => {
    player.dispose();
    xhrMock.restore();
  });

  it("should be able to add an external text track", async function () {
    xhrMock.lock();

    player.loadVideo({
      transport: manifestInfos.transport,
      url: manifestInfos.url,
      supplementaryTextTracks: {
        url: textTrackInfos.url,
        language: "en",
        closedCaption: false,
        mimeType: "text/vtt",
      },
    });

    await sleep(1);
    await xhrMock.flush();
    await sleep(1);

    const textTracks = player.getAvailableTextTracks();
    expect(textTracks.length).to.equal(1);
    expect(textTracks[0].language).to.equal("en");
    expect(textTracks[0].normalized).to.equal("eng");
    expect(textTracks[0].closedCaption).to.equal(false);
    expect(typeof textTracks[0].id).to.equal("string");
    expect(textTracks[0].id).to.not.equal("");
    expect(textTracks[0].active).to.equal(false);
  });

  it("should be able to add a closed caption text track", async function () {
    xhrMock.lock();

    player.loadVideo({
      transport: manifestInfos.transport,
      url: manifestInfos.url,
      supplementaryTextTracks: {
        url: textTrackInfos.url,
        language: "arm",
        closedCaption: true,
        mimeType: "text/vtt",
      },
    });

    await sleep(1);
    await xhrMock.flush();
    await sleep(1);

    const textTracks = player.getAvailableTextTracks();
    expect(textTracks.length).to.equal(1);
    expect(textTracks[0].language).to.equal("arm");
    expect(textTracks[0].normalized).to.equal("hye");
    expect(textTracks[0].closedCaption).to.equal(true);
    expect(typeof textTracks[0].id).to.equal("string");
    expect(textTracks[0].id).to.not.equal("");
    expect(textTracks[0].active).to.equal(false);

  });

  it("should be able to add multiple external text tracks", async function () {
    xhrMock.lock();

    player.loadVideo({
      transport: manifestInfos.transport,
      url: manifestInfos.url,
      supplementaryTextTracks: [
        {
          url: textTrackInfos.url,
          language: "en",
          closedCaption: false,
          mimeType: "text/vtt",
        },
        {
          url: textTrackInfos.url,
          language: "fr",
          closedCaption: false,
          mimeType: "text/vtt",
        },
        {
          url: textTrackInfos.url,
          language: "ger",
          closedCaption: true,
          mimeType: "text/vtt",
        },
      ],
    });

    await sleep(1);
    await xhrMock.flush();
    await sleep(1);

    const textTracks = player.getAvailableTextTracks();
    expect(textTracks.length).to.equal(3);

    expect(textTracks[0].language).to.equal("en");
    expect(textTracks[0].normalized).to.equal("eng");
    expect(textTracks[0].closedCaption).to.equal(false);
    expect(typeof textTracks[0].id).to.equal("string");
    expect(textTracks[0].id).to.not.equal("");
    expect(textTracks[0].active).to.equal(false);

    expect(textTracks[1].language).to.equal("fr");
    expect(textTracks[1].normalized).to.equal("fra");
    expect(textTracks[1].closedCaption).to.equal(false);
    expect(typeof textTracks[1].id).to.equal("string");
    expect(textTracks[1].id).to.not.equal("");
    expect(textTracks[1].active).to.equal(false);

    expect(textTracks[2].language).to.equal("ger");
    expect(textTracks[2].normalized).to.equal("deu");
    expect(textTracks[2].closedCaption).to.equal(true);
    expect(typeof textTracks[2].id).to.equal("string");
    expect(textTracks[2].id).to.not.equal("");
    expect(textTracks[2].active).to.equal(false);
  });

  it("should switch initially to external text track if set as default language", async function () {
    xhrMock.lock();

    const waysOfWritingDefaultTextTrack = [
      "en",
      "eng",
      { language: "en" },
      { language: "eng" },
      { language: "en", closedCaption: false },
      { language: "eng", closedCaption: false },
    ];

    for (const defaultTextTrack of waysOfWritingDefaultTextTrack) {
      player.loadVideo({
        transport: manifestInfos.transport,
        url: manifestInfos.url,
        supplementaryTextTracks: {
          url: textTrackInfos.url,
          language: "en",
          closedCaption: false,
          mimeType: "text/vtt",
        },
        defaultTextTrack,
      });

      await sleep(1);
      await xhrMock.flush();
      await sleep(1);

      const textTracks1 = player.getAvailableTextTracks();
      expect(textTracks1[0].active).to.equal(true);

      player.loadVideo({
        transport: manifestInfos.transport,
        url: manifestInfos.url,
        supplementaryTextTracks: [
          {
            url: textTrackInfos.url,
            language: "en",
            closedCaption: false,
            mimeType: "text/vtt",
          },
          {
            url: textTrackInfos.url,
            language: "fr",
            closedCaption: false,
            mimeType: "text/vtt",
          },
          {
            url: textTrackInfos.url,
            language: "ger",
            closedCaption: true,
            mimeType: "text/vtt",
          },
        ],
        defaultTextTrack,
      });

      await sleep(1);
      await xhrMock.flush();
      await sleep(1);

      const textTracks2 = player.getAvailableTextTracks();
      expect(textTracks2[0].active).to.equal(true);
    }
  });

  it("should switch initially to a closed caption external text track if set as default language", async function () {
    xhrMock.lock();

    const waysOfWritingDefaultTextTrack = [
      { language: "en", closedCaption: true },
      { language: "eng", closedCaption: true },
    ];

    for (const defaultTextTrack of waysOfWritingDefaultTextTrack) {
      player.loadVideo({
        transport: manifestInfos.transport,
        url: manifestInfos.url,
        supplementaryTextTracks: {
          url: textTrackInfos.url,
          language: "en",
          closedCaption: true,
          mimeType: "text/vtt",
        },
        defaultTextTrack,
      });

      await sleep(1);
      await xhrMock.flush();
      await sleep(1);

      const textTracks1 = player.getAvailableTextTracks();
      expect(textTracks1[0].active).to.equal(true);

      player.loadVideo({
        transport: manifestInfos.transport,
        url: manifestInfos.url,
        supplementaryTextTracks: [
          {
            url: textTrackInfos.url,
            language: "en",
            closedCaption: true,
            mimeType: "text/vtt",
          },
          {
            url: textTrackInfos.url,
            language: "fr",
            closedCaption: false,
            mimeType: "text/vtt",
          },
          {
            url: textTrackInfos.url,
            language: "ger",
            closedCaption: true,
            mimeType: "text/vtt",
          },
        ],
        defaultTextTrack,
      });

      await sleep(1);
      await xhrMock.flush();
      await sleep(1);

      const textTracks2 = player.getAvailableTextTracks();
      expect(textTracks2[0].active).to.equal(true);
    }
  });

  it("should not switch initially to external text track if not set as default language", async function () {
    xhrMock.lock();

    const waysOfWritingDefaultTextTrack = [
      "fr",
      undefined,
      null,
      { language: "english" },
      { language: "en", closedCaption: true },
      { language: "eng", closedCaption: true },
    ];

    for (const defaultTextTrack of waysOfWritingDefaultTextTrack) {
      player.loadVideo({
        transport: manifestInfos.transport,
        url: manifestInfos.url,
        supplementaryTextTracks: {
          url: textTrackInfos.url,
          language: "en",
          closedCaption: false,
          mimeType: "text/vtt",
        },
        defaultTextTrack,
      });

      await sleep(1);
      await xhrMock.flush();
      await sleep(1);

      const textTracks1 = player.getAvailableTextTracks();
      expect(textTracks1[0].active).to.equal(false);

      player.loadVideo({
        transport: manifestInfos.transport,
        url: manifestInfos.url,
        supplementaryTextTracks: [
          {
            url: textTrackInfos.url,
            language: "en",
            closedCaption: false,
            mimeType: "text/vtt",
          },
          {
            url: textTrackInfos.url,
            language: "fr",
            closedCaption: false,
            mimeType: "text/vtt",
          },
          {
            url: textTrackInfos.url,
            language: "ger",
            closedCaption: true,
            mimeType: "text/vtt",
          },
        ],
        defaultTextTrack,
      });

      await sleep(1);
      await xhrMock.flush();
      await sleep(1);

      const textTracks2 = player.getAvailableTextTracks();
      expect(textTracks2[0].active).to.equal(false);
    }
  });
});
<|endoftext|>


<commit_before>var mice = function() {
  mice.hidden = mice.hidden || false;
  // should be mentioned (bug: no mouse update without movement):
  // https://bugs.chromium.org/p/chromium/issues/detail?id=26723 //and ?id=676644
  return {
    hide: function() {
      document.addEventListener('mousemove', function(e) {
        var passive = function() {
          window.clearTimeout(mice.reveal);
          document.body.style.cursor = "url(data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7), none";
          // uri displays 1x1 px black dot in chrome
          mice.hidden = true;
          mice.reveal = window.setTimeout(function() {
            mice.position = { x: e.clientX, y: e.clientY };
            // storing position - if small movement don't reveal mouse cursor
            mice.hidden = false;
          }, 400);
        };

        var active = function() {
          window.clearTimeout(mice.active);
          document.body.style.cursor = "default";
          mice.active = window.setTimeout(passive, 1e3);
        };

        if(mice.position && !mice.hidden) {
          var moving = [
            Math.abs(e.clientX - mice.position.x) > 75,
            Math.abs(e.clientY - mice.position.y) > 75
          ];
          if(moving.includes(true)) { active(); }
        } else if(!mice.position && !mice.hidden) {
          active();
        }
      });
    }
  };
};

var mouse = mice();
// to hide cursor when inactive - call: mouse.hide();
<commit_msg>hide_inactive_mouse update considering relevant(old indeed) webkit fixes<commit_after>const mouse = {
  timer: (t = 2e3) => setTimeout(
    () => (document.documentElement.style.cursor = 'none'),
    t,
  ),
  hide: (t) => {
    document.addEventListener('mousemove', () => {
      clearTimeout(mouse.timer);
      document.documentElement.style.cursor = 'auto';
      mouse.timer(t);
    });
  },
};

// call: mouse.hide(time/*optional*/);
// webkit doesn't update cursor if dev tools are opened
<|endoftext|>