User:K599/Desmos.js

//Author: K599 / Kelvs599

//Code based on https://dev.fandom.com/wiki/MediaWiki:YoutubePlayer/code.js

//Loading this JavaScript allows Desmos graphs to be embedded by inserting the following code: // //data-id: The ID of the graph, which is found after the "calculator/" in the graph's URL. //Default width and height is 500x500.

mw.hook('wikipage.content').add(function($content) {   $content.find('.desmos:not(.loaded)').each(function { var $this = $(this), data = $this.data, uri = new mw.Uri('https://www.desmos.com/calculator/');

uri.path += String(data.id || '').trim; uri.query = { embed };

$this.html(           $(' ', { src: uri.toString, style: 'width: ' + (typeof data.width === 'number' ? data.width + 'px' : String(data.width || '500px').trim) + '; height: ' + (typeof data.height === 'number' ? data.height + 'px' : String(data.height || '500px').trim) + ';', frameborder: '0' })       ).addClass('loaded'); }); });