UNPKG

@zklogic/draw.io

Version:

Draw.IO - Graph Editor integration in Angular-cli

1 lines 4.64 kB
function handleSubmit(){return window.openForm||document.getElementById("openForm"),window.parent.openNew&&null!=window.parent.baseUrl&&(window.parent.openFile.setConsumer(null),window.parent.open(window.parent.baseUrl)),!0}function hideWindow(e){window.parent.openFile.cancel(e)}function fileChanged(){document.getElementById("openSupported");var e=window.openForm||document.getElementById("openForm"),t=document.getElementById("openButton");e.upfile.value.length>0?t.removeAttribute("disabled"):t.setAttribute("disabled","disabled")}function main(){if(null!=window.parent&&null!=window.parent.Editor)if(window.parent.Editor.useLocalStorage){document.body.innerHTML="";var e=document.createElement("div");e.style.fontFamily="Arial",window.parent.listBrowserFiles((function(t){if(null!=window.parent){if(0==t.length)window.parent.mxUtils.write(e,window.parent.mxResources.get("noFiles")),e.style.color=window.parent.Editor.isDarkMode()?"#cccccc":"",window.parent.mxUtils.br(e);else{t.sort((function(e,t){return e.title.toLowerCase().localeCompare(t.title.toLowerCase())}));var n=document.createElement("table"),o=document.createElement("tr");o.style.backgroundColor=window.parent.Editor.isDarkMode()?"#000":"#D6D6D6",o.style.color=window.parent.Editor.isDarkMode()?"#cccccc":"",o.style.height="25px",o.style.textAlign="left",n.appendChild(o);var i=document.createElement("th");window.parent.mxUtils.write(i,window.parent.mxResources.get("name")),o.appendChild(i);var r=document.createElement("th");r.style.width="180px",window.parent.mxUtils.write(r,window.parent.mxResources.get("lastModified")),o.appendChild(r);var d=document.createElement("th");window.parent.mxUtils.write(d,window.parent.mxResources.get("size")),d.style.width="70px",o.appendChild(d);var a=document.createElement("th");a.style.width="23px",o.appendChild(a),n.style.fontSize="12pt",n.style.width="100%";for(var l=0;l<t.length;l++){var w=t[l];if(w.title.length>0){var p=document.createElement("tr");p.style.color=window.parent.Editor.isDarkMode()?"#cccccc":"",n.appendChild(p),!0&l&&(p.style.backgroundColor=window.parent.Editor.isDarkMode()?"#000":"#E6E6E6");var c=document.createElement("td");p.appendChild(c);var s=document.createElement("a");s.style.fontDecoration="none",window.parent.mxUtils.write(s,w.title),s.style.cursor="pointer",c.appendChild(s);var m=document.createElement("td");p.appendChild(m);var u=window.parent.EditorUi.prototype.timeSince(new Date(w.lastModified));null==u&&(u=window.parent.mxResources.get("lessThanAMinute")),window.parent.mxUtils.write(m,window.parent.mxResources.get("timeAgo",[u]));var f=document.createElement("td");p.appendChild(f),window.parent.mxUtils.write(f,window.parent.EditorUi.prototype.formatFileSize(w.size));var E=document.createElement("td");p.appendChild(E),E.style.textAlign="center";var g=document.createElement("span");g.className="geSprite geSprite-delete",g.style.cursor="pointer",g.style.display="inline-block",E.appendChild(g),window.parent.Editor.isDarkMode()&&(g.style.filter="invert(100%)"),window.parent.mxEvent.addListener(g,"click",function(e){return function(){window.parent.mxUtils.confirm(window.parent.mxResources.get("delete")+' "'+e+'"?')&&window.parent.deleteBrowserFile(e,(function(){window.location.reload()}))}}(w.title)),window.parent.mxEvent.addListener(s,"click",function(e){return function(){if(window.parent.openNew&&null!=window.parent.baseUrl){var t=window.parent.openFile;window.parent.openBrowserFile(e,(function(n){window.parent.openWindow(window.parent.baseUrl+"#L"+encodeURIComponent(e),(function(){t.cancel(!1)}),(function(){t.setData(n,e)}))}),(function(){}))}else window.parent.openBrowserFile(e,(function(t){window.parent.openFile.setData(t,e)}),(function(){}))}}(w.title))}}e.appendChild(n)}var h=window.parent.mxUtils.button(window.parent.mxResources.get("close"),(function(){hideWindow(!0)}));h.className="geBtn",h.style.position="fixed",h.style.bottom="0px",h.style.right="0px",e.appendChild(h),document.body.appendChild(e)}}))}else{document.getElementById("editLink"),document.getElementById("openButton").value=window.parent.mxResources.get(window.parent.openKey||"open");var t=document.getElementById("closeButton");t.value=window.parent.mxResources.get("close"),document.getElementById("openSupported").innerHTML=window.parent.mxResources.get("openSupported");var n=window.openForm||document.getElementById("openForm");n.setAttribute("action",window.parent.OPEN_URL),n.onsubmit=function(){return handleSubmit()},n.upfile.onchange=fileChanged,t.onclick=function(){hideWindow(!0)}}else document.body.innerHTML="Missing parent window"}window.addEventListener("load",main);