پرش به محتوا

مدیاویکی:Gadget-HotCat.js: تفاوت میان نسخه‌ها

بدون خلاصۀ ویرایش
بدون خلاصۀ ویرایش
بدون خلاصۀ ویرایش
خط ۱: خط ۱:
/**
/**
HotCat V2.41
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'
},
},
// Set to false if your wiki has case-sensitive page names. MediaWiki has two modes: either the // any items, but that contains links to other categories where stuff should be categorized. If you don't have


// ("case-sensitive"; Category:aa !== Category:Aa). It doesn't currently have a fully case-insensitive mode
// Override the decision of whether HotCat should help users by automatically
// (which would mean Category:aa === Category:Aa === Category:AA === Category:aA)
// capitalising the title in the user input text if the wiki has case-sensitive page names.
// HotCat tries to set this correctly automatically using an API query. It's still a good idea to manually
// Basically, this will make an API query to check the MediaWiki configuration and HotCat then sets
// configure it correctly; either directly here if you copied HotCat, or in the local configuration file
// this to true for most wikis, and to false on Wiktionary.
// MediaWiki:Gadget-HotCat.js/local_defaults if you hotlink to the Commons-version, to ensure it is set even
//  
// if that API query should fail for some strange reason.
// You can set this directly if there is a problem with it. For example, Georgian Wikipedia (kawiki),
capitalizePageNames: true,
// 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: 5,
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( '//wikihaj.com/index.php?title=' +
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 ) {
// ResourceLoader's JSParser doesn't like .case, so override eslint.
// eslint-disable-next-line dot-notation
HC.capitalizePageNames = ( json.query.general[ 'case' ] === 'first-letter' );
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;
}
}
if ( commitButton || onUpload ) {
this.close();
this.close();
if ( !commitButton && !onUpload ) {
} else {
this.close();
var self = this;
var self = this;
initiateEdit( function ( failure ) {
initiateEdit( function ( failure ) {
خط ۲٬۶۵۶: خط ۲٬۶۶۲:


function initialize() {
function initialize() {
// User configurations. Do this here, called from the onload handler, so that users can
// 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="wikitext">' +
'<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="">' +