మీడియావికీ:Guidedtour-tour-CourseWizard.js

గమనిక: భద్రపరచిన తరువాత, మార్పులను చూడాలంటేమీ బ్రౌజరు కాషె ను తప్పించవలసి రావచ్చు. మొజిల్లా/ ఫైర్‌ఫాక్స్‌/ సఫారి: shift కీని నొక్కి పెట్టి Reload నొక్కండి, లేదా Ctrl-shift-R నొక్కండి (యాపుల్‌ మాక్‌ లో Cmd-shift-R); IE: Ctrl నొక్కి పెట్టి, Refresh నొక్కండి, లేదా Ctrl-F5 నొక్కండి; కాంకరర్‌:: Reload మీట నొక్కండి, లేదా F5 నొక్కండి; ఒపేరా ను వాడే వారు Tools→Preferences కు వెళ్ళి కాషె ను పూర్తిగా తీసివేయ వలసి ఉంటుంది.

// Guided Tour for learning wikicode by making a series of edits in a user sandbox, as an interactive interlude in Wikipedia:Training/For_students
 
( function ( window, document, $, mw, gt ) {
 
//automatic api:edit function to send yourself messages
sendMessage = function( targetPage, msgPage, linkTo ) {
	var api = new mw.Api();
 
	api.get( {
		'action' : 'query',
		'titles' : msgPage,
		'prop'   : 'revisions|info',
		'intoken' : 'edit',
		'rvprop' : 'content',
		'indexpageids' : 1
	}, {
		'ok' : function(result) {
			result = result.query;
			var page = result.pages[result.pageids[0]];
			var text = page.revisions[0]['*'];
			api.post(
				{
					'action' : 'edit',
					'title' : targetPage,
					'appendtext' : "\n" + text,
					'summary' : 'automatic post as part of the sandbox guided tour',
					'token' : page.edittoken
				},
				{
					'ok'  : function() { window.location.href = linkTo;}
				}
			);
		}
	}	);
}
 
gt.defineTour( {
        name: 'CourseWizard',
        shouldLog: true,
        steps: [ {
                //1
                title: 'Course page wizard',
                description: 'Project:Training/tour/course_wizard1',
                onShow: gt.getPageAsDescription,
                overlay: true,
                closeOnClickOutside: false,
	            buttons: [ {
                        name: 'Start',
                        onclick: function()  {  if(!mw.config.get('wgUserName')){  alert( "Please login." );   return;   } sendMessage( 'User:' + mw.config.get( 'wgUserName' ) + '/course_wizard', 'Project:Training/tour/course_wizard_preload' , mw.util.getUrl( 'Special:MyPage/course_wizard' ) + '?tour=CourseWizard&step=2'); }
                } ],
                allowAutomaticOkay: false

} , {
                //2
                title: 'Course wizard loaded.',
                description: 'Project:Training/tour/course_wizard2',
                onShow: gt.getPageAsDescription,
                overlay: false,
                closeOnClickOutside: false,
	            buttons: [ {
	            	    name: 'Okay',
                        action: 'end'
                } ],
                allowAutomaticOkay: false
 
}]
 
} );
 
} (window, document, jQuery, mediaWiki, mediaWiki.guidedTour ) ) ;