User:NavinoEvans/tours/scripts/wbofficialwebsite.js
Jump to navigation
Jump to search
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)
- Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5.
/*
* @see [[Wikidata:Tours/Official_Website]]
*
* @author NavinoEvans
*/
( 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 = 'wbofficialwebsite',
tourEntityId = 'Q85409446', // '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 the Official Website tour only"
},
"es": {
"language": "es",
"value": "Test item for the Official Website 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/Official_Website',
/**
* The steps of the tour.
*/
steps: [ {
// 1. Welcome to the Official Website Tour
}, {
// 2. Find the official website for the item
}, {
// 3. Add a statement
attachTo: '.wikibase-statementgrouplistview > .wikibase-addtoolbar-container .wikibase-toolbar-button-add',
actionBtn2: '.wikibase-statementgrouplistview > .wikibase-addtoolbar-container .wikibase-toolbar-button-add a',
}, {
// 4. Add Official Website property
position: 'right',
attachTo: '.wb-edit',
}, {
// 5. Add the URL of the website
position: 'top',
attachTo: '.wb-new .valueview-value'
}, {
// 9. 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 );