remove assignment

Former-commit-id: f4cad45f04
This commit is contained in:
Henrique Dias 2017-01-03 17:14:28 +00:00
parent 416626e1b8
commit 1dccba1404
3 changed files with 431 additions and 434 deletions

View File

@ -8,36 +8,36 @@ var tempID = "_fm_internal_temporary_id",
webdav = {}; webdav = {};
// Removes an element, if exists, from an array // Removes an element, if exists, from an array
Array.prototype.removeElement = function(element) { Array.prototype.removeElement = function (element) {
var i = this.indexOf(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 // Replaces an element inside an array by another
Array.prototype.replaceElement = function(oldElement, newElement) { Array.prototype.replaceElement = function (oldElement, newElement) {
var i = this.indexOf(oldElement); var i = this.indexOf(oldElement);
if (i != -1) this[i] = newElement; if (i != -1) this[i] = newElement;
} }
// Sends a costum event to itself // Sends a costum event to itself
Document.prototype.sendCostumEvent = function(text) { Document.prototype.sendCostumEvent = function (text) {
this.dispatchEvent(new CustomEvent(text)); this.dispatchEvent(new CustomEvent(text));
} }
// Gets the content of a cookie // Gets the content of a cookie
Document.prototype.getCookie = function(name) { Document.prototype.getCookie = function (name) {
var re = new RegExp("(?:(?:^|.*;\\s*)" + name + "\\s*\\=\\s*([^;]*).*$)|^.*$"); var re = new RegExp("(?:(?:^|.*;\\s*)" + name + "\\s*\\=\\s*([^;]*).*$)|^.*$");
return document.cookie.replace(re, "$1"); return document.cookie.replace(re, "$1");
} }
// Changes a button to the loading animation // Changes a button to the loading animation
Element.prototype.changeToLoading = function() { Element.prototype.changeToLoading = function () {
let element = this, let element = this,
originalText = element.innerHTML; originalText = element.innerHTML;
element.style.opacity = 0; element.style.opacity = 0;
setTimeout(function() { setTimeout(function () {
element.classList.add('spin'); element.classList.add('spin');
element.innerHTML = 'autorenew'; element.innerHTML = 'autorenew';
element.style.opacity = 1; element.style.opacity = 1;
@ -47,7 +47,7 @@ Element.prototype.changeToLoading = function() {
} }
// Changes an element to done animation // Changes an element to done animation
Element.prototype.changeToDone = function(error, html) { Element.prototype.changeToDone = function (error, html) {
this.style.opacity = 0; this.style.opacity = 0;
let thirdStep = () => { let thirdStep = () => {
@ -78,7 +78,7 @@ function toWebDavURL(url) {
} }
// Remove the last directory of an url // Remove the last directory of an url
var removeLastDirectoryPartOf = function(url) { var removeLastDirectoryPartOf = function (url) {
var arr = url.split('/'); var arr = url.split('/');
if (arr.pop() === "") { if (arr.pop() === "") {
arr.pop(); arr.pop();
@ -113,16 +113,15 @@ function getCSSRule(rules) {
return result; return result;
} }
/* * * * * * * * * * * * * * * * /* * * * * * * * * * * * * * * *
* * * *
* WEBDAV * * WEBDAV *
* * * *
* * * * * * * * * * * * * * * */ * * * * * * * * * * * * * * * */
// TODO: here, we should create an abstraction layer from the webdav. // TODO: here, we should create an abstraction layer from the webdav.
// We must create functions that do the requests to the webdav backend. // We must create functions that do the requests to the webdav backend.
webdav.move = function(oldLink, newLink) { webdav.move = function (oldLink, newLink) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
let request = new XMLHttpRequest(); let request = new XMLHttpRequest();
request.open('MOVE', toWebDavURL(oldLink), true); request.open('MOVE', toWebDavURL(oldLink), true);
@ -139,7 +138,7 @@ webdav.move = function(oldLink, newLink) {
}); });
} }
webdav.put = function(link, body) { webdav.put = function (link, body) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
let request = new XMLHttpRequest(); let request = new XMLHttpRequest();
request.open('PUT', toWebDavURL(link), true); request.open('PUT', toWebDavURL(link), true);
@ -155,12 +154,11 @@ webdav.put = function(link, body) {
}); });
} }
/* * * * * * * * * * * * * * * * /* * * * * * * * * * * * * * * *
* * * *
* EVENTS * * EVENTS *
* * * *
* * * * * * * * * * * * * * * */ * * * * * * * * * * * * * * * */
function closePrompt(event) { function closePrompt(event) {
let prompt = document.querySelector('.prompt'); let prompt = document.querySelector('.prompt');
@ -189,7 +187,7 @@ function notImplemented(event) {
} }
// Prevent Default event // Prevent Default event
var preventDefault = function(event) { var preventDefault = function (event) {
event.preventDefault(); event.preventDefault();
} }
@ -197,7 +195,7 @@ function logoutEvent(event) {
let request = new XMLHttpRequest(); let request = new XMLHttpRequest();
request.open('GET', window.location.pathname, true, "username", "password"); request.open('GET', window.location.pathname, true, "username", "password");
request.send(); request.send();
request.onreadystatechange = function() { request.onreadystatechange = function () {
if (request.readyState == 4) { if (request.readyState == 4) {
window.location = "/"; window.location = "/";
} }
@ -241,7 +239,7 @@ function loadNextFolder(event) {
request.open("GET", event.target.dataset.url); request.open("GET", event.target.dataset.url);
request.setRequestHeader("Accept", "application/json"); request.setRequestHeader("Accept", "application/json");
request.send(); request.send();
request.onreadystatechange = function() { request.onreadystatechange = function () {
if (request.readyState == 4 && request.status == 200) { if (request.readyState == 4 && request.status == 200) {
let dirs = 0; let dirs = 0;
@ -284,7 +282,7 @@ function moveSelected(event) {
request.open("MOVE", oldLink); request.open("MOVE", oldLink);
request.setRequestHeader("Destination", newLink); request.setRequestHeader("Destination", newLink);
request.send(); request.send();
request.onreadystatechange = function() { request.onreadystatechange = function () {
if (request.readyState == 4) { if (request.readyState == 4) {
if (request.status == 200 || request.status == 204) { if (request.status == 200 || request.status == 204) {
window.reload(); window.reload();
@ -300,7 +298,7 @@ function moveEvent(event) {
request.open("GET", window.location.pathname, true); request.open("GET", window.location.pathname, true);
request.setRequestHeader("Accept", "application/json"); request.setRequestHeader("Accept", "application/json");
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) {
let prompt = document.importNode(templates.move.content, true), let prompt = document.importNode(templates.move.content, true),
@ -338,7 +336,7 @@ function moveEvent(event) {
} }
function deleteSelected(single) { function deleteSelected(single) {
return function(event) { return function (event) {
event.preventDefault(); event.preventDefault();
Array.from(selectedItems).forEach(id => { Array.from(selectedItems).forEach(id => {
@ -354,7 +352,7 @@ function deleteSelected(single) {
} }
request.open('DELETE', toWebDavURL(url)); request.open('DELETE', toWebDavURL(url));
request.onreadystatechange = function() { request.onreadystatechange = function () {
if (request.readyState == 4) { if (request.readyState == 4) {
if (request.status == 204) { if (request.status == 204) {
if (single) { if (single) {
@ -428,7 +426,7 @@ function searchEvent(event) {
pieces = value.split(' '), pieces = value.split(' '),
supported = false; supported = false;
user.Commands.forEach(function(cmd) { user.Commands.forEach(function (cmd) {
if (cmd == pieces[0]) { if (cmd == pieces[0]) {
supported = true; supported = true;
} }
@ -453,16 +451,16 @@ function searchEvent(event) {
if (supported && user.AllowCommands) { if (supported && user.AllowCommands) {
let conn = new WebSocket(`ws://${url}?command=true`); let conn = new WebSocket(`ws://${url}?command=true`);
conn.onopen = function() { conn.onopen = function () {
conn.send(value); conn.send(value);
}; };
conn.onmessage = function(event) { conn.onmessage = function (event) {
box.innerHTML = event.data; box.innerHTML = event.data;
scrollable.scrollTop = scrollable.scrollHeight; scrollable.scrollTop = scrollable.scrollHeight;
} }
conn.onclose = function(event) { conn.onclose = function (event) {
search.classList.remove('ongoing'); search.classList.remove('ongoing');
reloadListing(); reloadListing();
} }
@ -475,22 +473,21 @@ function searchEvent(event) {
let ul = box.querySelector('ul'), let ul = box.querySelector('ul'),
conn = new WebSocket(`ws://${url}?search=true`); conn = new WebSocket(`ws://${url}?search=true`);
conn.onopen = function() { conn.onopen = function () {
conn.send(value); conn.send(value);
}; };
conn.onmessage = function(event) { conn.onmessage = function (event) {
ul.innerHTML += '<li><a href="' + event.data + '">' + event.data + '</a></li>'; ul.innerHTML += '<li><a href="' + event.data + '">' + event.data + '</a></li>';
scrollable.scrollTop = scrollable.scrollHeight; scrollable.scrollTop = scrollable.scrollHeight;
} }
conn.onclose = function(event) { conn.onclose = function (event) {
search.classList.remove('ongoing'); search.classList.remove('ongoing');
} }
} }
} }
function setupSearch() { function setupSearch() {
let search = document.getElementById("search"), let search = document.getElementById("search"),
searchInput = search.querySelector("input"), searchInput = search.querySelector("input"),
@ -562,12 +559,12 @@ window.addEventListener('keydown', (event) => {
}); });
/* * * * * * * * * * * * * * * * /* * * * * * * * * * * * * * * *
* * * *
* BOOTSTRAP * * BOOTSTRAP *
* * * *
* * * * * * * * * * * * * * * */ * * * * * * * * * * * * * * * */
document.addEventListener("DOMContentLoaded", function(event) { document.addEventListener("DOMContentLoaded", function (event) {
overlay = document.querySelector('.overlay'); overlay = document.querySelector('.overlay');
clickOverlay = document.querySelector('#click-overlay'); clickOverlay = document.querySelector('#click-overlay');

View File

@ -23,7 +23,7 @@ func PreProccessPUT(
) (err error) { ) (err error) {
var ( var (
data = map[string]interface{}{} data = map[string]interface{}{}
file = []byte{} file []byte
kind string kind string
rawBuffer = new(bytes.Buffer) rawBuffer = new(bytes.Buffer)
) )