跳转到内容

User:小躍/tools/selftalkarchive.js

维基百科,自由的百科全书
注意:保存之后,你必须清除浏览器缓存才能看到做出的更改。Google ChromeFirefoxMicrosoft EdgeSafari:按住⇧ Shift键并单击工具栏的“刷新”按钮。参阅Help:绕过浏览器缓存以获取更多帮助。
if ( (mw.config.get('wgPageName')=='User_talk:小躍'||mw.config.get('wgPageName')=='User_talk:小躍/News')&&mw.config.get('wgUserName')=='小躍') {//判斷開始
//start First function
mw.loader.using(['jquery.ui'], function() {
	var CountARworkid=0;
	function GetUrlParms(){

    var args=new Object();   

    var query=location.search.substring(1);//获取查询串   

    var pairs=query.split("&");//在逗号处断开   

    for(var   i=0;i<pairs.length;i++)   

    {   

        var pos=pairs[i].indexOf('=');//例如:查找name=value   

            if(pos==-1)   continue;//如果没有找到就跳过   

            var argname=pairs[i].substring(0,pos);//提取name   

            var value=pairs[i].substring(pos+1);//提取value   

            args[argname]=unescape(value);//存为属性   

    }

    return args;

}  
var args = new Object();
args = GetUrlParms();
if(args["section"]!=undefined)

{

//如果要查找参数key:

var GetSection = args["section"] ;
}
var SetSectionName=$('#wpSummary').val();
var SNCount=SetSectionName.length;
var GetSectionName=SetSectionName.substring(2,(SNCount-4));
var talkselect;
if(mw.config.get('wgPageName')=='User_talk:小躍'){
talkselect=	 
	 '<option value=一般存檔>一般存檔'+
     '<option value=通知存檔>通知存檔'
     ;
}else{
talkselect='<option value=技術新聞存檔>技術新聞存檔';
}
     

function SelfTalkArchive( tracePage,destinationPage,edittext,editsummary ) {
	var api = new mw.Api();
	api.get( {
		'action' : 'query',
		'titles' : tracePage,
		'prop'   : 'revisions|info',
		'intoken' : 'edit',
		'rvprop' : 'content',
		'indexpageids' : 1
	} ).done( function (result) {
		result = result.query;
		var page = result.pages[result.pageids[0]];
	
		api.post( {
			'action' : 'edit',
			'title' : destinationPage,
			'appendtext' :edittext,
			'summary' :editsummary,
			'token' : mw.user.tokens.get( 'csrfToken' )
		} ).done( function () {
			
		} );
	} );
}
function SelfTalkAlreadyArchived( tracePage,destinationPage,EditSection,editsummary,linkTo ) {
	var api = new mw.Api();
	api.get( {
		'action' : 'query',
		'titles' : tracePage,
		'prop'   : 'revisions|info',
		'intoken' : 'edit',
		'rvprop' : 'content',
		'indexpageids' : 1
	} ).done( function (result) {
		result = result.query;
		var page = result.pages[result.pageids[0]];
	
		api.post( {
			'action' : 'edit',
			'title' : destinationPage,
			'text' :'',
			'section':EditSection,
			'summary' :editsummary,
			'token' : mw.user.tokens.get( 'csrfToken' )
		} ).done( function () {
				window.location.href = linkTo;
			
		} );
	} );
}

// secure server?

if(GetSection==null){}else if ((mw.config.get('wgAction') == 'edit' || mw.config.get('wgAction') == 'submit') && mw.config.get('wgServer') == '//zh.wikipedia.org') {
    $('#wpDiff').after('\n<input id="wpSelfTalkArchiveButton" value="存檔" title="存檔此標題及標題相關的內容。" type="button"/>');
    $('#wpSelfTalkArchiveButton').click(SelfTalkArchiveEdit);
}

function SelfTalkArchiveEdit(event) {
	event.preventDefault();
	$('<div id="SelfTalkArchiveEdit" title="存檔編輯器">' +
	 '<label for="SelfTalkArchiveEditSelect">選擇存檔的頁面:</label>'+
	 '<select id="SelfTalkArchiveEditSelect" style="padding:1px;vertical-align:baseline;">'+
		talkselect+
     '</select><br/>'+
     '<input id="wpSelfTalkArchiveEditSave" value="開始存檔" title="儲存您的選擇存檔頁面進行儲存工作。" type="button"/>'+
     '</div>'
     ).dialog({
        modal: false,
        autoOpen: true,
        close: function() {CountARworkid++;},
        width: 500
    });
     $('#wpSelfTalkArchiveEditSave').click(SelfTalkArchiveSave);
}
function SelfTalkArchiveSave(event) {
	event.preventDefault();
	if($('#SelfTalkArchiveEditSelect').val()=='通知存檔'){
	SelfTalkArchive(mw.config.get('wgPageName'),'User_talk:小躍/存檔/通知區','\n'+$('#wpTextbox1').val(),SetSectionName+'存檔段落,使用自己的[[User:小躍/tools/selftalkarchive.js|存檔編輯器]]。' );
	SelfTalkAlreadyArchived(mw.config.get('wgPageName'),mw.config.get('wgPageName'),GetSection,SetSectionName+'已完成存檔,使用自己的[[User:小躍/tools/selftalkarchive.js|存檔編輯器]]。',mw.util.getUrl(mw.config.get('wgPageName')) );
	}else if($('#SelfTalkArchiveEditSelect').val()=='一般存檔'){
	SelfTalkArchive(mw.config.get('wgPageName'),'User_talk:小躍/存檔/11','\n'+$('#wpTextbox1').val(),SetSectionName+'存檔段落,使用自己的[[User:小躍/tools/selftalkarchive.js|存檔編輯器]]。' );
	SelfTalkAlreadyArchived(mw.config.get('wgPageName'),mw.config.get('wgPageName'),GetSection,SetSectionName+'已完成存檔,使用自己的[[User:小躍/tools/selftalkarchive.js|存檔編輯器]]。',mw.util.getUrl(mw.config.get('wgPageName')) );
	}else if($('#SelfTalkArchiveEditSelect').val()=='技術新聞存檔'){
	SelfTalkArchive(mw.config.get('wgPageName'),'User_talk:小躍/News/2018-2021','\n'+$('#wpTextbox1').val(),SetSectionName+'存檔段落,使用自己的[[User:小躍/tools/selftalkarchive.js|存檔編輯器]]。' );
	SelfTalkAlreadyArchived(mw.config.get('wgPageName'),mw.config.get('wgPageName'),GetSection,SetSectionName+'已完成存檔,使用自己的[[User:小躍/tools/selftalkarchive.js|存檔編輯器]]。',mw.util.getUrl(mw.config.get('wgPageName')) );
	}
	$('<div id="SelfTalkArchiveSaveSaveDone" title="存檔完成">' +
      '<img src="http://upload.wikimedia.org/wikipedia/commons/4/42/Loading.gif" /><label>正在存檔,請稍後......</label><br/>' +
      '</div>'
     ).dialog({
        modal: false,
        autoOpen: true,
        width: 500
    });
}

//end First function
});
}//判斷結束