Jump to content

User:Aaron Liu/TWA1.js

From Wikipedia, the free encyclopedia
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
// The Wikipedia Adventure Mission 1 - Source Editor

( function ( window, document, $, mw, gt ) {

//automatic api:edit function to send yourself messages
function sendMessage( targetPage, msgPage, linkTo ) {
	var api = new mw.Api();
	api.get( {
		'action' : 'query',
		'titles' : msgPage,
		'prop'   : 'revisions',
		'meta'   : 'tokens',
		'type'   : 'csrf',
		'rvprop' : 'content',
		'indexpageids' : 1
	} ).done( 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' : 'New Message (simulated automatically as part of [[WP:The Wikipedia Adventure|The Wikipedia Adventure]])',
			'token' : result.tokens.csrftoken
		} ).done( 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: 'twa1',
		shouldLog: true,
        steps: [ {
                //1
                title: 'Welcome to Wikipedia!',
                description: '<div align="left">[[File:TWA_guide_left_top.png|link=]]</div><p>Wikipedia is a free encyclopedia that <strong>anyone can edit</strong>.  I\'m here to take you on an interactive tour of our universe.</p><p>The journey has 7 missions, each with its own skills and surprises, all designed for you to become a great contributor to Wikipedia.</p>',
                onShow: gt.parseDescription,
                overlay: true,
                closeOnClickOutside: false,
	            buttons: [ {
                        name: 'Get equipped for the trip',
                        action: 'next',
                }, {
                        name: 'I\'d like to leave',
                        onclick: function()  {  document.cookie = 'enwiki-mw-tour=; Path=/; Expires=Thu, 01 Jan 1970 00:00:01 GMT;'; document.location.replace('/wiki/Wikipedia:The Wikipedia Adventure'); return false; } 
                } ],
                allowAutomaticOkay: false	
        		},  
        		{
                //2
                title: 'Know before you go',
                description: '<h4>Don\'t [x] out</h4> This box is your spacesuit: if you close it before completing a mission, you leave the adventure and need to restart the mission from the beginning.<h4>Automatic messages</h4> When you play this game, you send some messages to your personal Wikipedia page, any time you see <big><b>*</b></big> in the blue button.<h4>Source editor</h4> This tour uses only the Source editor, not the Visual editor. It has several advantages. For example, it loads faster!',
                onShow: gt.parseDescription,
                overlay: true,
                closeOnClickOutside: false,
		        buttons: [ {
                        name: '<big>←</big>',
                        action: 'externalLink',
                        url: mw.util.getUrl( 'Wikipedia:TWA/1/Start' ) + '?tour=twa1&step=1'          
                } , {
                        name: 'Come with me...',
                        action: 'next',
                         } ],
                allowAutomaticOkay: false		

        },  {
                //3
                title: 'Why Wikipedia?',
                description: '<br><div align="right">[[File:TWA_guide_right_top.png|link=]]</div>We have a really awesome goal.  <br><br><b>Imagine a world in which every single person on the planet is given free access to the sum of all human knowledge.</b><br><br>Most amazing is that...<br><br>',
                onShow: gt.parseDescription,
                overlay: false,
                closeOnClickOutside: false,
                buttons: [ {
                        name: '<big>←</big>',
                        action: 'externalLink',
                        url: mw.util.getUrl( 'Wikipedia:TWA/1/Start' ) + '?tour=twa1&step=2'          
                } , {
                         name: 'It is happening',
                         action: 'next',
                         } ],
                allowAutomaticOkay: false				

        },  {
                //4
                title: 'It is happening',
                description: '<br><div align="right">[[File:TWA_guide_right_top.png|link=]]</div>Wikipedia is viewed more than 8000 times a second by half a billion people each month. We\'re the only nonprofit top-ten website in the world. And we only got started in 2001!<br><br>',
                onShow: gt.parseDescription,
                overlay: false,
                closeOnClickOutside: false,
                buttons: [ {
                        name: '<big>←</big>',
                        action: 'externalLink',
                        url: mw.util.getUrl( 'Wikipedia:TWA/1/Start' ) + '?tour=twa1&step=3'          
                } , {
                        name: 'Who writes this Wikipedia?',
                        action: 'next',
                         } ],
	            allowAutomaticOkay: false
        },  {
                //5
                title: 'Who writes this Wikipedia?',
                description: '<br><div align="right">[[File:TWA_guide_right_top.png|link=]]</div>You do :) There are almost 50 million registered users. Most importantly, you don\'t have to be an expert to contribute. Almost all of our editors are volunteers.<br><br>',
                onShow: gt.parseDescription,
                overlay: false,
                closeOnClickOutside: false,
                buttons: [ {
                        name: '<big>←</big>',
                        action: 'externalLink',
                        url: mw.util.getUrl( 'Wikipedia:TWA/1/Start' ) + '?tour=twa1&step=4'          
                } , {
                        name: 'Why do people edit?',
                        action: 'next',
                         } ],
		        allowAutomaticOkay: false
        },  {

                //6
                title: 'Discover your special role',
                description: '<br><div align="left">[[File:TWA_guide_left_top.png|link=]]</div>The amazing part of Wikipedia is you get to discover your own path and purpose.  But each person\'s impact scales to make a huge difference. Your impact can change the world.<br><br>',
                onShow: gt.parseDescription,
                overlay: false,
                closeOnClickOutside: false,
                buttons: [ {
                        name: '<big>←</big>',
                        action: 'externalLink',
                        url: mw.util.getUrl( 'Wikipedia:TWA/1/Start' ) + '?tour=twa1&step=5'          
                } , {
                        name: 'Are you ready?',
                        action: 'next',
                         } ],
                allowAutomaticOkay: false,
},  {
                //7
                title: 'Login or create an account',
                description: '<br><div align="left">[[File:TWA_guide_left_top.png|link=]]</div>Creating an account gives you lots of neat benefits.  Go for it.<br><br>',
                onShow: gt.parseDescription,
                overlay: false,
                closeOnClickOutside: false,
                buttons: [ {
                        name: '<big>←</big>',
                        action: 'externalLink',
                        url: mw.util.getUrl( 'Wikipedia:TWA/1/Start' ) + '?tour=twa1&step=6'  
                } , {
                	name: 'I\'m logged in',
                        action: 'externalLink',
                        url: mw.util.getUrl( 'Wikipedia:TWA/1/Start' ) + '?tour=twa1&step=8'
                        
                } , {
                	name: 'I need to login',
                        action: 'externalLink',
                        url: mw.util.getUrl( 'Special:UserLogin' ) + '?tour=twa1&step=7'
                     
                } , {
                	name: 'Register!',
                    action: 'externalLink',
                    url: mw.config.get('wgServer') + mw.config.get('wgScriptPath') + '/index.php?title=Special:UserLogin&returnto=Wikipedia:TWA/1/Start&returntoquery=tour%3Dtwa1%26step%3D8%26showGettingStarted%3Dfalse&type=signup'
                        
                } ],
                allowAutomaticOkay: false,
                shouldSkip: function () {
                return mw.config.get( 'wgUserId' )  !== null;
                }
				
} , {
                //8
                title: 'Say hello to Wikipedia',
                description: '<br>  Let\'s start off by introducing yourself to the community.<br><br>It will take just a few seconds to load the universe—light only travels so fast.<br><br>(For the rest of the journey, you need to be logged in.)<br><br>',
                overlay: true,
                onShow: gt.parseDescription,
                closeOnClickOutside: false,
                buttons: [ {
                        name: '<big>←</big>',
                        action: 'externalLink',
                        url: mw.util.getUrl( 'Wikipedia:TWA/1/Start' ) + '?tour=twa1&step=6'          
                } , {
                         name: 'Hello World*',
                         onclick: function()  {  if(!mw.config.get('wgUserName')){  alert( "Please login." );   return;   } sendMessage( 'User talk:' + mw.config.get( 'wgUserName' ), 'Wikipedia:TWA/Welcome' , mw.util.getUrl( 'Special:MyPage' ) + '?tour=twa1&step=9'); } 
                } ],	
                allowAutomaticOkay: false
				
} , {
                //9
                title: 'Your userpage',
                description: '<br><div align="right">[[File:TWA_guide_right_top.png|link=]]</div>Your userpage is a place to tell other editors about yourself. You can share about your background and interests and what you\'d like to contribute to the project--share as much or as little as you like...<br><br><i>Remember this is a very public profile, so keep private information, well, private.</i><br><br>',
                onShow: gt.parseDescription,
                overlay: false,
                closeOnClickOutside: false,
                buttons: [ {
                        name: '<big>←</big>',
                        action: 'externalLink',
                        url: mw.util.getUrl( 'Wikipedia:TWA/1/Start' ) + '?tour=twa1&step=8'          
                } , {
                        name: 'What does a good userpage look like?',
                        action: 'externalLink',
                        url: mw.util.getUrl( 'Wikipedia:TWA/1/Bio' ) + '?tour=twa1&step=10'
                } ],
		allowAutomaticOkay: false
		
} , {
                //10
                title: 'Challenge yourself BELOW...',
                description: 'Hint: you can learn as much from getting it wrong as getting it right.  And you can always try again!',
                attachTo:'#contentSub',
                position: 'bottom',
                onShow: gt.parseDescription,
                overlay: false,
                closeOnClickOutside: false,
                allowAutomaticOkay: false, 
                buttons: [ {
                        name: '<big>←</big>',
                        action: 'externalLink',
                        url: mw.util.getUrl( 'Special:MyPage' ) + '?tour=twa1&step=9'          
                } ],
               
} , {
                //11
                title: 'Your turn!',
                description: '<br>Creating your userpage on Wikipedia is as simple as editing it.<br><br>Click <b>CREATE SOURCE</b> or <b>EDIT SOURCE</b> above.<br><br>(This adventure always uses the SOURCE editor, which is no longer enabled by default. If you do not see "Edit source", you can enable it by visiting the "Editing" tab of your Wikipedia preferences and selecting "Show me both editor tabs" for the "Editing mode" option, then saving your preferences and returning here.)<br><br>',
                attachTo: '#ca-edit',
                position: 'bottom',
                onShow: gt.parseDescription,
                overlay: false,
                closeOnClickOutside: false,
                allowAutomaticOkay: false,
                buttons: [ {
                        name: '<big>←</big>',
                        action: 'externalLink',
                        url: mw.util.getUrl( 'Special:MyPage' ) + '?tour=twa1&step=9'          
                } ],
                shouldSkip: function() {
                        return gt.hasQuery( { action: 'edit' } );
                }

}, {
                //12
                title: 'The editing interface',
                description: '<br><div align="right">[[File:TWA_guide_right_top.png|link=]]</div>First off, this journey does not use the Visual Editor, so just click KEEP EDITING in the box to the left.<br><br> Now, this is where the magic happens.<br><br>Type into the big text box towards the top left:  your username, city or country, education, skills, and interests.  What are you excited about <i>doing</i> here? Share as much or as little as you like, but make at least <b>ONE</b> edit.  <br><br>If you already have a userpage, make at least <b>ONE</b> improvement to it.<br><br>',
                onShow: gt.parseDescription,
                overlay: false,
                attachTo: '#wpTextbox1', 
                position: 'bottomRight',
                closeOnClickOutside: false,
	            buttons: [ {
                        name: '<big>←</big>',
                        action: 'externalLink',
                        url: mw.util.getUrl( 'Special:MyPage' ) + '?tour=twa1&step=11'          
                } , {
                        name: 'Typed it',
                        action: 'next'
               } ],
               
} , {
                //13
                title: 'Edit summary and Publish',
                description: '<br>That looks pretty good! Before you click Publish, leave a brief note about the changes you made, called an Edit Summary. This helps others follow along with your work.<br><br>Let\'s say that you "Introduced myself".<br><br>Now all you have to do is Publish it. Saving makes an edit live and public.  Click PUBLISH when you\'re ready.<br><br>',
                onShow: gt.parseDescription,
                overlay: false,
                attachTo:  '#wpSave', 
                position: 'bottomRight',
                closeOnClickOutside: false,
                allowAutomaticOkay: false,
                shouldSkip: function() {
                        return gt.isPostEdit();
                },
                buttons: [ {
                        name: '<big>←</big>',
                        action: 'externalLink',
                        url: mw.util.getUrl( 'Special:MyPage' ) + '?tour=twa1&step=12&action=edit'          
                } ],
                buttons: postEditButtons

} , {
                //14
                title: 'Congrats!',
                description: 'NEW TOOL EARNED:  <b>Editor Badge</b><div class="center">[[File:TWA badge 1.png|250px|link=]]</div><br>You\'re a Wikipedia editor! How does it feel? It\'s great that you introduced yourself.<br>',
                overlay: false,
                onShow: gt.parseDescription,
                closeOnClickOutside: false,
                allowAutomaticOkay: false,
                buttons: [ {
                        name: '<big>←</big>',
                        action: 'externalLink',
                        url: mw.util.getUrl( 'Special:MyPage' ) + '?tour=twa1&step=13&action=edit'          
                } , {
                        name: 'Make it even better*',
                        onclick: function()  {  if(!mw.config.get('wgUserName')){  alert( "Please login." );   return;   } sendMessage( 'User:' + mw.config.get( 'wgUserName' ), 'Wikipedia:TWA/Badge/1template2' , mw.util.getUrl( 'Special:MyPage' ) + '?tour=twa1&step=15'); } 
                } ],

} , {
                //15
                title: 'Even better',
                description: '<br>Let\'s go back and make a few changes to the text.  Click <b>EDIT SOURCE</b><br><br>',
                overlay: false,
                attachTo: '#ca-edit',
                position: 'bottom',
                onShow: gt.parseDescription,
                closeOnClickOutside: false,
                allowAutomaticOkay: false,
                buttons: [ {
                        name: '<big>←</big>',
                        action: 'externalLink',
                        url: mw.util.getUrl( 'Special:MyPage' ) + '?tour=twa1&step=14'          
                } ],
                shouldSkip: function() {
                        return gt.hasQuery( { action: 'edit' } );
                }

} , {
                //16
                title: 'Add bold',
                description: '<br><div align="right">[[File:TWA guide right top.png|link=]]</div>In the text box, Highlight your username (or another key phrase) with your mouse.<br><br>Then click the [[File:OOjs UI icon bold-b.svg]] button on the editing toolbar above the text box.<br><br>The editing toolbar makes Wikipedia much much easier, because it adds the formatting for you.',
                attachTo: '#wpTextbox1', 
                position: 'bottomRight',
                onShow: gt.parseDescription,
                overlay: false,
                closeOnClickOutside: false,
                buttons: [ {
                        name: '<big>←</big>',
                        action: 'externalLink',
                        url: mw.util.getUrl( 'Special:MyPage' ) + '?tour=twa1&step=15'          
                } , {
                	    name: 'Bolded',
                        action: 'next'
                } ],

} , {
                //17
                title: 'Add italics',
                description: '<br><div align="right">[[File:TWA guide right top.png|link=]]</div>Now highlight your interests.<br><br>Then click [[File:OOjs UI icon italic-i.svg]] on the editing toolbar to put them in italics.<br><br>',
                attachTo: '#wpTextbox1', 
                position: 'bottomRight',
                onShow: gt.parseDescription,
                overlay: false,
                closeOnClickOutside: false,
                allowAutomaticOkay: false	,
                buttons: [ {
                        name: '<big>←</big>',
                        action: 'externalLink',
                        url: mw.util.getUrl( 'Special:MyPage' ) + '?tour=twa1&step=16&action=edit'          
                } , {
                	    name: 'Italicized',
                        action: 'next'
                } ],

} , {
                //18
                title: 'Add wikilinks',
                description: '<br><div align="right">[[File:TWA guide right top.png|link=]]</div>You can link to other pages on Wikipedia. This helps "build the web", and keeps you from getting any work done while you bounce from one article to another ;)<br><br> Highlight the city or country where you\'re from. <br><br>Then click the [[File:OOjs UI icon link-ltr.svg]] button in the editing toolbar (it looks like part of a chain).<br><br>Last, INSERT the link.<br><br>',
                attachTo: '#wpTextbox1', 
                position: 'bottomRight',
                onShow: gt.parseDescription,
                overlay: false,
                closeOnClickOutside: false,
                buttons: [ {
                        name: '<big>←</big>',
                        action: 'externalLink',
                        url: mw.util.getUrl( 'Special:MyPage' ) + '?tour=twa1&step=17&action=edit'          
                } , {
                	    name: 'WikiLinked',
                        action: 'next'
                } ],

} , {
                //19
                title: 'Edit summary and Save',
                description: '<br>You "Added bold, italics, and wikilinks".  Just click SAVE, and your edits will go live.<br><br>',
                attachTo: '#wpSave',
                position: 'bottomRight',
                onShow: gt.parseDescription,
                overlay: false,
                closeOnClickOutside: false,
                allowAutomaticOkay: false,
                buttons: [ {
                        name: '<big>←</big>',
                        action: 'externalLink',
                        url: mw.util.getUrl( 'Special:MyPage' ) + '?tour=twa1&step=18&action=edit'          
                } ],
                shouldSkip: function() {
                        return gt.isPostEdit();
                },
                buttons: postEditButtons

} , {
                //20
                title: 'You did it :)',
                description: 'NEW TOOL EARNED:  <b>Formatter Badge</b><div class="center">[[File:TWA badge 2.png|250px|link=]]</div><br>You\'re learning fast.  You\'re awesome.  We\'re just getting started but already you have the basic tools to go on an adventure. Keep an eye on the skill meter at the bottom of the page as you develop more and more strengths.<br>',
                overlay: true,
                onShow: gt.parseDescription,
                closeOnClickOutside: false,
                buttons: [ {
                        name: '<big>←</big>',
                        action: 'externalLink',
                        url: mw.util.getUrl( 'Special:MyPage' ) + '?tour=twa1&step=19&action=edit'          
                } , {
                        name: 'What\'s next??*',
                        onclick: function()  {  if(!mw.config.get('wgUserName')){  alert( "Please login." );   return;   } sendMessage( 'User:' + mw.config.get( 'wgUserName' ), 'Wikipedia:TWA/Badge/2template2' , mw.util.getUrl( 'Wikipedia:TWA/1/End' ) + '?tour=twa1&step=21'); } 
                } ],
                allowAutomaticOkay: false

} , {
                //21
                title: 'Mission 1 complete!',
                description: '<br>[[File:Carl Czerny - Duo Concertante - 1. Allegro (short).ogg]]<br><b>Journey on to mission 2...</b>',
                onShow: gt.parseDescription,
                overlay: false,
                closeOnClickOutside: false,
                buttons: [ {
                	    name: 'Congrats me!',
                        action: 'end'      
                } ],


}]

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