Site Notice
hello, world
Difference between revisions of "MediaWiki:Js-InPageEdit-v2/min.js"
From Project-EPB Commons
([InPageEdit] 没有编辑摘要) |
([InPageEdit] 没有编辑摘要) |
||
Line 14: | Line 14: | ||
** https://common.wjghj.cn/wiki/InPageEdit-v2/version-info | ** https://common.wjghj.cn/wiki/InPageEdit-v2/version-info | ||
**/ | **/ | ||
− | + | ; |
Revision as of 00:33, 30 March 2020
/**
*『Wjghj Project Static』
* This _JavaScript_ code is from https://common.wjghj.cn
* GNU GENERAL PUBLIC LICENSE 3.0
*
* MediaWiki JS Plugin: In Page Edit
* Version: Minify
* Author: 机智的小鱼君
* Url:
** https://github.com/Dragon-Fish/wjghj-wiki/edit/master/Gadgets/in-page-edit
** https://common.wjghj.cn/wiki/InPageEdit-v2
* Logs:
** https://github.com/Dragon-Fish/wjghj-wiki/blob/master/Gadgets/in-page-edit/version-info.md
** https://common.wjghj.cn/wiki/InPageEdit-v2/version-info
**/
;(function(){'use strict';if(typeof InPageEdit!=='undefined')throw'[InPageEdit] 已经有一个IPE插件在执行了。';if(mw.config.get('wgVersion').split('.')[1]<21)throw'[InPageEdit] 警告:InPageEdit暂不支持您所在的平台';window.InPageEdit={};InPageEdit.isCanary=false;InPageEdit.version='2.10.0(build_2417)';mw.loader.load('https://cdn.bootcss.com/ssi-modal/1.0.27/js/ssi-modal.min.js');$('title').after('<link id="ssi-modal-style" rel="stylesheet" href="https://cdn.bootcss.com/ssi-modal/1.0.27/styles/ssi-modal.min.css"/>');$('link#ssi-modal-style').after('<link rel="stylesheet" href="https://common.wjghj.cn/css/InPageEdit-v2"/>');mw.loader.load('https://cdn.bootcss.com/material-design-icons/3.0.1/iconfont/material-icons.min.css','text/css');mw.loader.load('https://common.wjghj.cn/js/i18n-js');mw.hook('dev.i18n').add(function(a){a.loadMessages('InPageEdit-v2').then(init)});function init(j){function msg(i){return j.msg(i).escape()};var k=$('<br>'),$clear=$('<div>',{style:'clear:both'}),$hr=$('<hr>'),$progress=$('<div>',{class:'ipe-progress',style:'width: 100%'}).append($('<div>',{class:'ipe-progress-bar'}));InPageEdit.edit=function(g){if(g===undefined)g={};var h=JSON.parse(localStorage.getItem('InPageEditPreference'));var i=decodeURIComponent(g.page),editSection=g.section,titleSection='',editRevision=g.revision,titleRevision='',summaryRevision='',editText,editSummary=h.editSummary,editMinor=h.editMinor,editNotice='',outSideClose=h.outSideClose,jsonGet={action:'parse',page:i,prop:'wikitext',format:'json'},jsonGetInfo={action:'query',titles:i,prop:'revisions|info',inprop:'timestamp|protection',format:'json'},jsonPost={},protection='',basetimestamp,date=new Date(),timestamp=date.getTime(),now=date.toUTCString();InPageEdit.analysis({type:'functionCount',function:'快速编辑'});InPageEdit.analysis({type:'siteCount'});InPageEdit.analysis({type:'dateCount'});if(i===undefined)i=mw.config.get('wgPageName');if(editRevision!==undefined&&editRevision!==''&&editRevision!==mw.config.get('wgCurRevisionId')){ssi_modal.notify('warning',{className:'in-page-edit',content:msg('notify-editing-history'),title:msg('notify-info')});delete jsonGet.page;jsonGet.oldid=editRevision;titleRevision='<span style="font-size:small;">('+msg('editor-title-editRevision')+':'+editRevision+')</span>';summaryRevision='('+msg('editor-summary-rivision')+'[[Special:Diff/'+editRevision+']])'}else{if(editSection!==undefined&&editSection!==''&&editSection!==null){jsonGet.section=editSection;titleSection=msg('editor-title-editSection').replace('$1',editSection)}}if(typeof(MyInPageEditPreference)!=='undefined'){if(typeof(MyInPageEditPreference.editSummary)==='string')editSummary=MyInPageEditPreference.editSummary;if(typeof(MyInPageEditPreference.editMinor)==='boolean')editMinor=MyInPageEditPreference.editMinor;if(typeof(MyInPageEditPreference.outSideClose)==='boolean')outSideClose=MyInPageEditPreference.outSideClose}console.time('[InPageEdit] 获取页面源代码');ssi_modal.show({title:msg('editor-title-editing')+': <u class="editPage">'+i+'</u>'+titleSection+titleRevision,content:$('<div>').append($progress,$('<section>',{class:'editForm'}).append($('<textarea>',{class:'editArea'}),$('<div>',{class:'editOptionsLabel editForm'}).append($('<label>',{for:'editSummary',text:msg('editSummary')}),k,$('<input>',{class:'editSummary',id:'editSummary',placeholder:'Edit vis InPageEdit~',value:editSummary.replace(/\$section/ig,$($.parseHTML(titleSection)).text()).replace(/\$oldid/ig,summaryRevision)}),k,$('<input>',{type:'checkbox',class:'editMinor',id:'editMinor',checked:editMinor}),$('<label>',{for:'editMinor',text:msg('markAsMinor')})))).prop("outerHTML"),outSideClose:outSideClose,className:'in-page-edit ipe-editor timestamp-'+timestamp,sizeClass:'large',buttons:[{label:msg('editor-button-save'),className:'btn btn-primary leftBtn editForm',method:function(){ssi_modal.confirm({className:'in-page-edit',center:true,content:msg('editor-confirm-save'),okBtn:{className:'btn btn-primary',label:msg('confirm')},cancelBtn:{className:'btn btn-secondary',label:msg('cancel')},},function(a){if(a){var b=$('.ipe-editor.timestamp-'+timestamp+' .editArea').val(),minor=$('.ipe-editor.timestamp-'+timestamp+' .editMinor').prop('checked'),section=g.section,summary=$('.ipe-editor.timestamp-'+timestamp+' .editSummary').val();postArticle({text:b,page:i,minor:minor,section:section,summary:summary})}})}},{label:msg('editor-button-preview'),className:'btn btn-secondary leftBtn editForm',method:function(){InPageEdit.analysis({type:'functionCount',function:'previewEdit'});var a=$('.ipe-editor.timestamp-'+timestamp+' .editArea').val();InPageEdit.quickPreview({action:'parse',title:i,text:a,prop:'text',preview:true,format:'json'})}},{label:msg('editor-button-diff'),className:'btn btn-secondary leftBtn editForm',method:function(){InPageEdit.analysis({type:'functionCount',function:'快速差异Edit'});var a=$('.editArea').val();var b={};b.fromtext=editText;b.totext=a;b.hideBtn=true;b.pageName=i;b.isPreview=true;InPageEdit.quickDiff(b)}},{label:msg('editor-button-findAndReplace'),className:'btn btn-secondary leftBtn editForm',method:function(){InPageEdit.analysis({type:'functionCount',function:'查找替换'});InPageEdit.findAndReplace($('.ipe-editor.timestamp-'+timestamp+' .editArea'))}},{label:msg('cancel'),className:'btn btn-danger',method:function(e,a){a.close()}}],onShow:function(f){$(window).bind('beforeunload',function(){return msg('window-leave-confirm')});$('.ipe-editor.timestamp-'+timestamp+' .editForm').hide();$('.ipe-editor.timestamp-'+timestamp+' .ipe-progress').css('margin',Number($(window).height()/3-50)+'px 0');$('.ipe-editor.timestamp-'+timestamp+' .editArea').css('height',$(window).height()/3*2-100);$('.ipe-editor.timestamp-'+timestamp+' .editOptionsLabel').prependTo('.ipe-editor.timestamp-'+timestamp+' .ssi-buttons');$('.leftBtn').appendTo('.ssi-leftButtons');console.time('[InPageEdit] 获取页面基础信息');new mw.Api().get(jsonGetInfo).then(function(b){if(b&&b.query&&b.query.pages){var c=b.query.pages;for(var d in c){if(d!=='-1'){console.timeEnd('[InPageEdit] 获取页面基础信息');console.info('[InPageEdit] 获取页面基础信息成功');if(c[d].touched){$('.ipe-editor.timestamp-'+timestamp).attr('data-basetimestamp',c[d].touched)}else{$('.ipe-editor.timestamp-'+timestamp).attr('data-basetimestamp',now)}if(c[d].protection){if(typeof(c[d].protection[0].level)!=='undefined'){if(c[d].protection[0].type==='edit'){protection=c[d].protection[0].level}}if((protection==='autoconfirmed'&&!InPageEdit.hasRight('autoconfirmed'))||(protection==='sysop'&&!InPageEdit.hasRight('editprotected'))||(mw.config.get('wgNamespaceNumber')===8&&!InPageEdit.hasRight('editinterface'))){ssi_modal.notify('dialog',{className:'in-page-edit',position:'center bottom',title:msg('notify-no-right'),content:msg('editor-no-right'),okBtn:{label:msg('ok'),className:'btn btn-primary',method:function(e,a){a.close()}}});$('.ipe-editor.timestamp-'+timestamp+' .editArea').attr('readonly','readonly');$('.ipe-editor.timestamp-'+timestamp+' button.editForm').attr('disabled','disabled')}}}else{console.timeEnd('[InPageEdit] 获取页面基础信息');console.warn('[InPageEdit] 获取页面基础信息失败')}}}}).fail(function(){console.timeEnd('[InPageEdit] 获取页面基础信息');console.warn('[InPageEdit] 获取页面基础信息失败')});new mw.Api().get(jsonGet).then(function(a){console.timeEnd('[InPageEdit] 获取页面源代码');if(a.error===undefined){editText=a.parse.wikitext['*']}else{console.timeEnd('[InPageEdit] 获取页面源代码');editText='<!-- 警告:无法获取页面内容 -->';console.error('[InPageEdit]警告:无法获取页面内容')}$('.ipe-editor.timestamp-'+timestamp+' .ipe-progress').hide();$('.ipe-editor.timestamp-'+timestamp+' .editForm').fadeIn(500);$('.ipe-editor.timestamp-'+timestamp+' .editArea').val(editText+'\n')}).fail(function(a){console.timeEnd('[InPageEdit] 获取页面源代码');editText='<!-- 警告:无法获取页面内容 -->';console.error('[InPageEdit]警告:无法获取页面内容');$('.ipe-editor.timestamp-'+timestamp+' .ipe-progress').hide();$('.ipe-editor.timestamp-'+timestamp+' .editForm').fadeIn(500);$('.ipe-editor.timestamp-'+timestamp+' .editArea').val(editText+'\n')});$.get(mw.config.get('wgScript'),{action:'raw',title:'MediaWiki:Editnotice-'+mw.config.get('wgNamespaceNumber')},function(b){new mw.Api().post({action:'parse',title:i.replace(/\.(js|css|json)/g,'@Dot@$1'),preview:true,text:b}).then(function(a){editNotice='<section class="editNotice">'+a.parse.text['*'].replace(/\@Dot\@/g,'.')+'</section>';$('.ipe-editor.timestamp-'+timestamp+' .ssi-modalTitle').append($('<a>').attr({id:'showEditNotice',href:'javascript:;'}).click(function(){ssi_modal.show({className:'in-page-edit',center:true,title:msg('editor-title-editNotice'),content:editNotice})}).html('<i class="material-icons">info</i> '+msg('editor-has-editNotice')))})})},beforeClose:function(b){ssi_modal.confirm({className:'in-page-edit',center:true,content:msg('editor-leave-confirm'),okBtn:{className:'btn btn-danger',label:msg('confirm')},cancelBtn:{className:'btn btn-secondary',label:msg('cancel')}},function(a){if(a===true){$(window).unbind('beforeunload');b.options.keepContent=false;b.options.beforeClose='';b.close();ssi_modal.notify('info',{className:'in-page-edit',position:'right top',title:msg('cancel'),content:msg('notify-no-change')})}});return false}});function postArticle(d){InPageEdit.analysis({type:'functionCount',function:'保存编辑'});InPageEdit.progress(msg('editor-title-saving'));jsonPost={action:'edit',basetimestamp:$('.ipe-editor.timestamp-'+timestamp).attr('data-basetimestamp'),starttimestamp:now,text:d.text,title:d.page,minor:d.minor,summary:d.summary,errorformat:'plaintext'}if(d.section!==undefined&&d.section!==''&&d.section!==null){jsonPost.section=d.section;delete jsonPost.basetimestamp}console.info('%c[InPageEdit] Submitting with params: ','color:#fe20d1');console.table(jsonPost);new mw.Api().postWithToken('csrf',jsonPost).then(function(a){InPageEdit.progress(true);$(window).unbind('beforeunload');ssi_modal.notify('success',{className:'in-page-edit',position:'right top',title:msg('notify-success'),content:msg('notify-save-success')});setTimeout(function(){if(d.page===mw.config.get('wgPageName')){window.location=mw.config.get('wgArticlePath').replace('$1',d.page)}else{window.location.reload()}},500)}).fail(function(a,b,c){InPageEdit.progress(false);ssi_modal.notify('error',{className:'in-page-edit',position:'right top',closeAfter:{time:15},title:msg('notify-error'),content:msg('editor-save-error')+':<br/><span style="font-size:amall">'+c.errors[0]['*']+'(<code>'+c.errors[0]['code']+'</code>)</span>'});console.error('[InPageEdit] Submit failed: \nCode: '+c.errors[0]['code']+'\nDescription: '+c.errors[0]['*'])})}};InPageEdit.redirect=function(d){var e={action:'edit',minor:JSON.parse(localStorage.getItem('InPageEditPreference')).editMinor,token:mw.user.tokens.get('editToken'),errorformat:'plaintext'},summary=msg('redirect-summary')+' → [[:$1]]',text='#REDIRECT [[:$1]]',question,target;switch(d){case'to':e.title=mw.config.get('wgPageName');question=msg('redirect-question-to').replace('$1','<b>'+mw.config.get('wgPageName')+'</b>');break;case'from':question=msg('redirect-question-from').replace('$1','<b>'+mw.config.get('wgPageName')+'</b>');e.text=text.replace('$1',mw.config.get('wgPageName'));e.summary=summary.replace('$1',mw.config.get('wgPageName'));break}ssi_modal.show({outSideClose:false,className:'in-page-edit quick-redirect',center:true,sizeClass:'dialog',title:msg('redirect-title'),content:$('<div>').append($('<section>').append($('<span>',{html:question}),k,$('<input>',{id:'redirect-page',style:'width:80%;margin: 0 10%;',onclick:"$(this).css('box-shadow', '')"})),$progress.css('display','none')).prop('outerHTML'),buttons:[{label:msg('confirm'),className:'btn btn-primary btn-single okBtn',method:function(a,b){InPageEdit.analysis({type:'functionCount',function:'快速重定向'});InPageEdit.analysis({type:'dateCount'});InPageEdit.analysis({type:'siteCount'});var c=$('#redirect-page').val();if(c===''||c===mw.config.get('wgPageName')){$('#redirect-page').css('box-shadow','0 0 4px red')}else{$('.in-page-edit.quick-redirect .ipe-progress').show();$('.in-page-edit.quick-redirect section').hide();$('.in-page-edit.quick-redirect .okBtn').attr('disabled','disabled');switch(d){case'to':e.summary=summary.replace('$1',c);e.text=text.replace('$1',c);break;case'from':e.title=c;break}new mw.Api().post(e).done(function(){$('.in-page-edit.quick-redirect .ipe-progress').addClass('done');ssi_modal.notify('success',{className:'in-page-edit',content:msg('notify-redirect-success'),title:msg('notify-success')});if(d==='to'){window.location.reload()}else{$('.in-page-edit.quick-redirect .ipe-progress').addClass('done');setTimeout(function(){b.close()},2000)}}).fail(function(){$('.in-page-edit.quick-redirect .ipe-progress').hide();$('.in-page-edit.quick-redirect section').show();$('.in-page-edit.quick-redirect .okBtn').attr('disabled',false);$('.in-page-edit.quick-redirect .ipe-progress').addClass('done');ssi_modal.notify('error',{className:'in-page-edit',content:msg('notify-redirect-error'),title:msg('notify-error')})})}}}]})};InPageEdit.findAndReplace=function(g){if(g===this.undefined)g=$('.in-page-edit.ipe-editor .editArea');var h=g.val();ssi_modal.show({className:'in-page-edit',sizeClass:'dialog',outSideClose:false,position:'right bottom',title:msg('fAndR-title'),content:$('<div>',{class:'module far-module'}).append($('<div>',{class:'module_content',id:'findfielddiv'}).append($('<section>').append($('<h4>',{text:msg('fAndR-find-text')}),$('<textarea>',{id:'find_this',style:'margin: 0',rows:4}),$('<h4>',{text:msg('fAndR-replace-text')}),$('<textarea>',{id:'replace_with',style:'margin: 0',rows:4})),$('<section>',{style:'padding: 7px 0'}).append($('<input>',{type:'checkbox',id:'globl',checked:'',disabled:''}),$('<label>',{for:'globl',text:msg('fAndR-globl')}),k,$('<input>',{type:'checkbox',id:'case_sen'}),$('<label>',{for:'case_sen',text:msg('fAndR-case-sen')}),k,$('<input>',{type:'checkbox',id:'regex_search'}),$('<label>',{for:'regex_search',text:msg('fAndR-enable-regex')})))).prop('outerHTML'),buttons:[{label:msg('fAndR-button-undo'),className:'btn btn-danger',method:function(e,a){g.val(h);ssi_modal.notify('info',{className:'in-page-edit',title:msg('notify-info'),content:msg('notify-fAndR-undo')})}},{className:'btn btn-primary',label:msg('fAndR-button-replace'),method:function(a,b){if($('#find_this').val()==='')return;var c='',searchexp,$textarea=g,replacewith=$('#replace_with').val().replace(/\r/gi,''),text=$textarea.val().replace(/\r/gi,''),flagg='g',flagi='i',enableregex=0;if($('#globl').prop('checked')===false){flagg=''}if($('#case_sen').prop('checked')===true){flagi=''}if($('#regex_search').prop('checked')===true){enableregex=1}var d=flagg+flagi+'m';if(enableregex===1){c=$('#find_this').val()}else{c=$('#find_this').val().replace(/\r/gi,'').replace(/([.*+?^=!:${}()|\[\]\/\\])/g,'\\$1')}searchexp=new RegExp(c,d);var e=0;var f=text.match(searchexp);if(f!==null){e=f.length}text=text.replace(searchexp,replacewith);$textarea.val(text);ssi_modal.notify('success',{className:'in-page-edit',title:msg('notify-success'),content:msg('notify-fAndR-done').replace('$1',e)})}}]})};InPageEdit.deletepage=function(g){InPageEdit.analysis({type:'functionCount',function:'快速删除'});var h,reason=msg('delete-reason-default');if(g===this.undefined)g=mw.config.get('wgPageName');ssi_modal.show({outSideClose:false,className:'in-page-edit quick-delete',center:true,sizeClass:'dialog',title:msg('delete-title'),content:$('<div>').append($('<strong>',{text:msg('delete-ondev-notify')}),$('<section>',{id:'InPageEditDeletepage'}).append($('<span>',{html:msg('delete-reason').replace('$1','<b>'+g+'</b>')}),k,$('<input>',{type:'checkbox',id:'autoReason',checked:'',disabled:''}),$('<label>',{for:'autoReason',text:msg('delete-reason-auto')}),)).prop('outerHTML'),beforeShow:function(){if(!InPageEdit.hasRight('delete')){ssi_modal.dialog({title:msg('notify-no-right'),content:msg('delete-no-right'),className:'in-page-edit quick-deletepage',center:true,okBtn:{className:'btn btn-primary btn-single'}});return false}},buttons:[{label:msg('cancel'),className:'btn btn-primary',method:function(e,a){a.close()}},{label:msg('confirm'),className:'btn btn-danger',method:function(e,f){ssi_modal.confirm({center:true,className:'in-page-edit',title:msg('delete-confirm-title'),content:msg('delete-confirm-content'),okBtn:{label:msg('confirm'),className:'btn btn-danger'},cancelBtn:{label:msg('cancel'),className:'btn'}},function(d){if(d){var e='['+$('#InPageEditDeletepage #reasonType').val()+'] '+$('#InPageEditDeletepage #reason').val();new mw.Api().postWithToken('csrf',{action:'delete',title:g}).then(function(a){ssi_modal.notify('success',{className:'in-page-edit',title:msg('notify-success'),content:msg('notify-delete-success').replace('$1',g)})}).fail(function(a,b,c){ssi_modal.notify('error',{className:'in-page-edit',title:msg('notify-error'),content:msg('notify-delete-error')+': <br/><span style="font-size:amall">'+c.errors[0]['*']+'(<code>'+c.errors[0]['code']+'</code>)</span>'})});f.close()}else{return false}})}}]})};InPageEdit.renamepage=function(){var d=mw.config.get('wgPageName'),to,reason,movetalk,movesubpages,noredirect,ignorewarnings;ssi_modal.show({outSideClose:false,className:'in-page-edit quick-rename',center:true,sizeClass:'dialog',title:msg('rename-title'),content:'<section id="InPageEditRename"><label for="move-to">'+msg('rename-moveTo').replace('$1','<b>'+d+'</b>')+'</label><br/><input style="width:90%" id="move-to"><br/><input type="checkbox" id="movetalk" checked="checked"/><label for="movetalk">'+msg('rename-movetalk')+'</label><br/><input id="movesubpages" type="checkbox" checked="checked"/><label for="movesubpages">'+msg('rename-movesubpages')+'</label><br/><input id="noredirect" type="checkbox"/><label for="noredirect">'+msg('rename-noredirect')+'</label><br/><label for="move-reason">'+msg('editSummary')+'<br/><input style="width:90%" id="move-reason"/></label></section>',buttons:[{label:msg('cancel'),className:'btn btn-secondary',method:function(a,b){b.close()}},{label:msg('confirm'),className:'btn btn-primary',method:function(){InPageEdit.analysis({type:'functionCount',function:'快速重命名'});InPageEdit.analysis({type:'dateCount'});InPageEdit.analysis({type:'siteCount'});InPageEdit.progress('正在和土豆交涉……');movetalk=$('#movetalk').prop('checked');movesubpages=$('#movesubpages').prop('checked');noredirect=$('#noredirect').prop('checked');to=$('#move-to').val();if($('#move-reason').val()===''){reason=msg('rename-summary')+' → [[:'+to+']]'}else{reason=msg('rename-summary')+' → [[:'+to+']] (Reason: '+$('#move-reason').val()+')'}new mw.Api().postWithToken('csrf',{action:'move',from:d,to:to,reason:reason,movetalk:movetalk,movesubpages:movesubpages,noredirect:noredirect}).done(function(){InPageEdit.progress(true);ssi_modal.notify('success',{className:'in-page-edit',content:msg('notify-rename-success'),title:msg('notify-success')});location.href=mw.config.get('wgArticlePath').replace('$1',to)}).fail(function(a,b,c){InPageEdit.progress(false);ssi_modal.notify('error',{className:'in-page-edit',content:msg('notify-rename-error')+': '+c.error.info+'<code>'+c.error.code+'</code>',title:msg('notify-error')});if(c.error.code==='articleexists'){ssi_modal.dialog({className:'in-page-edit',title:msg('rename-articleexists-title'),center:true,content:msg('rename-articleexists'),okBtn:{label:msg('ok'),className:'btn btn-primary only-btn'}})}})}}],beforeShow:function(){if(!InPageEdit.hasRight('move')){ssi_modal.dialog({title:msg('notify-no-right'),content:msg('rename-no-right'),className:'in-page-edit quick-deletepage',center:true,okBtn:{className:'btn btn-primary btn-single'}});return false}}})};InPageEdit.preference=function(){InPageEdit.analysis({type:'functionCount',function:'插件设置'});var c=JSON.parse(localStorage.getItem('InPageEditPreference')),minor=c.editMinor,summary=c.editSummary,outSideClose=c.outSideClose;ssi_modal.show({outSideClose:false,title:msg('preference-title')+' - '+InPageEdit.version,content:'<section id="InPageEditSettingBox"><h4>'+msg('preference-editor-label')+'</h4><input id="ipeSetoutSideClose" type="checkbox"/> <label for="ipeSetoutSideClose">'+msg('preference-outSideClose')+'</label><br/><input id="ipeSetMinor" type="checkbox"/> <label for="ipeSetMinor">'+msg('preference-setMinor')+'</label><br/><label><h4>'+msg('preference-summary-label')+'</h4>'+msg('preference-editSummary').replace('%br%','<br/>').replace('$1','<code>$oldid</code>').replace('$2','<code>'+msg('editor-summary-rivision')+' [[Special:Diff/oldid]]</code>').replace('$3','<code>$section</code>').replace('$4','<code>/* '+msg('editor-title-editSection')+' */</code>')+'<br/><span style="font-size:10px"></span><input id="ipeSetSummary" value="'+summary+'" style="width:100%"/></label><br/><h4>'+msg('preference-analysis-label')+'</h4><span style="font-size: small; line-height: 0.9em;">'+msg('preference-analysis-view').replace('$1','<a href="https://doc.wjghj.cn/InPageEditAnalysis/" target="_blank">https://doc.wjghj.cn/InPageEditAnalysis/</a>')+'</span><h4>'+msg('preference-about-label')+'</h4><button class="btn btn-secondary" onclick="mw.loader.load(\'https://common.wjghj.cn/js/InPageEdit-v2.js/about\')">'+msg('preference-aboutAndHelp')+'</button> <button class="btn btn-secondary" onclick="InPageEdit.versionInfo()">'+msg('preference-updatelog')+'</button><hr><span style="font-size: small;line-height: 0.9em">'+msg('preference-savelocal-label')+'<br/>'+msg('preference-savelocal')+'<a href="javascript:;" id="ipeSaveLocalShow">'+msg('preference-savelocal-btn')+'</a></span></section>',sizeClass:'dialog',className:'in-page-edit ipe-preference',center:true,buttons:[{label:msg('preference-reset'),className:'btn btn-danger',method:function(){$('#InPageEditSettingBox #ipeSetoutSideClose').prop('checked',true);$('#InPageEditSettingBox #ipeSetMinor').prop('checked',false);$('#InPageEditSettingBox #ipeSetSummary').val(msg('preference-summary-default'))}},{label:msg('preference-save'),className:'btn btn-primary',method:function(a,b){localStorage.setItem('InPageEditPreference',JSON.stringify({outSideClose:$('#InPageEditSettingBox #ipeSetoutSideClose').prop('checked'),editMinor:$('#InPageEditSettingBox #ipeSetMinor').prop('checked'),editSummary:$('#InPageEditSettingBox #ipeSetSummary').val()}));b.close()}}]});$('#ipeSaveLocalShow').click(function(){ssi_modal.dialog({className:'in-page-edit',center:true,title:msg('preference-savelocal-popup-title'),content:'<section id="ipeSaveLocal"><b>'+msg('preference-savelocal-popup-notrecommended')+'</b><br/>'+msg('preference-savelocal-popup')+'<br/><input style="width:100%" readonly="readonly" onclick="$(this).select()"/><br/>'+msg('preference-savelocal-popup-notice')+'</section>',okBtn:{className:'btn btn-primary btn-single'}});$('#ipeSaveLocal input').val('window.MyInPageEditPreference = '+JSON.stringify({outSideClose:$('#InPageEditSettingBox #ipeSetoutSideClose').prop('checked'),editMinor:$('#InPageEditSettingBox #ipeSetMinor').prop('checked'),editSummary:$('#InPageEditSettingBox #ipeSetSummary').val()})+';')});if(outSideClose){$('#InPageEditSettingBox #ipeSetoutSideClose').prop('checked',true)}if(minor){$('#InPageEditSettingBox #ipeSetMinor').prop('checked',true)}if(typeof(MyInPageEditPreference)!=='undefined'){$('.ipe-preference .ssi-buttons .ssi-modalBtn').attr('disabled','');if(typeof(MyInPageEditPreference.editMinor)==='boolean'){$('#InPageEditSettingBox #ipeSetMinor').prop('checked',MyInPageEditPreference.editMinor).attr('disabled','')}if(typeof(MyInPageEditPreference.outSideClose)==='boolean'){$('#InPageEditSettingBox #ipeSetoutSideClose').prop('checked',MyInPageEditPreference.outSideClose).attr('disabled','')}if(typeof(MyInPageEditPreference.editSummary)==='string'){$('#InPageEditSettingBox #ipeSetSummary').attr('disabled','').val(MyInPageEditPreference.editSummary)}ssi_modal.dialog({content:msg('preference-savelocal-popup-haslocal').replace('$1','<a href="'+mw.util.getUrl('Special:Mypage/common.js')+'">'+msg('preference-savelocal-popup-yourjspage')+'</a>'),className:'in-page-edit',center:true,okBtn:{className:'btn btn-primary btn-single'}})}};InPageEdit.quickDiff=function(f){InPageEdit.analysis({type:'dateCount'});InPageEdit.analysis({type:'siteCount'});if($('[href*="mediawiki.diff.styles"]').length<1){mw.loader.load(mw.config.get('wgScriptPath')+'/load.php?modules=mediawiki.legacy.shared|mediawiki.diff.styles&only=styles','text/css')}if($('.quick-diff').length>0){console.info('[InPageEdit] Quick diff 正在加载新内容');$('.in-page-edit.quick-diff .diffArea').hide().html(msg('diff-loading'));if(f.isPreview){$('.quick-diff').appendTo('body')}}else{ssi_modal.show({className:'in-page-edit quick-diff',sizeClass:'large',fixedHeight:true,fitScreen:true,title:'<span class="pageName">'+msg('diff-loading')+'</span>',content:'<div class="ipe-progress" style="width:100%"><div class="ipe-progress-bar"></div></div><div class="diffArea"></div>',buttons:[{label:msg('diff-button-todiffpage'),className:'btn btn-secondary toDiffPage',method:function(){}}]})}$('.in-page-edit.quick-diff .ipe-progress').show().css('margin-top',$('.in-page-edit.quick-diff .ipe-progress').parent().height()/2);$('.quick-diff button.toDiffPage').unbind();f.action='compare';f.prop='diff|diffsize|rel|ids|title|user|comment|parsedcomment|size';f.format='json';new mw.Api().post(f).then(function(b){var c=b.compare['*'];$('.in-page-edit.quick-diff .ipe-progress').hide();if(f.pageName===undefined){var d=b.compare.totitle}else{var d=f.pageName}var e=function(a){return'<a href="'+mw.util.getUrl('User:'+a)+'">'+a+'</a> ( <a href="'+mw.util.getUrl('User_talk:'+a)+'">'+msg('diff-usertalk')+'</a> | <a href="'+mw.util.getUrl('Special:Contributions/'+a)+'">'+msg('diff-usercontrib')+'</a> | <a href="'+mw.util.getUrl('Special:Block/'+a)+'">'+msg('diff-userblock')+'</a> )'}$('.quick-diff .pageName').html(msg('diff-title')+': <u>'+d+'</u>');$('.quick-diff .diffArea').show().html('<table class="diff diffTable">'+'<colgroup>'+'<col class="diff-marker">'+'<col class="diff-content">'+'<col class="diff-marker">'+'<col class="diff-content">'+'</colgroup>'+'<tbody>'+'<tr class="diff-title">'+'<td colspan="2" class="diff-otitle">'+'<a class="" href="'+mw.config.get('wgScript')+'?oldid='+b.compare.fromrevid+'">'+b.compare.fromtitle+'</a> ('+msg('diff-version')+b.compare.fromrevid+') (<a class="editLink" href="'+mw.config.get('wgScript')+'?action=edit&title='+b.compare.fromtitle+'&oldid='+b.compare.fromrevid+'">'+msg('diff-edit')+'</a>)<br/>'+e(b.compare.fromuser)+'<br/>('+b.compare.fromparsedcomment+')<br/><a class="prevVersion" href="javascript:void(0);" onclick="InPageEdit.quickDiff({fromrev:'+b.compare.fromrevid+',torelative:\'prev\'});InPageEdit.analysis({type:\'functionCount\',function:\'快速差异History\'});">←'+msg('diff-prev')+'</a>'+'</td>'+'<td colspan="2" class="diff-ntitle">'+'<a class="" href="'+mw.config.get('wgScript')+'?oldid='+b.compare.torevid+'">'+b.compare.totitle+'</a> ('+msg('diff-version')+b.compare.torevid+') (<a class="editLink" href="'+mw.config.get('wgScript')+'?action=edit&title='+b.compare.totitle+'&oldid='+b.compare.torevid+'">'+msg('diff-edit')+'</a>)<br/>'+e(b.compare.touser)+'<br/>('+b.compare.toparsedcomment+')<br/><a class="nextVersion" href="javascript:void(0);" onclick="InPageEdit.quickDiff({fromrev:'+b.compare.torevid+',torelative:\'next\'});InPageEdit.analysis({type:\'functionCount\',function:\'快速差异History\'});">'+msg('diff-nextv')+'→</a>'+'</td>'+'</tr>'+c+'<tr class="diffSize" style="text-align: center;"><td colspan="2">'+b.compare.fromsize+msg('diff-bytes')+'</td><td colspan="2">'+b.compare.tosize+msg('diff-bytes')+'</td></tr>'+'</tbody>'+'</table>');$('.quick-diff button.toDiffPage').click(function(){location.href=mw.config.get('wgScript')+'?oldid='+b.compare.fromrevid+'&diff='+b.compare.torevid});InPageEdit.articleLink($('.quick-diff .editLink'));if(f.isPreview===true){$('.quick-diff button.toDiffPage').hide();$('.quick-diff .diff-otitle').html('<b>'+msg('diff-title-original-content')+'</b>');$('.quick-diff .diff-ntitle').html('<b>'+msg('diff-title-your-content')+'</b>')}if(b.compare.fromsize===undefined||b.compare.tosize===undefined){$('.quick-diff .diffSize').hide()}if(b.compare.fromrevid===undefined&&f.isPreview!==true){$('.quick-diff .diff-otitle').html('<span class="noNextVerson"><b>没有更多了哟~</b><br/><span style="font-size:10px">没有之前的版本了!之前的版本即使是盘古也没有见过呀!</span></span>')}else if(b.compare.torevid===undefined&&f.isPreview!==true){$('.quick-diff .diff-ntitle').html('<span class="noNextVerson"><b>没有更多了哟~</b><br/><span style="font-size:10px">没有之后的版本了!一点也没有了!!真的没有了!!!</span></span>')}}).fail(function(a,b,c){$('.in-page-edit.quick-diff .ipe-progress').hide();$('.diffArea').html(msg('diff-error')+': '+b)})};InPageEdit.loadQuickDiff=function(){function addLink(b){$('.mw-changeslist-groupdiff, .mw-changeslist-diff, .mw-changeslist-diff-cur, .mw-history-histlinks a').unbind('click',c);var c=$('.mw-changeslist-groupdiff, .mw-changeslist-diff, .mw-changeslist-diff-cur, .mw-history-histlinks a').click(function(e){e.preventDefault();InPageEdit.analysis({type:'functionCount',function:'快速差异RC'});var a=$(this),href=a.attr('href'),diff=mw.util.getParamValue('diff',href),curid=mw.util.getParamValue('curid',href),oldid=mw.util.getParamValue('oldid',href);if(diff==='0'){InPageEdit.quickDiff({fromrev:oldid,toid:curid})}else if(diff==='prev'||diff==='next'||diff==='cur'){InPageEdit.quickDiff({fromrev:oldid,torelative:diff})}else{InPageEdit.quickDiff({fromrev:oldid,torev:diff})}})}if($('.mw-rcfilters-enabled').length>0){setInterval(addLink,500);$('.mw-rcfilters-enabled').addClass('ipe-continuous-active')}else{addLink()}if(mw.config.get('wgAction')==='history'){$('.historysubmit.mw-history-compareselectedversions-button').after($('<button>').text(msg('quick-diff')).click(function(e){e.preventDefault();InPageEdit.analysis({type:'functionCount',function:'快速差异History'});var a=$('.selected.before').attr('data-mw-revid'),after=$('.selected.after').attr('data-mw-revid');InPageEdit.quickDiff({fromrev:after,torev:a})}));$('[data-mw-revid]').each(function(){var a=$(this),oldid=a.attr('data-mw-revid');a.find('.mw-history-undo').after($('<span>').html(' | <a class="in-page-edit-article-link" href="javascript:void(0);" onclick="InPageEdit.edit({page:mw.config.get(\'wgPageName\'),revision:'+oldid+'});">'+msg('quick-edit')+'</a>'))})}};InPageEdit.articleLink=function(c){if(c===undefined)c=$('#mw-content-text a:not(.new)');c.each(function(i){if($(this).attr('href')===undefined)return;var a=$(this).attr('href'),title=mw.util.getParamValue('title',a),section=mw.util.getParamValue('section',a),revision=mw.util.getParamValue('oldid',a);if(a.split('/')['2']!==location.href.split('/')['2']&&a.substr(0,1)!=='/')return;if(title===null){var b=mw.config.get('wgArticlePath').replace('$1','');if(b==='/'){b=mw.config.get('wgServer').substring(mw.config.get('wgServer').length-4)+'/'}title=a.split(b).pop().split('?')['0']}if(mw.util.getParamValue('action',a)==='edit'&&title!==undefined&§ion!=='new'){$(this).after($('<span>',{'class':'in-page-edit-article-link-group'}).append($('<a>',{'href':'javascript:void(0)','class':'in-page-edit-article-link'}).text(msg('quick-edit')).click(function(){if(revision!==null){InPageEdit.edit({page:title,revision:revision})}else{InPageEdit.edit({page:title,section:section})}})))}})};InPageEdit.quickPreview=function(d){var e=new Date().getTime();console.time('[InPageEdit] Request preview');ssi_modal.show({sizeClass:'large',className:'in-page-edit previewbox',content:'<div class="ipe-progress" style="width:100%"><div class="ipe-progress-bar"></div></div><section id="InPageEditPreview" data-timestamp="'+e+'" style="display:none">'+msg('preview-placeholder')+'</section>',title:msg('preview-title'),fixedHeight:true,fitScreen:true,buttons:[{label:'',className:'hideThisBtn'}],onShow:function(c){$('.previewbox .ipe-progress').css('margin-top',$('.previewbox .ipe-progress').parent().height()/2);$('.previewbox .hideThisBtn').hide();new mw.Api().post(d).then(function(a){console.timeEnd('[InPageEdit] Request preview');var b=a.parse.text['*'];$('.previewbox .ipe-progress').hide(150);$('#InPageEditPreview[data-timestamp="'+e+'"]').fadeIn(500).html(b)}).fail(function(){console.timeEnd('[InPageEdit] Request preview');console.warn('[InPageEdit] 预览失败');$('.previewbox .ipe-progress').hide(150);$('#InPageEditPreview[data-timestamp="'+e+'"]').fadeIn(500).html(msg('preview-error'))})}})};InPageEdit.progress=function(a){if(a===true){$('.in-page-edit.loadingbox .ssi-modalTitle').html(msg('done'));$('.in-page-edit.loadingbox .ipe-progress').addClass('done')}else if(a===false){if($('.in-page-edit.loadingbox').length>0){$('.in-page-edit.loadingbox').appendTo('body');ssi_modal.close()}}else{if($('.in-page-edit.loadingbox').length>0)return;if(typeof(a)==='undefined'){a='Loading...'}ssi_modal.show({title:a,content:'<div class="ipe-progress" style="width:100%"><div class="ipe-progress-bar"></div></div>',className:'in-page-edit loadingbox',center:true,sizeClass:'dialog',closeIcon:false,outSideClose:false})}};InPageEdit.analysis=function(a){var b=a.type;switch(b){case'siteCount':$.ajax({url:'https://doc.wjghj.cn/InPageEditAnalysis/site/log.php',data:{'sitename':mw.config.get('wgSiteName')},dataType:'json'});break;case'dateCount':var c=new Date(),y=c.getFullYear(),m=Number(c.getMonth()+1),d=Number(c.getDate());if(m<10)m='0'+m;if(d<10)d='0'+d;var e=y+'-'+m+'-'+d;$.ajax({url:'https://doc.wjghj.cn/InPageEditAnalysis/date/log.php',data:{'date':e},dataType:'json'});break;case'functionCount':$.ajax({url:'https://doc.wjghj.cn/InPageEditAnalysis/function/log.php',data:{'function':a.function},dataType:'json'});break}};(function(){var b=mw.config.get('wgUserName');if(b===null){console.warn('[InPageEdit] 警告:用户未登录');mw.config.set('wgUserRights','');return}new mw.Api().get({action:'query',list:'users',usprop:'rights',ususers:b}).done(function(a){console.info('[InPageEdit] 成功获取用户权限信息');mw.config.set('wgUserRights',a.query.users[0]['rights'])}).fail(function(){console.warn('[InPageEdit] 警告:无法获取用户权限信息');mw.config.set('wgUserRights','')})}());InPageEdit.hasRight=function(a){if(mw.config.get('wgUserRights').indexOf(a)>-1){return true}else{return false}};if(InPageEdit.isCanary){InPageEdit.specialNotice={id:JSON.parse(localStorage.getItem('i18n-cache-InPageEdit-v2-content'))['_metadata']['noticeid-canary'],title:msg('version-notice-canary-title'),content:msg('version-notice-canary')}}else{InPageEdit.specialNotice={id:JSON.parse(localStorage.getItem('i18n-cache-InPageEdit-v2-content'))['_metadata']['noticeid'],title:msg('version-notice-title'),content:msg('version-notice')}}InPageEdit.versionInfo=function(){var d=InPageEdit.version;ssi_modal.show({className:'in-page-edit version-info',title:msg('updatelog-title')+' - <span id="yourVersion">'+msg('updatelog-loading')+'</span>',content:'<div id="IPEversionInfoPlaceholder" class="ipe-progress" style="margin: calc(30% - 1em) auto;"><div class="ipe-progress-bar"></div></div><section style="display:none" id="IPEversionInfo"></section>',fitScreen:true,fixedHeight:true,buttons:[{label:msg('close'),className:'btn btn-danger',method:function(a,b){b.close()}},{label:'GitHub',className:'btn btn-secondary',method:function(){location.href='https://github.com/Dragon-Fish/InPageEdit-v2'}},{label:msg('updatelog-about'),className:'btn btn-secondary',method:function(){location.href='https://common.wjghj.cn/wiki/InPageEdit-v2'}}]});$.ajax({url:'https://common.wjghj.cn/api.php',dataType:'jsonp',type:'get',data:{page:'InPageEdit-v2/version-info',action:'parse',prop:'text',format:'json'},success:function(b){var c=b.parse.text['*'];$('#IPEversionInfoPlaceholder').addClass('done').delay(800).fadeOut(200);$('#IPEversionInfo').html(c);$('#yourVersion').html(localStorage.InPageEditVersion);$('#IPEversionInfo .mw-headline').each(function(){var a=$(this),text=a.text();if(text===d){a.html('<em class="curVersion" style="background: lightyellow; font-weight: bold">★ '+a.text()+'</em>')}});setTimeout('$("#IPEversionInfo").fadeIn(800)',1000)}})};$(function(){var c=InPageEdit.version;if(localStorage.InPageEditVersion===null||localStorage.InPageEditVersion!==c){ssi_modal.notify('',{title:msg('updatelog-update-success-title'),content:msg('updatelog-update-success').replace('$1',c),className:'in-page-edit',buttons:[{className:'btn btn-primary',label:msg('updatelog-button-versioninfo'),method:function(a,b){localStorage.InPageEditVersion=c;InPageEdit.versionInfo();b.close()}}],closeAfter:{time:30,resetOnHover:true},onClose:function(){ssi_modal.notify('',{className:'in-page-edit',content:msg('updatelog-after-close').replace('$1','<a href="'+msg('updatelog-url')+'" target="_blank">'+msg('updatelog-url')+'</a>').replace('$2','<a href="https://github.com/Dragon-Fish/InPageEdit-v2">'+msg('updatelog-file-issue')+'</a>'),closeAfter:{time:10}});localStorage.InPageEditVersion=c}})}if(localStorage.InPageEditNoticeId!==InPageEdit.specialNotice.id){ssi_modal.notify('dialog',{className:'in-page-edit ipe-special-notice',title:InPageEdit.specialNotice.title,content:InPageEdit.specialNotice.content,okBtn:{label:msg('updatelog-dismiss'),className:'btn btn-primary'}},function(e,a){localStorage.InPageEditNoticeId=InPageEdit.specialNotice.id;a.close()})}});(function(){InPageEdit.loadQuickDiff();if(mw.config.get('wgIsArticle')===false){console.warn('%c[InPageEdit] 不是文章页面,未载入工具盒。','color:orange;font-size:1.2em;font-weight:bold');return}if(localStorage.getItem('InPageEditPreference')===null){var a={};a.outSideClose=true;a.editMinor=false;a.editSummary=msg('preference-summary-default');localStorage.setItem('InPageEditPreference',JSON.stringify(a))}$('<div>',{id:'ipe-edit-toolbox'}).append($('<ul>',{class:'btn-group group1'}).append($('<li>',{class:'btn-tip-group'}).append($('<div>',{class:'btn-tip',text:msg('quick-edit')}),$('<button>',{id:'edit-btn',class:'ipe-toolbox-btn material-icons',text:'edit'})),$('<li>',{class:'btn-tip-group'}).append($('<div>',{class:'btn-tip',text:msg('redirect-from')}),$('<button>',{id:'redirectfrom-btn',class:'ipe-toolbox-btn material-icons',text:'flight_land'})),$('<li>',{class:'btn-tip-group'}).append($('<div>',{class:'btn-tip',text:msg('redirect-to')}),$('<button>',{id:'redirectto-btn',class:'ipe-toolbox-btn material-icons',text:'flight_takeoff'}))),$('<ul>',{class:'btn-group group2'}).append($('<div>',{style:'display: flex;'}).append($('<li>',{class:'btn-tip-group'}).append($('<div>',{class:'btn-tip',text:msg('quick-delete')}),$('<button>',{id:'deletepage-btn',class:'ipe-toolbox-btn material-icons',text:'delete_forever'})),$('<li>',{class:'btn-tip-group'}).append($('<div>',{class:'btn-tip',text:msg('quick-rename')}),$('<button>',{id:'renamepage-btn',class:'ipe-toolbox-btn material-icons',text:'format_italic'})),$('<li>',{class:'btn-tip-group'}).append($('<div>',{class:'btn-tip',text:msg('ipe-preference')}),$('<button>',{id:'preference-btn',class:'ipe-toolbox-btn material-icons',text:'settings'})))),$('<button>',{class:'ipe-toolbox-btn material-icons',id:'toolbox-toggle',text:'add'})).appendTo('body');$('#ipe-edit-toolbox #toolbox-toggle').click(function(){$('#ipe-edit-toolbox #toolbox-toggle, #ipe-edit-toolbox .btn-group').toggleClass('opened')});$('body > *:not(#ipe-edit-toolbox)').click(function(){$('#ipe-edit-toolbox #toolbox-toggle, #ipe-edit-toolbox .btn-group').removeClass('opened')});$('#ipe-edit-toolbox .btn-group .ipe-toolbox-btn').click(function(){InPageEdit.analysis({type:'functionCount',function:'工具盒'});switch($(this).attr('id')){case'edit-btn':InPageEdit.edit({page:mw.config.get('wgPageName'),revision:mw.config.get('wgRevisionId')});break;case'redirectfrom-btn':InPageEdit.redirect('from');break;case'redirectto-btn':InPageEdit.redirect('to');break;case'preference-btn':InPageEdit.preference();break;case'deletepage-btn':InPageEdit.deletepage();break;case'renamepage-btn':InPageEdit.renamepage();break}});InPageEdit.articleLink();var b=mw.util.getParamValue('ipe',location.href);if(b==='true'||b==='1'){InPageEdit.edit({page:mw.config.get('wgPageName'),revision:mw.config.get('wgRevisionId')})}}())}console.info(' ____ ____ ______ ___ __ _ _____ \n / _/___ / __ \\____ _____ ____ / ____/___/ (_) /_ | | / /__ \\\n / // __ \\/ /_/ / __ `/ __ `/ _ \\/ __/ / __ / / __/ ______ | | / /__/ /\n _/ // / / / ____/ /_/ / /_/ / __/ /___/ /_/ / / /_ /_____/ | |/ // __/ \n/___/_/ /_/_/ \\__,_/\\__, /\\___/_____/\\__,_/_/\\__/ |___//____/ \n /____/')}());;