/* WRAP xd - Embed XD frame */ jQuery(function() { if (typeof(wrap_xd) === 'undefined') { wrap_xd = true; /* console.log("Parse XD iframes"); */ function trimByChar(string, character) { const arr = Array.from(string); const first = arr.findIndex(char => char !== character); const last = arr.reverse().findIndex(char => char !== character); return (first === -1 && last === -1) ? '' : string.substring(first, string.length - last); } jQuery(".wrap_xd").each(function() { var $wrap = jQuery(this); var url = trimByChar($wrap.text().trim(), "/"); if (url.indexOf("/view/") > 0) { console.log("-----------------------------------------------------------------"); console.log(url); console.log(url.substring(0, url.indexOf("/view/"))); console.log(url.substring(6 + url.indexOf("/view/"), end)); var end = url.indexOf("/", 6 + url.indexOf("/view/")); if (end >= 0) /* has /screen/ */ { url = url.substring(0, url.indexOf("/view/")) + "/embed/" + url.substring(6 + url.indexOf("/view/"), end); } else { url = url.substring(0, url.indexOf("/view/")) + "/embed/" + url.substring(6 + url.indexOf("/view/")); } console.log(url); console.log("-----------------------------------------------------------------"); } var classes = [...$wrap[0].classList]; var w = 16; var h = 9; for (var c = 0; c < classes.length; ++c) { var classname = classes[c]; if (classname.indexOf("wrap_x") >= 0) { var s = classname.substring(6); if (!isNaN(s)) w = parseInt(s); } if (classname.indexOf("wrap_y") >= 0) { var s = classname.substring(6); if (!isNaN(s)) h = parseInt(s); } if (classname.indexOf("wrap_w") >= 0) { var s = classname.substring(6); if (!isNaN(s)) w = parseInt(s); } if (classname.indexOf("wrap_h") >= 0) { var s = classname.substring(6); if (!isNaN(s)) h = parseInt(s); } } var html = ""; html += '

'; html += ''; html += ''+url+''; html += '

'; console.log("Add iframe"); $wrap.html(html); }); } });