797
edits
No edit summary |
No edit summary |
||
Line 125: | Line 125: | ||
mw.hook( 'wikipage.collapsibleContent' ).add( mwCollapsibleSetup ); | mw.hook( 'wikipage.collapsibleContent' ).add( mwCollapsibleSetup ); | ||
$("div[data-iframe-type=\"minetestmap\"]").each(function() { | |||
const $this = $(this); | |||
const width = parseInt($this.attr("data-width")); | |||
const height = parseInt($this.attr("data-height")); | |||
if (Number.isNaN(width) || Number.isNaN(height)) { | |||
$this.text("ERROR: Invalid width and/or height."); | |||
return; | |||
} | |||
const layer = parseInt($this.attr("data-layer")); | |||
if (layer != 0) { | |||
/* Currently only 0 -> Ground */ | |||
$this.text("ERROR: Invalid layer."); | |||
return; | |||
} | |||
const zoom = parseInt($this.attr("data-zoom")); | |||
const pos_x = parseInt($this.attr("data-pos-x")); | |||
const pos_y = parseInt($this.attr("data-pos-y")); | |||
if (Number.isNaN(zoom) || zoom < 2 || Number.isNaN(pos_x) || Number.isNaN(pos_y)) { | |||
$this.text("ERROR: Invalid zoom, x coordinate, and/or y coordinate."); | |||
return; | |||
} | |||
const $frame = $("<iframe>") | |||
.attr("src", `https://map-twi.1f616emo.xyz/#!/map/${layer}/${zoom}/${pos_x}/${pos_y}`) | |||
.attr("width", width) | |||
.attr("height", height); | |||
$this.html($frame); | |||
}); | |||
/* End of mw.loader.using callback */ | /* End of mw.loader.using callback */ | ||
} ); | } ); | ||
/* DO NOT ADD CODE BELOW THIS LINE */ | /* DO NOT ADD CODE BELOW THIS LINE */ |