You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1 line
1.4 KiB
JavaScript
1 line
1.4 KiB
JavaScript
2 weeks ago
|
!function(){const e=document.getElementById("codepen-button");if(e){const t=document.getElementById("codepen-form");e.href=t.action,e.addEventListener("click",(function(e){e.preventDefault();const n=document.documentMode?"textContent":"innerText",o=document.getElementById("example-html-source")[n],c=document.getElementById("example-js-source")[n],r=document.getElementById("example-worker-source"),s=r?r[n]:void 0,a=document.getElementById("example-pkg-source")[n],i=new Set,m=(c.match(/'(\.\/)?data\/[^']*/g)||[]).concat(c.match(/'(\.\/)?resources\/[^']*/g)||[]).map((function(e){return e.replace(/^'(\.\/)?/,"")})).filter((function(e){return!i.has(e)&&(i.add(e)||i)})),d=m.map((function(e){return function(e){return new Promise((function(t,n){if(/\.(png|jpe?g|gif|tiff|svg|kmz)$/.test(e))t({isBinary:!0,content:new URL(e,window.location.href).href});else{const o=new XMLHttpRequest;o.open("GET",e),o.responseType="text",o.addEventListener("load",(function(){t({content:o.response})})),o.addEventListener("error",n),o.send()}}))}(e)}));Promise.all(d).then((function(e){const n={"index.html":{content:o},"main.js":{content:c},"package.json":{content:a},"sandbox.config.json":{content:'{"template": "parcel"}'}};s&&(n["worker.js"]={content:s});const r={files:n};for(let t=0;t<m.length;t++)r.files[m[t]]=e[t];var i;t.parameters.value=(i=r,LZString.compressToBase64(JSON.stringify(i)).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")),t.submit()}))}))}}();
|