Difference between revisions 40379 and 40380 on zhwikivoyage//<nowiki> // vim: set noet sts=0 sw=8: (function($){ /* (contracted; show full) if (Morebits.userIsInGroup('sysop')) { Morebits.wiki.actionCompleted.postfix = false; // avoid Action: completed notice Morebits.status.init($('div[name="currentprot"] span').last()[0]); } Twinkle.protect.fetchProtectionLevel(); }; Twinkle.protect.// Current protectionL level = null; in a human-readable format⏎ // (a string, or null if no protection; (only filled for sysops) Twinkle.protect.currentPprotectionLevels = null; ⏎ ⏎ // an array of objects { type, level, expiry, cascade }Contains the current protection level in an object // Once filled, it will look something like: // { edit: { level: "sysop", expiry: <some date>, cascade: true }, ... } Twinkle.protect.currentProtectionLevels = {}; Twinkle.protect.fetchProtectionLevel = function twinkleprotectFetchProtectionLevel() { var api = new mw.Api(); api.get({ format: 'json', indexpageids: true, action: 'query', prop: 'info', inprop: 'protection', titles: mw.config.get('wgPageName') }) .done(function(data){ var pageid = data.query.pageids[0]; var page = data.query.pages[pageid]; var result = []; var current = []{}; var updateResult = function(label, level, expiry, cascade) { // for sysops, stringify, so they can base their decision on existing protection if (Morebits.userIsInGroup('sysop')) { var boldnode = document.createElement('b'); boldnode.textContent = label + ":" + level; result.push(boldnode); if (expiry === 'infinity') { result.push("(无限期)"); } else { result.push("(过期:" + new Date(expiry).toUTCString() + ")"); } if (cascade) { result.push("(联锁)"); } } }; $.each(page.protection, function( index, protection ) { if (protection.type !== "aft") { current.push({ type: [protection.type,] = { level: protection.level, expiry: protection.expiry, cascade: protection.cascade && protection.cascade === '' }); updateResult( Morebits.string.toUpperCaseFirstChar(protection.type), protection.level, protection.expiry, protection.cascade ); } }); // show the protection level to sysops if (Morebits.userIsInGroup('sysop')) { if (!result.length) { (contracted; show full) default: words = ""; break; } words += params.typename; newtag += "请求" + Morebits.string.toUpperCaseFirstChar(words) + ( params.reason !== '' ? ":" + ⏎ ⏎ Morebits.string.formatReasonText(params.reason) : "。" ) + "--~~~~"; var reg; if ( params.category === 'unprotect' ) { reg = /(==\s*请求解除保护\s*==\n)/; } else { reg = /(\/header2}}\n)/; } var originalTextLength = text.length; text = text.replace( reg, "$1" + newtag + "\n"); if (text.length === originalTextLength) { var linknode = document.createElement('a'); linknode.setAttribute("href", mw.util.getUrl("Wikipedia:Twinkle/修复RFPP") ); linknode.appendChild(document.createTextNode('如何修复RFPP')); statusElement.error( [ '无法在WP:RFPP上找到相关位点标记,要修复此问题,请参见', linknode, '。' ] ); return; } statusElement.status( '添加新提名…' ); rppPage.setEditSummary( '请求对[[' + Morebits.pageNameNorm + ']]' + params.typename + Twinkle.getPref('summaryAd') ); rppPage.setPageText( text ); rppPage.setCreateOption( 'recreate' ); rppPage.save(); } }; })(jQuery); //</nowiki> All content in the above text box is licensed under the Creative Commons Attribution-ShareAlike license Version 4 and was originally sourced from https://zh.wikivoyage.org/w/index.php?diff=prev&oldid=40380.
![]() ![]() This site is not affiliated with or endorsed in any way by the Wikimedia Foundation or any of its affiliates. In fact, we fucking despise them.
|