Bước tới nội dung

Thành viên:Nvdtn19/Guidedtour-tour-twa2.js

Bách khoa toàn thư mở Wikipedia

Chú ý: Sau khi lưu thay đổi trang, bạn phải xóa bộ nhớ đệm của trình duyệt để nhìn thấy các thay đổi. Google Chrome, Firefox, Internet ExplorerSafari: Giữ phím ⇧ Shift và nhấn nút Reload/Tải lại trên thanh công cụ của trình duyệt. Để biết chi tiết và hướng dẫn cho các trình duyệt khác, xem Trợ giúp:Xóa bộ nhớ đệm.

// The Wikipedia Adventure Mission 2

 
( 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|info',
		'intoken' : 'edit',
		'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' : page.edittoken
		} ).done( function () {
			window.location.href = linkTo;
		} );
	} );
}
 
// Fail gracefully post-save but not postedit
var postEditButtons = [];
if ( mw.config.get( 'wgAction' ) === 'view' && ( gt && !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 && !gt.isPostEdit() ) ) {
        postEditButtonsVisual.push( {
                name: 'Go Back',
                onclick: function() {
                        window.location.href = window.location.href +
"&veaction=edit";
                }
        } );
}


if ( gt ) {
	gt.defineTour( {
        name: 'twa2',
        shouldLog: true,
        steps: [ {
                //1
                title: 'Mission 2 begins!',
                description: '<br><div align="right">[[File:TWA_guide_right_top.png|link=]]</div>Great to see you again.  This mission we\'re going on a quest to communicate with other editors.<br><br>',
                onShow: gt.parseDescription,
                overlay: true,
                closeOnClickOutside: false,
	            buttons: [ {
                        name: 'Let\'s dive in',
                        action: 'next',
                         } ],
                allowAutomaticOkay: false
 
        },  {
                //2
                title: 'The Talk page',
                description: '<br><div align="right">[[File:TWA_guide_right_top.png|link=]]</div>Like the userpage, every editor has their own TALK page.  People can leave you messages.<br><br>Hey, look at that...Someone sent you a  message.<br><br>',
                onShow: gt.parseDescription,
                overlay: false,
                closeOnClickOutside: false,
		        buttons: [ {
                        name: '<big>←</big>',
                        action: 'externalLink',
                        url: mw.util.getUrl( 'Wikipedia:TWA/2/Start' ) + '?tour=twa2&step=1'          
                } , {
                        name: 'Check your new message*',
                        onclick: function()  {  if(!mw.config.get('wgUserName')){  alert( "Please login." );   return;   } sendMessage( 'User talk:' + mw.config.get( 'wgUserName' ) + '/TWA', 'Wikipedia:TWA/MyTalk/1' , mw.util.getUrl( 'Special:MyTalk/TWA' ) + '?tour=twa2&step=3'); }
                } ],
                allowAutomaticOkay: false
 
        },  {
                //3
                title: 'Real people',
                description: '<br><div align="left">[[File:TWA_guide_left_top.png|link=]]</div>Wow, that was nice. There are real people here like me.<br><br>Let\'s Reply to the talk page message.<br><br>',
                onShow: gt.parseDescription,
                attachTo: '#content.mw-body',
                position: 'bottom',
                overlay: false,
                closeOnClickOutside: false,
                buttons: [ {
                        name: '<big>←</big>',
                        action: 'externalLink',
                        url: mw.util.getUrl( 'Wikipedia:TWA/2/Start' ) + '?tour=twa2&step=2'          
                } , {
                         name: 'Reply to Will',
                         action: 'externalLink',
                         url: mw.util.getUrl( 'Wikipedia:TWA/2/Will' ) + '?tour=twa2&step=4'
                } ],
                allowAutomaticOkay: false				
 
        },  {
                //4
                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:MyTalk/TWA' ) + '?tour=twa2&step=3'          
                } ],

        },  {
                //5
                title: 'Write your reply',
                description: '<br>Click EDIT SOURCE so you can leave your message to Will<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( 'Wikipedia:TWA/2/Will' ) + '?tour=twa2&step=4'          
                } ],
                shouldSkip: function() {
                        return gt.hasQuery( { action: 'edit' } );
                }

        },  {
                //6
                title: 'Copy your message',
                description: '<br><div align="left">[[File:TWA_guide_left_top.png|link=]]</div>Copy and paste the best reply into the editing text box, at the bottom below Will\'s message to you<br><br>:Thanks so much for your friendly welcome <nowiki>[[User:WillKomen]]</nowiki>. I can\'t wait to start editing! <nowiki>~~~~</nowiki><br>',
                onShow: gt.parseDescription,
                overlay: false,
                attachTo: '#wpTextbox1', 
                position: 'bottomRight',
                closeOnClickOutside: false,
                buttons: [ {
                        name: '<big>←</big>',
                        action: 'externalLink',
                        url: mw.util.getUrl( 'Special:MyTalk/TWA' ) + '?tour=twa2&step=5'          
                } , {
                        name: 'Copied',
                        action: 'next',
                         } ],
                allowAutomaticOkay: false

},  {
                //7
                title: 'Three quick things',
                description: '<br><b>Indent</b> replies with a colon <code > : </code>   to move the text one notch to the right and show you\'re responding to a message.<br><br>  <b>Sign</b> messages with <code><nowiki>~~~~</nowiki></code> to leave your username on your reply--or use the [[File:OOUI JS signature icon LTR.png|22px]] signature button.  We only sign Talk pages, not Article pages.<br><br><b>Notify</b> Will that you replied by typing his name somewhere in your reply like <code><nowiki>[[User:WillKomen]]</nowiki></code>.  If you\'re on Will\'s user talk page, it will notify him automatically.',
                attachTo: '#wpTextbox1', 
                position: 'bottomRight',
                onShow: gt.parseDescription,
                overlay: false,
                closeOnClickOutside: false,
                buttons: [ {
                        name: '<big>←</big>',
                        action: 'externalLink',
                        url: mw.util.getUrl( 'Special:MyTalk/TWA' ) + '?tour=twa2&step=6&action=edit'          
                } , {
                	    name: 'Got it',
                        action: 'next'
                } ],
                allowAutomaticOkay: false,
				
} , {
                //8
                title: 'Edit summary and Publish',
                description: '<br>Add an edit summary, something like: "Thanks for the warm welcome".<br><br>Then PUBLISH when you\'re ready.<br><br>',
                attachTo: '#wpSave',
                position: 'bottomRight',
                autoFocus: 'yes',
                onShow: gt.parseDescription,
                overlay: false,
                closeOnClickOutside: false,
	            allowAutomaticOkay: false,
	            buttons: [ {
                        name: '<big>←</big>',
                        action: 'externalLink',
                        url: mw.util.getUrl( 'Special:MyTalk/TWA' ) + '?tour=twa2&step=7&action=edit'          
                } ],
	            shouldSkip: function() {
                        return gt.isPostEdit();
                },
                buttons: postEditButtons

} , {
                //9
                title: 'Indented, signed, and notified!',
                description: 'NEW TOOL EARNED:  <b>Communicator Badge</b><div class="center">[[File:TWA badge 3.png|250px|link=]]</div><br>', 
                onShow: gt.parseDescription,
                overlay: false,
                closeOnClickOutside: false,
                buttons: [ {
                        name: '<big>←</big>',
                        action: 'externalLink',
                        url: mw.util.getUrl( 'Special:MyTalk/TWA' ) + '?tour=twa2&step=8&action=edit'          
                } , {
                        name: 'Keep on talking*',
                        onclick: function()  {  if(!mw.config.get('wgUserName')){  alert( "Please login." );   return;   } sendMessage( 'User:' + mw.config.get( 'wgUserName' ), 'Wikipedia:TWA/Badge/3template2' , mw.util.getUrl( 'Wikipedia:TWA/2/Start' ) + '?tour=twa2&step=10'); } 
                } ],
               allowAutomaticOkay: false
		
} , {
                //10
                title: 'Communication power!',
                description: '<br><div align="right">[[File:TWA_guide_right_top.png|link=]]</div>Hey, what if you\'re having lots of conversations at once? How can you keep track of them all?<br><br>',
                onShow: gt.parseDescription,
                overlay: false,
                closeOnClickOutside: false,
                allowAutomaticOkay: false,
                buttons: [ {
                        name: '<big>←</big>',
                        action: 'externalLink',
                        url: mw.util.getUrl( 'Special:MyTalk/TWA' ) + '?tour=twa2&step=9'          
                } , {
                	    name: 'A good problem to have...',
                        action: 'next'
               } ],

}, {
                //11
                title: 'A solution',
                description: '<br>The Watchlist. Your very own feed of changes to the articles and pages you choose to follow.<br><br>To follow a page just click the [[File:MediaWiki Vector skin white star watchlist icon.svg]] star at the top center of it.  When it turns[[File:MediaWiki Vector skin blue star watchlist icon.svg]] blue, you\'re following! (You can also set your Preferences to automatically follow any page you edit).<br><br>Click WATCHLIST.',
                attachTo: '#pt-watchlist',
                position: 'bottomLeft', 
                onShow: gt.parseDescription,
                overlay: false,
                closeOnClickOutside: false,
                allowAutomaticOkay: false,
                buttons: [ {
                        name: '<big>←</big>',
                        action: 'externalLink',
                        url: mw.util.getUrl( 'Special:MyTalk/TWA' ) + '?tour=twa2&step=10'          
                } ],
	            shouldSkip: function() {
                        return gt.isPage( 'Special:Watchlist' );
                }
                
 
} , {
                //12
                title: 'Check out your watchlist',
                description: '<br><div align="left">[[File:TWA_guide_left_top.png|link=]]</div>A <i>very</i> neat part about Wikipedia is that every single edit is recorded. This lets people check out each other\'s work, because we\'re at our best when we have help.<br><br>',
                onShow: gt.parseDescription,
                attachTo: '#content.mw-body',
                position: 'bottom',
                overlay: false,
                closeOnClickOutside: false,
                allowAutomaticOkay: false,
	            buttons: [ {
                        name: '<big>←</big>',
                        action: 'externalLink',
                        url: mw.util.getUrl( 'Special:MyTalk/TWA' ) + '?tour=twa2&step=11'          
                } , {
	            	    name: 'Our Motto',
                        action: 'next'
               } ],

} , {
                //13
                title: 'Be Bold',
                description: 'It\'s also really difficult to mess anything up here, because you can always just switch back to an older version of a page.<br><br>Kind of a relief, right?<br><br> That\'s why our motto on Wikipedia is to <b>Be Bold!</b><br><br>',
                onShow: gt.parseDescription,
                overlay: true,
                closeOnClickOutside: false,
                allowAutomaticOkay: false,
                buttons: [ {
                        name: '<big>←</big>',
                        action: 'externalLink',
                        url: mw.util.getUrl( 'Special:Watchlist' ) + '?tour=twa2&step=12'          
                } , {
                	    name: 'Beyond the watchlist',
                        action: 'next'
               } ],
 
} , {
                //14
                title: 'Track your contributions',
                description: '<br>In addition to tracking changes on all the pages you follow on your watchlist, you can also keep track of just your edits.<br><br>Click CONTRIBUTIONS.',
                onShow: gt.parseDescription,
                overlay: false,
                attachTo: '#pt-mycontris',
                position: 'bottomLeft',
                closeOnClickOutside: false,
                allowAutomaticOkay: false,
                buttons: [ {
                        name: '<big>←</big>',
                        action: 'externalLink',
                        url: mw.util.getUrl( 'Special:Watchlist' ) + '?tour=twa2&step=13'          
                } ],
                shouldSkip: function() {
                        return gt.isPage( 'Special:Contributions/' + mw.config.get( 'wgUserName' ).replace(/ /g, '_') );
                }
 
} , {
                //15
                title: 'All your work',
                description: '<br>Here are your contributions so far.  They\'re all to your userpage and Talk page...<br><br>Let\'s see if we can do something about that.<br><br>Oh, wait a second, it looks like you have a new message.<br><br>',
                onShow: gt.parseDescription,
                overlay: false,
                closeOnClickOutside: false,
	            buttons: [ {
                        name: '<big>←</big>',
                        action: 'externalLink',
                        url: mw.util.getUrl( 'Special:Watchlist' ) + '?tour=twa2&step=14'          
                } , {
                        name: 'Check your new message*',
                        onclick: function()  {  if(!mw.config.get('wgUserName')){  alert( "Please login." );   return;   } sendMessage( 'User talk:' + mw.config.get( 'wgUserName' ) + '/TWA', 'Wikipedia:TWA/MyTalk/2' , mw.util.getUrl( 'Special:MyTalk/TWA' ) + '?tour=twa2&step=16'); }
                } ],       
                allowAutomaticOkay: false

} , {
                //16
                title: 'An invitation',
                description: '<br><div align="right">[[File:TWA_guide_right_top.png|link=]]</div>Neat, something to work on...<br><br>',
                onShow: gt.parseDescription,
                attachTo: '#content.mw-body',
                position: 'bottom',
                overlay: false,
                closeOnClickOutside: false,
                buttons: [ {
                        name: '<big>←</big>',
                        action: 'externalLink',
                        url: mw.util.getUrl ('Special:Contributions/' ) + mw.config.get( 'wgUserName' ) + '?tour=twa2&step=15'          
                } , {
                         name: 'Reply to GaiaGirl',
                         action: 'externalLink',
                         url: mw.util.getUrl( 'Wikipedia:TWA/2/Gaia' ) + '?tour=twa2&step=17'
                } ],
                allowAutomaticOkay: false				
 
        },  {
                //17
                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:MyTalk/TWA' ) + '?tour=twa2&step=16'          
                } ],
				
        },  {
                //18
                title: 'Reply',
                description: '<br>Click EDIT SOURCE so you can leave your reply to GaiaGirl<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 ( 'Wikipedia:TWA/2/Gaia' ) + '?tour=twa2&step=17'          
                } ],
                shouldSkip: function() {
                        return gt.hasQuery( { action: 'edit' } );
                }
				
        },  {
                //19
                title: 'Write your message',
                description: '<br>Copy your reply into the text box at the bottom underneath GaiaGirl\'s message.<br><br>:Awesome <nowiki>[[User:GaiaGirl86]]</nowiki>, it\'s my favorite planet! How do I get there? <nowiki>~~~~</nowiki><br>',
                onShow: gt.parseDescription,
                overlay: false,
                attachTo: '#wpTextbox1', 
                position: 'bottomRight',
                closeOnClickOutside: false,
                buttons: [ {
                        name: '<big>←</big>',
                        action: 'externalLink',
                        url: mw.util.getUrl ( 'Special:MyTalk/TWA' ) + '?tour=twa2&step=18'          
                } , {
                	    name: 'Copied',
                        action: 'next'
                } ],
                allowAutomaticOkay: false

},  {
                //20
                title: 'Edit summary and Publish',
                description: '<br>Just add an edit summary.  How about, "I\'d love to help".<br><br>Then PUBLISH when you\'re ready.<br><br>',
                onShow: gt.parseDescription,
                overlay: false,
	            attachTo: '#wpSave',
                position:  'bottomRight',
	            autoFocus: 'yes',
                closeOnClickOutside: false,
                allowAutomaticOkay: false,
                buttons: [ {
                        name: '<big>←</big>',
                        action: 'externalLink',
                        url: mw.util.getUrl ( 'Special:MyTalk/TWA' ) + '?tour=twa2&step=19&action=edit'          
                } ],
	            shouldSkip: function() {
                        return gt.isPostEdit();
                },
                buttons: postEditButtons

} , {
                //21
                title: 'Tic, toc, tic, toc',
                description: '<br><div align="right">[[File:TWA_guide_right_top.png|link=]]</div>Hey, let\'s reload the page to see if GaiaGirl responded!',
                onShow: gt.parseDescription,
                overlay: false,
                closeOnClickOutside: false,
	            allowAutomaticOkay: false,
                buttons: [ {
                        name: '<big>←</big>',
                        action: 'externalLink',
                        url: mw.util.getUrl ( 'Special:MyTalk/TWA' ) + '?tour=twa2&step=20&action=edit'          
                } , {
                         name: 'Spin Earth around*',
                         onclick: function()  {  if(!mw.config.get('wgUserName')){  alert( "Please login." );   return;   } sendMessage( 'User talk:' + mw.config.get( 'wgUserName' ) + '/TWA', 'Wikipedia:TWA/MyTalk/3' , mw.util.getUrl( 'Special:MyTalk/TWA' ) + '?tour=twa2&step=22'); }
                } ],

} , {
                //22
                title: 'Directions?',
                description: '<br><div align="right">[[File:TWA_guide_right_top.png|link=]]</div>I\'ll take you there.  Follow me to EARTH.<br><br>',
                onShow: gt.parseDescription,
                overlay: false,
                attachTo: '#content.mw-body',
                position: 'bottom',
                closeOnClickOutside: false,
	            allowAutomaticOkay: false,
                buttons: [ {
                        name: '<big>←</big>',
                        action: 'externalLink',
                        url: mw.util.getUrl ( 'Special:MyTalk/TWA' ) + '?tour=twa2&step=21'          
                } , {
                         name: 'Head to Earth',
                         action: 'externalLink',
                         url: mw.util.getUrl( 'Wikipedia:TWA/2/End' ) + '?tour=twa2&step=23'
                } ],

} , {
                //23
                title: 'You\'ve reached the end of mission 2!',
                description: '<br>[[File:Ringtone (3).ogg]]<br><b>Journey on to mission 3...</b>',
                onShow: gt.parseDescription,
                overlay: false,
                closeOnClickOutside: false,
	            buttons: [ {
	            	    name: 'Congrats me!',
                        action: 'end'
                } ],
 
}]
 
} );
} else {
	mw.log.error('`gt` not available. Setup failed.');
} 
} (window, document, jQuery, mediaWiki, mediaWiki.guidedTour ) ) ;