javascript
function drawioPreviewer() {
const drawioDocuments = document.querySelectorAll('a[href$=".drawio"]');
let loaded = 0;
[].forEach.call(drawioDocuments, function (doc) {
const xhttp = new XMLHttpRequest();
xhttp.open("GET", doc.href, true);
xhttp.send();
xhttp.onload = function (e) {
const config = {
highlight: "#0000ff",
nav: true,
resize: true,
toolbar: "zoom layers lightbox",
xml: xhttp.responseText
};
const div = document.createElement('div');
div.setAttribute('class', 'mxgraph');
div.dataset.mxgraph = JSON.stringify(config);
doc.parentNode.replaceChild(div, doc);
++loaded;
if (loaded < drawioDocuments.length) {
return;
}
const script = document.createElement('script');
script.setAttribute('type', 'text/javascript');
script.setAttribute('src', '//viewer.diagrams.net/js/viewer-static.min.js');
document.body.appendChild(script);
};
})
}
export {drawioPreviewer};
Last posts
- Draw.io on a website
- Deploy elasticms on AWS
- Intégrer BOSA Accessibility Check dans un site web [Content in French]
- PHP - Convert Human Readable Size to Bytes
- Composer: How to use a specific branch acting like a specific revision in composer dependencies
- Stream a CSV from a JSON array
- Comment utiliser les commandes "locales" du skeleton [Content in French]
- How to extract data from a JsonMenuNestedEditorField
- Backup on AWS glacier
- Refer to environment variables in twig