MediaWiki:Common.js: Difference between revisions
Content deleted Content added
Piranhaplant (talk | contribs) No edit summary |
Piranhaplant (talk | contribs) No edit summary |
||
Line 2: | Line 2: | ||
function runUntilSuccess(f) { |
function runUntilSuccess(f) { |
||
⚫ | |||
(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(); |
||
⚫ | |||
clone.setAttribute("width", bbox.width + "px"); |
clone.setAttribute("width", bbox.width + "px"); |
||
clone.setAttribute("height", bbox.height + "px"); |
clone.setAttribute("height", bbox.height + "px"); |