var css_url = document.currentScript.src.replace(/\/[^\/]+$/, '') + '/webdav.css'; const WebDAVNavigator = (url, options) => { // Microdown // https://github.com/commit-intl/micro-down const microdown=function(){function l(n,e,r){return"<"+n+(r?" "+Object.keys(r).map(function(n){return r[n]?n+'="'+(a(r[n])||"")+'"':""}).join(" "):"")+">"+e+""}function c(n,e){return e=n.match(/^[+-]/m)?"ul":"ol",n?"<"+e+">"+n.replace(/(?:[+-]|\d+\.) +(.*)\n?(([ \t].*\n?)*)/g,function(n,e,r){return"
  • "+g(e+"\n"+(t=r||"").replace(new RegExp("^"+(t.match(/^\s+/)||"")[0],"gm"),"").replace(o,c))+"
  • ";var t})+"":""}function e(r,t,u,c){return function(n,e){return n=n.replace(t,u),l(r,c?c(n):n)}}function t(n,u){return f(n,[//g,"\x3c!--$1--\x3e",/^("""|```)(.*)\n((.*\n)*?)\1/gm,function(n,e,r,t){return'"""'===e?l("div",p(t,u),{class:r}):u&&u.preCode?l("pre",l("code",a(t),{class:r})):l("pre",a(t),{class:r})},/(^>.*\n?)+/gm,e("blockquote",/^> ?(.*)$/gm,"$1",r),/((^|\n)\|.+)+/g,e("table",/^.*(\n\|---.*?)?$/gm,function(n,t){return e("tr",/\|(-?)([^|]*)\1(\|$)?/gm,function(n,e,r){return l(e||t?"th":"td",g(r))})(n.slice(0,n.length-(t||"").length))}),o,c,/#\[([^\]]+?)]/g,'',/^(#+) +(.*)(?:$)/gm,function(n,e,r){return l("h"+e.length,g(r))},/^(===+|---+)(?=\s*$)/gm,"
    "],p,u)}var i=this,a=function(n){return n?n.replace(/"/g,""").replace(//g,">"):""},o=/(?:(^|\n)([+-]|\d+\.) +(.*(\n[ \t]+.*)*))+/g,g=function c(n,i){var o=[];return n=(n||"").trim().replace(/`([^`]*)`/g,function(n,e){return"\\"+o.push(l("code",a(e)))}).replace(/[!&]?\[([!&]?\[.*?\)|[^\]]*?)]\((.*?)( .*?)?\)|(\w+:\/\/[$\-.+!*'()/,\w]+)/g,function(n,e,r,t,u){return u?i?n:"\\"+o.push(l("a",u,{href:u})):"&"==n[0]?(e=e.match(/^(.+),(.+),([^ \]]+)( ?.+?)?$/),"\\"+o.push(l("iframe","",{width:e[1],height:e[2],frameborder:e[3],class:e[4],src:r,title:t}))):"\\"+o.push("!"==n[0]?l("img","",{src:r,alt:e,title:t}):l("a",c(e,1),{href:r,title:t}))}),n=function r(n){return n.replace(/\\(\d+)/g,function(n,e){return r(o[Number.parseInt(e)-1])})}(i?n:r(n))},r=function t(n){return f(n,[/([*_]{1,3})((.|\n)+?)\1/g,function(n,e,r){return e=e.length,r=t(r),1"],t)},f=function(n,e,r,t){for(var u,c=0;c typeof lang_strings != 'undefined' && key in lang_strings ? lang_strings[key] : key; const common_buttons = ` `; const edit_button = ``; const mkdir_dialog = ``; const mkfile_dialog = ``; const rename_dialog = ``; const paste_upload_dialog = `

    Upload this file?

    `; const edit_dialog = ``; const markdown_dialog = `
    `; const delete_dialog = `

    ${_('Confirm delete?')}

    `; const wopi_dialog = ``; const dialog_tpl = `

    %s
    %b
    `; const html_tpl = ` Files
    `; const body_tpl = `

    %title%

    %table%
    `; const dir_row_tpl = `%icon%%name%
    `; const file_row_tpl = `%icon%%name%%size%%modified%
    ${_('Download')}
    `; const propfind_tpl = ` `; const wopi_propfind_tpl = ` `; const html = (unsafe) => { return unsafe.replace(/&/g, "&").replace(//g, ">").replace(/"/g, """).replace(/'/g, "'"); }; const reqXML = (method, url, body, headers) => { return req(method, url, body, headers).then((r) => { if (!r.ok) { throw new Error(r.status + ' ' + r.statusText); } return r.text(); }).then(str => new window.DOMParser().parseFromString(str, "text/xml")); }; const reqAndReload = (method, url, body, headers) => { animateLoading(); req(method, url, body, headers).then(r => { stopLoading(); if (!r.ok) { return r.text().then(t => { var message; if (a = t.match(/<((?:\w+:)?message)>(.*)<\/\1>/)) { message = "\n" + a[2]; } throw new Error(r.status + ' ' + r.statusText + message); }); } reloadListing(); }).catch(e => { console.error(e); alert(e); }); return false; }; const get_url = async (url) => { if (temp_object_url) { window.URL.revokeObjectURL(temp_object_url); } return req('GET', url).then(r => r.blob()).then(blob => { temp_object_url = window.URL.createObjectURL(blob); return temp_object_url; }); } const req = (method, url, body, headers) => { if (!headers) { headers = {}; } if (auth_header) { headers.Authorization = auth_header; } return fetch(url, {method, body, headers}); }; const wopi_init = async () => { if (!wopi_discovery_url) { return; } var d = await reqXML('GET', wopi_discovery_url); d.querySelectorAll('app').forEach(app => { var mime = (a = app.getAttribute('name').match(/^.*\/.*$/)) ? a[0] : null; wopi_mimes[mime] = {}; app.querySelectorAll('action').forEach(action => { var ext = action.getAttribute('ext').toUpperCase(); var url = action.getAttribute('urlsrc').replace(/<[^>]*&>/g, ''); var name = action.getAttribute('name'); if (mime) { wopi_mimes[mime][name] = url; } else { if (!wopi_extensions.hasOwnProperty(ext)) { wopi_extensions[ext] = {}; } wopi_extensions[ext][name] = url; } }); }); }; const wopi_getEditURL = (name, mime) => { var file_ext = name.replace(/^.*\.(\w+)$/, '$1').toUpperCase(); if (wopi_mimes.hasOwnProperty(mime) && wopi_mimes[mime].hasOwnProperty('edit')) { return wopi_mimes[mime].edit; } else if (wopi_extensions.hasOwnProperty(file_ext) && wopi_extensions[file_ext].hasOwnProperty('edit')) { return wopi_extensions[file_ext].edit; } return null; }; const wopi_getViewURL = (name, mime) => { var file_ext = name.replace(/^.*\.(\w+)$/, '$1').toUpperCase(); if (wopi_mimes.hasOwnProperty(mime) && wopi_mimes[mime].hasOwnProperty('view')) { return wopi_mimes[mime].view; } else if (wopi_extensions.hasOwnProperty(file_ext) && wopi_extensions[file_ext].hasOwnProperty('view')) { return wopi_extensions[file_ext].view; } return wopi_getEditURL(name, mime); }; const wopi_open = async (document_url, wopi_url) => { var properties = await reqXML('PROPFIND', document_url, wopi_propfind_tpl, {'Depth': '0'}); var src = (a = properties.querySelector('file-url')) ? a.textContent : null; var token = (a = properties.querySelector('token')) ? a.textContent : null; var token_ttl = (a = properties.querySelector('token-ttl')) ? a.textContent : +(new Date(Date.now() + 3600 * 1000)); if (!src || !token) { alert('Cannot open document: WebDAV server did not return WOPI properties'); } wopi_url += '&WOPISrc=' + encodeURIComponent(src); openDialog(wopi_dialog, false); $('dialog').className = 'preview'; var f = $('dialog form'); f.target = 'wopi_frame'; f.action = wopi_url; f.method = 'post'; f.insertAdjacentHTML('beforeend', ``); f.submit(); }; const template = (tpl, params) => { return tpl.replace(/%(\w+)%/g, (a, b) => { return params[b]; }); }; const openDialog = (html, ok_btn = true) => { var tpl = dialog_tpl.replace(/%b/, ok_btn ? `

    ` : ''); $('body').classList.add('dialog'); $('body').insertAdjacentHTML('beforeend', tpl.replace(/%s/, html)); $('.close input').onclick = closeDialog; evt = window.addEventListener('keyup', (e) => { if (e.key != 'Escape') return; closeDialog(); return false; }); if (a = $('dialog form input, dialog form textarea')) a.focus(); }; const closeDialog = (e) => { $('body').classList.remove('dialog'); if (!$('dialog')) return; $('dialog').remove(); window.removeEventListener('keyup', evt); evt = null; }; const download = async (name, url) => { var url = await get_url(url); const a = document.createElement('a'); a.style.display = 'none'; a.href = url; a.download = name; document.body.appendChild(a); a.click(); window.URL.revokeObjectURL(url); a.remove(); }; const preview = (type, url) => { if (type.match(/^image\//)) { openDialog(``, false); } else if (type.match(/^audio\//)) { openDialog(`