User:Benoît Prieur/mapillary.js
Jump to navigation
Jump to search
Note: After saving, you have to bypass your browser's cache to see the changes. Internet Explorer: press Ctrl-F5, Mozilla: hold down Shift while clicking Reload (or press Ctrl-Shift-R), Opera/Konqueror: press F5, Safari: hold down Shift + Alt while clicking Reload, Chrome: hold down Shift while clicking Reload.
Documentation for this user script can be added at User:Benoît Prieur/mapillary. |
//Based on Gadget-CropTool, Gadget-Tineye.js and User:Peterneubauer/mapillary.js
(function(mw, $){
if (mw.config.get( 'wgNamespaceNumber' ) !== 6) return;
if (mw.config.get( 'wgAction' ) != 'view') return;
var keys = $('.mapillary_key');
if(keys.length>0 && $(keys[0]).text().length >0) {
$(function(){
mw.loader.load( 'https://unpkg.com/mapillary-js@2.0.0/dist/mapillary.min.css', 'text/css' );
$.getScript( 'https://unpkg.com/mapillary-js@2.0.0/dist/mapillary.min.js', function () {
console.log('keys', keys);
$('#mw-content-text')
.append('<div id="mapillary-content"></div>')
.append('<h2>Mapillary View</h2>')
.append('<div id="mapillary" style="width: 640px; height: 480px;"></div>');
var key = $(keys[0]).text();
console.log('key', key);
new Mapillary.Viewer('mapillary', 'WHZlUV9FNXhFZ24xZEZQRHZzUlZ3QTplNDE1Y2RiMWY3MTliZDc0', key);
});
});
}
})(mediaWiki, jQuery);