identation and stuff

This commit is contained in:
Henrique Dias 2017-01-03 17:35:13 +00:00
parent f4cad45f04
commit c706998a5a
11 changed files with 1515 additions and 1539 deletions

22
.jsbeautifyrc Normal file
View File

@ -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
}
}

View File

@ -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")
}
}

View File

@ -1,137 +1,137 @@
@font-face { @font-face {
font-family: 'Roboto'; font-family: 'Roboto';
font-style: normal; font-style: normal;
font-weight: 400; font-weight: 400;
src: local('Roboto'), local('Roboto-Regular'), url(roboto/normal-cyrillic-ext.woff2) format('woff2'); src: local('Roboto'), local('Roboto-Regular'), url(roboto/normal-cyrillic-ext.woff2) format('woff2');
unicode-range: U+0460-052F, U+20B4, U+2DE0-2DFF, U+A640-A69F; unicode-range: U+0460-052F, U+20B4, U+2DE0-2DFF, U+A640-A69F;
} }
@font-face { @font-face {
font-family: 'Roboto'; font-family: 'Roboto';
font-style: normal; font-style: normal;
font-weight: 400; font-weight: 400;
src: local('Roboto'), local('Roboto-Regular'), url(roboto/normal-cyrillic.woff2) format('woff2'); src: local('Roboto'), local('Roboto-Regular'), url(roboto/normal-cyrillic.woff2) format('woff2');
unicode-range: U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; unicode-range: U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
} }
@font-face { @font-face {
font-family: 'Roboto'; font-family: 'Roboto';
font-style: normal; font-style: normal;
font-weight: 400; font-weight: 400;
src: local('Roboto'), local('Roboto-Regular'), url(roboto/normal-greek-ext.woff2) format('woff2'); src: local('Roboto'), local('Roboto-Regular'), url(roboto/normal-greek-ext.woff2) format('woff2');
unicode-range: U+1F00-1FFF; unicode-range: U+1F00-1FFF;
} }
@font-face { @font-face {
font-family: 'Roboto'; font-family: 'Roboto';
font-style: normal; font-style: normal;
font-weight: 400; font-weight: 400;
src: local('Roboto'), local('Roboto-Regular'), url(roboto/normal-greek.woff2) format('woff2'); src: local('Roboto'), local('Roboto-Regular'), url(roboto/normal-greek.woff2) format('woff2');
unicode-range: U+0370-03FF; unicode-range: U+0370-03FF;
} }
@font-face { @font-face {
font-family: 'Roboto'; font-family: 'Roboto';
font-style: normal; font-style: normal;
font-weight: 400; font-weight: 400;
src: local('Roboto'), local('Roboto-Regular'), url(roboto/normal-vietnamese.woff2) format('woff2'); src: local('Roboto'), local('Roboto-Regular'), url(roboto/normal-vietnamese.woff2) format('woff2');
unicode-range: U+0102-0103, U+1EA0-1EF9, U+20AB; unicode-range: U+0102-0103, U+1EA0-1EF9, U+20AB;
} }
@font-face { @font-face {
font-family: 'Roboto'; font-family: 'Roboto';
font-style: normal; font-style: normal;
font-weight: 400; font-weight: 400;
src: local('Roboto'), local('Roboto-Regular'), url(roboto/normal-latin-ext.woff2) format('woff2'); src: local('Roboto'), local('Roboto-Regular'), url(roboto/normal-latin-ext.woff2) format('woff2');
unicode-range: U+0100-024F, U+1E00-1EFF, U+20A0-20AB, U+20AD-20CF, U+2C60-2C7F, U+A720-A7FF; unicode-range: U+0100-024F, U+1E00-1EFF, U+20A0-20AB, U+20AD-20CF, U+2C60-2C7F, U+A720-A7FF;
} }
@font-face { @font-face {
font-family: 'Roboto'; font-family: 'Roboto';
font-style: normal; font-style: normal;
font-weight: 400; font-weight: 400;
src: local('Roboto'), local('Roboto-Regular'), url(roboto/normal-latin.woff2) format('woff2'); src: local('Roboto'), local('Roboto-Regular'), url(roboto/normal-latin.woff2) format('woff2');
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2212, U+2215, U+E0FF, U+EFFD, U+F000; unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2212, U+2215, U+E0FF, U+EFFD, U+F000;
} }
@font-face { @font-face {
font-family: 'Roboto'; font-family: 'Roboto';
font-style: normal; font-style: normal;
font-weight: 500; font-weight: 500;
src: local('Roboto Medium'), local('Roboto-Medium'), url(roboto/medium-cyrillic-ext.woff2) format('woff2'); src: local('Roboto Medium'), local('Roboto-Medium'), url(roboto/medium-cyrillic-ext.woff2) format('woff2');
unicode-range: U+0460-052F, U+20B4, U+2DE0-2DFF, U+A640-A69F; unicode-range: U+0460-052F, U+20B4, U+2DE0-2DFF, U+A640-A69F;
} }
@font-face { @font-face {
font-family: 'Roboto'; font-family: 'Roboto';
font-style: normal; font-style: normal;
font-weight: 500; font-weight: 500;
src: local('Roboto Medium'), local('Roboto-Medium'), url(roboto/medium-cyrillic.woff2) format('woff2'); src: local('Roboto Medium'), local('Roboto-Medium'), url(roboto/medium-cyrillic.woff2) format('woff2');
unicode-range: U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116; unicode-range: U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
} }
@font-face { @font-face {
font-family: 'Roboto'; font-family: 'Roboto';
font-style: normal; font-style: normal;
font-weight: 500; font-weight: 500;
src: local('Roboto Medium'), local('Roboto-Medium'), url(roboto/medium-greek-ext.woff2) format('woff2'); src: local('Roboto Medium'), local('Roboto-Medium'), url(roboto/medium-greek-ext.woff2) format('woff2');
unicode-range: U+1F00-1FFF; unicode-range: U+1F00-1FFF;
} }
@font-face { @font-face {
font-family: 'Roboto'; font-family: 'Roboto';
font-style: normal; font-style: normal;
font-weight: 500; font-weight: 500;
src: local('Roboto Medium'), local('Roboto-Medium'), url(roboto/medium-greek.woff2) format('woff2'); src: local('Roboto Medium'), local('Roboto-Medium'), url(roboto/medium-greek.woff2) format('woff2');
unicode-range: U+0370-03FF; unicode-range: U+0370-03FF;
} }
@font-face { @font-face {
font-family: 'Roboto'; font-family: 'Roboto';
font-style: normal; font-style: normal;
font-weight: 500; font-weight: 500;
src: local('Roboto Medium'), local('Roboto-Medium'), url(roboto/medium-vietnamese.woff2) format('woff2'); src: local('Roboto Medium'), local('Roboto-Medium'), url(roboto/medium-vietnamese.woff2) format('woff2');
unicode-range: U+0102-0103, U+1EA0-1EF9, U+20AB; unicode-range: U+0102-0103, U+1EA0-1EF9, U+20AB;
} }
@font-face { @font-face {
font-family: 'Roboto'; font-family: 'Roboto';
font-style: normal; font-style: normal;
font-weight: 500; font-weight: 500;
src: local('Roboto Medium'), local('Roboto-Medium'), url(roboto/medium-latin-ext.woff2) format('woff2'); src: local('Roboto Medium'), local('Roboto-Medium'), url(roboto/medium-latin-ext.woff2) format('woff2');
unicode-range: U+0100-024F, U+1E00-1EFF, U+20A0-20AB, U+20AD-20CF, U+2C60-2C7F, U+A720-A7FF; unicode-range: U+0100-024F, U+1E00-1EFF, U+20A0-20AB, U+20AD-20CF, U+2C60-2C7F, U+A720-A7FF;
} }
@font-face { @font-face {
font-family: 'Roboto'; font-family: 'Roboto';
font-style: normal; font-style: normal;
font-weight: 500; font-weight: 500;
src: local('Roboto Medium'), local('Roboto-Medium'), url(roboto/medium-latin.woff2) format('woff2'); src: local('Roboto Medium'), local('Roboto-Medium'), url(roboto/medium-latin.woff2) format('woff2');
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2212, U+2215, U+E0FF, U+EFFD, U+F000; unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2212, U+2215, U+E0FF, U+EFFD, U+F000;
} }
@font-face { @font-face {
font-family: 'Material Icons'; font-family: 'Material Icons';
font-style: normal; font-style: normal;
font-weight: 400; font-weight: 400;
src: local('Material Icons'), local('MaterialIcons-Regular'), url(material/icons.woff2) format('woff2'); src: local('Material Icons'), local('MaterialIcons-Regular'), url(material/icons.woff2) format('woff2');
} }
.prompt .file-list ul li:before, .prompt .file-list ul li:before,
.material-icons { .material-icons {
font-family: 'Material Icons'; font-family: 'Material Icons';
font-weight: normal; font-weight: normal;
font-style: normal; font-style: normal;
font-size: 24px; font-size: 24px;
line-height: 1; line-height: 1;
letter-spacing: normal; letter-spacing: normal;
text-transform: none; text-transform: none;
display: inline-block; display: inline-block;
white-space: nowrap; white-space: nowrap;
word-wrap: normal; word-wrap: normal;
direction: ltr; direction: ltr;
-webkit-font-smoothing: antialiased; -webkit-font-smoothing: antialiased;
text-rendering: optimizeLegibility; text-rendering: optimizeLegibility;
-moz-osx-font-smoothing: grayscale; -moz-osx-font-smoothing: grayscale;
font-feature-settings: 'liga'; font-feature-settings: 'liga';
} }

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -2,8 +2,8 @@
var editor = {}; var editor = {};
editor.textareaAutoGrow = function() { editor.textareaAutoGrow = function () {
let autogrow = function() { let autogrow = function () {
console.log(this.style.height) console.log(this.style.height)
this.style.height = 'auto'; this.style.height = 'auto';
this.style.height = (this.scrollHeight) + 'px'; this.style.height = (this.scrollHeight) + 'px';
@ -36,7 +36,7 @@ function makeFromBaseTemplate(id, type, name, parent) {
clone.querySelector('.delete').addEventListener('click', deleteFrontMatterItem); clone.querySelector('.delete').addEventListener('click', deleteFrontMatterItem);
clone.querySelector('.add').addEventListener('click', addFrontMatterItem); clone.querySelector('.add').addEventListener('click', addFrontMatterItem);
if (parent.classList.contains("frontmatter")) { if(parent.classList.contains("frontmatter")) {
parent.insertBefore(clone, document.querySelector('div.button.add')); parent.insertBefore(clone, document.querySelector('div.button.add'));
return return
} }
@ -71,20 +71,20 @@ function makeFromObjectItemTemplate(id, name, parent) {
} }
function addFrontMatterItemPrompt(parent) { function addFrontMatterItemPrompt(parent) {
return function(event) { return function (event) {
event.preventDefault(); event.preventDefault();
let value = event.currentTarget.querySelector('input').value; let value = event.currentTarget.querySelector('input').value;
if (value === '') { if(value === '') {
return true; return true;
} }
closePrompt(event); closePrompt(event);
let name = value.substring(0, value.lastIndexOf(':')), let name = value.substring(0, value.lastIndexOf(':')),
type = value.substring(value.lastIndexOf(':') + 1, value.length); type = value.substring(value.lastIndexOf(':') + 1, value.length);
if (type !== "" && type !== "array" && type !== "object") { if(type !== "" && type !== "array" && type !== "object") {
name = value; name = value;
} }
@ -92,12 +92,12 @@ function addFrontMatterItemPrompt(parent) {
let id = name; let id = name;
if (parent.id != '') { if(parent.id != '') {
id = parent.id + "." + id; id = parent.id + "." + id;
} }
if (type == "array" || type == "object") { if(type == "array" || type == "object") {
if (parent.dataset.type == "parent") { if(parent.dataset.type == "parent") {
makeFromBaseTemplate(id, type, name, document.querySelector('.frontmatter')); makeFromBaseTemplate(id, type, name, document.querySelector('.frontmatter'));
return; return;
} }
@ -108,7 +108,7 @@ function addFrontMatterItemPrompt(parent) {
let group = parent.querySelector('.group'); let group = parent.querySelector('.group');
if (group == null) { if(group == null) {
parent.insertAdjacentHTML('afterbegin', '<div class="group"></div>'); parent.insertAdjacentHTML('afterbegin', '<div class="group"></div>');
group = parent.querySelector('.group'); group = parent.querySelector('.group');
} }
@ -121,18 +121,18 @@ function addFrontMatterItem(event) {
event.preventDefault(); event.preventDefault();
let parent = event.currentTarget.parentNode, let parent = event.currentTarget.parentNode,
type = parent.dataset.type; type = parent.dataset.type;
// If the block is an array // If the block is an array
if (type === "array") { if(type === "array") {
let id = parent.id + "[]", let id = parent.id + "[]",
count = parent.querySelectorAll('.group > div').length, count = parent.querySelectorAll('.group > div').length,
fieldsets = parent.getElementsByTagName("fieldset"); fieldsets = parent.getElementsByTagName("fieldset");
if (fieldsets.length > 0) { if(fieldsets.length > 0) {
let itemType = fieldsets[0].dataset.type, let itemType = fieldsets[0].dataset.type,
itemID = parent.id + "[" + fieldsets.length + "]", itemID = parent.id + "[" + fieldsets.length + "]",
itemName = fieldsets.length; itemName = fieldsets.length;
makeFromBaseTemplate(itemID, itemType, itemName, parent); makeFromBaseTemplate(itemID, itemType, itemName, parent);
} else { } else {
@ -142,7 +142,7 @@ function addFrontMatterItem(event) {
return; return;
} }
if (type == "object" || type == "parent") { if(type == "object" || type == "parent") {
let clone = document.importNode(templates.question.content, true); let clone = document.importNode(templates.question.content, true);
clone.querySelector('form').id = tempID; clone.querySelector('form').id = tempID;
clone.querySelector('h3').innerHTML = 'New field'; clone.querySelector('h3').innerHTML = 'New field';
@ -160,7 +160,7 @@ function addFrontMatterItem(event) {
} }
document.addEventListener("DOMContentLoaded", (event) => { document.addEventListener("DOMContentLoaded", (event) => {
if (!document.getElementById('editor')) return; if(!document.getElementById('editor')) return;
editor.textareaAutoGrow(); editor.textareaAutoGrow();
templates.arrayItem = document.getElementById("array-item-template"); templates.arrayItem = document.getElementById("array-item-template");
@ -170,29 +170,29 @@ document.addEventListener("DOMContentLoaded", (event) => {
buttons.save = document.querySelector('#save'); buttons.save = document.querySelector('#save');
let container = document.getElementById('editor'), let container = document.getElementById('editor'),
kind = container.dataset.kind; kind = container.dataset.kind;
if (kind != 'frontmatter-only') { if(kind != 'frontmatter-only') {
let editor = document.querySelector('.content #ace'), let editor = document.querySelector('.content #ace'),
mode = editor.dataset.mode, mode = editor.dataset.mode,
textarea = document.querySelector('textarea[name="content"]'), textarea = document.querySelector('textarea[name="content"]'),
aceEditor = ace.edit('ace'), aceEditor = ace.edit('ace'),
options = { options = {
wrap: true, wrap: true,
maxLines: Infinity, maxLines: Infinity,
theme: "ace/theme/github", theme: "ace/theme/github",
showPrintMargin: false, showPrintMargin: false,
fontSize: "1em", fontSize: "1em",
minLines: 20 minLines: 20
}; };
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 () {
textarea.value = aceEditor.getSession().getValue(); textarea.value = aceEditor.getSession().getValue();
}); });
if (mode == "markdown") options.showGutter = false; if(mode == "markdown") options.showGutter = false;
aceEditor.setOptions(options); aceEditor.setOptions(options);
} }
@ -206,25 +206,25 @@ document.addEventListener("DOMContentLoaded", (event) => {
button.addEventListener('click', addFrontMatterItem); button.addEventListener('click', addFrontMatterItem);
}); });
let saveContent = function() { let saveContent = function () {
let data = form2js(document.querySelector('form')); let data = form2js(document.querySelector('form'));
if (typeof data.content === "undefined" && kind != 'frontmatter-only') { if(typeof data.content === "undefined" && kind != 'frontmatter-only') {
data.content = ""; data.content = "";
} }
if (typeof data.content === "number") { if(typeof data.content === "number") {
data.content = data.content.toString(); data.content = data.content.toString();
} }
let html = buttons.save.querySelector('i').changeToLoading(), let html = buttons.save.querySelector('i').changeToLoading(),
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) {
buttons.save.querySelector('i').changeToDone((request.status != 201), html); buttons.save.querySelector('i').changeToDone((request.status != 201), html);
} }
} }
@ -241,9 +241,9 @@ document.addEventListener("DOMContentLoaded", (event) => {
}); });
window.addEventListener('keydown', (event) => { window.addEventListener('keydown', (event) => {
if (event.ctrlKey || event.metaKey) { if(event.ctrlKey || event.metaKey) {
switch (String.fromCharCode(event.which).toLowerCase()) { switch(String.fromCharCode(event.which).toLowerCase()) {
case 's': case 's':
event.preventDefault(); event.preventDefault();
saveContent(); saveContent();
break; break;

View File

@ -4,19 +4,19 @@ var listing = {
selectMultiple: false selectMultiple: false
}; };
listing.reload = function(callback) { listing.reload = function (callback) {
let request = new XMLHttpRequest(); let request = new XMLHttpRequest();
request.open('GET', window.location); request.open('GET', window.location);
request.setRequestHeader('Minimal', 'true'); request.setRequestHeader('Minimal', 'true');
request.send(); request.send();
request.onreadystatechange = function() { request.onreadystatechange = function () {
if (request.readyState == 4) { if(request.readyState == 4) {
if (request.status == 200) { if(request.status == 200) {
document.querySelector('body main').innerHTML = request.responseText; document.querySelector('body main').innerHTML = request.responseText;
listing.addDoubleTapEvent(); listing.addDoubleTapEvent();
if (typeof callback == 'function') { if(typeof callback == 'function') {
callback(); callback();
} }
} }
@ -24,11 +24,11 @@ listing.reload = function(callback) {
} }
} }
listing.itemDragStart = function(event) { listing.itemDragStart = function (event) {
let el = event.target; let el = event.target;
for (let i = 0; i < 5; i++) { for(let i = 0; i < 5; i++) {
if (!el.classList.contains('item')) { if(!el.classList.contains('item')) {
el = el.parentElement; el = el.parentElement;
} }
} }
@ -37,12 +37,12 @@ listing.itemDragStart = function(event) {
event.dataTransfer.setData("name", el.querySelector('.name').innerHTML); event.dataTransfer.setData("name", el.querySelector('.name').innerHTML);
} }
listing.itemDragOver = function(event) { listing.itemDragOver = function (event) {
event.preventDefault(); event.preventDefault();
let el = event.target; let el = event.target;
for (let i = 0; i < 5; i++) { for(let i = 0; i < 5; i++) {
if (!el.classList.contains('item')) { if(!el.classList.contains('item')) {
el = el.parentElement; el = el.parentElement;
} }
} }
@ -50,46 +50,46 @@ listing.itemDragOver = function(event) {
el.style.opacity = 1; el.style.opacity = 1;
} }
listing.itemDrop = function(e) { listing.itemDrop = function (e) {
e.preventDefault(); e.preventDefault();
let el = e.target, let el = e.target,
id = e.dataTransfer.getData("id"), id = e.dataTransfer.getData("id"),
name = e.dataTransfer.getData("name"); name = e.dataTransfer.getData("name");
if (id == "" || name == "") return; if(id == "" || name == "") return;
for (let i = 0; i < 5; i++) { for(let i = 0; i < 5; i++) {
if (!el.classList.contains('item')) { if(!el.classList.contains('item')) {
el = el.parentElement; el = el.parentElement;
} }
} }
if (el.id === id) return; if(el.id === id) return;
let oldLink = document.getElementById(id).dataset.url, let oldLink = document.getElementById(id).dataset.url,
newLink = el.dataset.url + name; newLink = el.dataset.url + name;
webdav.move(oldLink, newLink) webdav.move(oldLink, newLink)
.then(() => listing.reload()) .then(() => listing.reload())
.catch(e => console.log(e)); .catch(e => console.log(e));
} }
listing.documentDrop = function(event) { listing.documentDrop = function (event) {
event.preventDefault(); event.preventDefault();
let dt = event.dataTransfer, let dt = event.dataTransfer,
files = dt.files, files = dt.files,
el = event.target, el = event.target,
items = document.getElementsByClassName('item'); items = document.getElementsByClassName('item');
for (let i = 0; i < 5; i++) { for(let i = 0; i < 5; i++) {
if (el != null && !el.classList.contains('item')) { if(el != null && !el.classList.contains('item')) {
el = el.parentElement; el = el.parentElement;
} }
} }
if (files.length > 0) { if(files.length > 0) {
if (el != null && el.classList.contains('item') && el.dataset.dir == "true") { if(el != null && el.classList.contains('item') && el.dataset.dir == "true") {
listing.handleFiles(files, el.querySelector('.name').innerHTML + "/"); listing.handleFiles(files, el.querySelector('.name').innerHTML + "/");
return; return;
} }
@ -102,27 +102,27 @@ listing.documentDrop = function(event) {
} }
} }
listing.rename = function(event) { listing.rename = function (event) {
if (!selectedItems.length || selectedItems.length > 1) { if(!selectedItems.length || selectedItems.length > 1) {
return false; return false;
} }
let item = document.getElementById(selectedItems[0]); let item = document.getElementById(selectedItems[0]);
if (item.classList.contains('disabled')) { if(item.classList.contains('disabled')) {
return false; return false;
} }
let link = item.dataset.url, let link = item.dataset.url,
field = item.querySelector('.name'), field = item.querySelector('.name'),
name = field.innerHTML; name = field.innerHTML;
let submit = (event) => { let submit = (event) => {
event.preventDefault(); event.preventDefault();
let newName = event.currentTarget.querySelector('input').value, let newName = event.currentTarget.querySelector('input').value,
newLink = removeLastDirectoryPartOf(link) + "/" + newName, newLink = removeLastDirectoryPartOf(link) + "/" + newName,
html = buttons.rename.querySelector('i').changeToLoading(); html = buttons.rename.querySelector('i').changeToLoading();
closePrompt(event); closePrompt(event);
webdav.move(link, newLink).then(() => { webdav.move(link, newLink).then(() => {
@ -157,28 +157,28 @@ listing.rename = function(event) {
return false; return false;
} }
listing.handleFiles = function(files, base) { listing.handleFiles = function (files, base) {
let html = buttons.upload.querySelector('i').changeToLoading(), let html = buttons.upload.querySelector('i').changeToLoading(),
promises = []; promises = [];
for (let file of files) { for(let file of files) {
promises.push(webdav.put(window.location.pathname + base + file.name, file)); promises.push(webdav.put(window.location.pathname + base + file.name, file));
} }
Promise.all(promises) Promise.all(promises)
.then(() => { .then(() => {
listing.reload(); listing.reload();
buttons.upload.querySelector('i').changeToDone(false, html); buttons.upload.querySelector('i').changeToDone(false, html);
}) })
.catch(e => { .catch(e => {
console.log(e); console.log(e);
buttons.upload.querySelector('i').changeToDone(true, html); buttons.upload.querySelector('i').changeToDone(true, html);
}) })
return false; return false;
} }
listing.unselectAll = function() { listing.unselectAll = function () {
let items = document.getElementsByClassName('item'); let items = document.getElementsByClassName('item');
Array.from(items).forEach(link => { Array.from(items).forEach(link => {
link.setAttribute("aria-selected", false); link.setAttribute("aria-selected", false);
@ -190,22 +190,22 @@ listing.unselectAll = function() {
return false; return false;
} }
listing.handleSelectionChange = function(event) { listing.handleSelectionChange = function (event) {
listing.redefineDownloadURLs(); listing.redefineDownloadURLs();
let selectedNumber = selectedItems.length, let selectedNumber = selectedItems.length,
fileAction = document.getElementById("file-only"); fileAction = document.getElementById("file-only");
if (selectedNumber) { if(selectedNumber) {
fileAction.classList.remove("disabled"); fileAction.classList.remove("disabled");
if (selectedNumber > 1) { if(selectedNumber > 1) {
buttons.open.classList.add("disabled"); buttons.open.classList.add("disabled");
buttons.rename.classList.add("disabled"); buttons.rename.classList.add("disabled");
} }
if (selectedNumber == 1) { if(selectedNumber == 1) {
if (document.getElementById(selectedItems[0]).dataset.dir == "true") { if(document.getElementById(selectedItems[0]).dataset.dir == "true") {
buttons.open.classList.add("disabled"); buttons.open.classList.add("disabled");
} else { } else {
buttons.open.classList.remove("disabled"); buttons.open.classList.remove("disabled");
@ -221,10 +221,10 @@ listing.handleSelectionChange = function(event) {
return false; return false;
} }
listing.redefineDownloadURLs = function() { listing.redefineDownloadURLs = function () {
let files = ""; 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; let url = document.getElementById(selectedItems[i]).dataset.url;
files += url.replace(window.location.pathname, "") + ","; 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; window.location = event.currentTarget.dataset.url;
} }
listing.selectItem = function(event) { listing.selectItem = function (event) {
let el = event.currentTarget; let el = event.currentTarget;
if (selectedItems.length != 0) event.preventDefault(); if(selectedItems.length != 0) event.preventDefault();
if (selectedItems.indexOf(el.id) == -1) { if(selectedItems.indexOf(el.id) == -1) {
if (!event.ctrlKey && !listing.selectMultiple) listing.unselectAll(); if(!event.ctrlKey && !listing.selectMultiple) listing.unselectAll();
el.setAttribute("aria-selected", true); el.setAttribute("aria-selected", true);
selectedItems.push(el.id); selectedItems.push(el.id);
@ -260,7 +260,7 @@ listing.selectItem = function(event) {
return false; return false;
} }
listing.newFileButton = function(event) { listing.newFileButton = function (event) {
event.preventDefault(); event.preventDefault();
let clone = document.importNode(templates.question.content, true); let clone = document.importNode(templates.question.content, true);
@ -274,18 +274,18 @@ listing.newFileButton = function(event) {
document.querySelector('.prompt').classList.add('active'); document.querySelector('.prompt').classList.add('active');
} }
listing.newFilePrompt = function(event) { listing.newFilePrompt = function (event) {
event.preventDefault(); event.preventDefault();
let button = document.getElementById('new'), let button = document.getElementById('new'),
html = button.querySelector('i').changeToLoading(), html = button.querySelector('i').changeToLoading(),
request = new XMLHttpRequest(), request = new XMLHttpRequest(),
name = event.currentTarget.querySelector('input').value; name = event.currentTarget.querySelector('input').value;
request.open((name.endsWith("/") ? "MKCOL" : "PUT"), toWebDavURL(window.location.pathname + name)); request.open((name.endsWith("/") ? "MKCOL" : "PUT"), toWebDavURL(window.location.pathname + name));
request.send(); request.send();
request.onreadystatechange = function() { request.onreadystatechange = function () {
if (request.readyState == 4) { if(request.readyState == 4) {
button.querySelector('i').changeToDone((request.status != 201), html); button.querySelector('i').changeToDone((request.status != 201), html);
listing.reload(); listing.reload();
} }
@ -295,23 +295,23 @@ listing.newFilePrompt = function(event) {
return false; return false;
} }
listing.updateColumns = function(event) { listing.updateColumns = function (event) {
let columns = Math.floor(document.getElementById('listing').offsetWidth / 300), let columns = Math.floor(document.getElementById('listing').offsetWidth / 300),
items = getCSSRule(['#listing.mosaic .item', '.mosaic#listing .item']); items = getCSSRule(['#listing.mosaic .item', '.mosaic#listing .item']);
items.style.width = `calc(${100/columns}% - 1em)`; items.style.width = `calc(${100/columns}% - 1em)`;
} }
listing.addDoubleTapEvent = function() { listing.addDoubleTapEvent = function () {
let items = document.getElementsByClassName('item'), let items = document.getElementsByClassName('item'),
touches = { touches = {
id: '', id: '',
count: 0 count: 0
}; };
Array.from(items).forEach(file => { Array.from(items).forEach(file => {
file.addEventListener('touchstart', event => { file.addEventListener('touchstart', event => {
if (touches.id != file.id) { if(touches.id != file.id) {
touches.id = file.id; touches.id = file.id;
touches.count = 1; touches.count = 1;
@ -324,7 +324,7 @@ listing.addDoubleTapEvent = function() {
touches.count++; touches.count++;
if (touches.count > 1) { if(touches.count > 1) {
window.location = file.dataset.url; window.location = file.dataset.url;
} }
}); });
@ -333,22 +333,22 @@ listing.addDoubleTapEvent = function() {
// Keydown events // Keydown events
window.addEventListener('keydown', (event) => { window.addEventListener('keydown', (event) => {
if (event.keyCode == 27) { if(event.keyCode == 27) {
listing.unselectAll(); listing.unselectAll();
if (document.querySelectorAll('.prompt').length) { if(document.querySelectorAll('.prompt').length) {
closePrompt(event); closePrompt(event);
} }
} }
if (event.keyCode == 113) { if(event.keyCode == 113) {
listing.rename(); listing.rename();
} }
if (event.ctrlKey || event.metaKey) { if(event.ctrlKey || event.metaKey) {
console.log("hey") console.log("hey")
switch (String.fromCharCode(event.which).toLowerCase()) { switch(String.fromCharCode(event.which).toLowerCase()) {
case 's': case 's':
event.preventDefault(); event.preventDefault();
window.location = "?download=true" window.location = "?download=true"
} }
@ -383,13 +383,13 @@ document.addEventListener('DOMContentLoaded', event => {
document.getElementById('multiple-selection').classList.remove('active'); document.getElementById('multiple-selection').classList.remove('active');
}) })
if (user.AllowEdit) { if(user.AllowEdit) {
buttons.rename.addEventListener("click", listing.rename); buttons.rename.addEventListener("click", listing.rename);
} }
let items = document.getElementsByClassName('item'); let items = document.getElementsByClassName('item');
if (user.AllowNew) { if(user.AllowNew) {
buttons.upload.addEventListener("click", (event) => { buttons.upload.addEventListener("click", (event) => {
document.getElementById("upload-input").click(); document.getElementById("upload-input").click();
}); });
@ -397,7 +397,7 @@ document.addEventListener('DOMContentLoaded', event => {
buttons.new.addEventListener('click', listing.newFileButton); buttons.new.addEventListener('click', listing.newFileButton);
// Drag and Drop // Drag and Drop
document.addEventListener("dragover", function(event) { document.addEventListener("dragover", function (event) {
event.preventDefault(); event.preventDefault();
}, false); }, false);
@ -416,5 +416,4 @@ document.addEventListener('DOMContentLoaded', event => {
document.addEventListener("drop", listing.documentDrop, false); document.addEventListener("drop", listing.documentDrop, false);
} }
}); });

View File

@ -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)
}
}

View File

@ -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)
}
}