<commit_before>﻿<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <style type="text/css">
        * {
            -webkit-touch-callout: none;
            -webkit-user-select: none;
            -khtml-user-select: none;
            -moz-user-select: none;
            -ms-user-select: none;
            user-select: none;
        }

        body {
            margin: 0;
            padding: 0;
            background-color: transparent;
            color: white;
            overflow: hidden;
        }

        #main {
            font-size: 8pt;
        }

        table {
            width: 100%;
        }

        th {
            text-align: left;
            background-color: black;
            color: white;
            opacity: 0.5;
        }
    </style>
    <link rel="stylesheet" type="text/css" href="../common/sexyscroll.css">
    <script src="../vendor/jquery-2.1.1.js"></script>
    <script src="../vendor/lodash.js"></script>
    <script src="../cu-rest/rest.js"></script>
</head>
<body>
    <div id="msg">
    </div>
    <div id="main">
    </div>
    <script>
        console.log(navigator.userAgent);
        if (typeof cuAPI === "undefined") {
            cuAPI = {};
        }
        var serverURL = cuAPI.serverURL || "http://chat.camelotunchained.com:8000/api/";
        var cache = [], gameStart, gameTimeout, gameState, killsTimeout, startTime = new Date();

        // Maintains a window of kills.  Polls the server on a 5s interval asking for all kills since the last
        // known kill, appends these to the array.  The head of the queue will be pruned when we know the start
        // time of the next game.
        function getKills(showKills) {
            var from,
                pollKills = function () {
                    killsTimeout = setTimeout(function () { killsTimeout = null; getKills(showKills); }, 5000);
                };
            if (cache.length) {
                var time = new Date(cache[cache.length - 1].time);
                time.setTime(time.getTime() + 1);
                from = time.toISOString();
            } else {
                // for first run, user the game start time
                from = gameStart;
            }
            Rest.getKills({ start: from }).then(function (kills) {
                cache = cache.concat(kills);
                if (kills.length) showKills(cache);
                pollKills();
            }, function (e) {
                pollKills();
            });
        }

        // remove kills we have cached prior to the start of the current game, so kill starts
        // can just process the entire array (and we keep the memory usage down)
        function pruneHead(start) {
            for (var i = 0; i < cache.length; i++) {
                if (cache[i].time >= start) {
                    break;
                }
            }
            cache = cache.slice(i);
        }

        function checkControlGame() {
            var checkAgainIn = function (ms) {
                    if (!gameTimeout) {
                        // poll regularily while game running
                        // if (gameStart && ms > 5000) ms = 5000;
                        ms = ms | 0;
                        if (ms < 0) ms = 1000;
                        console.log('check again in ' + ms);
                        gameTimeout = setTimeout(function () {
                            gameTimeout = null;
                            setTimeout(checkControlGame, 0);          // restart the check process
                        }, ms);
                    }
                },
                startGame = function (timeLeft) {
                    if (!gameStart) {
                        var start = new Date();
                        start.setTime(((start.getTime() / 1000) - 600 + timeLeft) * 1000);
                        if (gameState <= 2) {
                            // transitioning from no game to game, make sure now is reasonable
                            console.log('game start diff ' + ((new Date()).getTime() - start.getTime()));
                        }
                        gameStart = start.toISOString();
                        console.log('Set game start time: ' + gameStart);
                        pruneHead(gameStart);
                        console.log('[[[[ let the games begin ]]]]');
                        if (killsTimeout) clearTimeout(killsTimeout);
                        killsTimeout = null;
                        getKills(displayKills);
                    }
                    displayKills(cache);
                },
                endGame = function () {
                    if (gameStart) {
                        gameStart = null;
                        console.log('[[[[ Game over man! Game over! ]]]]');
                    }
                    if (killsTimeout) clearTimeout(killsTimeout);
                    killsTimeout = null;
                };
            Rest.getControlGame().then(function (game) {
                switch (game.gameState) {
                    case 0: // Inactive
                        endGame();
                        break;
                    case 1: // waiting for players
                        endGame();
                        break;
                    case 2: // basic game running
                        startGame(game.timeLeft);
                        break;
                    case 3: // advanced game running
                        startGame(game.timeLeft);
                        break;
                }
                checkAgainIn(game.timeLeft * 1000);
                gameState = game.gameState;
            }, function () {<commit_msg>Remove console log messages<commit_after>﻿<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <style type="text/css">
        * {
            -webkit-touch-callout: none;
            -webkit-user-select: none;
            -khtml-user-select: none;
            -moz-user-select: none;
            -ms-user-select: none;
            user-select: none;
        }

        body {
            margin: 0;
            padding: 0;
            background-color: transparent;
            color: white;
            overflow: hidden;
        }

        #main {
            font-size: 8pt;
        }

        table {
            width: 100%;
        }

        th {
            text-align: left;
            background-color: black;
            color: white;
            opacity: 0.5;
        }
    </style>
    <link rel="stylesheet" type="text/css" href="../common/sexyscroll.css">
    <script src="../vendor/jquery-2.1.1.js"></script>
    <script src="../vendor/lodash.js"></script>
    <script src="../cu-rest/rest.js"></script>
</head>
<body>
    <div id="msg">
    </div>
    <div id="main">
    </div>
    <script>
        console.log(navigator.userAgent);
        if (typeof cuAPI === "undefined") {
            cuAPI = {};
        }
        var serverURL = cuAPI.serverURL || "http://chat.camelotunchained.com:8000/api/";
        var cache = [], gameStart, gameTimeout, gameState, killsTimeout, startTime = new Date();

        // Maintains a window of kills.  Polls the server on a 5s interval asking for all kills since the last
        // known kill, appends these to the array.  The head of the queue will be pruned when we know the start
        // time of the next game.
        function getKills(showKills) {
            var from,
                pollKills = function () {
                    killsTimeout = setTimeout(function () { killsTimeout = null; getKills(showKills); }, 5000);
                };
            if (cache.length) {
                var time = new Date(cache[cache.length - 1].time);
                time.setTime(time.getTime() + 1);
                from = time.toISOString();
            } else {
                // for first run, user the game start time
                from = gameStart;
            }
            Rest.getKills({ start: from }).then(function (kills) {
                cache = cache.concat(kills);
                if (kills.length) showKills(cache);
                pollKills();
            }, function (e) {
                pollKills();
            });
        }

        // remove kills we have cached prior to the start of the current game, so kill starts
        // can just process the entire array (and we keep the memory usage down)
        function pruneHead(start) {
            for (var i = 0; i < cache.length; i++) {
                if (cache[i].time >= start) {
                    break;
                }
            }
            cache = cache.slice(i);
        }

        function checkControlGame() {
            var checkAgainIn = function (ms) {
                    if (!gameTimeout) {
                        // poll regularily while game running
                        // if (gameStart && ms > 5000) ms = 5000;
                        ms = ms | 0;
                        if (ms < 0) ms = 1000;
//                        console.log('check again in ' + ms);
                        gameTimeout = setTimeout(function () {
                            gameTimeout = null;
                            setTimeout(checkControlGame, 0);          // restart the check process
                        }, ms);
                    }
                },
                startGame = function (timeLeft) {
                    if (!gameStart) {
                        var start = new Date();
                        start.setTime(((start.getTime() / 1000) - 600 + timeLeft) * 1000);
                        if (gameState <= 2) {
                            // transitioning from no game to game, make sure now is reasonable
                            console.log('game start diff ' + ((new Date()).getTime() - start.getTime()));
                        }
                        gameStart = start.toISOString();
//                        console.log('Set game start time: ' + gameStart);
                        pruneHead(gameStart);
//                        console.log('[[[[ let the games begin ]]]]');
                        if (killsTimeout) clearTimeout(killsTimeout);
                        killsTimeout = null;
                        getKills(displayKills);
                    }
                    displayKills(cache);
                },
                endGame = function () {
                    if (gameStart) {
                        gameStart = null;
//                        console.log('[[[[ Game over man! Game over! ]]]]');
                    }
                    if (killsTimeout) clearTimeout(killsTimeout);
                    killsTimeout = null;
                };
            Rest.getControlGame().then(function (game) {
                switch (game.gameState) {
                    case 0: // Inactive
                        endGame();
                        break;
                    case 1: // waiting for players
                        endGame();
                        break;
                    case 2: // basic game running
                        startGame(game.timeLeft);
                        break;
                    case 3: // advanced game running
                        startGame(game.timeLeft);
                        break;
                }
                checkAgainIn(game.timeLeft * 1000);
                gameState = game.gameState;
            }, function () {
{'fraction_non_alphanumeric': 0.10994213571804314, 'fraction_numerical': 0.011046817464492372, 'mean_word_length': 1.1038362227960161, 'pattern_counts': {'":': 0, '<': 51, '<?xml version=': 0, '>': 49, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6218194', 'n_tokens_mistral': 2992, 'n_tokens_neox': 2729, 'n_words': 741}