Merge branch 'master' of https://github.com/hacdias/caddy-filemanager
Former-commit-id: 69d175e738
pull/726/head
commit
c74063507d
|
@ -48,11 +48,10 @@ function addFrontMatterItem(event) {
|
||||||
let fieldsets = block.getElementsByTagName("fieldset");
|
let fieldsets = block.getElementsByTagName("fieldset");
|
||||||
|
|
||||||
if (fieldsets.length > 0) {
|
if (fieldsets.length > 0) {
|
||||||
let newtype = fieldsets[0].dataset.type;
|
let newtype = fieldsets[0].dataset.type,
|
||||||
let bid = id + "[" + fieldsets.length + "]";
|
bid = id + "[" + fieldsets.length + "]",
|
||||||
let name = fieldsets.length;
|
name = fieldsets.length,
|
||||||
|
template = `<fieldset id="${bid}" data-type="${newtype}">
|
||||||
let template = `<fieldset id="${bid}" data-type="${newtype}">
|
|
||||||
<h3>${name}</h3>
|
<h3>${name}</h3>
|
||||||
<div class="action add">
|
<div class="action add">
|
||||||
<i class="material-icons">add</i>
|
<i class="material-icons">add</i>
|
||||||
|
@ -94,8 +93,8 @@ function addFrontMatterItem(event) {
|
||||||
block.querySelector('.delete').insertAdjacentHTML('afterend', template);
|
block.querySelector('.delete').insertAdjacentHTML('afterend', template);
|
||||||
}
|
}
|
||||||
|
|
||||||
let temp = document.getElementById(tempID);
|
let temp = document.getElementById(tempID),
|
||||||
let input = temp.querySelector('input');
|
input = temp.querySelector('input');
|
||||||
input.focus();
|
input.focus();
|
||||||
input.addEventListener('keydown', (event) => {
|
input.addEventListener('keydown', (event) => {
|
||||||
if (event.keyCode == 27) {
|
if (event.keyCode == 27) {
|
||||||
|
@ -112,8 +111,8 @@ function addFrontMatterItem(event) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
let name = value.substring(0, value.lastIndexOf(':'));
|
let name = value.substring(0, value.lastIndexOf(':')),
|
||||||
let newtype = value.substring(value.lastIndexOf(':') + 1, value.length);
|
newtype = value.substring(value.lastIndexOf(':') + 1, value.length);
|
||||||
if (newtype !== "" && newtype !== "array" && newtype !== "object") {
|
if (newtype !== "" && newtype !== "array" && newtype !== "object") {
|
||||||
name = value;
|
name = value;
|
||||||
}
|
}
|
||||||
|
@ -180,15 +179,15 @@ function addFrontMatterItem(event) {
|
||||||
document.addEventListener("DOMContentLoaded", (event) => {
|
document.addEventListener("DOMContentLoaded", (event) => {
|
||||||
textareaAutoGrow();
|
textareaAutoGrow();
|
||||||
|
|
||||||
let container = document.getElementById('editor');
|
let container = document.getElementById('editor'),
|
||||||
let button = document.querySelector('#submit span:first-child');
|
button = document.querySelector('#submit span:first-child'),
|
||||||
let kind = container.dataset.kind;
|
kind = container.dataset.kind;
|
||||||
|
|
||||||
if (kind != 'frontmatter-only') {
|
if (kind != 'frontmatter-only') {
|
||||||
let editor = document.getElementById('editor-source');
|
let editor = document.getElementById('editor-source'),
|
||||||
let mode = editor.dataset.mode;
|
mode = editor.dataset.mode,
|
||||||
let textarea = document.querySelector('textarea[name="content"]');
|
textarea = document.querySelector('textarea[name="content"]'),
|
||||||
let aceEditor = ace.edit('editor-source');
|
aceEditor = ace.edit('editor-source');
|
||||||
aceEditor.getSession().setMode("ace/mode/" + mode);
|
aceEditor.getSession().setMode("ace/mode/" + mode);
|
||||||
aceEditor.getSession().setValue(textarea.value);
|
aceEditor.getSession().setValue(textarea.value);
|
||||||
aceEditor.getSession().on('change', function() {
|
aceEditor.getSession().on('change', function() {
|
||||||
|
@ -225,11 +224,11 @@ document.addEventListener("DOMContentLoaded", (event) => {
|
||||||
data.content = data.content.toString();
|
data.content = data.content.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
let html = button.changeToLoading();
|
let html = button.changeToLoading(),
|
||||||
let request = new XMLHttpRequest();
|
request = new XMLHttpRequest();
|
||||||
|
|
||||||
request.open("PUT", toWebDavURL(window.location.pathname));
|
request.open("PUT", toWebDavURL(window.location.pathname));
|
||||||
request.setRequestHeader('Kind', kind);
|
request.setRequestHeader('Kind', kind);
|
||||||
|
|
||||||
request.send(JSON.stringify(data));
|
request.send(JSON.stringify(data));
|
||||||
request.onreadystatechange = function() {
|
request.onreadystatechange = function() {
|
||||||
if (request.readyState == 4) {
|
if (request.readyState == 4) {
|
||||||
|
|
Loading…
Reference in New Issue