User:CBM/ratemath.js
Appearance
< User:CBM
Code that you insert on this page could contain malicious content capable of compromising your account. If you import a script from another page with "importScript", "mw.loader.load", "iusc", or "lusc", take note that this causes you to dynamically load a remote script, which could be changed by others. Editors are responsible for all edits and actions they perform, including by scripts. User scripts are not centrally supported and may malfunction or become inoperable due to software changes. A guide to help you find broken scripts is available. If you are unsure whether code you are adding to this page is safe, you can ask at the appropriate village pump. This code will be executed when previewing this page. |
![]() | This user script seems to have a documentation page at User:CBM/ratemath. |
// If TwinkleConfig aint exist.
if( typeof( TwinkleConfig ) == 'undefined' ) {
TwinkleConfig = {};
}
/**
TwinkleConfig.summaryAd (string)
If ad should be added or not to summary, default [[WP:TWINKLE|TWINKLE]]
*/
if( typeof( TwinkleConfig.summaryAd ) == 'undefined' ) {
TwinkleConfig.summaryAd = " using [[WP:TW|TW]]";
}
/**
TwinkleConfig.watchRatedMathPages (boolean)
If, when applying rating template to page, watch it, default true
*/
if( typeof( TwinkleConfig.watchRatedMathPages ) == 'undefined' ) {
TwinkleConfig.watchRatedMathPages = true;
}
function twinklerate() {
if( (wgNamespaceNumber != 0 && wgNamespaceNumber != 1) || wgCurRevisionId == false ) {
return;
}
addPortletLink( 'p-cactions', "javascript:twinklerate.callback()",
"Rate", "tw-rate", "Rate article for WikiProject Mathematics", "");
}
addOnloadHook(twinklerate);
twinklerate.callback = function twinklerateCallback() {
var Window = new SimpleWindow( 400, 300 );
Window.setTitle( "Rate article" );
var form = new QuickForm( twinklerate.callback.evaluate );
form.append( {
type: 'select',
name: 'quality',
label: 'Quality: ',
list: [
{ label: 'Featured Article', value: 'FA' },
{ label: 'A class', value: 'A' },
{ label: 'Good Article', value: 'GA' },
{ label: 'B+ class', value: 'Bplus' },
{ label: 'B class', value: 'B' },
{ label: 'Start class', value: 'Start' },
{ label: 'Stub class', value: 'Stub' }
]
} );
form.append( {
type: 'select',
name: 'priority',
label: 'priority: ',
list: [
{ label: 'Top', value: 'Top' },
{ label: 'High', value: 'High' },
{ label: 'Mid', value: 'Mid' },
{ label: 'Low', value: 'Low' }
]
} );
form.append( {
type: 'select',
name: 'field',
label: 'Field: ',
list: [
{ label: 'General', value: 'general' },
{ label: 'Analysis', value: 'analysis' },
{ label: 'Algebra', value: 'algebra' },
{ label: 'Applied mathematics', value: 'applied' },
{ label: 'Basic topics (elementary material and common facts)', value: 'basics' },
{ label: 'Discrete mathematics', value: 'discrete' },
{ label: 'Foundations (logic and set theory)', value: 'foundations' },
{ label: 'Geometry', value: 'geometry' },
{ label: 'History', value: 'history' },
{ label: 'Mathematical Physics', value: 'mathematical physics' },
{ label: 'Mathematicians', value: 'mathematicians' },
{ label: 'Number theory', value: 'number theory' },
{ label: 'Probability and statistics', value: 'probability and statistics' },
{ label: 'Topology', value: 'topology' }
]
} );
form.append( { type:'submit' } );
var result = form.render();
Window.setContent( result );
Window.display();
}
twinklerate.callbacks = {
main: function( self ) {
var form = self.responseXML.getElementById('editform');
var text = form.wpTextbox1.value;
var tag_re = /\{\{math(s)? rating/;
if( tag_re.test( text ) ) {
self.statelem.warn('Page already has a rating template, aborting procedure');
return;
}
var postData = {
'wpMinoredit': undefined, // Per memo
'wpWatchthis': TwinkleConfig.watchRatedMathPages ? 'true' : undefined,
'wpStarttime': form.wpStarttime.value,
'wpEdittime': form.wpEdittime.value,
'wpAutoSummary': form.wpAutoSummary.value,
'wpEditToken': form.wpEditToken.value,
'wpSummary': "Rating article for WikiProject Mathematics" + TwinkleConfig.summaryAd,
'wpTextbox1': "\{\{maths rating|quality=" + self.params.quality
+ "|priority=" + self.params.priority
+ "|field=" +self.params.field + "}}\n" + text
};
self.post( postData );
},
}
twinklerate.callback.evaluate = function twinklerateCallbackEvaluate(e) {
var form = e.target;
var quality = form.quality.value;
var priority = form.priority.value;
var field = form.field.value;
wgPageName = wgPageName.replace(/_/g, ' ');
if ( wgNamespaceNumber == 0){
wgPageName = 'Talk:' + wgPageName;
}
Status.init( form );
var query = {
'title': wgPageName,
'action': 'submit'
};
Wikipedia.actionCompleted.redirect = wgPageName;
Wikipedia.actionCompleted.notice = "Tagging complete, reloading talk page in some seconds";
var wikipedia_wiki = new Wikipedia.wiki('Tagging page', query, twinklerate.callbacks.main);
wikipedia_wiki.params = { quality: quality, priority: priority, field: field};
wikipedia_wiki.followRedirect = false;
wikipedia_wiki.get();
}