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

View File

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