<commit_before>var eid = -1;
var bgmEditorTpl =
    '\
<div class="bgm-editor">\
    <form>\
        <div class="row">\
            <div class="one-half column">\
                <label for="bgmName">番剧名称</label>\
                <input type="text" id="bgmName" class="u-full-width" value="{{bgmTitle}}">\
            </div>\
            <div class="three columns">\
                <label for="bgmCurEpi">已看到</label>\
                <input type="number" id="bgmCurEpi" class="u-full-width" value="{{bgmCurEpi}}">\
            </div>\
            <div class="three columns">\
                <label for="bgmOnAir">更新于</label>\
                <select id="bgmOnAir" class="u-full-width">\
                    <option value="1">周一</option>\
                    <option value="2">周二</option>\
                    <option value="3">周三</option>\
                    <option value="4">周四</option>\
                    <option value="5">周五</option>\
                    <option value="6">周六</option>\
                    <option value="7">周日</option>\
                    <option value="9">不定期</option>\
                    <option value="0">已完结</option>\
                </select>\
            </div>\
        </div>\
        <div class="row bgm-seeker-editor-ctn">\
          <h5>设置检查器</h5>\
        </div><a href="javascript:void(0)" class="button button-primary" onclick="doModify({{bgmBid}})">保存</a> <a href="javascript:void(0)" class="button" onclick="doRemove({{bgmBid}})">删除</a> <a href="javascript:void(0)" class="button" onclick="hideBgmEditor()">取消</a>\
    </form>\
</div>\
    ';

var bgmRowTpl =
    '<div class="row bgm-row" style="margin-top: 50px" data-bid="{{bgmBid}}" data-onair="{{bgmOnAirCode}}"><div class="two-thirds column"><h3><small>[{{bgmOnAir}}]</small> <a href="javascript:void(0)" class="bgm-title">{{bgmTitle}} (<span class="cur-epi">{{bgmCurEpi}}</span>)</a></h3></div><div class="one-third column bgm-action"><a class="button button-primary" href="javascript:void(0)" onclick="doPlus({{bgmBid}})">+1</a> <a class="button" href="javascript:void(0)" onclick="doDecrease({{bgmBid}})">-1</a> <a class="button" href="javascript:void(0)" onclick="doChk({{bgmBid}})">检查</a></div></div>';

var bgmSeekerEditorTpl =
    '<div class="row bgm-seeker-editor" data-id="{{seekerIdx}}">\
        <h6>{{seekerName}} 检查器</h6>\
        <label>检查关键字 <input type="text" value="{{seekerChkKey}}" /></label>\
    </div>';

var bgmChkModalTpl =
    '\
    <div class="bgm-chk-modal">\
        <h3>{{ChkStatus}}</h3>\
    </div>\
    ';

var seekers = [];

anicolle = {

    urls: {
        getAni: "/action/get/",
        modify: "/action/modify/",
        plus: "/action/plus/",
        decrease: "/action/decrease/",
        add: "/action/add",
        remove: "/action/remove/",
        chkup: "/action/chkup/",
        getSeekers: "/action/get_seekers/"
    },

    getSeekers: function() {
        return $.ajax({
            url: this.urls.getSeekers,
            type: "GET",
            dataType: "json"
        })
    },

    getAni: function(bid){
        return $.ajax( {
            url: this.urls.getAni + bid,
            type: "GET",
            dataType: "json"
        });
    },

    plus: function( bid ) {
        return $.ajax({
            url: this.urls.plus + bid,
            type: "GET",
            dataType: "json"
        });
    },

    decrease: function( bid ) {
        return $.ajax({
            url: this.urls.decrease + bid,
            type: "GET",
            dataType: "json"
        });
    },

    modify: function( bid, name, cur_epi, on_air, seeker) {
        return $.ajax({
            url: this.urls.modify + bid,
            type: "POST",
            data: { "name": name, "cur_epi": cur_epi,
                    "on_air": on_air, "seeker": JSON.stringify(seeker)}
        });
    },

    add: function( name, cur_epi, on_air, seeker ) {
        return $.ajax({
            url: this.urls.add,
            type: "POST",
            data: { "name": name, "cur_epi": cur_epi,
                    "on_air": on_air, "seeker": JSON.stringify(seeker)}
        });
    },

    remove: function( bid ) {
        return $.ajax({
            url: this.urls.remove + bid,
            type: "GET"
        });
    },

    chkup: function( bid ) {
        return $.ajax({
            url: this.urls.chkup + bid,
            type: "GET",
            dataType: "json"
        });
    }
};

function showBgmEditor(obj) {
    $(".bgm-editor").remove();
    var beh = bgmEditorTpl;
    if( $(obj).hasClass('bgm-row') ) {
        var r = anicolle.getAni( getBid(obj) );
        r.done(function(data){
            beh = beh.replace(/{{bgmBid}}/g, data['id']);
            beh = beh.replace(/{{bgmTitle}}/g, escapeQuote(data['name']));
            beh = beh.replace(/{{bgmCurEpi}}/g, data['cur_epi']);
            $(obj).append(beh);
            var data_seeker = JSON.parse(data['seeker']);;
            seekers.forEach(function(item, index){
                var bseh = bgmSeekerEditorTpl;
                bseh = bseh.replace(/{{seekerIdx}}/g, index);
                bseh = bseh.replace(/{{seekerName}}/g, item);
                bseh = bseh.replace(/{{seekerChkKey}}/g, getChkkeyFromSeekerData(data_seeker, item));
                $('.bgm-seeker-editor-ctn').append(bseh);
            });
            $(".bgm-editor select option[value="+data[3]+"]").attr("selected", true);
        });
    } else {
        beh = beh.replace(/{{bgmBid}}/g, 0);
        beh = beh.replace(/{{bgmTitle}}/g, "");
        beh = beh.replace(/{{bgmCurEpi}}/g, "");
        beh = beh.replace(/{{bgmChkKey}}/g, "");
        $(obj).append(beh);
        seekers.forEach(function(item, index){
            var bseh = bgmSeekerEditorTpl;
            bseh = bseh.replace(/{{seekerIdx}}/g, index);
            bseh = bseh.replace(/{{seekerName}}/g, item);
                bseh = bseh.replace(/{{seekerChkKey}}/g, "");
            $('.bgm-seeker-editor-ctn').append(bseh);
        });
        $(".bgm-editor select option[value=0]").attr("selected", true);
        $(".bgm-editor a.button:eq(1)").remove();
    }
}

function hideBgmEditor() {
    $('.bgm-editor').remove();
}<commit_msg>Fix namespace error for default on air weekday selection in webui.<commit_after>var eid = -1;
var bgmEditorTpl =
    '\
<div class="bgm-editor">\
    <form>\
        <div class="row">\
            <div class="one-half column">\
                <label for="bgmName">番剧名称</label>\
                <input type="text" id="bgmName" class="u-full-width" value="{{bgmTitle}}">\
            </div>\
            <div class="three columns">\
                <label for="bgmCurEpi">已看到</label>\
                <input type="number" id="bgmCurEpi" class="u-full-width" value="{{bgmCurEpi}}">\
            </div>\
            <div class="three columns">\
                <label for="bgmOnAir">更新于</label>\
                <select id="bgmOnAir" class="u-full-width">\
                    <option value="1">周一</option>\
                    <option value="2">周二</option>\
                    <option value="3">周三</option>\
                    <option value="4">周四</option>\
                    <option value="5">周五</option>\
                    <option value="6">周六</option>\
                    <option value="7">周日</option>\
                    <option value="9">不定期</option>\
                    <option value="0">已完结</option>\
                </select>\
            </div>\
        </div>\
        <div class="row bgm-seeker-editor-ctn">\
          <h5>设置检查器</h5>\
        </div><a href="javascript:void(0)" class="button button-primary" onclick="doModify({{bgmBid}})">保存</a> <a href="javascript:void(0)" class="button" onclick="doRemove({{bgmBid}})">删除</a> <a href="javascript:void(0)" class="button" onclick="hideBgmEditor()">取消</a>\
    </form>\
</div>\
    ';

var bgmRowTpl =
    '<div class="row bgm-row" style="margin-top: 50px" data-bid="{{bgmBid}}" data-onair="{{bgmOnAirCode}}"><div class="two-thirds column"><h3><small>[{{bgmOnAir}}]</small> <a href="javascript:void(0)" class="bgm-title">{{bgmTitle}} (<span class="cur-epi">{{bgmCurEpi}}</span>)</a></h3></div><div class="one-third column bgm-action"><a class="button button-primary" href="javascript:void(0)" onclick="doPlus({{bgmBid}})">+1</a> <a class="button" href="javascript:void(0)" onclick="doDecrease({{bgmBid}})">-1</a> <a class="button" href="javascript:void(0)" onclick="doChk({{bgmBid}})">检查</a></div></div>';

var bgmSeekerEditorTpl =
    '<div class="row bgm-seeker-editor" data-id="{{seekerIdx}}">\
        <h6>{{seekerName}} 检查器</h6>\
        <label>检查关键字 <input type="text" value="{{seekerChkKey}}" /></label>\
    </div>';

var bgmChkModalTpl =
    '\
    <div class="bgm-chk-modal">\
        <h3>{{ChkStatus}}</h3>\
    </div>\
    ';

var seekers = [];

anicolle = {

    urls: {
        getAni: "/action/get/",
        modify: "/action/modify/",
        plus: "/action/plus/",
        decrease: "/action/decrease/",
        add: "/action/add",
        remove: "/action/remove/",
        chkup: "/action/chkup/",
        getSeekers: "/action/get_seekers/"
    },

    getSeekers: function() {
        return $.ajax({
            url: this.urls.getSeekers,
            type: "GET",
            dataType: "json"
        })
    },

    getAni: function(bid){
        return $.ajax( {
            url: this.urls.getAni + bid,
            type: "GET",
            dataType: "json"
        });
    },

    plus: function( bid ) {
        return $.ajax({
            url: this.urls.plus + bid,
            type: "GET",
            dataType: "json"
        });
    },

    decrease: function( bid ) {
        return $.ajax({
            url: this.urls.decrease + bid,
            type: "GET",
            dataType: "json"
        });
    },

    modify: function( bid, name, cur_epi, on_air, seeker) {
        return $.ajax({
            url: this.urls.modify + bid,
            type: "POST",
            data: { "name": name, "cur_epi": cur_epi,
                    "on_air": on_air, "seeker": JSON.stringify(seeker)}
        });
    },

    add: function( name, cur_epi, on_air, seeker ) {
        return $.ajax({
            url: this.urls.add,
            type: "POST",
            data: { "name": name, "cur_epi": cur_epi,
                    "on_air": on_air, "seeker": JSON.stringify(seeker)}
        });
    },

    remove: function( bid ) {
        return $.ajax({
            url: this.urls.remove + bid,
            type: "GET"
        });
    },

    chkup: function( bid ) {
        return $.ajax({
            url: this.urls.chkup + bid,
            type: "GET",
            dataType: "json"
        });
    }
};

function showBgmEditor(obj) {
    $(".bgm-editor").remove();
    var beh = bgmEditorTpl;
    if( $(obj).hasClass('bgm-row') ) {
        var r = anicolle.getAni( getBid(obj) );
        r.done(function(data){
            beh = beh.replace(/{{bgmBid}}/g, data['id']);
            beh = beh.replace(/{{bgmTitle}}/g, escapeQuote(data['name']));
            beh = beh.replace(/{{bgmCurEpi}}/g, data['cur_epi']);
            $(obj).append(beh);
            var data_seeker = JSON.parse(data['seeker']);;
            seekers.forEach(function(item, index){
                var bseh = bgmSeekerEditorTpl;
                bseh = bseh.replace(/{{seekerIdx}}/g, index);
                bseh = bseh.replace(/{{seekerName}}/g, item);
                bseh = bseh.replace(/{{seekerChkKey}}/g, getChkkeyFromSeekerData(data_seeker, item));
                $('.bgm-seeker-editor-ctn').append(bseh);
            });
            $(".bgm-editor select option[value="+data['on_air_day']+"]").attr("selected", true);
        });
    } else {
        beh = beh.replace(/{{bgmBid}}/g, 0);
        beh = beh.replace(/{{bgmTitle}}/g, "");
        beh = beh.replace(/{{bgmCurEpi}}/g, "");
        beh = beh.replace(/{{bgmChkKey}}/g, "");
        $(obj).append(beh);
        seekers.forEach(function(item, index){
            var bseh = bgmSeekerEditorTpl;
            bseh = bseh.replace(/{{seekerIdx}}/g, index);
            bseh = bseh.replace(/{{seekerName}}/g, item);
                bseh = bseh.replace(/{{seekerChkKey}}/g, "");
            $('.bgm-seeker-editor-ctn').append(bseh);
        });
        $(".bgm-editor select option[value=0]").attr("selected", true);
        $(".bgm-editor a.button:eq(1)").remove();
    }
}

function hideBgmEditor() {
    $('.bgm-editor').remove();
}
{'fraction_non_alphanumeric': 0.20043415340086831, 'fraction_numerical': 0.0052259205660073966, 'mean_word_length': 1.9673187022900764, 'pattern_counts': {'":': 16, '<': 165, '<?xml version=': 0, '>': 165, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, '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': '7131262', 'n_tokens_mistral': 4286, 'n_tokens_neox': 4234, 'n_words': 694}