UNPKG

cloudcmd

Version:

File manager for the web with console and editor

2 lines 4.59 kB
!function(e){function t(t){for(var o,s,i=t[0],a=t[1],u=t[2],f=0,d=[];f<i.length;f++)s=i[f],Object.prototype.hasOwnProperty.call(c,s)&&c[s]&&d.push(c[s][0]),c[s]=0;for(o in a)Object.prototype.hasOwnProperty.call(a,o)&&(e[o]=a[o]);for(l&&l(t);d.length;)d.shift()();return r.push.apply(r,u||[]),n()}function n(){for(var e,t=0;t<r.length;t++){for(var n=r[t],o=!0,i=1;i<n.length;i++){var a=n[i];0!==c[a]&&(o=!1)}o&&(r.splice(t--,1),e=s(s.s=n[0]))}return e}var o={},c={3:0},r=[];function s(t){if(o[t])return o[t].exports;var n=o[t]={i:t,l:!1,exports:{}};return e[t].call(n.exports,n,n.exports,s),n.l=!0,n.exports}s.m=e,s.c=o,s.d=function(e,t,n){s.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},s.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},s.t=function(e,t){if(1&t&&(e=s(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(s.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)s.d(n,o,function(t){return e[t]}.bind(null,o));return n},s.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return s.d(t,"a",t),t},s.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},s.p="/dist/";var i=window.webpackJsonp=window.webpackJsonp||[],a=i.push.bind(i);i.push=t,i=i.slice();for(var u=0;u<i.length;u++)t(i[u]);var l=a;r.push([101,0]),n()}({101:function(e,t,n){"use strict";n(172);const o=n(12),c=n(0),r=n(8),s=n(37),{promisify:i}=n(13),a=n(3),u=n(4),l=n(2),f=n(102),d=n(1),p=n(16),g=n(15),{getTitle:m}=n(6),{Dialog:y,setTitle:h}=DOM;CloudCmd.Config=e.exports;const b=i(DOM.loadSocket),w=c((e,t)=>(p.addKey(t,e),t)),C=c((e,t)=>(p.add("change",t,e),t)),v={};let x;const k=u.css;e.exports.init=async()=>{if(!CloudCmd.config("configDialog"))return;d.show.load("top");const{prefix:e}=CloudCmd;[x]=await Promise.all([g.get("config-tmpl"),b(),k(e+"/dist/config.css"),CloudCmd.View()]),function(){const e=function(){const{host:e,origin:t,protocol:n}=location;return t||`${n}//${e}`}(),{prefixSocket:t,prefix:n}=CloudCmd,o=io.connect(e+t+"/config",{reconnectionAttempts:1/0,reconnectionDelay:6e4,path:n+"/socket.io"}),c=e=>{P(e),o.send(e)};(function(e){e.emit("auth",O("username"),O("password")),e.on("reject",r(y.alert,"Wrong credentials!"))})(o),o.on("connect",()=>{v.save=c}),o.on("message",P),o.on("log",CloudCmd.log),o.on("disconnect",()=>{v.save=D}),o.on("err",y.alert)}()};const{config:O,Key:j}=CloudCmd;let S;function M(){CloudCmd.View.hide()}async function N(e){const t={},n=f.getName(e),o=f.getValue(n,S);"name"===n?function(e){h(m({name:e}))}(o):"auth"===n&&E(o),t[n]=o,await v.save(t)}function P(e){for(const t of Object.keys(e)){const n=e[t];CloudCmd._config(t,n),f.setValue(t,n,S)}}async function D(e){const{RESTful:t}=DOM,[n]=await t.Config.write(e);n||P(e)}function E(e){const t=f.getElementByName("username",S),n=f.getElementByName("password",S);t.disabled=!e,n.disabled=!e}async function T({keyCode:e,target:t}){switch(e){case j.ESC:return M();case j.ENTER:return await N(t)}}v.save=D,e.exports.show=async function(){if(!CloudCmd.config("configDialog"))return;await async function(){const[e,t]=await a(g.get,"config");if(e)return y.alert("Could not load config!");const{editor:n,packer:c,columns:r,theme:i,configAuth:u,...d}=f.convert(t);d[n+"-selected"]="selected",d[c+"-selected"]="selected",d[r+"-selected"]="selected",d[i+"-selected"]="selected",d.configAuth=u?"":"hidden";const p=o(x,d);S=l("form",{className:"config",innerHTML:p});const m=document.querySelectorAll("input, select",S),[h]=m;let b;h&&(E(h.checked),b=h.focus.bind(h));const v=s(N,({target:e})=>e);Array.from(m).map(w(T)).map(C(v));CloudCmd.View.show(S,{autoSize:!0,afterShow:b})}()},e.exports.hide=M},102:function(e,t,n){"use strict";const o=n(0)((e,t,n)=>e===typeof t[n])("boolean");function c(e,t){const n=`[data-name="js-${e}"]`;return t.querySelector(n)}function r(e){return e?" checked":""}e.exports.getElementByName=c,e.exports.getName=e=>e.getAttribute("data-name").replace(/^js-/,""),e.exports.convert=e=>{const t=e,n=Object.keys(e).filter(o(e));for(const o of n){const n=e[o];t[o]=r(n)}return t},e.exports.getValue=(e,t)=>{const n=c(e,t),{type:o}=n;switch(o){case"checkbox":return n.checked;case"number":return Number(n.value);default:return n.value}},e.exports.setValue=(e,t,n)=>{const o=c(e,n),{type:r}=o;switch(r){case"checkbox":o.checked=t;break;default:o.value=t}}},172:function(e,t){}}); //# sourceMappingURL=config.js.map