۵٬۱۲۵
ویرایش
بدون خلاصۀ ویرایش |
بدون خلاصۀ ویرایش |
||
خط ۱: | خط ۱: | ||
/** | /** | ||
HotCat V2. | HotCat V2.43 | ||
Ajax-based simple Category manager. Allows adding/removing/changing categories on a page view. | Ajax-based simple Category manager. Allows adding/removing/changing categories on a page view. | ||
خط ۱۴۷: | خط ۱۴۷: | ||
parentcat: 'Parent categories' | parentcat: 'Parent categories' | ||
}, | }, | ||
// | // Override the decision of whether HotCat should help users by automatically | ||
// | // capitalising the title in the user input text if the wiki has case-sensitive page names. | ||
// | // Basically, this will make an API query to check the MediaWiki configuration and HotCat then sets | ||
// | // this to true for most wikis, and to false on Wiktionary. | ||
// MediaWiki | // | ||
// | // You can set this directly if there is a problem with it. For example, Georgian Wikipedia (kawiki), | ||
capitalizePageNames: | // is known to have different capitalisation logic between MediaWiki PHP and JavaScript. As such, automatic | ||
// case changes in JavaScript by HotCat would be wrong. | |||
capitalizePageNames: null, | |||
// If upload_disabled is true, HotCat will not be used on the Upload form. | // If upload_disabled is true, HotCat will not be used on the Upload form. | ||
upload_disabled: false, | upload_disabled: false, | ||
خط ۱۸۶: | خط ۱۸۷: | ||
use_up_down: true, | use_up_down: true, | ||
// Default list size | // Default list size | ||
listSize: | listSize: 10, | ||
// If true, single category changes are marked as minor edits. If false, they're not. | // If true, single category changes are marked as minor edits. If false, they're not. | ||
single_minor: true, | single_minor: true, | ||
خط ۲۸۴: | خط ۲۸۵: | ||
// Localization hook to localize HotCat messages, tooltips, and engine names for wgUserLanguage. | // Localization hook to localize HotCat messages, tooltips, and engine names for wgUserLanguage. | ||
if ( window.hotcat_translations_from_commons && conf.wgServer.indexOf( '//commons' ) < 0 ) { | if ( window.hotcat_translations_from_commons && conf.wgServer.indexOf( '//commons' ) < 0 ) { | ||
loadURI( '// | loadURI( '//commons.wikimedia.org/w/index.php?title=' + | ||
'MediaWiki:Gadget-HotCat.js/' + conf.wgUserLanguage + | 'MediaWiki:Gadget-HotCat.js/' + conf.wgUserLanguage + | ||
'&action=raw&ctype=text/javascript', loadTrigger.loaded ); | '&action=raw&ctype=text/javascript', loadTrigger.loaded ); | ||
خط ۷۳۳: | خط ۷۳۴: | ||
// Siteinfo | // Siteinfo | ||
if ( json.query.general ) { | if ( json.query.general ) { | ||
if ( json.query.general.time && !startTime ) startTime = json.query.general.time.replace( /\D/g, '' ); | if ( json.query.general.time && !startTime ) startTime = json.query.general.time.replace( /\D/g, '' ); | ||
if ( HC.capitalizePageNames === null ) { | |||
// ResourceLoader's JSParser doesn't like .case, so override eslint. | |||
// eslint-disable-next-line dot-notation | |||
HC.capitalizePageNames = ( json.query.general[ 'case' ] === 'first-letter' ); | |||
} | |||
} | } | ||
serverTime = startTime; | serverTime = startTime; | ||
خط ۱٬۳۶۴: | خط ۱٬۳۶۸: | ||
after.parentNode.insertBefore( span, after.nextSibling ); | after.parentNode.insertBefore( span, after.nextSibling ); | ||
after = after.nextSibling; | after = after.nextSibling; | ||
} else { | } else if (line) { | ||
line.appendChild( span ); | line.appendChild( span ); | ||
} | } | ||
} else if ( line.firstChild ) { | } else if ( line && line.firstChild ) { | ||
span.appendChild( make( ' ', true ) ); | span.appendChild( make( ' ', true ) ); | ||
line.appendChild( span ); | line.appendChild( span ); | ||
خط ۱٬۳۸۵: | خط ۱٬۳۸۹: | ||
span.appendChild( this.linkSpan ); | span.appendChild( this.linkSpan ); | ||
if ( after ) after.parentNode.insertBefore( span, after.nextSibling ); else line.appendChild( span ); | if ( after ) { | ||
after.parentNode.insertBefore( span, after.nextSibling ); | |||
} else if ( line ) { | |||
line.appendChild( span ); | |||
} | |||
this.normalLinks = null; | this.normalLinks = null; | ||
خط ۱٬۷۰۴: | خط ۱٬۷۱۲: | ||
display: function ( evt ) { | display: function ( evt ) { | ||
if ( this.isAddCategory && !onUpload ) { | if ( this.isAddCategory && !onUpload && this.line ) { | ||
// eslint-disable-next-line no-new | // eslint-disable-next-line no-new | ||
new CategoryEditor( this.line, null, this.span, true ); // Create a new one | new CategoryEditor( this.line, null, this.span, true ); // Create a new one | ||
خط ۱٬۹۳۱: | خط ۱٬۹۳۹: | ||
this.catLink.style.display = ''; | this.catLink.style.display = ''; | ||
if ( this.isAddCategory ) { | if ( this.isAddCategory ) { | ||
if ( onUpload ) { | if ( onUpload && this.line ) { | ||
// eslint-disable-next-line no-new | // eslint-disable-next-line no-new | ||
new CategoryEditor( this.line, null, this.span, true ); // Create a new one | new CategoryEditor( this.line, null, this.span, true ); // Create a new one | ||
خط ۱٬۹۸۲: | خط ۱٬۹۹۰: | ||
return; | return; | ||
} | } | ||
this.close(); | |||
if ( !commitButton && !onUpload ) { | |||
var self = this; | var self = this; | ||
initiateEdit( function ( failure ) { | initiateEdit( function ( failure ) { | ||
خط ۲٬۶۵۶: | خط ۲٬۶۶۲: | ||
function initialize() { | function initialize() { | ||
// User configurations | // User configurations: Do this here, called from the onload handler, so that users can | ||
// override it easily in their own user script files by just declaring variables. JSconfig | // override it easily in their own user script files by just declaring variables. JSconfig | ||
// is some feature used at Wikimedia Commons. | // is some feature used at Wikimedia Commons. | ||
خط ۲٬۶۶۷: | خط ۲٬۶۷۳: | ||
!!window.hotcat_no_autocommit : ( config.HotCatNoAutoCommit !== undefined ? | !!window.hotcat_no_autocommit : ( config.HotCatNoAutoCommit !== undefined ? | ||
config.HotCatNoAutoCommit : | config.HotCatNoAutoCommit : | ||
HC.no_autocommit ) ); | // On talk namespace default autocommit off | ||
( conf.wgNamespaceNumber % 2 ? | |||
true : HC.no_autocommit ) ) ); | |||
HC.del_needs_diff = ( window.hotcat_del_needs_diff !== undefined ? | HC.del_needs_diff = ( window.hotcat_del_needs_diff !== undefined ? | ||
!!window.hotcat_del_needs_diff : | !!window.hotcat_del_needs_diff : | ||
خط ۳٬۰۳۰: | خط ۳٬۰۳۸: | ||
for ( i = 0; i < copyCats.length; i++ ) { | for ( i = 0; i < copyCats.length; i++ ) { | ||
var test = isOnPage( copyCats[ i ] ); | var test = isOnPage( copyCats[ i ] ); | ||
if ( test !== null && test.match !== null ) { | if ( test !== null && test.match !== null && line ) { | ||
// eslint-disable-next-line no-new | // eslint-disable-next-line no-new | ||
new CategoryEditor( line, copyCats[ i ], test.title, test.match[ 2 ], is_hidden ); | new CategoryEditor( line, copyCats[ i ], test.title, test.match[ 2 ], is_hidden ); | ||
خط ۳٬۰۸۰: | خط ۳٬۰۸۸: | ||
conf.wgScript + '?title=' + encodeURIComponent( conf.wgPageName ) + '&action=submit">' + | conf.wgScript + '?title=' + encodeURIComponent( conf.wgPageName ) + '&action=submit">' + | ||
'<input type="hidden" name="wpTextbox1">' + | '<input type="hidden" name="wpTextbox1">' + | ||
'<input type="hidden" name="model" value=" | '<input type="hidden" name="model" value="' + conf.wgPageContentModel + '">' + | ||
'<input type="hidden" name="format" value="text/x-wiki">' + | '<input type="hidden" name="format" value="text/x-wiki">' + | ||
'<input type="hidden" name="wpSummary" value="">' + | '<input type="hidden" name="wpSummary" value="">' + |
ویرایش