architecture too complex
This commit is contained in:
parent
f94e603698
commit
bf04daff82
2
3rdparty
2
3rdparty
|
@ -1 +1 @@
|
||||||
Subproject commit 2f3ae9f56a9838b45254393e13c14f8a8c380d6b
|
Subproject commit 75a05d76ab86ba7454b4312fd0ff2ca5bd5828cf
|
|
@ -1,4 +1,7 @@
|
||||||
/**
|
/**
|
||||||
|
*
|
||||||
|
* use put t ocacnel upload before it starts? use chunked uploads?
|
||||||
|
*
|
||||||
* 1. tracking which file to upload next -> upload queue with data elements added whenever add is called
|
* 1. tracking which file to upload next -> upload queue with data elements added whenever add is called
|
||||||
* 2. tracking progress for each folder individually -> track progress in a progress[dirname] object
|
* 2. tracking progress for each folder individually -> track progress in a progress[dirname] object
|
||||||
* - every new selection increases the total size and number of files for a directory
|
* - every new selection increases the total size and number of files for a directory
|
||||||
|
@ -63,6 +66,7 @@ OC.Upload = {
|
||||||
* @type Array
|
* @type Array
|
||||||
*/
|
*/
|
||||||
_selections: {},
|
_selections: {},
|
||||||
|
_selectionCount: 0,
|
||||||
/*
|
/*
|
||||||
* queue which progress tracker to use for the next upload
|
* queue which progress tracker to use for the next upload
|
||||||
* @type Array
|
* @type Array
|
||||||
|
@ -77,7 +81,7 @@ OC.Upload = {
|
||||||
},
|
},
|
||||||
getSelection:function(originalFiles) {
|
getSelection:function(originalFiles) {
|
||||||
if (!originalFiles.selectionKey) {
|
if (!originalFiles.selectionKey) {
|
||||||
originalFiles.selectionKey = 'selection-' + $.assocArraySize(this._selections);
|
originalFiles.selectionKey = 'selection-' + this._selectionCount++;
|
||||||
this._selections[originalFiles.selectionKey] = {
|
this._selections[originalFiles.selectionKey] = {
|
||||||
selectionKey:originalFiles.selectionKey,
|
selectionKey:originalFiles.selectionKey,
|
||||||
files:{},
|
files:{},
|
||||||
|
@ -90,22 +94,41 @@ OC.Upload = {
|
||||||
}
|
}
|
||||||
return this._selections[originalFiles.selectionKey];
|
return this._selections[originalFiles.selectionKey];
|
||||||
},
|
},
|
||||||
|
deleteSelection:function(selectionKey) {
|
||||||
|
if (this._selections[selectionKey]) {
|
||||||
|
jQuery.each(this._selections[selectionKey].uploads, function(i, upload) {
|
||||||
|
upload.abort();
|
||||||
|
});
|
||||||
|
delete this._selections[selectionKey];
|
||||||
|
} else {
|
||||||
|
console.log('OC.Upload: selection ' + selectionKey + ' does not exist');
|
||||||
|
}
|
||||||
|
},
|
||||||
|
deleteSelectionUpload:function(selection, filename) {
|
||||||
|
if(selection.uploads[filename]) {
|
||||||
|
selection.uploads[filename].abort();
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
console.log('OC.Upload: selection ' + selection.selectionKey + ' does not contain upload for ' + filename);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
},
|
||||||
cancelUpload:function(dir, filename) {
|
cancelUpload:function(dir, filename) {
|
||||||
|
var self = this;
|
||||||
var deleted = false;
|
var deleted = false;
|
||||||
jQuery.each(this._selections, function(i, selection) {
|
jQuery.each(this._selections, function(i, selection) {
|
||||||
if (selection.dir === dir && selection.uploads[filename]) {
|
if (selection.dir === dir && selection.uploads[filename]) {
|
||||||
delete selection.uploads[filename];
|
deleted = self.deleteSelectionUpload(selection, filename);
|
||||||
deleted = true;
|
|
||||||
return false; // end searching through selections
|
return false; // end searching through selections
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return deleted;
|
return deleted;
|
||||||
},
|
},
|
||||||
cancelUploads:function() {
|
cancelUploads:function() {
|
||||||
jQuery.each(this._selections,function(i,selection){
|
console.log('canceling uploads');
|
||||||
jQuery.each(selection.uploads, function (j, jqXHR) {
|
var self = this;
|
||||||
delete jqXHR;
|
jQuery.each(this._selections,function(i, selection){
|
||||||
});
|
self.deleteSelection(selection.selectionKey);
|
||||||
});
|
});
|
||||||
this._queue = [];
|
this._queue = [];
|
||||||
this._isProcessing = false;
|
this._isProcessing = false;
|
||||||
|
@ -132,7 +155,7 @@ OC.Upload = {
|
||||||
} else {
|
} else {
|
||||||
//queue is empty, we are done
|
//queue is empty, we are done
|
||||||
this._isProcessing = false;
|
this._isProcessing = false;
|
||||||
//TODO free data
|
OC.Upload.cancelUploads();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
progressBytes: function() {
|
progressBytes: function() {
|
||||||
|
@ -157,13 +180,13 @@ OC.Upload = {
|
||||||
total += selection.totalBytes;
|
total += selection.totalBytes;
|
||||||
});
|
});
|
||||||
return total;
|
return total;
|
||||||
},
|
|
||||||
handleExists:function(data) {
|
|
||||||
|
|
||||||
},
|
},
|
||||||
onCancel:function(data){
|
onCancel:function(data){
|
||||||
//TODO cancel all uploads
|
//TODO cancel all uploads of this selection
|
||||||
OC.Upload.cancelUploads();
|
|
||||||
|
var selection = this.getSelection(data.originalFiles);
|
||||||
|
OC.Upload.deleteSelection(selection.selectionKey);
|
||||||
|
//FIXME hide progressbar
|
||||||
},
|
},
|
||||||
onSkip:function(data){
|
onSkip:function(data){
|
||||||
var selection = this.getSelection(data.originalFiles);
|
var selection = this.getSelection(data.originalFiles);
|
||||||
|
@ -171,20 +194,19 @@ OC.Upload = {
|
||||||
this.nextUpload();
|
this.nextUpload();
|
||||||
},
|
},
|
||||||
onReplace:function(data){
|
onReplace:function(data){
|
||||||
//TODO overwrite file
|
|
||||||
data.data.append('replace', true);
|
data.data.append('replace', true);
|
||||||
data.submit();
|
data.submit();
|
||||||
},
|
},
|
||||||
onRename:function(data, newName){
|
onRename:function(data, newName){
|
||||||
//TODO rename file in filelist, stop spinner
|
|
||||||
data.data.append('newname', newName);
|
data.data.append('newname', newName);
|
||||||
data.submit();
|
data.submit();
|
||||||
},
|
},
|
||||||
setAction:function(data, action) {
|
logStatus:function(caption, e, data) {
|
||||||
|
console.log(caption+' ' +OC.Upload.loadedBytes()+' / '+OC.Upload.totalBytes());
|
||||||
},
|
if (data) {
|
||||||
setDefaultAction:function(action) {
|
console.log(data);
|
||||||
|
}
|
||||||
|
console.log(e);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -195,6 +217,7 @@ $(document).ready(function() {
|
||||||
|
|
||||||
//singleFileUploads is on by default, so the data.files array will always have length 1
|
//singleFileUploads is on by default, so the data.files array will always have length 1
|
||||||
add: function(e, data) {
|
add: function(e, data) {
|
||||||
|
OC.Upload.logStatus('add', e, data);
|
||||||
var that = $(this);
|
var that = $(this);
|
||||||
|
|
||||||
// lookup selection for dir
|
// lookup selection for dir
|
||||||
|
@ -267,14 +290,17 @@ $(document).ready(function() {
|
||||||
* @param e
|
* @param e
|
||||||
*/
|
*/
|
||||||
start: function(e) {
|
start: function(e) {
|
||||||
|
OC.Upload.logStatus('start', e, null);
|
||||||
//IE < 10 does not fire the necessary events for the progress bar.
|
//IE < 10 does not fire the necessary events for the progress bar.
|
||||||
if($('html.lte9').length > 0) {
|
if($('html.lte9').length > 0) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
$('#uploadprogresswrapper input.stop').show();
|
||||||
$('#uploadprogressbar').progressbar({value:0});
|
$('#uploadprogressbar').progressbar({value:0});
|
||||||
$('#uploadprogressbar').fadeIn();
|
$('#uploadprogressbar').fadeIn();
|
||||||
},
|
},
|
||||||
fail: function(e, data) {
|
fail: function(e, data) {
|
||||||
|
OC.Upload.logStatus('fail', e, data);
|
||||||
if (typeof data.textStatus !== 'undefined' && data.textStatus !== 'success' ) {
|
if (typeof data.textStatus !== 'undefined' && data.textStatus !== 'success' ) {
|
||||||
if (data.textStatus === 'abort') {
|
if (data.textStatus === 'abort') {
|
||||||
$('#notification').text(t('files', 'Upload cancelled.'));
|
$('#notification').text(t('files', 'Upload cancelled.'));
|
||||||
|
@ -289,12 +315,26 @@ $(document).ready(function() {
|
||||||
}, 5000);
|
}, 5000);
|
||||||
}
|
}
|
||||||
var selection = OC.Upload.getSelection(data.originalFiles);
|
var selection = OC.Upload.getSelection(data.originalFiles);
|
||||||
delete selection.uploads[data.files[0]];
|
OC.Upload.deleteSelectionUpload(selection, data.files[0].name);
|
||||||
|
|
||||||
|
//if user pressed cancel hide upload progress bar and cancel button
|
||||||
|
if (data.errorThrown === 'abort') {
|
||||||
|
$('#uploadprogresswrapper input.stop').fadeOut();
|
||||||
|
$('#uploadprogressbar').fadeOut();
|
||||||
|
}
|
||||||
},
|
},
|
||||||
progress: function(e, data) {
|
progress: function(e, data) {
|
||||||
|
OC.Upload.logStatus('progress', e, data);
|
||||||
// TODO: show nice progress bar in file row
|
// TODO: show nice progress bar in file row
|
||||||
},
|
},
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param {type} e
|
||||||
|
* @param {type} data (only has loaded, total and lengthComputable)
|
||||||
|
* @returns {unresolved}
|
||||||
|
*/
|
||||||
progressall: function(e, data) {
|
progressall: function(e, data) {
|
||||||
|
OC.Upload.logStatus('progressall', e, data);
|
||||||
//IE < 10 does not fire the necessary events for the progress bar.
|
//IE < 10 does not fire the necessary events for the progress bar.
|
||||||
if($('html.lte9').length > 0) {
|
if($('html.lte9').length > 0) {
|
||||||
return;
|
return;
|
||||||
|
@ -309,6 +349,7 @@ $(document).ready(function() {
|
||||||
* @param data
|
* @param data
|
||||||
*/
|
*/
|
||||||
done:function(e, data) {
|
done:function(e, data) {
|
||||||
|
OC.Upload.logStatus('done', e, data);
|
||||||
// handle different responses (json or body from iframe for ie)
|
// handle different responses (json or body from iframe for ie)
|
||||||
var response;
|
var response;
|
||||||
if (typeof data.result === 'string') {
|
if (typeof data.result === 'string') {
|
||||||
|
@ -323,7 +364,9 @@ $(document).ready(function() {
|
||||||
if(typeof result[0] !== 'undefined'
|
if(typeof result[0] !== 'undefined'
|
||||||
&& result[0].status === 'success'
|
&& result[0].status === 'success'
|
||||||
) {
|
) {
|
||||||
|
if (selection) {
|
||||||
selection.loadedBytes+=data.loaded;
|
selection.loadedBytes+=data.loaded;
|
||||||
|
}
|
||||||
OC.Upload.nextUpload();
|
OC.Upload.nextUpload();
|
||||||
} else {
|
} else {
|
||||||
if (result[0].status === 'existserror') {
|
if (result[0].status === 'existserror') {
|
||||||
|
@ -333,7 +376,7 @@ $(document).ready(function() {
|
||||||
var fu = $(this).data('blueimp-fileupload') || $(this).data('fileupload');
|
var fu = $(this).data('blueimp-fileupload') || $(this).data('fileupload');
|
||||||
OC.dialogs.fileexists(data, original, replacement, OC.Upload, fu);
|
OC.dialogs.fileexists(data, original, replacement, OC.Upload, fu);
|
||||||
} else {
|
} else {
|
||||||
delete selection.uploads[data.files[0]];
|
OC.Upload.deleteSelectionUpload(selection, data.files[0].name);
|
||||||
data.textStatus = 'servererror';
|
data.textStatus = 'servererror';
|
||||||
data.errorThrown = t('files', result.data.message);
|
data.errorThrown = t('files', result.data.message);
|
||||||
var fu = $(this).data('blueimp-fileupload') || $(this).data('fileupload');
|
var fu = $(this).data('blueimp-fileupload') || $(this).data('fileupload');
|
||||||
|
@ -341,6 +384,12 @@ $(document).ready(function() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//if user pressed cancel hide upload chrome
|
||||||
|
if (! OC.Upload.isProcessing()) {
|
||||||
|
$('#uploadprogresswrapper input.stop').fadeOut();
|
||||||
|
$('#uploadprogressbar').fadeOut();
|
||||||
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* called after last upload
|
* called after last upload
|
||||||
|
@ -348,7 +397,10 @@ $(document).ready(function() {
|
||||||
* @param data
|
* @param data
|
||||||
*/
|
*/
|
||||||
stop: function(e, data) {
|
stop: function(e, data) {
|
||||||
if(OC.Upload.progressBytes()>=100) {
|
OC.Upload.logStatus('stop', e, data);
|
||||||
|
if(OC.Upload.progressBytes()>=100) { //only hide controls when all selections have ended uploading
|
||||||
|
|
||||||
|
OC.Upload.cancelUploads(); //cleanup
|
||||||
|
|
||||||
if(data.dataType !== 'iframe') {
|
if(data.dataType !== 'iframe') {
|
||||||
$('#uploadprogresswrapper input.stop').hide();
|
$('#uploadprogresswrapper input.stop').hide();
|
||||||
|
@ -362,6 +414,11 @@ $(document).ready(function() {
|
||||||
$('#uploadprogressbar').progressbar('value', 100);
|
$('#uploadprogressbar').progressbar('value', 100);
|
||||||
$('#uploadprogressbar').fadeOut();
|
$('#uploadprogressbar').fadeOut();
|
||||||
}
|
}
|
||||||
|
//if user pressed cancel hide upload chrome
|
||||||
|
if (! OC.Upload.isProcessing()) {
|
||||||
|
$('#uploadprogresswrapper input.stop').fadeOut();
|
||||||
|
$('#uploadprogressbar').fadeOut();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -384,8 +441,8 @@ $(document).ready(function() {
|
||||||
};
|
};
|
||||||
|
|
||||||
// warn user not to leave the page while upload is in progress
|
// warn user not to leave the page while upload is in progress
|
||||||
$(window).bind('beforeunload', function(e) {
|
$(window).on('beforeunload', function(e) {
|
||||||
if ($.assocArraySize(uploadingFiles) > 0) {
|
if (OC.Upload.isProcessing()) {
|
||||||
return t('files', 'File upload is in progress. Leaving the page now will cancel the upload.');
|
return t('files', 'File upload is in progress. Leaving the page now will cancel the upload.');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -409,7 +409,7 @@ $(document).ready(function(){
|
||||||
var file_upload_start = $('#file_upload_start');
|
var file_upload_start = $('#file_upload_start');
|
||||||
|
|
||||||
file_upload_start.on('fileuploaddrop', function(e, data) {
|
file_upload_start.on('fileuploaddrop', function(e, data) {
|
||||||
console.log('fileuploaddrop ' +OC.Upload.loadedBytes()+' / '+OC.Upload.totalBytes());
|
OC.Upload.logStatus('fileuploaddrop', e, data);
|
||||||
|
|
||||||
var dropTarget = $(e.originalEvent.target).closest('tr');
|
var dropTarget = $(e.originalEvent.target).closest('tr');
|
||||||
if(dropTarget && dropTarget.data('type') === 'dir') { // drag&drop upload to folder
|
if(dropTarget && dropTarget.data('type') === 'dir') { // drag&drop upload to folder
|
||||||
|
@ -448,7 +448,7 @@ $(document).ready(function(){
|
||||||
|
|
||||||
});
|
});
|
||||||
file_upload_start.on('fileuploadadd', function(e, data) {
|
file_upload_start.on('fileuploadadd', function(e, data) {
|
||||||
console.log('fileuploadadd ' +OC.Upload.loadedBytes()+' / '+OC.Upload.totalBytes());
|
OC.Upload.logStatus('fileuploadadd', e, data);
|
||||||
|
|
||||||
// lookup selection for dir
|
// lookup selection for dir
|
||||||
var selection = OC.Upload.getSelection(data.originalFiles);
|
var selection = OC.Upload.getSelection(data.originalFiles);
|
||||||
|
@ -482,8 +482,11 @@ $(document).ready(function(){
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
file_upload_start.on('fileuploadstart', function(e, data) {
|
||||||
|
OC.Upload.logStatus('fileuploadstart', e, data);
|
||||||
|
});
|
||||||
file_upload_start.on('fileuploaddone', function(e, data) {
|
file_upload_start.on('fileuploaddone', function(e, data) {
|
||||||
console.log('fileuploaddone ' +OC.Upload.loadedBytes()+' / '+OC.Upload.totalBytes());
|
OC.Upload.logStatus('fileuploaddone', e, data);
|
||||||
|
|
||||||
var response;
|
var response;
|
||||||
if (typeof data.result === 'string') {
|
if (typeof data.result === 'string') {
|
||||||
|
@ -545,28 +548,58 @@ $(document).ready(function(){
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//if user pressed cancel hide upload chrome
|
||||||
|
if (! OC.Upload.isProcessing()) {
|
||||||
|
//cleanup uploading to a dir
|
||||||
|
var uploadtext = $('tr .uploadtext');
|
||||||
|
var img = OC.imagePath('core', 'filetypes/folder.png');
|
||||||
|
uploadtext.parents('td.filename').attr('style','background-image:url('+img+')');
|
||||||
|
uploadtext.fadeOut();
|
||||||
|
uploadtext.attr('currentUploads', 0);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
file_upload_start.on('fileuploadalways', function(e, data) {
|
file_upload_start.on('fileuploadalways', function(e, data) {
|
||||||
console.log('fileuploadalways ' +OC.Upload.loadedBytes()+' / '+OC.Upload.totalBytes());
|
OC.Upload.logStatus('fileuploadalways', e, data);
|
||||||
});
|
});
|
||||||
file_upload_start.on('fileuploadsend', function(e, data) {
|
file_upload_start.on('fileuploadsend', function(e, data) {
|
||||||
console.log('fileuploadsend ' +OC.Upload.loadedBytes()+' / '+OC.Upload.totalBytes());
|
OC.Upload.logStatus('fileuploadsend', e, data);
|
||||||
|
|
||||||
// TODOD add vis
|
// TODOD add vis
|
||||||
//data.context.element =
|
//data.context.element =
|
||||||
});
|
});
|
||||||
file_upload_start.on('fileuploadprogress', function(e, data) {
|
file_upload_start.on('fileuploadprogress', function(e, data) {
|
||||||
console.log('fileuploadprogress ' +OC.Upload.loadedBytes()+' / '+OC.Upload.totalBytes());
|
OC.Upload.logStatus('fileuploadprogress', e, data);
|
||||||
});
|
});
|
||||||
file_upload_start.on('fileuploadprogressall', function(e, data) {
|
file_upload_start.on('fileuploadprogressall', function(e, data) {
|
||||||
console.log('fileuploadprogressall ' +OC.Upload.loadedBytes()+' / '+OC.Upload.totalBytes());
|
OC.Upload.logStatus('fileuploadprogressall', e, data);
|
||||||
});
|
});
|
||||||
file_upload_start.on('fileuploadstop', function(e, data) {
|
file_upload_start.on('fileuploadstop', function(e, data) {
|
||||||
console.log('fileuploadstop ' +OC.Upload.loadedBytes()+' / '+OC.Upload.totalBytes());
|
OC.Upload.logStatus('fileuploadstop', e, data);
|
||||||
|
|
||||||
|
//if user pressed cancel hide upload chrome
|
||||||
|
if (! OC.Upload.isProcessing()) {
|
||||||
|
//cleanup uploading to a dir
|
||||||
|
var uploadtext = $('tr .uploadtext');
|
||||||
|
var img = OC.imagePath('core', 'filetypes/folder.png');
|
||||||
|
uploadtext.parents('td.filename').attr('style','background-image:url('+img+')');
|
||||||
|
uploadtext.fadeOut();
|
||||||
|
uploadtext.attr('currentUploads', 0);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
file_upload_start.on('fileuploadfail', function(e, data) {
|
file_upload_start.on('fileuploadfail', function(e, data) {
|
||||||
console.log('fileuploadfail ' +OC.Upload.loadedBytes()+' / '+OC.Upload.totalBytes());
|
OC.Upload.logStatus('fileuploadfail', e, data);
|
||||||
|
|
||||||
|
//if user pressed cancel hide upload chrome
|
||||||
|
if (data.errorThrown === 'abort') {
|
||||||
|
//cleanup uploading to a dir
|
||||||
|
var uploadtext = $('tr .uploadtext');
|
||||||
|
var img = OC.imagePath('core', 'filetypes/folder.png');
|
||||||
|
uploadtext.parents('td.filename').attr('style','background-image:url('+img+')');
|
||||||
|
uploadtext.fadeOut();
|
||||||
|
uploadtext.attr('currentUploads', 0);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
/*
|
/*
|
||||||
file_upload_start.on('fileuploadfail', function(e, data) {
|
file_upload_start.on('fileuploadfail', function(e, data) {
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
var uploadingFiles = {};
|
|
||||||
Files={
|
Files={
|
||||||
updateMaxUploadFilesize:function(response) {
|
updateMaxUploadFilesize:function(response) {
|
||||||
if(response == undefined) {
|
if(response == undefined) {
|
||||||
|
@ -235,12 +234,6 @@ $(document).ready(function() {
|
||||||
return size;
|
return size;
|
||||||
};
|
};
|
||||||
|
|
||||||
// warn user not to leave the page while upload is in progress
|
|
||||||
$(window).bind('beforeunload', function(e) {
|
|
||||||
if ($.assocArraySize(uploadingFiles) > 0)
|
|
||||||
return t('files','File upload is in progress. Leaving the page now will cancel the upload.');
|
|
||||||
});
|
|
||||||
|
|
||||||
//add multiply file upload attribute to all browsers except konqueror (which crashes when it's used)
|
//add multiply file upload attribute to all browsers except konqueror (which crashes when it's used)
|
||||||
if(navigator.userAgent.search(/konqueror/i)==-1){
|
if(navigator.userAgent.search(/konqueror/i)==-1){
|
||||||
$('#file_upload_start').attr('multiple','multiple')
|
$('#file_upload_start').attr('multiple','multiple')
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* jQuery Iframe Transport Plugin 1.3
|
* jQuery Iframe Transport Plugin 1.7
|
||||||
* https://github.com/blueimp/jQuery-File-Upload
|
* https://github.com/blueimp/jQuery-File-Upload
|
||||||
*
|
*
|
||||||
* Copyright 2011, Sebastian Tschan
|
* Copyright 2011, Sebastian Tschan
|
||||||
|
@ -30,27 +30,45 @@
|
||||||
// The iframe transport accepts three additional options:
|
// The iframe transport accepts three additional options:
|
||||||
// options.fileInput: a jQuery collection of file input fields
|
// options.fileInput: a jQuery collection of file input fields
|
||||||
// options.paramName: the parameter name for the file form data,
|
// options.paramName: the parameter name for the file form data,
|
||||||
// overrides the name property of the file input field(s)
|
// overrides the name property of the file input field(s),
|
||||||
|
// can be a string or an array of strings.
|
||||||
// options.formData: an array of objects with name and value properties,
|
// options.formData: an array of objects with name and value properties,
|
||||||
// equivalent to the return data of .serializeArray(), e.g.:
|
// equivalent to the return data of .serializeArray(), e.g.:
|
||||||
// [{name: 'a', value: 1}, {name: 'b', value: 2}]
|
// [{name: 'a', value: 1}, {name: 'b', value: 2}]
|
||||||
$.ajaxTransport('iframe', function (options) {
|
$.ajaxTransport('iframe', function (options) {
|
||||||
if (options.async && (options.type === 'POST' || options.type === 'GET')) {
|
if (options.async) {
|
||||||
var form,
|
var form,
|
||||||
iframe;
|
iframe,
|
||||||
|
addParamChar;
|
||||||
return {
|
return {
|
||||||
send: function (_, completeCallback) {
|
send: function (_, completeCallback) {
|
||||||
form = $('<form style="display:none;"></form>');
|
form = $('<form style="display:none;"></form>');
|
||||||
|
form.attr('accept-charset', options.formAcceptCharset);
|
||||||
|
addParamChar = /\?/.test(options.url) ? '&' : '?';
|
||||||
|
// XDomainRequest only supports GET and POST:
|
||||||
|
if (options.type === 'DELETE') {
|
||||||
|
options.url = options.url + addParamChar + '_method=DELETE';
|
||||||
|
options.type = 'POST';
|
||||||
|
} else if (options.type === 'PUT') {
|
||||||
|
options.url = options.url + addParamChar + '_method=PUT';
|
||||||
|
options.type = 'POST';
|
||||||
|
} else if (options.type === 'PATCH') {
|
||||||
|
options.url = options.url + addParamChar + '_method=PATCH';
|
||||||
|
options.type = 'POST';
|
||||||
|
}
|
||||||
// javascript:false as initial iframe src
|
// javascript:false as initial iframe src
|
||||||
// prevents warning popups on HTTPS in IE6.
|
// prevents warning popups on HTTPS in IE6.
|
||||||
// IE versions below IE8 cannot set the name property of
|
// IE versions below IE8 cannot set the name property of
|
||||||
// elements that have already been added to the DOM,
|
// elements that have already been added to the DOM,
|
||||||
// so we set the name along with the iframe HTML markup:
|
// so we set the name along with the iframe HTML markup:
|
||||||
|
counter += 1;
|
||||||
iframe = $(
|
iframe = $(
|
||||||
'<iframe src="javascript:false;" name="iframe-transport-' +
|
'<iframe src="javascript:false;" name="iframe-transport-' +
|
||||||
(counter += 1) + '"></iframe>'
|
counter + '"></iframe>'
|
||||||
).bind('load', function () {
|
).bind('load', function () {
|
||||||
var fileInputClones;
|
var fileInputClones,
|
||||||
|
paramNames = $.isArray(options.paramName) ?
|
||||||
|
options.paramName : [options.paramName];
|
||||||
iframe
|
iframe
|
||||||
.unbind('load')
|
.unbind('load')
|
||||||
.bind('load', function () {
|
.bind('load', function () {
|
||||||
|
@ -79,7 +97,12 @@
|
||||||
// (happens on form submits to iframe targets):
|
// (happens on form submits to iframe targets):
|
||||||
$('<iframe src="javascript:false;"></iframe>')
|
$('<iframe src="javascript:false;"></iframe>')
|
||||||
.appendTo(form);
|
.appendTo(form);
|
||||||
|
window.setTimeout(function () {
|
||||||
|
// Removing the form in a setTimeout call
|
||||||
|
// allows Chrome's developer tools to display
|
||||||
|
// the response result
|
||||||
form.remove();
|
form.remove();
|
||||||
|
}, 0);
|
||||||
});
|
});
|
||||||
form
|
form
|
||||||
.prop('target', iframe.prop('name'))
|
.prop('target', iframe.prop('name'))
|
||||||
|
@ -101,8 +124,11 @@
|
||||||
return fileInputClones[index];
|
return fileInputClones[index];
|
||||||
});
|
});
|
||||||
if (options.paramName) {
|
if (options.paramName) {
|
||||||
options.fileInput.each(function () {
|
options.fileInput.each(function (index) {
|
||||||
$(this).prop('name', options.paramName);
|
$(this).prop(
|
||||||
|
'name',
|
||||||
|
paramNames[index] || options.paramName
|
||||||
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
// Appending the file input fields to the hidden form
|
// Appending the file input fields to the hidden form
|
||||||
|
@ -144,20 +170,34 @@
|
||||||
});
|
});
|
||||||
|
|
||||||
// The iframe transport returns the iframe content document as response.
|
// The iframe transport returns the iframe content document as response.
|
||||||
// The following adds converters from iframe to text, json, html, and script:
|
// The following adds converters from iframe to text, json, html, xml
|
||||||
|
// and script.
|
||||||
|
// Please note that the Content-Type for JSON responses has to be text/plain
|
||||||
|
// or text/html, if the browser doesn't include application/json in the
|
||||||
|
// Accept header, else IE will show a download dialog.
|
||||||
|
// The Content-Type for XML responses on the other hand has to be always
|
||||||
|
// application/xml or text/xml, so IE properly parses the XML response.
|
||||||
|
// See also
|
||||||
|
// https://github.com/blueimp/jQuery-File-Upload/wiki/Setup#content-type-negotiation
|
||||||
$.ajaxSetup({
|
$.ajaxSetup({
|
||||||
converters: {
|
converters: {
|
||||||
'iframe text': function (iframe) {
|
'iframe text': function (iframe) {
|
||||||
return $(iframe[0].body).text();
|
return iframe && $(iframe[0].body).text();
|
||||||
},
|
},
|
||||||
'iframe json': function (iframe) {
|
'iframe json': function (iframe) {
|
||||||
return $.parseJSON($(iframe[0].body).text());
|
return iframe && $.parseJSON($(iframe[0].body).text());
|
||||||
},
|
},
|
||||||
'iframe html': function (iframe) {
|
'iframe html': function (iframe) {
|
||||||
return $(iframe[0].body).html();
|
return iframe && $(iframe[0].body).html();
|
||||||
|
},
|
||||||
|
'iframe xml': function (iframe) {
|
||||||
|
var xmlDoc = iframe && iframe[0];
|
||||||
|
return xmlDoc && $.isXMLDoc(xmlDoc) ? xmlDoc :
|
||||||
|
$.parseXML((xmlDoc.XMLDocument && xmlDoc.XMLDocument.xml) ||
|
||||||
|
$(xmlDoc.body).html());
|
||||||
},
|
},
|
||||||
'iframe script': function (iframe) {
|
'iframe script': function (iframe) {
|
||||||
return $.globalEval($(iframe[0].body).text());
|
return iframe && $.globalEval($(iframe[0].body).text());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
<input type="hidden" id="disableSharing" data-status="<?php p($_['disableSharing']); ?>">
|
<input type="hidden" id="disableSharing" data-status="<?php p($_['disableSharing']); ?>">
|
||||||
<?php $totalfiles = 0;
|
<?php $totalfiles = 0;
|
||||||
$totaldirs = 0;
|
$totaldirs = 0;
|
||||||
$totalsize = 0; ?>
|
$totalsize = 0;
|
||||||
|
$pc = 0; ?>
|
||||||
<?php foreach($_['files'] as $file):
|
<?php foreach($_['files'] as $file):
|
||||||
$totalsize += $file['size'];
|
$totalsize += $file['size'];
|
||||||
if ($file['type'] === 'dir') {
|
if ($file['type'] === 'dir') {
|
||||||
|
@ -17,7 +18,9 @@ $totalsize = 0; ?>
|
||||||
$relative_date_color = round((time()-$file['mtime'])/60/60/24*14);
|
$relative_date_color = round((time()-$file['mtime'])/60/60/24*14);
|
||||||
if($relative_date_color>160) $relative_date_color = 160;
|
if($relative_date_color>160) $relative_date_color = 160;
|
||||||
$name = \OCP\Util::encodePath($file['name']);
|
$name = \OCP\Util::encodePath($file['name']);
|
||||||
$directory = \OCP\Util::encodePath($file['directory']); ?>
|
$directory = \OCP\Util::encodePath($file['directory']);
|
||||||
|
?>
|
||||||
|
<!--<tr style="position:absolute; width:100%"><td colspan="3" style="display:block;"><div style="width: <?php echo $pc++; ?>%; height: 31px;background-color: green;"/></td></tr>-->
|
||||||
<tr data-id="<?php p($file['fileid']); ?>"
|
<tr data-id="<?php p($file['fileid']); ?>"
|
||||||
data-file="<?php p($name);?>"
|
data-file="<?php p($name);?>"
|
||||||
data-type="<?php ($file['type'] == 'dir')?p('dir'):p('file')?>"
|
data-type="<?php ($file['type'] == 'dir')?p('dir'):p('file')?>"
|
||||||
|
@ -52,12 +55,14 @@ $totalsize = 0; ?>
|
||||||
</td>
|
</td>
|
||||||
<td class="filesize"
|
<td class="filesize"
|
||||||
style="color:rgb(<?php p($simple_size_color.','.$simple_size_color.','.$simple_size_color) ?>)">
|
style="color:rgb(<?php p($simple_size_color.','.$simple_size_color.','.$simple_size_color) ?>)">
|
||||||
|
<span style="position:relative;">
|
||||||
<?php print_unescaped(OCP\human_file_size($file['size'])); ?>
|
<?php print_unescaped(OCP\human_file_size($file['size'])); ?>
|
||||||
|
</span>
|
||||||
</td>
|
</td>
|
||||||
<td class="date">
|
<td class="date">
|
||||||
<span class="modified"
|
<span class="modified"
|
||||||
title="<?php p($file['date']); ?>"
|
title="<?php p($file['date']); ?>"
|
||||||
style="color:rgb(<?php p($relative_date_color.','
|
style="position:relative; color:rgb(<?php p($relative_date_color.','
|
||||||
.$relative_date_color.','
|
.$relative_date_color.','
|
||||||
.$relative_date_color) ?>)">
|
.$relative_date_color) ?>)">
|
||||||
<?php p($relative_modified_date); ?>
|
<?php p($relative_modified_date); ?>
|
||||||
|
|
Loading…
Reference in New Issue