https://tnfshwiki.tfcis.org/index.php?title=MediaWiki:Gadget-ToolsRedirect.js&feed=atom&action=history
MediaWiki:Gadget-ToolsRedirect.js - 修訂歷史
2024-03-28T21:37:07Z
本 Wiki 上此頁面的修訂歷史
MediaWiki 1.39.2
https://tnfshwiki.tfcis.org/index.php?title=MediaWiki:Gadget-ToolsRedirect.js&diff=7536&oldid=prev
Xiplus 於 2019年10月5日 (六) 00:42
2019-10-05T00:42:28Z
<p></p>
<table style="background-color: #fff; color: #202122;" data-mw="interface">
<col class="diff-marker" />
<col class="diff-content" />
<col class="diff-marker" />
<col class="diff-content" />
<tr class="diff-title" lang="zh-Hant-TW">
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">←上個修訂</td>
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">於 2019年10月5日 (六) 08:42 的修訂</td>
</tr><tr>
<td colspan="2" class="diff-lineno">行 4:</td>
<td colspan="2" class="diff-lineno">行 4:</td>
</tr>
<tr>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> "use strict";</div></td>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> "use strict";</div></td>
</tr>
<tr>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br /></td>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br /></td>
</tr>
<tr>
<td class="diff-marker" data-marker="−"></td>
<td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div> var _TR, msglang = 'zh-<del style="font-weight: bold; text-decoration: none;">hans</del>',</div></td>
<td class="diff-marker" data-marker="+"></td>
<td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div> var _TR, msglang = 'zh-<ins style="font-weight: bold; text-decoration: none;">hant</ins>',</div></td>
</tr>
<tr>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> origPageName = mw.config.get('wgPageName'),</div></td>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> origPageName = mw.config.get('wgPageName'),</div></td>
</tr>
<tr>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> scriptPath = mw.config.get('wgScriptPath'),</div></td>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> scriptPath = mw.config.get('wgScriptPath'),</div></td>
</tr>
<tr>
<td colspan="2" class="diff-lineno">行 678:</td>
<td colspan="2" class="diff-lineno">行 678:</td>
</tr>
<tr>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> }</div></td>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> }</div></td>
</tr>
<tr>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> };</div></td>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> };</div></td>
</tr>
<tr>
<td class="diff-marker" data-marker="−"></td>
<td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><br /></td>
<td colspan="2" class="diff-empty diff-side-added"></td>
</tr>
<tr>
<td class="diff-marker" data-marker="−"></td>
<td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div> if ( 'zh-hant|zh-hk|zh-tw|zh-mo'.indexOf( mw.config.get('wgUserVariant') ) > -1 ) {</div></td>
<td colspan="2" class="diff-empty diff-side-added"></td>
</tr>
<tr>
<td class="diff-marker" data-marker="−"></td>
<td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div> msglang = 'zh-hant';</div></td>
<td colspan="2" class="diff-empty diff-side-added"></td>
</tr>
<tr>
<td class="diff-marker" data-marker="−"></td>
<td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div> }</div></td>
<td colspan="2" class="diff-empty diff-side-added"></td>
</tr>
<tr>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br /></td>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><br /></td>
</tr>
<tr>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> importScriptCallback( 'MediaWiki:Gadget-ToolsRedirect-msg-' + msglang + '.js', function() {</div></td>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> importScriptCallback( 'MediaWiki:Gadget-ToolsRedirect-msg-' + msglang + '.js', function() {</div></td>
</tr>
</table>
Xiplus
https://tnfshwiki.tfcis.org/index.php?title=MediaWiki:Gadget-ToolsRedirect.js&diff=7533&oldid=prev
Xiplus 於 2019年10月5日 (六) 00:41
2019-10-05T00:41:31Z
<p></p>
<table style="background-color: #fff; color: #202122;" data-mw="interface">
<col class="diff-marker" />
<col class="diff-content" />
<col class="diff-marker" />
<col class="diff-content" />
<tr class="diff-title" lang="zh-Hant-TW">
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">←上個修訂</td>
<td colspan="2" style="background-color: #fff; color: #202122; text-align: center;">於 2019年10月5日 (六) 08:41 的修訂</td>
</tr><tr>
<td colspan="2" class="diff-lineno">行 218:</td>
<td colspan="2" class="diff-lineno">行 218:</td>
</tr>
<tr>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> token: page.edittoken,</div></td>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> token: page.edittoken,</div></td>
</tr>
<tr>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> text: self.addRedirectTextSuffix( page.title, text ),</div></td>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> text: self.addRedirectTextSuffix( page.title, text ),</div></td>
</tr>
<tr>
<td class="diff-marker" data-marker="−"></td>
<td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div> summary: summary<del style="font-weight: bold; text-decoration: none;">,</del></div></td>
<td class="diff-marker" data-marker="+"></td>
<td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div> summary: summary</div></td>
</tr>
<tr>
<td class="diff-marker" data-marker="−"></td>
<td style="color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div> tags: 'ToolsRedirect'</div></td>
<td colspan="2" class="diff-empty diff-side-added"></td>
</tr>
<tr>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> } ) ) );</div></td>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> } ) ) );</div></td>
</tr>
<tr>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> });</div></td>
<td class="diff-marker"></td>
<td style="background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;"><div> });</div></td>
</tr>
<!-- diff cache key tnfshwiki-tnfshwiki_:diff:wikidiff2:1.12:old-7524:rev-7533:1.13.0 -->
</table>
Xiplus
https://tnfshwiki.tfcis.org/index.php?title=MediaWiki:Gadget-ToolsRedirect.js&diff=7524&oldid=prev
Xiplus:已從 :zhwiki:MediaWiki:Gadget-ToolsRedirect.js 匯入 1 筆修訂
2019-10-05T00:36:47Z
<p>已從 <a href="https://zh.wikipedia.org/wiki/MediaWiki:Gadget-ToolsRedirect.js" class="extiw" title="zhwiki:MediaWiki:Gadget-ToolsRedirect.js">zhwiki:MediaWiki:Gadget-ToolsRedirect.js</a> 匯入 1 筆修訂</p>
<table style="background-color: #fff; color: #202122;" data-mw="interface">
<tr class="diff-title" lang="zh-Hant-TW">
<td colspan="1" style="background-color: #fff; color: #202122; text-align: center;">←上個修訂</td>
<td colspan="1" style="background-color: #fff; color: #202122; text-align: center;">於 2019年10月5日 (六) 08:36 的修訂</td>
</tr><tr><td colspan="2" class="diff-notice" lang="zh-Hant-TW"><div class="mw-diff-empty">(無差異)</div>
</td></tr></table>
Xiplus
https://tnfshwiki.tfcis.org/index.php?title=MediaWiki:Gadget-ToolsRedirect.js&diff=7523&oldid=prev
zhwiki>Xiplus:per User:YFdyh000 EP
2018-06-15T00:37:12Z
<p>per <a href="/index.php?title=%E4%BD%BF%E7%94%A8%E8%80%85:YFdyh000&action=edit&redlink=1" class="new" title="使用者:YFdyh000(頁面不存在)">User:YFdyh000</a> <a href="/%E7%89%B9%E6%AE%8A:%E9%9D%9C%E6%85%8B%E9%80%A3%E7%B5%90/49967051" title="特殊:靜態連結/49967051">EP</a></p>
<p><b>新頁面</b></p><div>/* vim: set noexpandtab ft=javascript ts=4 sw=4: */<br />
<br />
( function ( $ ) {<br />
"use strict";<br />
<br />
var _TR, msglang = 'zh-hans',<br />
origPageName = mw.config.get('wgPageName'),<br />
scriptPath = mw.config.get('wgScriptPath'),<br />
nsNumber = mw.config.get('wgNamespaceNumber'),<br />
isCategory = nsNumber === 14,<br />
_findRedirectCallbacks = [],<br />
_pageWithRedirectTextSuffix = {},<br />
_redirectExcludes = {},<br />
SUFFIX_APPEND = 0,<br />
SUFFIX_REPLACE = 1,<br />
SUFFIX_SETDEFAULT = 2,<br />
_nsCanonPrefix = origPageName.split( ':' )[0] + ':',<br />
_nsPrefixPattern = $.map(<br />
mw.config.get( 'wgNamespaceIds' ), function( nsid, text ) {<br />
return nsid === nsNumber ? text : null;<br />
} ).join( '|' );<br />
_nsPrefixPattern = new RegExp( '^(' + _nsPrefixPattern + '):', 'i' );<br />
<br />
if ( nsNumber === 0 ) { // articles<br />
_nsCanonPrefix = '';<br />
_nsPrefixPattern = /^/;<br />
}<br />
<br />
function fixNamespace( title ) {<br />
if ( nsNumber === 0 ) {<br />
// do nothing if it's articles<br />
return title;<br />
}<br />
else if ( _nsPrefixPattern.test( title ) ) {<br />
// canonize the namespace<br />
return title.replace( _nsPrefixPattern, _nsCanonPrefix );<br />
}<br />
else {<br />
// don't have a namespace<br />
return _nsCanonPrefix + title;<br />
}<br />
}<br />
<br />
mw.toolsRedirect = {<br />
<br />
SUFFIX_APPEND: SUFFIX_APPEND,<br />
SUFFIX_REPLACE: SUFFIX_REPLACE,<br />
SUFFIX_SETDEFAULT: SUFFIX_SETDEFAULT,<br />
<br />
findRedirectCallback: function( callback ) {<br />
/* Add new custom callback for finding new<br />
* potential redirect titles.<br />
*<br />
* @param {function} callback( pagename, $content, titles ) -> title list<br />
*/<br />
if ( arguments.length === 1 ) {<br />
_findRedirectCallbacks.push( callback );<br />
}<br />
else {<br />
$.merge( _findRedirectCallbacks, arguments );<br />
}<br />
return this;<br />
},<br />
<br />
findRedirectBySelector: function( selector ) {<br />
/* A shortcut to add CSS selectors as rule to find new potential<br />
* redirect titles.<br />
*<br />
* @param {string} selector<br />
*/<br />
_findRedirectCallbacks.push( function( pagename, $content ) {<br />
return $( selector ).map( function() {<br />
var title = $( this ).text();<br />
return title ? title : null;<br />
} );<br />
} );<br />
return this;<br />
},<br />
<br />
setRedirectTextSuffix: function( title, suffix, flag ) {<br />
var flag_set = false,<br />
flag_append = false;<br />
flag = flag || SUFFIX_APPEND; // default append<br />
flag_set = flag === SUFFIX_REPLACE;<br />
title = fixNamespace( title );<br />
if ( title in _pageWithRedirectTextSuffix ) {<br />
flag_append = flag === SUFFIX_APPEND;<br />
}<br />
else {<br />
// if not exist, every flag can set<br />
flag_set = true;<br />
}<br />
<br />
if ( flag_set ) {<br />
_pageWithRedirectTextSuffix[title] = suffix;<br />
}<br />
else if ( flag_append ) {<br />
_pageWithRedirectTextSuffix[title] =<br />
_pageWithRedirectTextSuffix[title] + suffix;<br />
}<br />
}<br />
<br />
};<br />
<br />
_TR = {<br />
msg: null,<br />
tabselem: null,<br />
tagselem: null,<br />
variants: [<br />
'zh-hans', 'zh-hant', 'zh-cn', 'zh-hk',<br />
'zh-mo', 'zh-sg', 'zh-tw'],<br />
init: function() {<br />
var self = this,<br />
btn = $(<br />
'<li id="ca-redirect" class="collapsible"><span><a title="' + this.msg.btndesc + '">' +<br />
this.msg.btntitle + '</a></span></li>' );<br />
btn.click( function( evt ) {<br />
evt.preventDefault();<br />
self.dialog();<br />
} );<br />
$( 'li#ca-history' ).after( btn );<br />
},<br />
dialog: function() {<br />
var dlg = $( '<div class="dialog-redirect" title="' + this.msg.dlgtitle + '">' )<br />
.dialog( {<br />
bgiframe: true, resizable: false, modal: true, width: 600 } );<br />
this.tabselem = $( '<div class="tab-redirect">' ).appendTo( dlg );<br />
this.tagselem = $( '<ul>' ).appendTo( this.tabselem );<br />
this.addTabs();<br />
this.tabselem.tabs();<br />
},<br />
addTabs: function() {<br />
for ( var kname in this.tabs ) {<br />
if ( this.tabs[kname] === null ) {<br />
this.tabs[kname] = this['_initTab' + kname[0].charAt(0).toUpperCase() + kname.slice(1)]();<br />
}<br />
var tab = this.tabs[kname];<br />
this.tagselem.append( tab.tag );<br />
this.tabselem.append( tab.cont );<br />
}<br />
// default tab, autoload when dialog initiate<br />
this.loadView();<br />
},<br />
createTab: function( tabname, tabtitle, onClick ) {<br />
var self = this,<br />
tag = $( '<li><a href="#tab-' + tabname + '">' + tabtitle + '</a></li>' ),<br />
cont = $( '<div id="tab-' + tabname + '"/>' );<br />
$( 'a', tag ).click( function() { onClick.call( self ); } );<br />
return { 'tag': tag, 'cont': cont, loaded: false };<br />
},<br />
_initTabView: function() {<br />
return this.createTab( 'view', this.msg.tabviewtitle, this.loadView );<br />
},<br />
_initTabCreate: function() {<br />
return this.createTab( 'create', this.msg.tabcreatetitle, this.loadCreate );<br />
},<br />
tabs: {<br />
view: null,<br />
create: null<br />
},<br />
fix: function( pagenames ) {<br />
var self = this,<br />
desc = $( 'p.desc', this.tabs.view.cont ).text( this.msg.fixloading );<br />
$( 'p[class!=desc]', this.tabs.view.cont ).remove();<br />
this.loading( this.tabs.view.cont );<br />
this<br />
.bulkEdit(<br />
pagenames,<br />
this.msg.fixtext.replace( '$1', origPageName ),<br />
this.msg.fixsummary<br />
)<br />
.done( function() {<br />
// delay load before the asynchronous tasks on server finished<br />
setTimeout( function() {<br />
self.loaded( self.tabs.view.cont );<br />
self.loadView( true );<br />
}, 3000 );<br />
} );<br />
},<br />
create: function( pagenames ) {<br />
var self = this,<br />
desc = $( 'p.desc', this.tabs.create.cont ).text( this.msg.createloading );<br />
$( 'p[class!=desc]', this.tabs.create.cont ).remove();<br />
this.loading( this.tabs.create.cont );<br />
this<br />
.bulkEdit(<br />
pagenames,<br />
this.msg.createtext.replace( '$1', origPageName ),<br />
this.msg.createsummary.replace( '$1', origPageName )<br />
)<br />
.done( function() {<br />
// delay load before the asynchronous tasks on server finished<br />
setTimeout( function() {<br />
self.loaded( self.tabs.create.cont );<br />
self.tabs.view.loaded = false;<br />
self.loadCreate( true );<br />
}, 500 );<br />
} );<br />
},<br />
addRedirectTextSuffix: function( title, text ) {<br />
if ( title in _pageWithRedirectTextSuffix ) {<br />
text = text + _pageWithRedirectTextSuffix[title];<br />
}<br />
return text;<br />
},<br />
bulkEdit: function( titles, text, summary ) {<br />
var self = this;<br />
titles = titles.join( '|' );<br />
<br />
return $.ajax( this.buildQuery(<br />
{ action: 'query', prop: 'info', titles: titles, intoken: 'edit' } ) )<br />
.then( function( data ) {<br />
var deferreds = [];<br />
$.each( data.query.pages, function( idx, page ) {<br />
deferreds.push( $.ajax( self.buildQuery( {<br />
action: 'edit',<br />
title: page.title,<br />
token: page.edittoken,<br />
text: self.addRedirectTextSuffix( page.title, text ),<br />
summary: summary,<br />
tags: 'ToolsRedirect'<br />
} ) ) );<br />
});<br />
return $.when.apply( $, deferreds );<br />
} );<br />
},<br />
loadTabCont: function( tabname, callback, reload ) {<br />
var self = this,<br />
tab = this.tabs[tabname];<br />
if ( reload ) tab.loaded = false;<br />
if ( !tab.loaded ) {<br />
tab.cont.html( '' );<br />
var desc = $( '<p class="desc"><span class="desc-text">' +<br />
this.msg.rediloading + '</span></p>' ).appendTo( tab.cont ),<br />
$text = desc.find( '> .desc-text' );<br />
callback.apply( this )<br />
.done( function() { $text.text( self.msg['tab' + tabname + 'desc'] ); } )<br />
.fail( function() { $text.text( self.msg['tab' + tabname + 'notfound'] ); } )<br />
.always( function() {<br />
self.addMethods( desc, [ {<br />
href: '#refresh',<br />
title: self.msg.refresh,<br />
click: function( evt ) {<br />
evt.preventDefault();<br />
self.loadTabCont( tabname, callback, true );<br />
}<br />
} ] );<br />
} );<br />
tab.loaded = true;<br />
}<br />
},<br />
loading: function( container ) {<br />
if ( container.prop( 'tagName' ).toLowerCase() == 'span' ) {<br />
container.addClass( 'mw-ajax-loader' );<br />
} else if ( $( 'span.mw-ajax-loader', container ).length === 0 ) {<br />
$( '<span class="mw-ajax-loader"></span>' ).appendTo( container );<br />
}<br />
},<br />
loaded: function( container ) {<br />
if ( container.prop( 'tagName' ).toLowerCase() == 'span' ) {<br />
container.removeClass( 'mw-ajax-loader' );<br />
} else {<br />
$( 'span.mw-ajax-loader', container ).remove();<br />
}<br />
},<br />
selectAll: function( cont ) {<br />
$( 'input[type=checkbox]:not(:disabled)', cont )<br />
.prop( 'checked', true );<br />
},<br />
selectInverse: function( cont ) {<br />
$( 'input[type=checkbox]:not(:disabled)', cont )<br />
.each( function() {<br />
var e = $( this );<br />
e.prop( 'checked', !e.prop( 'checked' ) );<br />
} ); <br />
},<br />
selectAction: function( cont, cb ) {<br />
var pagenames = [];<br />
$( 'input[type=checkbox]:checked', cont )<br />
.each( function() {<br />
pagenames.push( $( this ).data( 'page-title' ) );<br />
} );<br />
if ( pagenames.length )<br />
cb.call( this, pagenames );<br />
},<br />
clickAction: function( cont, cb ) {<br />
var pagename = $( 'input[type="checkbox"]', cont ).data( 'page-title' );<br />
cb.call( this, [pagename] );<br />
},<br />
buildLink: function( attr ) {<br />
var a = $(<br />
'<a href="' + attr.href + '" title="' + attr.title +<br />
'" target="blank">' + attr.title + '</a>' );<br />
if ( attr.click )<br />
a.click( attr.click );<br />
if ( attr.classname )<br />
a.addClass( attr.classname );<br />
return $( '<span class="tools-redirect_link">' ).append( a );<br />
},<br />
addMethods: function( $parent, methods ) {<br />
var self = this,<br />
$container = $parent.find( '> .tools-redirect_methods' );<br />
<br />
function methodExist( method ) {<br />
return $container.find(<br />
'a[href=' + JSON.stringify( method.href ) + ']' ).length > 0;<br />
}<br />
<br />
if ( $container.length === 0 ) {<br />
$container = $( '<span class="tools-redirect_methods">' ).appendTo( $parent );<br />
}<br />
<br />
$.each( methods, function( idx, method ) {<br />
if ( !methodExist( method ) ) {<br />
self.buildLink( method ).appendTo( $container );<br />
}<br />
} );<br />
},<br />
buildSelection: function( main, metd, mt, dsab ) {<br />
var cont = $( '<span/>' ),<br />
sele = $( '<input type="checkbox"/>' ).appendTo( cont );<br />
this.buildLink( main ).appendTo( cont );<br />
this.addMethods( cont, metd );<br />
sele.data( 'page-title', mt );<br />
if ( dsab ) {<br />
sele.attr( 'disabled', true );<br />
}<br />
return cont;<br />
},<br />
loadView: function( reload ) {<br />
var $container = this.tabs.view.cont;<br />
this.loadTabCont( 'view', function() {<br />
return this.loadRedirect( origPageName, $container, 0 );<br />
}, reload );<br />
},<br />
loadCreate: function( reload ) {<br />
this.loadTabCont( 'create', function() {<br />
return this.findRedirect( origPageName );<br />
}, reload );<br />
},<br />
loadRedirect: function( pagename, container, deep, loaded ) {<br />
this.loading( container );<br />
var self = this,<br />
deferObj = $.Deferred(),<br />
top = deep ? $( '<dl/>' ).appendTo( container ) : container;<br />
<br />
if ( !loaded ) {<br />
loaded = {};<br />
loaded[pagename] = true;<br />
}<br />
<br />
function onClickFix( evt ) {<br />
/* jshint validthis: true */<br />
var entry = $( this ).parents( 'dd, p' ).first();<br />
evt.preventDefault();<br />
self.clickAction( entry, self.fix );<br />
}<br />
<br />
$.ajax( this.buildQuery(<br />
{ action: 'query', prop: 'redirects', titles: pagename, rdlimit: 'max' } ) )<br />
.done( function( data ) {<br />
self.loaded( container );<br />
var has_redirect = false,<br />
desc = $( 'p.desc', self.tabs.view.cont ),<br />
maximumRedirectDepth = mw.config.get('toolsRedirectMaximumRedirectDepth', 10);<br />
<br />
$.each( data.query.pages, function( _, page ) {<br />
if ( !( 'redirects' in page ) ) {<br />
return;<br />
}<br />
$.each( page.redirects, function( _, rdpage ) {<br />
var $container,<br />
isCycleRedirect,<br />
rdtitle = rdpage.title,<br />
ultitle = rdtitle.replace( / /g, '_' ),<br />
baseuri = scriptPath + '/index.php?title=' + encodeURIComponent( ultitle ),<br />
entry = ( deep ? $( '<dd/>' ) : $( '<p/>' ) ).appendTo( top ),<br />
methods = [ {href: baseuri + '&action=edit',<br />
title: self.msg.rediedit } ];<br />
isCycleRedirect = rdtitle in loaded;<br />
loaded[rdtitle] = true;<br />
if ( !isCycleRedirect && deep ) {<br />
methods.push({<br />
href: '#fix-redirect',<br />
title: self.msg.tabviewfix,<br />
click: onClickFix<br />
} );<br />
}<br />
$container = self.buildSelection(<br />
{ href: baseuri + '&redirect=no', title: rdtitle },<br />
methods, ultitle, !deep ).appendTo( entry );<br />
if ( isCycleRedirect ) {<br />
$container.append(<br />
'<span class="error">' + self.msg.errcycleredirect + '</span>');<br />
}<br />
else if ( deep < maximumRedirectDepth ) {<br />
deferObj.done( function() {<br />
return self.loadRedirect( rdtitle, entry, deep + 1, loaded );<br />
} );<br />
}<br />
has_redirect = true;<br />
} );<br />
} );<br />
<br />
if ( has_redirect && deep === 1 ) {<br />
self.addMethods( desc, [ {<br />
href: '#select-all',<br />
title: self.msg.selectall,<br />
click: function( evt ) {<br />
evt.preventDefault();<br />
self.selectAll( self.tabs.view.cont ); }<br />
}, {<br />
href: '#select-inverse',<br />
title: self.msg.selectinverse,<br />
click: function( evt ) {<br />
evt.preventDefault();<br />
self.selectInverse( self.tabs.view.cont ); }<br />
}, {<br />
href: '#fix-selected',<br />
title: self.msg.tabviewfix,<br />
click: function( evt ) {<br />
evt.preventDefault();<br />
self.selectAction( self.tabs.view.cont, self.fix ); }<br />
} ] );<br />
}<br />
<br />
if ( has_redirect ) {<br />
deferObj.resolveWith( self );<br />
}<br />
else {<br />
deferObj.rejectWith( self );<br />
}<br />
<br />
} );<br />
<br />
return deferObj.promise();<br />
},<br />
findVariants: function( pagename, titles ) {<br />
var self = this,<br />
suffixReg = /^.+?( \(.+?\))$/,<br />
retTitles = [],<br />
deferreds = [],<br />
simpAndTrad = { 'zh-hans': true, 'zh-hant': true };<br />
$.each( this.variants, function( _, variant ) {<br />
var xhr = $.ajax( self.buildQuery( {<br />
action: 'parse',<br />
page: pagename,<br />
prop: 'displaytitle',<br />
variant: variant<br />
} ) )<br />
.then( function( data ) {<br />
var title = fixNamespace( data.parse.displaytitle );<br />
if ( variant in simpAndTrad ) {<br />
mw.toolsRedirect.setRedirectTextSuffix(<br />
title, '\n{{簡繁重定向}}', SUFFIX_APPEND );<br />
}<br />
return title;<br />
} );<br />
if ( isCategory ) {<br />
xhr = xhr.then( function( origTitle ) {<br />
return $.ajax( self.buildQuery( {<br />
action: 'parse',<br />
text: pagename,<br />
prop: 'text',<br />
variant: variant<br />
} ) )<br />
.then( function( data ) {<br />
var tmpTitle = $( data.parse.text['*'] )<br />
.text().replace( /(^\s*|\s*$)/g, '' );<br />
// should not create redirect categories<br />
// if the conversion is already in global table,<br />
// or it will mess up a lot<br />
_redirectExcludes[tmpTitle] = true;<br />
return origTitle;<br />
} );<br />
} );<br />
}<br />
deferreds.push( xhr );<br />
} );<br />
return $.when.apply( $, deferreds )<br />
.then( function() {<br />
var suffixes = [];<br />
<br />
$.each( arguments, function() {<br />
var suffix,<br />
title = this;<br />
<br />
// find title suffix,<br />
// for example " (济南市)" to "市中区 (济南市)"<br />
suffix = suffixReg.exec( title );<br />
if ( suffix && suffix.length === 2) {<br />
suffix = suffix[1];<br />
}<br />
else {<br />
suffix = '';<br />
}<br />
<br />
retTitles.push( title );<br />
suffixes.push( suffix );<br />
<br />
} );<br />
<br />
// append suffixes<br />
$.each( $.unique( suffixes ), function( _, suffix ) {<br />
$.merge( retTitles, $.map( titles, function( title ) {<br />
title = fixNamespace( title );<br />
return suffixReg.test( title ) ? title : title + suffix;<br />
} ) );<br />
} );<br />
<br />
return self.findNotExists( $.unique( retTitles ) );<br />
} );<br />
},<br />
<br />
findNotExists: function( titles ) {<br />
var self = this,<br />
deferreds = [],<br />
alltitles = [],<br />
variants = ['zh-hans', 'zh-hant'],<br />
excludes = [ '用字模式' ];<br />
titles = titles.join( '|' );<br />
<br />
$.each( [ 'zh-hans', 'zh-hant' ], function( idx, variant ) {<br />
deferreds.push( $.ajax( self.buildQuery(<br />
{ action: 'parse', text: titles, prop: 'text', variant: variant } ) ) );<br />
} );<br />
<br />
return $.when.apply( $, deferreds )<br />
.then( function() {<br />
$.each( arguments, function() {<br />
alltitles = alltitles.concat(<br />
$( this[0].parse.text['*'] )<br />
.text().replace( /(^\s*|\s*$)/g, '' ).split( '|' )<br />
);<br />
} );<br />
alltitles = alltitles.join( '|' );<br />
return $.ajax( self.buildQuery( {<br />
action: 'query',<br />
prop: 'info',<br />
titles: alltitles<br />
} ) )<br />
.then( function( data ) {<br />
titles = [];<br />
$.each( data.query.pages, function( pageid, page ) {<br />
var title = page.title;<br />
if ( pageid < 0 && excludes.indexOf( title ) === -1 ) {<br />
<br />
if ( title in _redirectExcludes ) {<br />
// exclude special titles<br />
return;<br />
}<br />
<br />
titles.push( title );<br />
<br />
if ( isCategory ) {<br />
var target = origPageName.replace( /^Category:/, '' );<br />
mw.toolsRedirect.setRedirectTextSuffix(<br />
title,<br />
'\n{{分类重定向|$1}}'.replace( '$1', target )<br />
);<br />
}<br />
<br />
// only set default suffix<br />
mw.toolsRedirect.setRedirectTextSuffix(<br />
title, '\n{{別名重定向}}', SUFFIX_SETDEFAULT );<br />
}<br />
} );<br />
return titles;<br />
} );<br />
} );<br />
},<br />
<br />
findRedirect: function( pagename ) {<br />
var self = this,<br />
titles = [],<br />
frcDeferreds = [],<br />
findBoldsAsTitles = mw.config.get('toolsRedirectFindBoldsAsTitles', false),<br />
container = this.tabs.create.cont,<br />
$content = $( '#mw-content-text' ),<br />
deferObj = $.Deferred();<br />
this.loading( container );<br />
<br />
$.each( _findRedirectCallbacks, function( _, callback ) {<br />
var ret = callback( pagename, $content, titles );<br />
if ( typeof ret === 'string' ) {<br />
titles.push( ret );<br />
}<br />
else if ( 'done' in ret ) {<br />
// is Deferred<br />
frcDeferreds.push( ret );<br />
}<br />
else {<br />
$.merge( titles, ret );<br />
}<br />
} );<br />
<br />
// remove all empty titles<br />
titles = $.map( titles, function( title ) {<br />
return title ? title : null;<br />
} );<br />
<br />
function onClickCreate( evt ) {<br />
/* jshint validthis: true */<br />
var entry = $( this ).parents( 'p:first' );<br />
evt.preventDefault();<br />
self.clickAction( entry, self.create );<br />
}<br />
<br />
// handles the deferred callbacks<br />
$.when.apply( $, frcDeferreds )<br />
.then( function() {<br />
$.each( arguments, function( _, ret ) {<br />
if (typeof ret == 'string' ) {<br />
titles.push( ret );<br />
}<br />
else {<br />
$.merge( titles, ret );<br />
}<br />
} );<br />
return self.findVariants( pagename, titles );<br />
} )<br />
.done( function ( titles ) {<br />
// build HTML<br />
self.loaded( container );<br />
$.each( titles, function( _, title ) {<br />
var ultitle = title.replace( ' ', '_' ),<br />
baseuri = scriptPath + '/index.php?title=' + encodeURIComponent( ultitle ),<br />
entry = $( '<p/>' ).appendTo( container );<br />
self.buildSelection(<br />
{ href: baseuri + '&action=edit&redlink=1',<br />
title: title,<br />
classname: 'new' },<br />
[ { href: '#create-redirect',<br />
title: self.msg.tabcreatetitle,<br />
click: onClickCreate<br />
} ],<br />
ultitle, false<br />
).appendTo( entry );<br />
} );<br />
var desc = $( 'p.desc', container );<br />
if ( titles.length > 0 ) {<br />
self<br />
.addMethods( desc, [ {<br />
href: '#select-all',<br />
title: self.msg.selectall,<br />
click: function( evt ) {<br />
evt.preventDefault();<br />
self.selectAll( container );<br />
}<br />
}, {<br />
href: '#select-inverse',<br />
title: self.msg.selectinverse,<br />
click: function( evt ) {<br />
evt.preventDefault();<br />
self.selectInverse( container );<br />
}<br />
}, {<br />
href: '#create-selected',<br />
title: self.msg.tabcreatetitle,<br />
click: function( evt ) {<br />
evt.preventDefault();<br />
self.selectAction( container, self.create );<br />
}<br />
} ] );<br />
deferObj.resolveWith( self, [ titles ] );<br />
}<br />
else {<br />
deferObj.rejectWith( self, [ titles ] );<br />
}<br />
} );<br />
<br />
return deferObj.promise();<br />
},<br />
buildQuery: function( data ) {<br />
var query = { url: scriptPath + '/api.php', dataType: 'json', type: 'POST' };<br />
query.data = data;<br />
query.data.format = 'json';<br />
return query;<br />
}<br />
};<br />
<br />
if ( 'zh-hant|zh-hk|zh-tw|zh-mo'.indexOf( mw.config.get('wgUserVariant') ) > -1 ) {<br />
msglang = 'zh-hant';<br />
}<br />
<br />
importScriptCallback( 'MediaWiki:Gadget-ToolsRedirect-msg-' + msglang + '.js', function() {<br />
<br />
_TR.msg = window.tools_redirect_msg;<br />
<br />
$( function() {<br />
mw.loader.using( ['jquery.ui.dialog', 'jquery.ui.tabs'], function () {<br />
_TR.init();<br />
} );<br />
} );<br />
<br />
} );<br />
<br />
} )( jQuery );</div>
zhwiki>Xiplus