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

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

// FindDPLA Guided Tour for installation and instruction

( 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' : 'Installing FindDPLA script (API:EDIT) through The Wikipedia Library',
					'token' : page.edittoken
				},
				{
					'ok'  : function() { window.location.href = linkTo;}
				}
			);
		}
	}	);
}

// Fail gracefully post-save but not postedit
var postEditButtons = [];
if ( mw.config.get( 'wgAction' ) === 'view' && !gt.isPostEdit() ) {
        postEditButtons.push( {
                name: 'Click here to go back and make an edit',
                onclick: function() {
                        window.location.href = new mw.Uri().extend( { action: 'edit' } ).toString();
                }
        } );
}

// Fail gracefully post-save but not postedit for visual editor
var postEditButtonsVisual = [];
if ( mw.config.get( 'wgAction' ) === 'view' && !gt.isPostEdit() ) {
        postEditButtonsVisual.push( {
                name: 'Go Back',
                onclick: function() {
                        window.location.href = window.location.href + "&veaction=edit";
                }
        } );
}

gt.defineTour( {
        name: 'finddpla',
		shouldLog: true,
        steps: [ {
        	    //1
                title: 'Welcome to Wikipedia!',
                description: '<br>We built a tool so you can see relevant content from the [[Digital Public Library of America]] (DPLA) any time you view a Wikipedia article. (Use an updated version of the Chrome or Firefox browser for now).<br><br>',
                onShow: gt.parseDescription,
                overlay: true,
                closeOnClickOutside: false,
	            buttons: [ {
                        name: 'Install the script',
                        action: 'next',
                } ],
                
                                allowAutomaticOkay: false	
                
        },  {
                //2
                title: 'First create an account or login',
                description: '<br>Accounts are free and easy to create. Go for it.<br><br>',
                onShow: gt.parseDescription,
                overlay: false,
                closeOnClickOutside: false,
                buttons: [ {
                        name: '<small>←</small>',
                        action: 'externalLink',
                        url: mw.util.getUrl( 'Wikipedia:FindDPLA' ) + '?tour=finddpla&step=1'          
                } , {
                	name: 'Have account, need to login',
                        action: 'externalLink',
                        url: mw.util.getUrl( 'Special:UserLogin' ) + '?tour=finddpla&step=3'
                     
                } , {
                	name: 'Register!',
                    action: 'externalLink',
                    url: mw.util.getUrl( 'Special:UserLogin/signup' ) + '?tour=finddpla&step=3'
                        
                } ],
                allowAutomaticOkay: false,
                shouldSkip: function () {
                return mw.config.get( 'wgUserId' )  !== null;
                }	
                

        },  {
        	
        	    //3
                title: 'One click and you\'re done',
                description: '<br>This is easy, just click the Install button<br><br>',
                overlay: true,
                onShow: gt.parseDescription,
                closeOnClickOutside: false,
                buttons: [ {
                        name: '<small>←</small>',
                        action: 'externalLink',
                        url: mw.util.getUrl( 'Wikipedia:FindDPLA' ) + '?tour=finddpla&step=1' 
                } , {
                         name: 'Install script*',
                         onclick: function()  {  if(!mw.config.get('wgUserName')){  alert( "Please login." );   return;   } sendMessage( 'User:' + mw.config.get( 'wgUserName' ) + '/common.js', 'Wikipedia:FindDPLA.js' , mw.util.getUrl( 'Haymarket affair' ) + '?tour=finddpla&step=4'); } 
                
               } ],	
                allowAutomaticOkay: false	
                
        },  {

                //4
                title: 'Try it out!',
                description: '<br>Let\'s see what they have on the... Haymarket affair.  Note that since Wikipedia now uses https, you have to approve the script to run.<br><br>At the article, Click the <b>Shield</b> icon in the url address bar to load the results!  (We will fix this soon).<br><br>',
                onShow: gt.parseDescription,
                overlay: false,
                closeOnClickOutside: false,
	            buttons: [ {
                        name: '<small>←</small>',
                        action: 'externalLink',
                        url: mw.util.getUrl( 'Wikipedia:FindDPLA' ) + '?tour=finddpla&step=3'   
                } , {
                        name: 'I clicked the shield',
                        action: 'next',
                } ],
                allowAutomaticOkay: false
                
        },  {

        		//5
		 		title: 'That is it!  Go exploring :)',
                description: '<br>Note that DPLA Images have an icon next to them in the results.  The rest are text sources.  You can learn about more neat Wikipedia tricks through [[WP:TWL|The Wikipedia Library]].<br>To uninstall this script, search for <b>WP:FindDPLA</b> in the Wikipedia search box.<br><br>',
                onShow: gt.parseDescription,
                overlay: false,
                closeOnClickOutside: true,
	            buttons: [ {
                        name: '<small>←</small>',
                        action: 'externalLink',
                        url: mw.util.getUrl( 'Wikipedia:FindDPLA' ) + '?tour=finddpla&step=4'   
                } , {
                	    name: 'That was fun.  Congrats me!',
                              action: 'end'      
                } ],
}]

} );
 
} (window, document, jQuery, mediaWiki, mediaWiki.guidedTour ) ) ;