Commit 874e42ad by Dányi Bence

cloud.js reindent

parent 13a3166b
var toggleDetails;
$(function(){
$(function() {
function getCookie(name) {
var cookieValue = null;
if (document.cookie && document.cookie != '') {
if(document.cookie && document.cookie != '') {
var cookies = document.cookie.split(';');
for (var i = 0; i < cookies.length; i++) {
for(var i = 0; i < cookies.length; i++) {
var cookie = jQuery.trim(cookies[i]);
if (cookie.substring(0, name.length + 1) == (name + '=')) {
if(cookie.substring(0, name.length + 1) == (name + '=')) {
cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
break;
}
......@@ -15,165 +15,204 @@ $(function(){
return cookieValue;
}
var csrftoken = getCookie('csrftoken');
function csrfSafeMethod(method) {
return (/^(GET|HEAD|OPTIONS|TRACE)$/.test(method));
return(/^(GET|HEAD|OPTIONS|TRACE)$/.test(method));
}
$.ajaxSetup({
crossDomain: false,
beforeSend: function(xhr, settings) {
if (!csrfSafeMethod(settings.type)) {
if(!csrfSafeMethod(settings.type)) {
xhr.setRequestHeader("X-CSRFToken", csrftoken);
}
}
});
toggleDetails=function(){
if($(this).next('.details').is(':hidden')){
toggleDetails = function() {
if($(this).next('.details').is(':hidden')) {
$(this).next('.details').slideDown(700);
$(this).parent('.wm').addClass('opened');
} else {
var that=this;
$(this).next('.details').slideUp(700,function(){
var that = this;
$(this).next('.details').slideUp(700, function() {
$(that).parent('.wm').removeClass('opened');
});
}
}
$('.wm .summary').unbind('click').click(toggleDetails);
$('#load-more-files').click(function(){
$('#load-more-files').click(function() {
$('.actions', this).show();
var that=this;
setTimeout(function(){
$(that).prev('li').slideDown(500,function(){
var that = this;
setTimeout(function() {
$(that).prev('li').slideDown(500, function() {
$('.actions', that).hide();
});
},2000);
}, 2000);
})
$('#new-wm-button').click(function(){
$('#new-wm-button').click(function() {
$('#modal').show();
$('#modal-container').html($('#new-wm').html());
$('#modal-container .wm .summary').each(function(){
this.originalHeight=parseInt($(this).next('.details').css('height'));
$('#modal-container .wm .summary').each(function() {
this.originalHeight = parseInt($(this).next('.details').css('height'));
})
$('#modal-container .wm .summary').click(toggleDetails);
});
$('#new-template-button').click(function(){
});
$('#new-template-button').click(function() {
$('#modal').show();
$('#modal-container').html($('#new-template').html());
});
$('#shadow').click(function(){
$('#shadow').click(function() {
$('#modal').hide();
})
$('#new-template-button').click(function(){
$.get('/ajax/templateWizard', function(data){
$('#new-template-button').click(function() {
$.get('/ajax/templateWizard', function(data) {
$('#modal-container').html(data);
})
$('#modal').show();
});
var Model=function(){
var self=this;
self.files=ko.observableArray();
self.allFiles=[];
self.notInRoot=ko.observable(false);
self.fileLimit=5;
self.jumpUp=function(){
var s=self.currentPath();
self.currentPath(s.substr(0,s.substr(0,s.length-1).lastIndexOf('/')+1));
loadFolder(self.currentPath());
function Model() {
var self = this;
self.files = ko.observableArray();
self.allFiles = [];
self.notInRoot = ko.observable(false);
self.fileLimit = 5;
var disabled = false;
function throttle(f) {
return function() {
if(disabled) {
console.log('disabled');
return
};
disabled = true;
setTimeout(function() {
disabled = false;
}, 700);
f.apply(null, arguments);
}
}
var loadFolder=function(path){
self.fileLimit=5;
self.jumpUp = function() {
var s = self.currentPath();
loadFolder(s.substr(0, s.substr(0, s.length - 1).lastIndexOf('/') + 1));
}
var loadFolder = throttle(function(path) {
self.currentPath(path);
self.fileLimit = 5;
$.ajax({
type: 'POST',
data: 'path='+path,
data: 'path=' + path,
url: '/ajax/store/list',
dataType: 'json',
success: function(data){
$('.file-list .real').css({left:0,position:'relative'}).animate({left:'-100%'},500).promise().done(function(){
success: function(data) {
$('.file-list .real').css({
left: 0,
position: 'relative'
}).animate({
left: '-100%'
}, 500).promise().done(function() {
loadFolderDone(data);
$('.file-list .real').css({left:'-300%',position:'relative'}).animate({left:0},500);
$('.file-list .real').css({
left: '-300%',
position: 'relative'
}).animate({
left: 0
}, 500);
});
},
})
}
var loadFolderDone=function(data){
})
function loadFolderDone(data) {
var viewData = [];
var added = 0;
self.notInRoot(self.currentPath().lastIndexOf('/') !== 0);
self.files([]);
self.allFiles=data;
var viewData=[];
var added=0;
for(var i in data){
self.allFiles = data;
for(var i in data) {
added++;
if(added<6)
addFile(data[i]);
if(added < 6) addFile(data[i]);
}
}
var addFile=function(d){
function addFile(d) {
var viewData;
if(d.TYPE === 'D'){
viewData={
if(d.TYPE === 'D') {
viewData = {
originalName: d.NAME,
name: d.NAME.length>30?(d.NAME.substr(0,27)+'...'):d.NAME,
name: d.NAME.length > 30 ? (d.NAME.substr(0, 27) + '...') : d.NAME,
size: 'katalógus',
type: 'katalógus',
mTime: d.MTIME,
getTypeClass: 'name filetype-folder',
clickHandler: function(item){
self.currentPath(self.currentPath()+item.originalName+'/');
loadFolder(self.currentPath());
clickHandler: function(item) {
loadFolder(self.currentPath() + item.originalName + '/');
}
};
} else {
viewData={
viewData = {
originalName: d.NAME,
name: d.NAME.length>30?(d.NAME.substr(0,27)+'...'):d.NAME,
size: d.SIZE+'K',
name: d.NAME.length > 30 ? (d.NAME.substr(0, 27) + '...') : d.NAME,
size: d.SIZE + 'K',
type: 'fájl',
mTime: d.MTIME,
getTypeClass: 'name filetype-text',
clickHandler: function(item, event){
}
clickHandler: function(item, event) {}
};
}
self.files.push(viewData);
}
self.fadeIn=function(e){
console.log(e,arguments);
self.fadeIn = function(e) {
$(e).hide().slideDown(500);
}
self.currentPath=ko.observable('/');
self.showMore=function(){
for(var i=self.fileLimit;i<self.fileLimit+5;i++){
self.currentPath = ko.observable('/');
self.showMore = function() {
for(var i = self.fileLimit; i < self.fileLimit + 5; i++) {
if(self.allFiles[i] === undefined) break;
addFile(self.allFiles[i]);
}
self.fileLimit+=5;
self.fileLimit += 5;
}
self.download=function(item){
self.download = function(item) {
$.ajax({
type: 'POST',
data: 'dl='+self.currentPath()+item.originalName,
data: 'dl=' + self.currentPath() + item.originalName,
url: '/ajax/store/download',
dataType: 'json',
success: function(data){
window.location.href=data.url;
success: function(data) {
window.location.href = data.url;
}
})
}
self.delete=function(item){
$.ajax({
self.delete = function(item) {
$.ajax({
type: 'POST',
data: 'rm='+self.currentPath()+item.originalName,
data: 'rm=' + self.currentPath() + item.originalName,
url: '/ajax/store/delete',
dataType: 'json',
success: function(data){
success: function(data) {
loadFolder(self.currentPath());
}
})
}
loadFolder(self.currentPath());
}
var model=new Model();
var model = new Model();
ko.applyBindings(model);
document.addEventListener('dragenter', function(e){console.log(e);e.stopPropagation();e.preventDefault();return false;});
document.addEventListener('dragover', function(e){console.log(e);e.stopPropagation();e.preventDefault();return false;});
document.addEventListener('drop', function(e){console.log(e);e.stopPropagation();e.preventDefault();return false;});
document.addEventListener('dragenter', function(e) {
console.log(e);
e.stopPropagation();
e.preventDefault();
return false;
});
document.addEventListener('dragover', function(e) {
console.log(e);
e.stopPropagation();
e.preventDefault();
return false;
});
document.addEventListener('drop', function(e) {
console.log(e);
e.stopPropagation();
e.preventDefault();
return false;
});
})
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment