User:NavinoEvans/tours/scripts/wbcoordinates.js

Note: After publishing, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
  • Opera: Press Ctrl-F5.
/*
 * @see [[Wikidata:Tours/Coordinates]]
 * 
 * @author Pasleim
 */
( function( $, mw, gt, wb ) {
 
	$.ajax( {
		async: false,
		url: mw.util.wikiScript() + '?title=MediaWiki:Guidedtour-lib.js&action=raw&ctype=text/javascript',
		dataType: 'script'
	} );

	var tourName = 'wbcoordinates',
		tourEntityId = 'Q85408938', // 'Q211911'
		newData = {
			"labels": {
                "en": {
                    "language": "en",
                    "value": "National Museum of Anthropology"
                },
                 "es": {
                    "language": "es",
                    "value": "Museo Nacional de Antropología"
                },
			},
			"descriptions": {
                "en": {
                    "language": "en",
                    "value": "Test item for Coordinates tour only"
                },
                 "es": {
                    "language": "es",
                    "value": "Test item for Coordinates tour only"
                },
			},
			"claims": [{
				"mainsnak": {
					"snaktype": "value",
					"property": "P31", // "P39"
					"datavalue": {
						"value": {
							"entity-type": "item",
							"id": "Q24699794", // "Q497"
						},
						"type": "wikibase-entityid"
					},
					"datatype": "wikibase-item"
				},
				"type": "statement",
				"rank": "normal"
			}, {
				"mainsnak": {
					"snaktype": "value",
					"property": "P1705", // "P246"
					"datavalue": {
						"value": {
							"text": "Museo Nacional de Antropolog\u00eda",
							"language": "es"
						},
						"type": "monolingualtext"
					},
					"datatype": "monolingualtext"
				},
				"type": "statement",
				"rank": "normal"
			}, {
				"mainsnak": {
					"snaktype": "value",
					"property": "P131", // "P82"
					"datavalue": {
						"value": {
							"entity-type": "item",
							"id": "Q1489" // "Q497"
						},
						"type": "wikibase-entityid"
					},
					"datatype": "wikibase-item"
				},
				"type": "statement",
				"rank": "normal"
			}]};

	gt.init( tourName, tourEntityId, newData, {

		/**
		 * The page from where the tour texts should be loaded.
		 */
		pageName: 'Wikidata:Tours/Coordinates',

		/**
		 * The steps of the tour.
		 */
		steps: [ {
			// Welcome to the Coordinates Tour
		}, {
			// Find coordinates for the item
		}, {
			// Add a statement
			attachTo: '.wikibase-statementgrouplistview > .wikibase-addtoolbar-container .wikibase-toolbar-button-add',
			actionBtn2: '.wikibase-statementgrouplistview > .wikibase-addtoolbar-container .wikibase-toolbar-button-add a',
		}, {
			// Add coordinate location property
			position: 'top',
			attachTo: '.wb-edit',
			//actionBtn2: '.ui-entityselector-list li'
		}, {
			// Add the coordinates
			position: 'top',
			attachTo: '.wb-new .valueview-value'
		}, {
			// Add reference
			position: 'top',
			attachTo: '.wb-new .wikibase-statementview-references .wikibase-toolbar-button-add',
			actionBtn2: '.wb-new .wikibase-statementview-references .wikibase-toolbar-button-add a'
		}, {
			// Add reference property
			position: 'top',
			attachTo: '.wb-reference-new .ui-suggester-input'			
		}, {
			// Add reference link
			position: 'top',			
			attachTo: '.wb-reference-new .valueview-value',
		}, {
			// Publish
			position: 'top',
			attachTo: '.wb-new .wikibase-toolbar-button-save',
			actionBtn2: '.wb-new .wikibase-toolbar-button-save a',			
		}, {
			// Congratulations!
			onShow: function() {
				// Quick hack to redirect to Tours page.
				// Todo: should be the default action for clicking the "end tour" button on any Wikidata 
				$('.guidedtour-end-button').off('click').on('click', function() {
					window.location = window.location.origin + '/wiki/Wikidata:tours';
				})
			}
		} ]
	} );

} )( jQuery, mediaWiki, mediaWiki.guidedTour, wikibase );