parent
1dccba1404
commit
4bc7e4c1e3
|
@ -0,0 +1,22 @@
|
|||
{
|
||||
"html": {
|
||||
"brace_style": "collapse",
|
||||
"indent_scripts": "normal",
|
||||
"max_preserve_newlines": 1,
|
||||
"preserve_newlines": true,
|
||||
"unformatted": ["a", "sub", "sup", "b", "i", "u"],
|
||||
"wrap_line_length": 0
|
||||
},
|
||||
"css": {
|
||||
"end_with_newline": false,
|
||||
"newline_between_rules": true,
|
||||
"selector_separator": " ",
|
||||
"selector_separator_newline": true
|
||||
},
|
||||
"js": {
|
||||
"indent_with_tabs": false,
|
||||
"preserve_newlines": true,
|
||||
"max_preserve_newlines": 2,
|
||||
"jslint_happy": true
|
||||
}
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
{
|
||||
"css": {
|
||||
"allowed_file_extensions": ["css", "scss", "sass", "less"],
|
||||
"end_with_newline": false, // End output with newline
|
||||
"indent_char": " ", // Indentation character
|
||||
"indent_size": 4, // Indentation size
|
||||
"newline_between_rules": true, // Add a new line after every css rule
|
||||
"selector_separator": " ",
|
||||
"selector_separator_newline": true // Separate selectors with newline or not (e.g. "a,\nbr" or "a, br")
|
||||
}
|
||||
}
|
|
@ -1021,6 +1021,7 @@ header .actions {
|
|||
background-color: #e9eaeb;
|
||||
}
|
||||
|
||||
|
||||
/* * * * * * * * * * * * * * * *
|
||||
* PROMPT - MOVE *
|
||||
* * * * * * * * * * * * * * * */
|
||||
|
|
|
@ -4,19 +4,22 @@ var tempID = "_fm_internal_temporary_id",
|
|||
buttons = {},
|
||||
templates = {},
|
||||
selectedItems = [],
|
||||
overlay, clickOverlay,
|
||||
overlay,
|
||||
clickOverlay,
|
||||
webdav = {};
|
||||
|
||||
// Removes an element, if exists, from an array
|
||||
Array.prototype.removeElement = function (element) {
|
||||
var i = this.indexOf(element);
|
||||
if (i != -1) this.splice(i, 1);
|
||||
if(i != -1)
|
||||
this.splice(i, 1);
|
||||
}
|
||||
|
||||
// Replaces an element inside an array by another
|
||||
Array.prototype.replaceElement = function (oldElement, newElement) {
|
||||
var i = this.indexOf(oldElement);
|
||||
if (i != -1) this[i] = newElement;
|
||||
if(i != -1)
|
||||
this[i] = newElement;
|
||||
}
|
||||
|
||||
// Sends a costum event to itself
|
||||
|
@ -54,7 +57,8 @@ Element.prototype.changeToDone = function (error, html) {
|
|||
this.innerHTML = html;
|
||||
this.style.opacity = null;
|
||||
|
||||
if (selectedItems.length == 0 && document.getElementById('listing')) document.sendCostumEvent('changed-selected');
|
||||
if(selectedItems.length == 0 && document.getElementById('listing'))
|
||||
document.sendCostumEvent('changed-selected');
|
||||
}
|
||||
|
||||
let secondStep = () => {
|
||||
|
@ -64,7 +68,9 @@ Element.prototype.changeToDone = function (error, html) {
|
|||
|
||||
let firstStep = () => {
|
||||
this.classList.remove('spin');
|
||||
this.innerHTML = error ? 'close' : 'done';
|
||||
this.innerHTML = error ?
|
||||
'close' :
|
||||
'done';
|
||||
this.style.opacity = 1;
|
||||
setTimeout(secondStep, 1000);
|
||||
}
|
||||
|
@ -80,14 +86,14 @@ function toWebDavURL(url) {
|
|||
// Remove the last directory of an url
|
||||
var removeLastDirectoryPartOf = function (url) {
|
||||
var arr = url.split('/');
|
||||
if (arr.pop() === "") {
|
||||
if(arr.pop() === "") {
|
||||
arr.pop();
|
||||
}
|
||||
return (arr.join('/'));
|
||||
return(arr.join('/'));
|
||||
}
|
||||
|
||||
function getCSSRule(rules) {
|
||||
for (let i = 0; i < rules.length; i++) {
|
||||
for(let i = 0; i < rules.length; i++) {
|
||||
rules[i] = rules[i].toLowerCase();
|
||||
}
|
||||
|
||||
|
@ -98,9 +104,10 @@ function getCSSRule(rules) {
|
|||
result = find.call(styleSheet.cssRules, cssRule => {
|
||||
let found = false;
|
||||
|
||||
if (cssRule instanceof CSSStyleRule) {
|
||||
for (let i = 0; i < rules.length; i++) {
|
||||
if (cssRule.selectorText.toLowerCase() == rules[i]) found = true;
|
||||
if(cssRule instanceof CSSStyleRule) {
|
||||
for(let i = 0; i < rules.length; i++) {
|
||||
if(cssRule.selectorText.toLowerCase() == rules[i])
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -127,7 +134,7 @@ webdav.move = function (oldLink, newLink) {
|
|||
request.open('MOVE', toWebDavURL(oldLink), true);
|
||||
request.setRequestHeader('Destination', toWebDavURL(newLink));
|
||||
request.onload = () => {
|
||||
if (request.status == 201 || request.status == 204) {
|
||||
if(request.status == 201 || request.status == 204) {
|
||||
resolve(request.response);
|
||||
} else {
|
||||
reject(request.statusText);
|
||||
|
@ -143,7 +150,7 @@ webdav.put = function (link, body) {
|
|||
let request = new XMLHttpRequest();
|
||||
request.open('PUT', toWebDavURL(link), true);
|
||||
request.onload = () => {
|
||||
if (request.status == 201) {
|
||||
if(request.status == 201) {
|
||||
resolve(request.response);
|
||||
} else {
|
||||
reject(request.statusText);
|
||||
|
@ -162,7 +169,8 @@ webdav.put = function (link, body) {
|
|||
function closePrompt(event) {
|
||||
let prompt = document.querySelector('.prompt');
|
||||
|
||||
if (!prompt) return;
|
||||
if(!prompt)
|
||||
return;
|
||||
|
||||
event.preventDefault();
|
||||
document.querySelector('.overlay').classList.remove('active');
|
||||
|
@ -196,18 +204,19 @@ function logoutEvent(event) {
|
|||
request.open('GET', window.location.pathname, true, "username", "password");
|
||||
request.send();
|
||||
request.onreadystatechange = function () {
|
||||
if (request.readyState == 4) {
|
||||
if(request.readyState == 4) {
|
||||
window.location = "/";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function openEvent(event) {
|
||||
if (event.currentTarget.classList.contains('disabled')) return false;
|
||||
if(event.currentTarget.classList.contains('disabled'))
|
||||
return false;
|
||||
|
||||
let link = '?raw=true';
|
||||
|
||||
if (selectedItems.length) {
|
||||
if(selectedItems.length) {
|
||||
link = document.getElementById(selectedItems[0]).dataset.url + link;
|
||||
} else {
|
||||
link = window.location + link;
|
||||
|
@ -218,11 +227,11 @@ function openEvent(event) {
|
|||
}
|
||||
|
||||
function selectMoveFolder(event) {
|
||||
if (event.target.getAttribute("aria-selected") === "true") {
|
||||
if(event.target.getAttribute("aria-selected") === "true") {
|
||||
event.target.setAttribute("aria-selected", false);
|
||||
return;
|
||||
} else {
|
||||
if (document.querySelector(".file-list li[aria-selected=true]")) {
|
||||
if(document.querySelector(".file-list li[aria-selected=true]")) {
|
||||
document.querySelector(".file-list li[aria-selected=true]").setAttribute("aria-selected", false);
|
||||
}
|
||||
event.target.setAttribute("aria-selected", true);
|
||||
|
@ -240,14 +249,14 @@ function loadNextFolder(event) {
|
|||
request.setRequestHeader("Accept", "application/json");
|
||||
request.send();
|
||||
request.onreadystatechange = function () {
|
||||
if (request.readyState == 4 && request.status == 200) {
|
||||
if(request.readyState == 4 && request.status == 200) {
|
||||
let dirs = 0;
|
||||
|
||||
prompt.querySelector("ul").innerHTML = "";
|
||||
prompt.querySelector('code').innerHTML = event.target.dataset.url;
|
||||
|
||||
for (let f of JSON.parse(request.response)) {
|
||||
if (f.IsDir === true) {
|
||||
for(let f of JSON.parse(request.response)) {
|
||||
if(f.IsDir === true) {
|
||||
dirs++;
|
||||
|
||||
let newNode = document.createElement("li");
|
||||
|
@ -262,7 +271,7 @@ function loadNextFolder(event) {
|
|||
}
|
||||
}
|
||||
|
||||
if (dirs === 0) {
|
||||
if(dirs === 0) {
|
||||
prompt.querySelector("p").innerHTML = `There aren't any folders in this directory.`;
|
||||
}
|
||||
}
|
||||
|
@ -283,8 +292,8 @@ function moveSelected(event) {
|
|||
request.setRequestHeader("Destination", newLink);
|
||||
request.send();
|
||||
request.onreadystatechange = function () {
|
||||
if (request.readyState == 4) {
|
||||
if (request.status == 200 || request.status == 204) {
|
||||
if(request.readyState == 4) {
|
||||
if(request.status == 200 || request.status == 204) {
|
||||
window.reload();
|
||||
}
|
||||
}
|
||||
|
@ -292,23 +301,24 @@ function moveSelected(event) {
|
|||
}
|
||||
|
||||
function moveEvent(event) {
|
||||
if (event.currentTarget.classList.contains("disabled")) return;
|
||||
if(event.currentTarget.classList.contains("disabled"))
|
||||
return;
|
||||
|
||||
let request = new XMLHttpRequest();
|
||||
request.open("GET", window.location.pathname, true);
|
||||
request.setRequestHeader("Accept", "application/json");
|
||||
request.send();
|
||||
request.onreadystatechange = function () {
|
||||
if (request.readyState == 4) {
|
||||
if (request.status == 200) {
|
||||
if(request.readyState == 4) {
|
||||
if(request.status == 200) {
|
||||
let prompt = document.importNode(templates.move.content, true),
|
||||
dirs = 0;
|
||||
|
||||
prompt.querySelector("form").addEventListener("submit", moveSelected);
|
||||
prompt.querySelector('code').innerHTML = window.location.pathname;
|
||||
|
||||
for (let f of JSON.parse(request.response)) {
|
||||
if (f.IsDir === true) {
|
||||
for(let f of JSON.parse(request.response)) {
|
||||
if(f.IsDir === true) {
|
||||
dirs++;
|
||||
|
||||
let newNode = document.createElement("li");
|
||||
|
@ -323,7 +333,7 @@ function moveEvent(event) {
|
|||
}
|
||||
}
|
||||
|
||||
if (dirs === 0) {
|
||||
if(dirs === 0) {
|
||||
prompt.querySelector("p").innerHTML = `There aren't any folders in this directory.`;
|
||||
}
|
||||
|
||||
|
@ -342,9 +352,10 @@ function deleteSelected(single) {
|
|||
Array.from(selectedItems).forEach(id => {
|
||||
let request = new XMLHttpRequest(),
|
||||
html = buttons.delete.querySelector('i').changeToLoading(),
|
||||
el, url;
|
||||
el,
|
||||
url;
|
||||
|
||||
if (single) {
|
||||
if(single) {
|
||||
url = window.location.pathname;
|
||||
} else {
|
||||
el = document.getElementById(id);
|
||||
|
@ -353,9 +364,9 @@ function deleteSelected(single) {
|
|||
|
||||
request.open('DELETE', toWebDavURL(url));
|
||||
request.onreadystatechange = function () {
|
||||
if (request.readyState == 4) {
|
||||
if (request.status == 204) {
|
||||
if (single) {
|
||||
if(request.readyState == 4) {
|
||||
if(request.status == 204) {
|
||||
if(single) {
|
||||
window.location.pathname = removeLastDirectoryPartOf(window.location.pathname);
|
||||
} else {
|
||||
el.remove();
|
||||
|
@ -378,7 +389,7 @@ function deleteSelected(single) {
|
|||
function deleteEvent(event) {
|
||||
let single = false;
|
||||
|
||||
if (!selectedItems.length) {
|
||||
if(!selectedItems.length) {
|
||||
selectedItems = ["placeholder"];
|
||||
single = true;
|
||||
}
|
||||
|
@ -386,7 +397,7 @@ function deleteEvent(event) {
|
|||
let clone = document.importNode(templates.question.content, true);
|
||||
clone.querySelector('h3').innerHTML = 'Delete files';
|
||||
|
||||
if (single) {
|
||||
if(single) {
|
||||
clone.querySelector('p').innerHTML = `Are you sure you want to delete this file/folder?`;
|
||||
} else {
|
||||
clone.querySelector('p').innerHTML = `Are you sure you want to delete ${selectedItems.length} file(s)?`;
|
||||
|
@ -406,7 +417,7 @@ function deleteEvent(event) {
|
|||
function resetSearchText() {
|
||||
let box = document.querySelector('#search > div div');
|
||||
|
||||
if (user.AllowCommands) {
|
||||
if(user.AllowCommands) {
|
||||
box.innerHTML = `Search or use one of your supported commands: ${user.Commands.join(", ")}.`;
|
||||
} else {
|
||||
box.innerHTML = "Type and press enter to search.";
|
||||
|
@ -414,7 +425,7 @@ function resetSearchText() {
|
|||
}
|
||||
|
||||
function searchEvent(event) {
|
||||
if (this.value.length == 0) {
|
||||
if(this.value.length == 0) {
|
||||
resetSearchText();
|
||||
return;
|
||||
}
|
||||
|
@ -427,28 +438,28 @@ function searchEvent(event) {
|
|||
supported = false;
|
||||
|
||||
user.Commands.forEach(function (cmd) {
|
||||
if (cmd == pieces[0]) {
|
||||
if(cmd == pieces[0]) {
|
||||
supported = true;
|
||||
}
|
||||
});
|
||||
|
||||
if (!supported || !user.AllowCommands) {
|
||||
if(!supported || !user.AllowCommands) {
|
||||
box.innerHTML = "Press enter to search."
|
||||
} else {
|
||||
box.innerHTML = "Press enter to execute."
|
||||
}
|
||||
|
||||
if (event.keyCode == 13) {
|
||||
if(event.keyCode == 13) {
|
||||
box.innerHTML = '';
|
||||
search.classList.add('ongoing');
|
||||
|
||||
let url = window.location.host + window.location.pathname;
|
||||
|
||||
if (document.getElementById("editor")) {
|
||||
if(document.getElementById("editor")) {
|
||||
url = removeLastDirectoryPartOf(url);
|
||||
}
|
||||
|
||||
if (supported && user.AllowCommands) {
|
||||
if(supported && user.AllowCommands) {
|
||||
let conn = new WebSocket(`ws://${url}?command=true`);
|
||||
|
||||
conn.onopen = function () {
|
||||
|
@ -509,13 +520,15 @@ function setupSearch() {
|
|||
|
||||
searchInput.addEventListener('blur', event => {
|
||||
focus = false;
|
||||
if (hover) return;
|
||||
if(hover)
|
||||
return;
|
||||
search.classList.remove('active');
|
||||
});
|
||||
|
||||
search.addEventListener('mouseleave', event => {
|
||||
hover = false;
|
||||
if (focus) return;
|
||||
if(focus)
|
||||
return;
|
||||
search.classList.remove('active');
|
||||
});
|
||||
|
||||
|
@ -542,17 +555,17 @@ function openHelp(event) {
|
|||
}
|
||||
|
||||
window.addEventListener('keydown', (event) => {
|
||||
if (event.keyCode == 27) {
|
||||
if (document.querySelector('.help.active')) {
|
||||
if(event.keyCode == 27) {
|
||||
if(document.querySelector('.help.active')) {
|
||||
closeHelp(event);
|
||||
}
|
||||
}
|
||||
|
||||
if (event.keyCode == 46) {
|
||||
if(event.keyCode == 46) {
|
||||
deleteEvent(event);
|
||||
}
|
||||
|
||||
if (event.keyCode == 112) {
|
||||
if(event.keyCode == 112) {
|
||||
event.preventDefault();
|
||||
openHelp(event);
|
||||
}
|
||||
|
@ -583,7 +596,7 @@ document.addEventListener("DOMContentLoaded", function (event) {
|
|||
templates.info = document.querySelector('#info-template');
|
||||
templates.move = document.querySelector("#move-template");
|
||||
|
||||
if (user.AllowEdit) {
|
||||
if(user.AllowEdit) {
|
||||
buttons.delete.addEventListener("click", deleteEvent);
|
||||
}
|
||||
|
||||
|
@ -601,7 +614,7 @@ document.addEventListener("DOMContentLoaded", function (event) {
|
|||
});
|
||||
|
||||
overlay.addEventListener('click', event => {
|
||||
if (document.querySelector('.help.active')) {
|
||||
if(document.querySelector('.help.active')) {
|
||||
closeHelp(event);
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
|
||||
var editor = {};
|
||||
|
||||
editor.textareaAutoGrow = function() {
|
||||
let autogrow = function() {
|
||||
editor.textareaAutoGrow = function () {
|
||||
let autogrow = function () {
|
||||
console.log(this.style.height)
|
||||
this.style.height = 'auto';
|
||||
this.style.height = (this.scrollHeight) + 'px';
|
||||
|
@ -36,7 +36,7 @@ function makeFromBaseTemplate(id, type, name, parent) {
|
|||
clone.querySelector('.delete').addEventListener('click', deleteFrontMatterItem);
|
||||
clone.querySelector('.add').addEventListener('click', addFrontMatterItem);
|
||||
|
||||
if (parent.classList.contains("frontmatter")) {
|
||||
if(parent.classList.contains("frontmatter")) {
|
||||
parent.insertBefore(clone, document.querySelector('div.button.add'));
|
||||
return
|
||||
}
|
||||
|
@ -71,11 +71,11 @@ function makeFromObjectItemTemplate(id, name, parent) {
|
|||
}
|
||||
|
||||
function addFrontMatterItemPrompt(parent) {
|
||||
return function(event) {
|
||||
return function (event) {
|
||||
event.preventDefault();
|
||||
|
||||
let value = event.currentTarget.querySelector('input').value;
|
||||
if (value === '') {
|
||||
if(value === '') {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -84,7 +84,7 @@ function addFrontMatterItemPrompt(parent) {
|
|||
let name = value.substring(0, value.lastIndexOf(':')),
|
||||
type = value.substring(value.lastIndexOf(':') + 1, value.length);
|
||||
|
||||
if (type !== "" && type !== "array" && type !== "object") {
|
||||
if(type !== "" && type !== "array" && type !== "object") {
|
||||
name = value;
|
||||
}
|
||||
|
||||
|
@ -92,12 +92,12 @@ function addFrontMatterItemPrompt(parent) {
|
|||
|
||||
let id = name;
|
||||
|
||||
if (parent.id != '') {
|
||||
if(parent.id != '') {
|
||||
id = parent.id + "." + id;
|
||||
}
|
||||
|
||||
if (type == "array" || type == "object") {
|
||||
if (parent.dataset.type == "parent") {
|
||||
if(type == "array" || type == "object") {
|
||||
if(parent.dataset.type == "parent") {
|
||||
makeFromBaseTemplate(id, type, name, document.querySelector('.frontmatter'));
|
||||
return;
|
||||
}
|
||||
|
@ -108,7 +108,7 @@ function addFrontMatterItemPrompt(parent) {
|
|||
|
||||
let group = parent.querySelector('.group');
|
||||
|
||||
if (group == null) {
|
||||
if(group == null) {
|
||||
parent.insertAdjacentHTML('afterbegin', '<div class="group"></div>');
|
||||
group = parent.querySelector('.group');
|
||||
}
|
||||
|
@ -124,12 +124,12 @@ function addFrontMatterItem(event) {
|
|||
type = parent.dataset.type;
|
||||
|
||||
// If the block is an array
|
||||
if (type === "array") {
|
||||
if(type === "array") {
|
||||
let id = parent.id + "[]",
|
||||
count = parent.querySelectorAll('.group > div').length,
|
||||
fieldsets = parent.getElementsByTagName("fieldset");
|
||||
|
||||
if (fieldsets.length > 0) {
|
||||
if(fieldsets.length > 0) {
|
||||
let itemType = fieldsets[0].dataset.type,
|
||||
itemID = parent.id + "[" + fieldsets.length + "]",
|
||||
itemName = fieldsets.length;
|
||||
|
@ -142,7 +142,7 @@ function addFrontMatterItem(event) {
|
|||
return;
|
||||
}
|
||||
|
||||
if (type == "object" || type == "parent") {
|
||||
if(type == "object" || type == "parent") {
|
||||
let clone = document.importNode(templates.question.content, true);
|
||||
clone.querySelector('form').id = tempID;
|
||||
clone.querySelector('h3').innerHTML = 'New field';
|
||||
|
@ -160,7 +160,7 @@ function addFrontMatterItem(event) {
|
|||
}
|
||||
|
||||
document.addEventListener("DOMContentLoaded", (event) => {
|
||||
if (!document.getElementById('editor')) return;
|
||||
if(!document.getElementById('editor')) return;
|
||||
|
||||
editor.textareaAutoGrow();
|
||||
templates.arrayItem = document.getElementById("array-item-template");
|
||||
|
@ -172,7 +172,7 @@ document.addEventListener("DOMContentLoaded", (event) => {
|
|||
let container = document.getElementById('editor'),
|
||||
kind = container.dataset.kind;
|
||||
|
||||
if (kind != 'frontmatter-only') {
|
||||
if(kind != 'frontmatter-only') {
|
||||
let editor = document.querySelector('.content #ace'),
|
||||
mode = editor.dataset.mode,
|
||||
textarea = document.querySelector('textarea[name="content"]'),
|
||||
|
@ -188,11 +188,11 @@ document.addEventListener("DOMContentLoaded", (event) => {
|
|||
|
||||
aceEditor.getSession().setMode("ace/mode/" + mode);
|
||||
aceEditor.getSession().setValue(textarea.value);
|
||||
aceEditor.getSession().on('change', function() {
|
||||
aceEditor.getSession().on('change', function () {
|
||||
textarea.value = aceEditor.getSession().getValue();
|
||||
});
|
||||
|
||||
if (mode == "markdown") options.showGutter = false;
|
||||
if(mode == "markdown") options.showGutter = false;
|
||||
aceEditor.setOptions(options);
|
||||
}
|
||||
|
||||
|
@ -206,14 +206,14 @@ document.addEventListener("DOMContentLoaded", (event) => {
|
|||
button.addEventListener('click', addFrontMatterItem);
|
||||
});
|
||||
|
||||
let saveContent = function() {
|
||||
let saveContent = function () {
|
||||
let data = form2js(document.querySelector('form'));
|
||||
|
||||
if (typeof data.content === "undefined" && kind != 'frontmatter-only') {
|
||||
if(typeof data.content === "undefined" && kind != 'frontmatter-only') {
|
||||
data.content = "";
|
||||
}
|
||||
|
||||
if (typeof data.content === "number") {
|
||||
if(typeof data.content === "number") {
|
||||
data.content = data.content.toString();
|
||||
}
|
||||
|
||||
|
@ -223,8 +223,8 @@ document.addEventListener("DOMContentLoaded", (event) => {
|
|||
request.open("PUT", toWebDavURL(window.location.pathname));
|
||||
request.setRequestHeader('Kind', kind);
|
||||
request.send(JSON.stringify(data));
|
||||
request.onreadystatechange = function() {
|
||||
if (request.readyState == 4) {
|
||||
request.onreadystatechange = function () {
|
||||
if(request.readyState == 4) {
|
||||
buttons.save.querySelector('i').changeToDone((request.status != 201), html);
|
||||
}
|
||||
}
|
||||
|
@ -241,8 +241,8 @@ document.addEventListener("DOMContentLoaded", (event) => {
|
|||
});
|
||||
|
||||
window.addEventListener('keydown', (event) => {
|
||||
if (event.ctrlKey || event.metaKey) {
|
||||
switch (String.fromCharCode(event.which).toLowerCase()) {
|
||||
if(event.ctrlKey || event.metaKey) {
|
||||
switch(String.fromCharCode(event.which).toLowerCase()) {
|
||||
case 's':
|
||||
event.preventDefault();
|
||||
saveContent();
|
||||
|
|
|
@ -4,19 +4,19 @@ var listing = {
|
|||
selectMultiple: false
|
||||
};
|
||||
|
||||
listing.reload = function(callback) {
|
||||
listing.reload = function (callback) {
|
||||
let request = new XMLHttpRequest();
|
||||
|
||||
request.open('GET', window.location);
|
||||
request.setRequestHeader('Minimal', 'true');
|
||||
request.send();
|
||||
request.onreadystatechange = function() {
|
||||
if (request.readyState == 4) {
|
||||
if (request.status == 200) {
|
||||
request.onreadystatechange = function () {
|
||||
if(request.readyState == 4) {
|
||||
if(request.status == 200) {
|
||||
document.querySelector('body main').innerHTML = request.responseText;
|
||||
listing.addDoubleTapEvent();
|
||||
|
||||
if (typeof callback == 'function') {
|
||||
if(typeof callback == 'function') {
|
||||
callback();
|
||||
}
|
||||
}
|
||||
|
@ -24,11 +24,11 @@ listing.reload = function(callback) {
|
|||
}
|
||||
}
|
||||
|
||||
listing.itemDragStart = function(event) {
|
||||
listing.itemDragStart = function (event) {
|
||||
let el = event.target;
|
||||
|
||||
for (let i = 0; i < 5; i++) {
|
||||
if (!el.classList.contains('item')) {
|
||||
for(let i = 0; i < 5; i++) {
|
||||
if(!el.classList.contains('item')) {
|
||||
el = el.parentElement;
|
||||
}
|
||||
}
|
||||
|
@ -37,12 +37,12 @@ listing.itemDragStart = function(event) {
|
|||
event.dataTransfer.setData("name", el.querySelector('.name').innerHTML);
|
||||
}
|
||||
|
||||
listing.itemDragOver = function(event) {
|
||||
listing.itemDragOver = function (event) {
|
||||
event.preventDefault();
|
||||
let el = event.target;
|
||||
|
||||
for (let i = 0; i < 5; i++) {
|
||||
if (!el.classList.contains('item')) {
|
||||
for(let i = 0; i < 5; i++) {
|
||||
if(!el.classList.contains('item')) {
|
||||
el = el.parentElement;
|
||||
}
|
||||
}
|
||||
|
@ -50,22 +50,22 @@ listing.itemDragOver = function(event) {
|
|||
el.style.opacity = 1;
|
||||
}
|
||||
|
||||
listing.itemDrop = function(e) {
|
||||
listing.itemDrop = function (e) {
|
||||
e.preventDefault();
|
||||
|
||||
let el = e.target,
|
||||
id = e.dataTransfer.getData("id"),
|
||||
name = e.dataTransfer.getData("name");
|
||||
|
||||
if (id == "" || name == "") return;
|
||||
if(id == "" || name == "") return;
|
||||
|
||||
for (let i = 0; i < 5; i++) {
|
||||
if (!el.classList.contains('item')) {
|
||||
for(let i = 0; i < 5; i++) {
|
||||
if(!el.classList.contains('item')) {
|
||||
el = el.parentElement;
|
||||
}
|
||||
}
|
||||
|
||||
if (el.id === id) return;
|
||||
if(el.id === id) return;
|
||||
|
||||
let oldLink = document.getElementById(id).dataset.url,
|
||||
newLink = el.dataset.url + name;
|
||||
|
@ -75,21 +75,21 @@ listing.itemDrop = function(e) {
|
|||
.catch(e => console.log(e));
|
||||
}
|
||||
|
||||
listing.documentDrop = function(event) {
|
||||
listing.documentDrop = function (event) {
|
||||
event.preventDefault();
|
||||
let dt = event.dataTransfer,
|
||||
files = dt.files,
|
||||
el = event.target,
|
||||
items = document.getElementsByClassName('item');
|
||||
|
||||
for (let i = 0; i < 5; i++) {
|
||||
if (el != null && !el.classList.contains('item')) {
|
||||
for(let i = 0; i < 5; i++) {
|
||||
if(el != null && !el.classList.contains('item')) {
|
||||
el = el.parentElement;
|
||||
}
|
||||
}
|
||||
|
||||
if (files.length > 0) {
|
||||
if (el != null && el.classList.contains('item') && el.dataset.dir == "true") {
|
||||
if(files.length > 0) {
|
||||
if(el != null && el.classList.contains('item') && el.dataset.dir == "true") {
|
||||
listing.handleFiles(files, el.querySelector('.name').innerHTML + "/");
|
||||
return;
|
||||
}
|
||||
|
@ -102,14 +102,14 @@ listing.documentDrop = function(event) {
|
|||
}
|
||||
}
|
||||
|
||||
listing.rename = function(event) {
|
||||
if (!selectedItems.length || selectedItems.length > 1) {
|
||||
listing.rename = function (event) {
|
||||
if(!selectedItems.length || selectedItems.length > 1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
let item = document.getElementById(selectedItems[0]);
|
||||
|
||||
if (item.classList.contains('disabled')) {
|
||||
if(item.classList.contains('disabled')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -157,11 +157,11 @@ listing.rename = function(event) {
|
|||
return false;
|
||||
}
|
||||
|
||||
listing.handleFiles = function(files, base) {
|
||||
listing.handleFiles = function (files, base) {
|
||||
let html = buttons.upload.querySelector('i').changeToLoading(),
|
||||
promises = [];
|
||||
|
||||
for (let file of files) {
|
||||
for(let file of files) {
|
||||
promises.push(webdav.put(window.location.pathname + base + file.name, file));
|
||||
}
|
||||
|
||||
|
@ -178,7 +178,7 @@ listing.handleFiles = function(files, base) {
|
|||
return false;
|
||||
}
|
||||
|
||||
listing.unselectAll = function() {
|
||||
listing.unselectAll = function () {
|
||||
let items = document.getElementsByClassName('item');
|
||||
Array.from(items).forEach(link => {
|
||||
link.setAttribute("aria-selected", false);
|
||||
|
@ -190,22 +190,22 @@ listing.unselectAll = function() {
|
|||
return false;
|
||||
}
|
||||
|
||||
listing.handleSelectionChange = function(event) {
|
||||
listing.handleSelectionChange = function (event) {
|
||||
listing.redefineDownloadURLs();
|
||||
|
||||
let selectedNumber = selectedItems.length,
|
||||
fileAction = document.getElementById("file-only");
|
||||
|
||||
if (selectedNumber) {
|
||||
if(selectedNumber) {
|
||||
fileAction.classList.remove("disabled");
|
||||
|
||||
if (selectedNumber > 1) {
|
||||
if(selectedNumber > 1) {
|
||||
buttons.open.classList.add("disabled");
|
||||
buttons.rename.classList.add("disabled");
|
||||
}
|
||||
|
||||
if (selectedNumber == 1) {
|
||||
if (document.getElementById(selectedItems[0]).dataset.dir == "true") {
|
||||
if(selectedNumber == 1) {
|
||||
if(document.getElementById(selectedItems[0]).dataset.dir == "true") {
|
||||
buttons.open.classList.add("disabled");
|
||||
} else {
|
||||
buttons.open.classList.remove("disabled");
|
||||
|
@ -221,10 +221,10 @@ listing.handleSelectionChange = function(event) {
|
|||
return false;
|
||||
}
|
||||
|
||||
listing.redefineDownloadURLs = function() {
|
||||
listing.redefineDownloadURLs = function () {
|
||||
let files = "";
|
||||
|
||||
for (let i = 0; i < selectedItems.length; i++) {
|
||||
for(let i = 0; i < selectedItems.length; i++) {
|
||||
let url = document.getElementById(selectedItems[i]).dataset.url;
|
||||
files += url.replace(window.location.pathname, "") + ",";
|
||||
}
|
||||
|
@ -238,16 +238,16 @@ listing.redefineDownloadURLs = function() {
|
|||
});
|
||||
}
|
||||
|
||||
listing.openItem = function(event) {
|
||||
listing.openItem = function (event) {
|
||||
window.location = event.currentTarget.dataset.url;
|
||||
}
|
||||
|
||||
listing.selectItem = function(event) {
|
||||
listing.selectItem = function (event) {
|
||||
let el = event.currentTarget;
|
||||
|
||||
if (selectedItems.length != 0) event.preventDefault();
|
||||
if (selectedItems.indexOf(el.id) == -1) {
|
||||
if (!event.ctrlKey && !listing.selectMultiple) listing.unselectAll();
|
||||
if(selectedItems.length != 0) event.preventDefault();
|
||||
if(selectedItems.indexOf(el.id) == -1) {
|
||||
if(!event.ctrlKey && !listing.selectMultiple) listing.unselectAll();
|
||||
|
||||
el.setAttribute("aria-selected", true);
|
||||
selectedItems.push(el.id);
|
||||
|
@ -260,7 +260,7 @@ listing.selectItem = function(event) {
|
|||
return false;
|
||||
}
|
||||
|
||||
listing.newFileButton = function(event) {
|
||||
listing.newFileButton = function (event) {
|
||||
event.preventDefault();
|
||||
|
||||
let clone = document.importNode(templates.question.content, true);
|
||||
|
@ -274,7 +274,7 @@ listing.newFileButton = function(event) {
|
|||
document.querySelector('.prompt').classList.add('active');
|
||||
}
|
||||
|
||||
listing.newFilePrompt = function(event) {
|
||||
listing.newFilePrompt = function (event) {
|
||||
event.preventDefault();
|
||||
|
||||
let button = document.getElementById('new'),
|
||||
|
@ -284,8 +284,8 @@ listing.newFilePrompt = function(event) {
|
|||
|
||||
request.open((name.endsWith("/") ? "MKCOL" : "PUT"), toWebDavURL(window.location.pathname + name));
|
||||
request.send();
|
||||
request.onreadystatechange = function() {
|
||||
if (request.readyState == 4) {
|
||||
request.onreadystatechange = function () {
|
||||
if(request.readyState == 4) {
|
||||
button.querySelector('i').changeToDone((request.status != 201), html);
|
||||
listing.reload();
|
||||
}
|
||||
|
@ -295,14 +295,14 @@ listing.newFilePrompt = function(event) {
|
|||
return false;
|
||||
}
|
||||
|
||||
listing.updateColumns = function(event) {
|
||||
listing.updateColumns = function (event) {
|
||||
let columns = Math.floor(document.getElementById('listing').offsetWidth / 300),
|
||||
items = getCSSRule(['#listing.mosaic .item', '.mosaic#listing .item']);
|
||||
|
||||
items.style.width = `calc(${100/columns}% - 1em)`;
|
||||
}
|
||||
|
||||
listing.addDoubleTapEvent = function() {
|
||||
listing.addDoubleTapEvent = function () {
|
||||
let items = document.getElementsByClassName('item'),
|
||||
touches = {
|
||||
id: '',
|
||||
|
@ -311,7 +311,7 @@ listing.addDoubleTapEvent = function() {
|
|||
|
||||
Array.from(items).forEach(file => {
|
||||
file.addEventListener('touchstart', event => {
|
||||
if (touches.id != file.id) {
|
||||
if(touches.id != file.id) {
|
||||
touches.id = file.id;
|
||||
touches.count = 1;
|
||||
|
||||
|
@ -324,7 +324,7 @@ listing.addDoubleTapEvent = function() {
|
|||
|
||||
touches.count++;
|
||||
|
||||
if (touches.count > 1) {
|
||||
if(touches.count > 1) {
|
||||
window.location = file.dataset.url;
|
||||
}
|
||||
});
|
||||
|
@ -333,21 +333,21 @@ listing.addDoubleTapEvent = function() {
|
|||
|
||||
// Keydown events
|
||||
window.addEventListener('keydown', (event) => {
|
||||
if (event.keyCode == 27) {
|
||||
if(event.keyCode == 27) {
|
||||
listing.unselectAll();
|
||||
|
||||
if (document.querySelectorAll('.prompt').length) {
|
||||
if(document.querySelectorAll('.prompt').length) {
|
||||
closePrompt(event);
|
||||
}
|
||||
}
|
||||
|
||||
if (event.keyCode == 113) {
|
||||
if(event.keyCode == 113) {
|
||||
listing.rename();
|
||||
}
|
||||
|
||||
if (event.ctrlKey || event.metaKey) {
|
||||
if(event.ctrlKey || event.metaKey) {
|
||||
console.log("hey")
|
||||
switch (String.fromCharCode(event.which).toLowerCase()) {
|
||||
switch(String.fromCharCode(event.which).toLowerCase()) {
|
||||
case 's':
|
||||
event.preventDefault();
|
||||
window.location = "?download=true"
|
||||
|
@ -383,13 +383,13 @@ document.addEventListener('DOMContentLoaded', event => {
|
|||
document.getElementById('multiple-selection').classList.remove('active');
|
||||
})
|
||||
|
||||
if (user.AllowEdit) {
|
||||
if(user.AllowEdit) {
|
||||
buttons.rename.addEventListener("click", listing.rename);
|
||||
}
|
||||
|
||||
let items = document.getElementsByClassName('item');
|
||||
|
||||
if (user.AllowNew) {
|
||||
if(user.AllowNew) {
|
||||
buttons.upload.addEventListener("click", (event) => {
|
||||
document.getElementById("upload-input").click();
|
||||
});
|
||||
|
@ -397,7 +397,7 @@ document.addEventListener('DOMContentLoaded', event => {
|
|||
buttons.new.addEventListener('click', listing.newFileButton);
|
||||
|
||||
// Drag and Drop
|
||||
document.addEventListener("dragover", function(event) {
|
||||
document.addEventListener("dragover", function (event) {
|
||||
event.preventDefault();
|
||||
}, false);
|
||||
|
||||
|
@ -416,5 +416,4 @@ document.addEventListener('DOMContentLoaded', event => {
|
|||
document.addEventListener("drop", listing.documentDrop, false);
|
||||
}
|
||||
|
||||
|
||||
});
|
|
@ -1,32 +0,0 @@
|
|||
{
|
||||
"js": {
|
||||
"allowed_file_extensions": ["js", "json", "jshintrc", "jsbeautifyrc"],
|
||||
|
||||
// Set brace_style
|
||||
// collapse: (old default) Put braces on the same line as control statements
|
||||
// collapse-preserve-inline: (new default) Same as collapse but better support for ES6 destructuring and other features. https://github.com/victorporof/Sublime-HTMLPrettify/issues/231
|
||||
// expand: Put braces on own line (Allman / ANSI style)
|
||||
// end-expand: Put end braces on own line
|
||||
// none: Keep them where they are
|
||||
"brace_style": "collapse-preserve-inline",
|
||||
|
||||
"break_chained_methods": false, // Break chained method calls across subsequent lines
|
||||
"e4x": false, // Pass E4X xml literals through untouched
|
||||
"end_with_newline": false, // End output with newline
|
||||
"indent_char": " ", // Indentation character
|
||||
"indent_level": 0, // Initial indentation level
|
||||
"indent_size": 2, // Indentation size
|
||||
"indent_with_tabs": false, // Indent with tabs, overrides `indent_size` and `indent_char`
|
||||
"jslint_happy": false, // If true, then jslint-stricter mode is enforced
|
||||
"keep_array_indentation": false, // Preserve array indentation
|
||||
"keep_function_indentation": false, // Preserve function indentation
|
||||
"max_preserve_newlines": 0, // Maximum number of line breaks to be preserved in one chunk (0 disables)
|
||||
"preserve_newlines": true, // Whether existing line breaks should be preserved
|
||||
"space_after_anon_function": false, // Should the space before an anonymous function's parens be added, "function()" vs "function ()"
|
||||
"space_before_conditional": true, // Should the space before conditional statement be added, "if(true)" vs "if (true)"
|
||||
"space_in_empty_paren": false, // Add padding spaces within empty paren, "f()" vs "f( )"
|
||||
"space_in_paren": false, // Add padding spaces within paren, ie. f( a, b )
|
||||
"unescape_strings": false, // Should printable characters in strings encoded in \xNN notation be unescaped, "example" vs "\x65\x78\x61\x6d\x70\x6c\x65"
|
||||
"wrap_line_length": 0 // Lines should wrap at next opportunity after this number of characters (0 disables)
|
||||
}
|
||||
}
|
|
@ -1,16 +0,0 @@
|
|||
{
|
||||
"html": {
|
||||
"allowed_file_extensions": ["htm", "html", "xhtml", "shtml", "xml", "svg"],
|
||||
"brace_style": "collapse", // [collapse|expand|end-expand|none] Put braces on the same line as control statements (default), or put braces on own line (Allman / ANSI style), or just put end braces on own line, or attempt to keep them where they are
|
||||
"end_with_newline": false, // End output with newline
|
||||
"indent_char": " ", // Indentation character
|
||||
"indent_handlebars": false, // e.g. {{#foo}}, {{/foo}}
|
||||
"indent_inner_html": false, // Indent <head> and <body> sections
|
||||
"indent_scripts": "keep", // [keep|separate|normal]
|
||||
"indent_size": 4, // Indentation size
|
||||
"max_preserve_newlines": 0, // Maximum number of line breaks to be preserved in one chunk (0 disables)
|
||||
"preserve_newlines": true, // Whether existing line breaks before elements should be preserved (only works before elements, not inside tags or for text)
|
||||
"unformatted": ["a", "span", "img", "code", "pre", "sub", "sup", "em", "strong", "b", "i", "u", "strike", "big", "small", "pre", "h1", "h2", "h3", "h4", "h5", "h6"], // List of tags that should not be reformatted
|
||||
"wrap_line_length": 0 // Lines should wrap at next opportunity after this number of characters (0 disables)
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue