MediaWiki:Common.js: Difference between revisions

Content deleted Content added
No edit summary
No edit summary
Line 2: Line 2:


function runUntilSuccess(f) {
function runUntilSuccess(f) {
console.log("Running function");
(function run() {
(function run() {
if (!f()) {
if (!f()) {
console.log("Rerunning function");
setTimeout(run, 10);
setTimeout(run, 10);
}
}
Line 50: Line 48:
// Modify BPMN chart embeds to be just the SVG
// Modify BPMN chart embeds to be just the SVG
runUntilSuccess(function() {
runUntilSuccess(function() {
console.log("Checking for BPMN");
if (document.getElementsByClassName("bpmn_embed").length > 0) {
if (document.getElementsByClassName("bpmn_embed").length > 0) {
console.log("BPMN found");
var canvas = document.getElementById("canvas");
var canvas = document.getElementById("canvas");
var parent = canvas.parentElement;
var parent = canvas.parentElement;
var svgs = canvas.getElementsByTagName("svg");
var svgs = canvas.getElementsByTagName("svg");
if (svgs.length == 0) {
if (svgs.length == 0 && svgs[0].getAttribute("data-element-id") != null) {
console.log("No SVG found");
console.log("No SVG found");
return false;
return false;
Line 67: Line 63:
var bbox = clone.getBBox();
var bbox = clone.getBBox();
console.log(bbox);
clone.setAttribute("width", bbox.width + "px");
clone.setAttribute("width", bbox.width + "px");
clone.setAttribute("height", bbox.height + "px");
clone.setAttribute("height", bbox.height + "px");