<commit_before><!doctype html>
<html>

<head>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=0.5, maximum-scale=2.0, user-scalable=yes"
    />
    <meta charset="utf-8" />
    <title>10000数字</title>
    <script src="https://cdn.bootcss.com/dot/1.1.2/doT.min.js"></script>
    <script src="https://cdn.bootcss.com/jquery/1.12.4/jquery.min.js"></script>
    <script src="https://cdn.bootcss.com/underscore.js/1.8.3/underscore.js"></script>
    <script src="http://echarts.baidu.com/build/dist/echarts.js"></script>
</head>

<body style="background-color:white;">
    <h4>数字训练</h4>
    <p>八进制、扑克牌的随机训练，仅作为辅助熟悉连接。
        <br> 由于赛制、编码数量等都不相同无法作为真实训练材料，熟悉编码连接后务必使用真实的二进制、扑克牌进行直映训练。
        <br> 二进制、扑克牌所用到的连接共有5041个，在10000连中地位比较重要些，而扑克牌的2704更重要，需要特别优化。
    </p>
    <table style="width:100%;">
        <tr>
            <td style="width:200px">左侧编码从：</td>
            <td style="width:200px">
                <input id="fromLeft" type="text" value="00" />
            </td>
            <td style="width:40px; text-align:right;">到：</td>
            <td>
                <input id="toLeft" type="text" value="99" />
            </td>
        </tr>
        <tr>
            <td>额外(逗号分开)：</td>
            <td style="width:200px">
                <input id="extraLeft" type="text" />
            </td>
            <td style="text-align:left;" colspan="2">&nbsp;
                <input type="button" onclick="DecimalLeft()" value="十进制10000" title="填充十进制的所有组合，最多10000个组合" />&nbsp;
                <input type="button" onclick="OctonaryLeft()" value="八进制4096" title="填充八进制的所有组合，最多4096个组合" />&nbsp;
                <input type="button" onclick="PockerLeft()" value="扑克牌2704" title="填充扑克牌的所有组合，最多2704个组合" />
            </td>
        </tr>
        <tr>
            <td style="width:200px">右侧编码从：</td>
            <td style="width:200px">
                <input id="fromRight" type="text" value="00" />
            </td>
            <td style="width:40px; text-align:right;">到：</td>
            <td>
                <input id="toRight" type="text" value="99" />
            </td>
        </tr>
        <tr>
            <td>额外(逗号分开)：</td>
            <td style="width:200px">
                <input id="extraRight" type="text" />
            </td>
            <td style="text-align:left;" colspan="2">&nbsp;
                <input type="button" onclick="DecimalRight()" value="十进制10000" title="填充十进制的所有组合，最多10000个组合" />&nbsp;
                <input type="button" onclick="OctonaryRight()" value="八进制4096" title="填充八进制的所有组合，最多4096个组合" />&nbsp;
                <input type="button" onclick="PockerRight()" value="扑克牌2704" title="填充扑克牌的所有组合，最多2704个组合" />
            </td>
        </tr>
        <tr>
            <td>数字模式：</td>
            <td colspan="3">
                <select id="modeNumber" onchange="ChangeNumberMode(this)">
                    <option value="10" selected="selected">十进制模式</option>
                    <option value="8">八进制模式</option>
                    <option value="2">二进制模式</option>
                    <option value="52">扑克牌模式</option>
                </select>
            </td>
        </tr>
        <tr>
            <td colspan="4">
                <input type="button" onclick="Randomize()" value="排列组合" style="width:40%" title="从上面的条件的集合中排列组合" />&nbsp;
                <input type="button" onclick="Randomize2()" value="随机生成10页" style="width:40%" title="从上面的条件的集合中随机选取" />
            </td>
        </tr>
    </table>

    <!-- Table1 -->
    <div id="container"></div>
    <textarea id="tpl" style="display:none">
     
    <div class="wrap-table">
    <table style="width:100%;">
        <tbody>
            <tr>
                <td></td>
                <td><p>第1页<span id="pTitle1"></span></p></td>
                <td></td>
                <td>
                    <p><input type="button" onclick="Start(this)" value="开始" /></p>
                </td>
                <td></td>
            </tr>
        <!-- Content Row -->
        {{
        for (var rowIdx = 0; rowIdx < it.list.length; rowIdx ++) {
            var row = it.list[rowIdx];
            var page = 0;
            if (row[0][0] == "&")
                page = parseInt(it.list[rowIdx-1][row.length-1])/25+1;
        }}
        <tr id="row{{=row[row.length-1]}}">
                <td>
                    {{? row[0][0] != "&" }}
                    <span style="border:1px solid gray; padding:0px 5px 1px 5px;background-color:lightgray;" onclick="Finish1(this, {{=row[row.length-1]}})">完成</span>
                    {{??}}
                    <p><input type="button" onclick="Restart(this,{{=page}})" value="重来" /></p>
                    {{?}}
                </td>
                <td>
                    {{? it.mode == 8 && row[0].length === 7 }}
                        {{
                        for (var i = 0; i < 5; i ++) {
                        }}
                        <span onclick="ToggleColor(this)">{{=row[i]}}</span> 
                        {{
                        }
                        }}
                    {{?? it.mode == 2 && row[0].length === 23 }}
                        {{
                        for (var i = 0; i < 5; i ++) {
                        }}
                        <span onclick="ToggleColor(this)">{{=row[i]}}</span> 
                        {{
                        }
                        }}
                    {{?? it.mode == 52 && row[0].length === 7 }}
                        {{
                        for (var i = 0; i < 10; i ++) {
                            var col0 = row[i][0];
                            var col4 = row[i][4];

                            var newCol0 = row[i][0]+row[i][1]+row[i][2];
                            if(col0 == "♥" || col0 == "♦"){
                                newCol0 = "<span style='color:red'>"+newCol0+"</span>"
                            }

                            var newCol4 = row[i][4]+row[i][5]+row[i][6];
                            if(col4 == "♥" || col4 == "♦"){
                                newCol4 = "<span style='color:red'>"+newCol4+"</span>"
                            }

                            var newCol = newCol0 + " " + newCol4;
                        }}
                        <span onclick="ToggleColor(this)" style"width:50px;display:block;">{{=newCol}}</span> 
                        {{
                        }
                        }}
                    {{?? row[0].length === 7 }}
                        {{
                        for (var i = 0; i < 10; i ++) {
                        }}
                        <span onclick="ToggleColor(this)">{{=row[i]}}</span> 
                        {{
                        }
                        }}
                    {{?? rowIdx == it.list.length - 1}}
                        &nbsp;
                    {{??}}
                        <p><span style="float:right">《重来》不清空上面的训练历史，休息后可以重新开始训练</span>第{{=page}}页<span id="pTitle{{=page}}"></span></p>
                    {{?}}
                </td>
                <td style="width:80px;">
                    {{? row[0][0] != "&" }}
                    Row {{=row[row.length-1]}}
                    {{?}}
                </td>
                <td style="width:100px;">
                    {{? row[0][0] != "&" }}
                    <span style="border:1px solid gray; padding:0px 5px 1px 5px;background-color:lightgray;" id="finisherTimerBtn{{=row[row.length-1]}}" onclick="Finish(this, {{=row[row.length-1]}})">完成</span>
                    <span style="border:1px solid white; padding:0px 5px 1px 5px;" id="finisherTimer{{=row[row.length-1]}}"></span>
                    {{??}}
                    <p><input type="button" onclick="Restart(this,{{=page}})" value="重来" /></p>
                    {{?}}
                </td>
                <td></td>
        </tr>
        {{
        }
        }}               
        <!-- End of Content Rows -->
        </tbody>
    </table>
    </div>
            
    </textarea>
    <p>&nbsp;</p>

    <!-- Table2 -->
    <div id="container2"></div>
    <textarea id="tpl2" style="display:none">
     
    <div class="wrap-table">
    <table border="1" cellspacing="0" cellpadding="5" style="border-color:azure">
        <thead>
            <td>行号</td>
            <td>耗时（毫秒）</td>
            <td>耗时</td>
            <td>完成时间</td>
        </thead>
        <tbody>
        <!-- Content Row -->
        {{
        for (var rowIdx = 0; rowIdx < it.List.length; rowIdx ++) {
            var row = it.List[rowIdx];
        }}
        <tr id="row{{=row.id}}">
                <td>
                    {{=row.id}}
                </td>    
                <td>
                    {{=row.diffTimeMs}}
                </td>
                <td>
                    {{? row.diffTimeDisplay == it.Fastest }}
                    <span style="background-color:green;color:white">{{=row.diffTimeDisplay}}</span>
                    {{?? row.diffTimeDisplay == it.Slowest }}
                    <span style="color:red">{{=row.diffTimeDisplay}}</span>
                    {{??}}
                    {{=row.diffTimeDisplay}}
                    {{?}}
                </td>
                <td>
                    {{=row.currentTime}}
                </td>
        </tr>
        {{
        }
        }}               
        <!-- End of Content Rows -->
        </tbody>
        <tfoot>
            <tr>
                <td>最快：{{=it.Fastest}}</td>
                <td>最慢：{{=it.Slowest}}</td>
                <td>平均：{{=it.Average}}</td>
                <td title="总行数超过10行时，除去前3名和后3名后的平均值">平均（除最高最低）：{{=it.Average2}}</td>
            </tr>
        </tfoot>
    </table>
    </div>
            
    </textarea>

    <p>&nbsp;</p>
    <div id="main" style="height:400px;"></div>

    <div>
        <button onclick="ExportRawData()">导出原始数据</button>
    </div>
    <textarea id="rawData" style="width:100%" rows="10"></textarea>
</body>
<script>

    var OctonaryLeft = function () {
        $("#fromLeft").val("00");
        $("#toLeft").val("07");

        var extra = [];
        for (var i = 1; i < 8; i++) {
            for (var j = 0; j < 8; j++) {
                extra.push(i + "" + j);
            }
        }
        $("#extraLeft").val(extra.join(","));
    }

    var OctonaryRight = function () {
        $("#fromRight").val("00");
        $("#toRight").val("07");

        var extra = [];
        for (var i = 1; i < 8; i++) {
            for (var j = 0; j < 8; j++) {
                extra.push(i + "" + j);
            }
        }
        $("#extraRight").val(extra.join(","));
    }

    var PockerLeft = function () {
        $("#fromLeft").val("10");
        $("#toLeft").val("49");
        $("#extraLeft").val("51,52,53,54,61,62,63,64,71,72,73,74");
    }

    var PockerRight = function () {
        $("#fromRight").val("10");
        $("#toRight").val("49");
        $("#extraRight").val("51,52,53,54,61,62,63,64,71,72,73,74");
    }

    var DecimalLeft = function () {
        $("#fromLeft").val("00");
        $("#toLeft").val("99");
        $("#extraLeft").val("");
    }

    var DecimalRight = function () {
        $("#fromRight").val("00");
        $("#toRight").val("99");
        $("#extraRight").val("");
    }

    var Pad = function (num, full) {
        num = parseInt(num);
        if (full) {
            if (num < 10) {
                return "000" + num;
            }
            else if (num < 100) {
                return "00" + num;
            }
            else if (num < 1000) {
                return "0" + num;
            }
            return num + "";
        }
        else {
            return num < 10 ? '0' + num : num + "";
        }
    }

    var Shuffle = function (input) {
        for (var i = input.length - 1; i >= 0; i--) {
            var randomIndex = Math.floor(Math.random() * (i + 1));
            var itemAtIndex = input[randomIndex];
            input[randomIndex] = input[i];
            input[i] = itemAtIndex;
        }
    }

    //所有有效的数字
    var Combination = function () {
        var numbersLeft = [];
        var numbersRight = [];

        //左侧编码
        var fromLeft = parseInt(document.getElementById("fromLeft").value);
        var toLeft = parseInt(document.getElementById("toLeft").value);
        for (var i = fromLeft; i <= toLeft && i < 100; i++) {
            numbersLeft.push(i);
        }
        var extraLeft = document.getElementById("extraLeft").value.split(',');
        for (var i = 0; i < extraLeft.length; i++) {
            var ii = parseInt(extraLeft[i]);
            if (ii && ii >= 0 && ii < 100) numbersLeft.push(ii);
        }

        //右侧编码
        var fromRight = parseInt(document.getElementById("fromRight").value);
        var toRight = parseInt(document.getElementById("toRight").value);
        for (var i = fromRight; i <= toRight && i < 100; i++) {
            numbersRight.push(i);
        }
        var extraRight = document.getElementById("extraRight").value.split(',');
        for (var i = 0; i < extraRight.length; i++) {
            var ii = parseInt(extraRight[i]);
            if (ii && ii >= 0 && ii < 100) numbersRight.push(ii);
        }

        //所有组合编码
        var numbers = [];
        for (var leftIdx = 0; leftIdx < numbersLeft.length; leftIdx++) {
            for (var rightIdx = 0; rightIdx < numbersRight.length; rightIdx++) {
                numbers.push(Pad(numbersLeft[leftIdx]) + Pad(numbersRight[rightIdx]));
            }
        }

        return _.uniq(numbers);
    }

    var pageSize = 10;
    var mode = 10;

    var ChangeNumberMode = function (o) {
        mode = parseInt($(o).val());
        switch (mode) {
            case 2:
            case 8:
                pageSize = 5;
                break;
            case 10:
            case 52:
                pageSize = 10;
                break;
        }
    }

    var Translate = function (num) {
        var newNum = num;
        var n = num + "";
        switch (mode) {
            case 2:
                newNum = TranslateBinary(n.substr(0, 1)) + TranslateBinary(n.substr(1, 1)) + TranslateBinary(n.substr(2, 1)) + TranslateBinary(n.substr(3, 1));
                break;
            case 52:
                newNum = TranslatePocker(n.substr(0, 2)) + TranslatePocker(n.substr(2, 2));
                break;
        }
        return (newNum + "").split("").join(" ");
    }

    var TranslateBinary = function (num) {
        switch (num) {
            case "0":
                return "000";
            case "1":
                return "001";
            case "2":
                return "010";
            case "3":
                return "011";
            case "4":
                return "100";
            case "5":
                return "101";
            case "6":
                return "110";
            case "7":
                return "111";
        }
        return "000";
    }

    var TranslatePocker = function (num) {
        var n = (num + "").substr(1, 1);
        if (num >= 10 && num <= 19) {
            return "♠" + (n == 1 ? "A" : n);
        }
        else if (num >= 20 && num <= 29) {
            return "♥" + (n == 1 ? "A" : n);
        }
        else if (num >= 30 && num <= 39) {
            return "♣" + (n == 1 ? "A" : n);
        }
        else if (num >= 40 && num <= 49) {
            return "♦" + (n == 1 ? "A" : n);
        }
        else if (num >= 51 && num <= 54) {
            var n = num % 50;
            switch (n) {
                case 1:
                    return "♠J";
                case 2:
                    return "♥J";
                case 3:
                    return "♣J";
                case 4:
                    return "♦J";
            }
        }
        else if (num >= 61 && num <= 64) {
            var n = num % 60;
            switch (n) {
                case 1:
                    return "♠Q";
                case 2:
                    return "♥Q";
                case 3:
                    return "♣Q";
                case 4:
                    return "♦Q";
            }
        }
        else if (num >= 71 && num <= 74) {
            var n = num % 70;
            switch (n) {
                case 1:
                    return "♠K";
                case 2:
                    return "♥K";
                case 3:
                    return "♣K";
                case 4:
                    return "♦K";
            }
        }
        return "♠A"
    }

    //将所有组合随机排列
    var Randomize = function () {
        var numbers = Combination();

        //随机排序
        var numbersIndices = [];
        for (var idx = 0; idx < numbers.length; idx++) {
            numbersIndices[idx] = idx;
        }
        Shuffle(numbersIndices);//索引随机排序

        var numbersFinal = [];
        for (var idx = 0; idx < numbers.length; idx++) {
            numbersFinal[idx] = numbers[numbersIndices[idx]];
        }

        var json = {};
        json.mode = mode;
        json.list = [];
        var rowCount = Math.ceil(numbersFinal.length / pageSize);
        for (var rowIdx = 0; rowIdx < rowCount; rowIdx++) {
            var row = [];
            for (var colIdx = 0; colIdx < pageSize; colIdx++) {
                row[colIdx] = Translate(Pad(numbersFinal.pop() || "0000", true));
            }
            row[pageSize] = rowIdx + 1;
            json.list.push(row);

            if ((rowIdx + 1) % 25 == 0) {
                var aa = [];
                for (var x = 0; x <= pageSize; x++) {
                    aa.push('&nbsp;')
                }
                json.list.push(aa);
            }
        }

        var tmpText = doT.template(document.getElementById("tpl").innerText);
        var result = tmpText(json);
        document.getElementById("container").innerHTML = result;
    }

    //从所有组合中随机抽取
    var Randomize2 = function () {
        var numbers = Combination();

        //生成随机的索引
        var numbersIndices = [];
        for (var i = 0; i < 250 * pageSize; i++) {
            numbersIndices.push(Math.floor(Math.random() * numbers.length));
        }

        //按照随机索引提取编码
        var numbersFinal = [];
        for (var i = 0; i < numbersIndices.length; i++) {
            numbersFinal.push(numbers[numbersIndices[i]]);
        }

        var json = {};
        json.mode = mode;
        json.list = [];
        var rowCount = Math.ceil(numbersFinal.length / pageSize);
        for (var rowIdx = 0; rowIdx < rowCount; rowIdx++) {
            var row = [];
            for (var colIdx = 0; colIdx < pageSize; colIdx++) {
                row[colIdx] = Translate(Pad(numbersFinal.pop() || "0000", true));
            }
            row[pageSize] = rowIdx + 1;
            json.list.push(row);

            if ((rowIdx + 1) % 25 == 0) {
                var aa = [];
                for (var x = 0; x <= pageSize; x++) {
                    aa.push('&nbsp;')
                }
                json.list.push(aa);
            }
        }

        var tmpText = doT.template(document.getElementById("tpl").innerText);
        var result = tmpText(json);
        document.getElementById("container").innerHTML = result;
    }

    var ToggleColor = function (o) {
        var mark = $(o).attr("MarkError");
        if (mark) {
            if (mode != 52) {
                $(o).css("color", "");
            }
            $(o).css("text-decoration", "");
            $(o).removeAttr("MarkError");
        }
        else {
            if (mode != 52) {
                $(o).css("color", "red");
            }
            $(o).css("text-decoration", "underline");
            $(o).attr("MarkError", true);
        }
    }

    var startTimeOfLine = 0;
    var data = [];

    var Start = function (o) {
        $("#pTitle1").html(FormatDateTime(new Date()));
        startTimeOfLine = GetTimeStamp();

        data = [];
        DrawGraph();//清空表格
        RefreshData([], []);//重绘曲线
    }

    var FormatDateTime = function (date) {
        var y = date.getFullYear();
        var m = date.getMonth() + 1;
        m = m < 10 ? ('0' + m) : m;
        var d = date.getDate();
        d = d < 10 ? ('0' + d) : d;
        var h = date.getHours();
        var minute = date.getMinutes();
        minute = minute < 10 ? ('0' + minute) : minute;
        var second = date.getSeconds();
        second = second < 10 ? ('0' + second) : second;
        var millisecond = date.getMilliseconds();
        millisecond = millisecond < 10 ? ('0' + millisecond) : millisecond < 100 ? ('00' + millisecond) : millisecond;
        return y + '-' + m + '-' + d + ' ' + h + ':' + minute + ":" + second + "." + millisecond;
    };

    var Finish1 = function (o, id) {
        var o2 = $("#finisherTimerBtn" + id);
        Finish(o2, id);
        $(o).hide();
    }

    var Finish = function (o, id) {
        var newTime = GetTimeStamp();
        if (startTimeOfLine == 0) startTimeOfLine = newTime - 1000 * 300;//如果没有点击开始，则默认5分钟

        var diffTimeMs = newTime - startTimeOfLine;<commit_msg>修改完成样式<commit_after><!doctype html>
<html>

<head>
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=0.5, maximum-scale=2.0, user-scalable=yes"
    />
    <meta charset="utf-8" />
    <title>10000数字</title>
    <script src="https://cdn.bootcss.com/dot/1.1.2/doT.min.js"></script>
    <script src="https://cdn.bootcss.com/jquery/1.12.4/jquery.min.js"></script>
    <script src="https://cdn.bootcss.com/underscore.js/1.8.3/underscore.js"></script>
    <script src="http://echarts.baidu.com/build/dist/echarts.js"></script>
</head>

<body style="background-color:white;">
    <h4>数字训练</h4>
    <p>八进制、扑克牌的随机训练，仅作为辅助熟悉连接。
        <br> 由于赛制、编码数量等都不相同无法作为真实训练材料，熟悉编码连接后务必使用真实的二进制、扑克牌进行直映训练。
        <br> 二进制、扑克牌所用到的连接共有5041个，在10000连中地位比较重要些，而扑克牌的2704更重要，需要特别优化。
    </p>
    <table style="width:100%;">
        <tr>
            <td style="width:200px">左侧编码从：</td>
            <td style="width:200px">
                <input id="fromLeft" type="text" value="00" />
            </td>
            <td style="width:40px; text-align:right;">到：</td>
            <td>
                <input id="toLeft" type="text" value="99" />
            </td>
        </tr>
        <tr>
            <td>额外(逗号分开)：</td>
            <td style="width:200px">
                <input id="extraLeft" type="text" />
            </td>
            <td style="text-align:left;" colspan="2">&nbsp;
                <input type="button" onclick="DecimalLeft()" value="十进制10000" title="填充十进制的所有组合，最多10000个组合" />&nbsp;
                <input type="button" onclick="OctonaryLeft()" value="八进制4096" title="填充八进制的所有组合，最多4096个组合" />&nbsp;
                <input type="button" onclick="PockerLeft()" value="扑克牌2704" title="填充扑克牌的所有组合，最多2704个组合" />
            </td>
        </tr>
        <tr>
            <td style="width:200px">右侧编码从：</td>
            <td style="width:200px">
                <input id="fromRight" type="text" value="00" />
            </td>
            <td style="width:40px; text-align:right;">到：</td>
            <td>
                <input id="toRight" type="text" value="99" />
            </td>
        </tr>
        <tr>
            <td>额外(逗号分开)：</td>
            <td style="width:200px">
                <input id="extraRight" type="text" />
            </td>
            <td style="text-align:left;" colspan="2">&nbsp;
                <input type="button" onclick="DecimalRight()" value="十进制10000" title="填充十进制的所有组合，最多10000个组合" />&nbsp;
                <input type="button" onclick="OctonaryRight()" value="八进制4096" title="填充八进制的所有组合，最多4096个组合" />&nbsp;
                <input type="button" onclick="PockerRight()" value="扑克牌2704" title="填充扑克牌的所有组合，最多2704个组合" />
            </td>
        </tr>
        <tr>
            <td>数字模式：</td>
            <td colspan="3">
                <select id="modeNumber" onchange="ChangeNumberMode(this)">
                    <option value="10" selected="selected">十进制模式</option>
                    <option value="8">八进制模式</option>
                    <option value="2">二进制模式</option>
                    <option value="52">扑克牌模式</option>
                </select>
            </td>
        </tr>
        <tr>
            <td colspan="4">
                <input type="button" onclick="Randomize()" value="排列组合" style="width:40%" title="从上面的条件的集合中排列组合" />&nbsp;
                <input type="button" onclick="Randomize2()" value="随机生成10页" style="width:40%" title="从上面的条件的集合中随机选取" />
            </td>
        </tr>
    </table>

    <!-- Table1 -->
    <div id="container"></div>
    <textarea id="tpl" style="display:none">
     
    <div class="wrap-table">
    <table style="width:100%;">
        <tbody>
            <tr>
                <td></td>
                <td><p>第1页<span id="pTitle1"></span></p></td>
                <td></td>
                <td>
                    <p><input type="button" onclick="Start(this)" value="开始" /></p>
                </td>
                <td></td>
            </tr>
        <!-- Content Row -->
        {{
        for (var rowIdx = 0; rowIdx < it.list.length; rowIdx ++) {
            var row = it.list[rowIdx];
            var page = 0;
            if (row[0][0] == "&")
                page = parseInt(it.list[rowIdx-1][row.length-1])/25+1;
        }}
        <tr id="row{{=row[row.length-1]}}">
                <td>
                    {{? row[0][0] != "&" }}
                    <span style="border:1px solid gray; padding:0px 5px 1px 5px;background-color:lightgray;" onclick="Finish1(this, {{=row[row.length-1]}})">完成</span>
                    {{??}}
                    <p><input type="button" onclick="Restart(this,{{=page}})" value="重来" /></p>
                    {{?}}
                </td>
                <td>
                    {{? it.mode == 8 && row[0].length === 7 }}
                        {{
                        for (var i = 0; i < 5; i ++) {
                        }}
                        <span onclick="ToggleColor(this)">{{=row[i]}}</span> 
                        {{
                        }
                        }}
                    {{?? it.mode == 2 && row[0].length === 23 }}
                        {{
                        for (var i = 0; i < 5; i ++) {
                        }}
                        <span onclick="ToggleColor(this)">{{=row[i]}}</span> 
                        {{
                        }
                        }}
                    {{?? it.mode == 52 && row[0].length === 7 }}
                        {{
                        for (var i = 0; i < 10; i ++) {
                            var col0 = row[i][0];
                            var col4 = row[i][4];

                            var newCol0 = row[i][0]+row[i][1]+row[i][2];
                            if(col0 == "♥" || col0 == "♦"){
                                newCol0 = "<span style='color:red'>"+newCol0+"</span>"
                            }

                            var newCol4 = row[i][4]+row[i][5]+row[i][6];
                            if(col4 == "♥" || col4 == "♦"){
                                newCol4 = "<span style='color:red'>"+newCol4+"</span>"
                            }

                            var newCol = newCol0 + " " + newCol4;
                        }}
                        <span onclick="ToggleColor(this)" style"width:50px;display:block;">{{=newCol}}</span> 
                        {{
                        }
                        }}
                    {{?? row[0].length === 7 }}
                        {{
                        for (var i = 0; i < 10; i ++) {
                        }}
                        <span onclick="ToggleColor(this)">{{=row[i]}}</span> 
                        {{
                        }
                        }}
                    {{?? rowIdx == it.list.length - 1}}
                        &nbsp;
                    {{??}}
                        <p><span style="float:right">《重来》不清空上面的训练历史，休息后可以重新开始训练</span>第{{=page}}页<span id="pTitle{{=page}}"></span></p>
                    {{?}}
                </td>
                <td style="width:80px;">
                    {{? row[0][0] != "&" }}
                    Row {{=row[row.length-1]}}
                    {{?}}
                </td>
                <td style="width:100px;">
                    {{? row[0][0] != "&" }}
                    <span style="border:1px solid gray; padding:0px 5px 1px 5px;background-color:lightgray;" id="finisherTimerBtn{{=row[row.length-1]}}" onclick="Finish(this, {{=row[row.length-1]}})">完成</span>
                    <span style="border:1px solid white; padding:0px 5px 1px 5px;" id="finisherTimer{{=row[row.length-1]}}"></span>
                    {{??}}
                    <p><input type="button" onclick="Restart(this,{{=page}})" value="重来" /></p>
                    {{?}}
                </td>
                <td></td>
        </tr>
        {{
        }
        }}               
        <!-- End of Content Rows -->
        </tbody>
    </table>
    </div>
            
    </textarea>
    <p>&nbsp;</p>

    <!-- Table2 -->
    <div id="container2"></div>
    <textarea id="tpl2" style="display:none">
     
    <div class="wrap-table">
    <table border="1" cellspacing="0" cellpadding="5" style="border-color:azure">
        <thead>
            <td>行号</td>
            <td>耗时（毫秒）</td>
            <td>耗时</td>
            <td>完成时间</td>
        </thead>
        <tbody>
        <!-- Content Row -->
        {{
        for (var rowIdx = 0; rowIdx < it.List.length; rowIdx ++) {
            var row = it.List[rowIdx];
        }}
        <tr id="row{{=row.id}}">
                <td>
                    {{=row.id}}
                </td>    
                <td>
                    {{=row.diffTimeMs}}
                </td>
                <td>
                    {{? row.diffTimeDisplay == it.Fastest }}
                    <span style="background-color:green;color:white">{{=row.diffTimeDisplay}}</span>
                    {{?? row.diffTimeDisplay == it.Slowest }}
                    <span style="color:red">{{=row.diffTimeDisplay}}</span>
                    {{??}}
                    {{=row.diffTimeDisplay}}
                    {{?}}
                </td>
                <td>
                    {{=row.currentTime}}
                </td>
        </tr>
        {{
        }
        }}               
        <!-- End of Content Rows -->
        </tbody>
        <tfoot>
            <tr>
                <td>最快：{{=it.Fastest}}</td>
                <td>最慢：{{=it.Slowest}}</td>
                <td>平均：{{=it.Average}}</td>
                <td title="总行数超过10行时，除去前3名和后3名后的平均值">平均（除最高最低）：{{=it.Average2}}</td>
            </tr>
        </tfoot>
    </table>
    </div>
            
    </textarea>

    <p>&nbsp;</p>
    <div id="main" style="height:400px;"></div>

    <div>
        <button onclick="ExportRawData()">导出原始数据</button>
    </div>
    <textarea id="rawData" style="width:100%" rows="10"></textarea>
</body>
<script>

    var OctonaryLeft = function () {
        $("#fromLeft").val("00");
        $("#toLeft").val("07");

        var extra = [];
        for (var i = 1; i < 8; i++) {
            for (var j = 0; j < 8; j++) {
                extra.push(i + "" + j);
            }
        }
        $("#extraLeft").val(extra.join(","));
    }

    var OctonaryRight = function () {
        $("#fromRight").val("00");
        $("#toRight").val("07");

        var extra = [];
        for (var i = 1; i < 8; i++) {
            for (var j = 0; j < 8; j++) {
                extra.push(i + "" + j);
            }
        }
        $("#extraRight").val(extra.join(","));
    }

    var PockerLeft = function () {
        $("#fromLeft").val("10");
        $("#toLeft").val("49");
        $("#extraLeft").val("51,52,53,54,61,62,63,64,71,72,73,74");
    }

    var PockerRight = function () {
        $("#fromRight").val("10");
        $("#toRight").val("49");
        $("#extraRight").val("51,52,53,54,61,62,63,64,71,72,73,74");
    }

    var DecimalLeft = function () {
        $("#fromLeft").val("00");
        $("#toLeft").val("99");
        $("#extraLeft").val("");
    }

    var DecimalRight = function () {
        $("#fromRight").val("00");
        $("#toRight").val("99");
        $("#extraRight").val("");
    }

    var Pad = function (num, full) {
        num = parseInt(num);
        if (full) {
            if (num < 10) {
                return "000" + num;
            }
            else if (num < 100) {
                return "00" + num;
            }
            else if (num < 1000) {
                return "0" + num;
            }
            return num + "";
        }
        else {
            return num < 10 ? '0' + num : num + "";
        }
    }

    var Shuffle = function (input) {
        for (var i = input.length - 1; i >= 0; i--) {
            var randomIndex = Math.floor(Math.random() * (i + 1));
            var itemAtIndex = input[randomIndex];
            input[randomIndex] = input[i];
            input[i] = itemAtIndex;
        }
    }

    //所有有效的数字
    var Combination = function () {
        var numbersLeft = [];
        var numbersRight = [];

        //左侧编码
        var fromLeft = parseInt(document.getElementById("fromLeft").value);
        var toLeft = parseInt(document.getElementById("toLeft").value);
        for (var i = fromLeft; i <= toLeft && i < 100; i++) {
            numbersLeft.push(i);
        }
        var extraLeft = document.getElementById("extraLeft").value.split(',');
        for (var i = 0; i < extraLeft.length; i++) {
            var ii = parseInt(extraLeft[i]);
            if (ii && ii >= 0 && ii < 100) numbersLeft.push(ii);
        }

        //右侧编码
        var fromRight = parseInt(document.getElementById("fromRight").value);
        var toRight = parseInt(document.getElementById("toRight").value);
        for (var i = fromRight; i <= toRight && i < 100; i++) {
            numbersRight.push(i);
        }
        var extraRight = document.getElementById("extraRight").value.split(',');
        for (var i = 0; i < extraRight.length; i++) {
            var ii = parseInt(extraRight[i]);
            if (ii && ii >= 0 && ii < 100) numbersRight.push(ii);
        }

        //所有组合编码
        var numbers = [];
        for (var leftIdx = 0; leftIdx < numbersLeft.length; leftIdx++) {
            for (var rightIdx = 0; rightIdx < numbersRight.length; rightIdx++) {
                numbers.push(Pad(numbersLeft[leftIdx]) + Pad(numbersRight[rightIdx]));
            }
        }

        return _.uniq(numbers);
    }

    var pageSize = 10;
    var mode = 10;

    var ChangeNumberMode = function (o) {
        mode = parseInt($(o).val());
        switch (mode) {
            case 2:
            case 8:
                pageSize = 5;
                break;
            case 10:
            case 52:
                pageSize = 10;
                break;
        }
    }

    var Translate = function (num) {
        var newNum = num;
        var n = num + "";
        switch (mode) {
            case 2:
                newNum = TranslateBinary(n.substr(0, 1)) + TranslateBinary(n.substr(1, 1)) + TranslateBinary(n.substr(2, 1)) + TranslateBinary(n.substr(3, 1));
                break;
            case 52:
                newNum = TranslatePocker(n.substr(0, 2)) + TranslatePocker(n.substr(2, 2));
                break;
        }
        return (newNum + "").split("").join(" ");
    }

    var TranslateBinary = function (num) {
        switch (num) {
            case "0":
                return "000";
            case "1":
                return "001";
            case "2":
                return "010";
            case "3":
                return "011";
            case "4":
                return "100";
            case "5":
                return "101";
            case "6":
                return "110";
            case "7":
                return "111";
        }
        return "000";
    }

    var TranslatePocker = function (num) {
        var n = (num + "").substr(1, 1);
        if (num >= 10 && num <= 19) {
            return "♠" + (n == 1 ? "A" : n);
        }
        else if (num >= 20 && num <= 29) {
            return "♥" + (n == 1 ? "A" : n);
        }
        else if (num >= 30 && num <= 39) {
            return "♣" + (n == 1 ? "A" : n);
        }
        else if (num >= 40 && num <= 49) {
            return "♦" + (n == 1 ? "A" : n);
        }
        else if (num >= 51 && num <= 54) {
            var n = num % 50;
            switch (n) {
                case 1:
                    return "♠J";
                case 2:
                    return "♥J";
                case 3:
                    return "♣J";
                case 4:
                    return "♦J";
            }
        }
        else if (num >= 61 && num <= 64) {
            var n = num % 60;
            switch (n) {
                case 1:
                    return "♠Q";
                case 2:
                    return "♥Q";
                case 3:
                    return "♣Q";
                case 4:
                    return "♦Q";
            }
        }
        else if (num >= 71 && num <= 74) {
            var n = num % 70;
            switch (n) {
                case 1:
                    return "♠K";
                case 2:
                    return "♥K";
                case 3:
                    return "♣K";
                case 4:
                    return "♦K";
            }
        }
        return "♠A"
    }

    //将所有组合随机排列
    var Randomize = function () {
        var numbers = Combination();

        //随机排序
        var numbersIndices = [];
        for (var idx = 0; idx < numbers.length; idx++) {
            numbersIndices[idx] = idx;
        }
        Shuffle(numbersIndices);//索引随机排序

        var numbersFinal = [];
        for (var idx = 0; idx < numbers.length; idx++) {
            numbersFinal[idx] = numbers[numbersIndices[idx]];
        }

        var json = {};
        json.mode = mode;
        json.list = [];
        var rowCount = Math.ceil(numbersFinal.length / pageSize);
        for (var rowIdx = 0; rowIdx < rowCount; rowIdx++) {
            var row = [];
            for (var colIdx = 0; colIdx < pageSize; colIdx++) {
                row[colIdx] = Translate(Pad(numbersFinal.pop() || "0000", true));
            }
            row[pageSize] = rowIdx + 1;
            json.list.push(row);

            if ((rowIdx + 1) % 25 == 0) {
                var aa = [];
                for (var x = 0; x <= pageSize; x++) {
                    aa.push('&nbsp;')
                }
                json.list.push(aa);
            }
        }

        var tmpText = doT.template(document.getElementById("tpl").innerText);
        var result = tmpText(json);
        document.getElementById("container").innerHTML = result;
    }

    //从所有组合中随机抽取
    var Randomize2 = function () {
        var numbers = Combination();

        //生成随机的索引
        var numbersIndices = [];
        for (var i = 0; i < 250 * pageSize; i++) {
            numbersIndices.push(Math.floor(Math.random() * numbers.length));
        }

        //按照随机索引提取编码
        var numbersFinal = [];
        for (var i = 0; i < numbersIndices.length; i++) {
            numbersFinal.push(numbers[numbersIndices[i]]);
        }

        var json = {};
        json.mode = mode;
        json.list = [];
        var rowCount = Math.ceil(numbersFinal.length / pageSize);
        for (var rowIdx = 0; rowIdx < rowCount; rowIdx++) {
            var row = [];
            for (var colIdx = 0; colIdx < pageSize; colIdx++) {
                row[colIdx] = Translate(Pad(numbersFinal.pop() || "0000", true));
            }
            row[pageSize] = rowIdx + 1;
            json.list.push(row);

            if ((rowIdx + 1) % 25 == 0) {
                var aa = [];
                for (var x = 0; x <= pageSize; x++) {
                    aa.push('&nbsp;')
                }
                json.list.push(aa);
            }
        }

        var tmpText = doT.template(document.getElementById("tpl").innerText);
        var result = tmpText(json);
        document.getElementById("container").innerHTML = result;
    }

    var ToggleColor = function (o) {
        var mark = $(o).attr("MarkError");
        if (mark) {
            if (mode != 52) {
                $(o).css("color", "");
            }
            $(o).css("text-decoration", "");
            $(o).removeAttr("MarkError");
        }
        else {
            if (mode != 52) {
                $(o).css("color", "red");
            }
            $(o).css("text-decoration", "underline");
            $(o).attr("MarkError", true);
        }
    }

    var startTimeOfLine = 0;
    var data = [];

    var Start = function (o) {
        $("#pTitle1").html(FormatDateTime(new Date()));
        startTimeOfLine = GetTimeStamp();

        data = [];
        DrawGraph();//清空表格
        RefreshData([], []);//重绘曲线
    }

    var FormatDateTime = function (date) {
        var y = date.getFullYear();
        var m = date.getMonth() + 1;
        m = m < 10 ? ('0' + m) : m;
        var d = date.getDate();
        d = d < 10 ? ('0' + d) : d;
        var h = date.getHours();
        var minute = date.getMinutes();
        minute = minute < 10 ? ('0' + minute) : minute;
        var second = date.getSeconds();
        second = second < 10 ? ('0' + second) : second;
        var millisecond = date.getMilliseconds();
        millisecond = millisecond < 10 ? ('0' + millisecond) : millisecond < 100 ? ('00' + millisecond) : millisecond;
        return y + '-' + m + '-' + d + ' ' + h + ':' + minute + ":" + second + "." + millisecond;
    };

    var Finish1 = function (o, id) {
        var o2 = $("#finisherTimerBtn" + id);
        Finish(o2, id);
        $(o).css("background-color","white");
        $(o).attr("disabled","disabled");
    }

    var Finish = function (o, id) {
        var newTime = GetTimeStamp();
        if (startTimeOfLine == 0) startTimeOfLine = newTime - 1000 * 300;//如果没有点击开始，则默认5分钟

        var diffTimeMs = newTime - startTimeOfLine;
{'fraction_non_alphanumeric': 0.1731410073312387, 'fraction_numerical': 0.026659049795296583, 'mean_word_length': 1.3089140470433063, 'pattern_counts': {'":': 18, '<': 561, '<?xml version=': 0, '>': 487, 'https://': 6, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4058694', 'n_tokens_mistral': 14203, 'n_tokens_neox': 13300, 'n_words': 2514}