cleanup dead code

This commit is contained in:
Jörn Friedrich Dreyer 2013-09-05 17:46:19 +02:00
parent 03ddf8da80
commit 8a7e26b268
2 changed files with 42 additions and 33 deletions

View File

@ -157,25 +157,6 @@ OC.Upload = {
}
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) {
var self = this;
var deleted = false;
@ -244,24 +225,48 @@ OC.Upload = {
});
return total;
},
onCancel:function(data){
onCancel:function(data) {
//TODO cancel all uploads of this selection
var selection = this.getSelection(data.originalFiles);
OC.Upload.deleteSelection(selection.selectionKey);
//FIXME hide progressbar
},
onContinue:function(conflicts) {
var self = this;
//iterate over all conflicts
jQuery.each(conflicts, function (i, conflict) {
conflict = $(conflict);
var keepOriginal = conflict.find('.original input[type="checkbox"]:checked').length === 1;
var keepReplacement = conflict.find('.replacement input[type="checkbox"]:checked').length === 1;
if (keepOriginal && keepReplacement) {
// when both selected -> autorename
self.onAutorename(conflict.data('data'));
} else if (keepReplacement) {
// when only replacement selected -> overwrite
self.onReplace(conflict.data('data'));
} else {
// when only original seleted -> skip
// when none selected -> skip
self.onSkip(conflict.data('data'));
}
});
},
onSkip:function(data){
var selection = this.getSelection(data.originalFiles);
selection.loadedBytes += data.loaded;
this.nextUpload();
OC.Upload.logStatus('skip', null, data);
//var selection = this.getSelection(data.originalFiles);
//selection.loadedBytes += data.loaded;
//this.nextUpload();
//TODO trigger skip? what about progress?
},
onReplace:function(data){
OC.Upload.logStatus('replace', null, data);
data.data.append('replace', true);
data.submit();
},
onRename:function(data, newName){
data.data.append('newname', newName);
onAutorename:function(data){
OC.Upload.logStatus('autorename', null, data);
data.data.append('autorename', true);
data.submit();
},
logStatus:function(caption, e, data) {
@ -446,16 +451,19 @@ $(document).ready(function() {
var result=$.parseJSON(response);
//var selection = OC.Upload.getSelection(data.originalFiles);
if(typeof result[0] !== 'undefined'
&& result[0].status === 'existserror'
) {
if(typeof result[0] === 'undefined') {
data.textStatus = 'servererror';
data.errorThrown = t('files', 'Could not get result from server.');
var fu = $(this).data('blueimp-fileupload') || $(this).data('fileupload');
fu._trigger('fail', e, data);
} else if (result[0].status === 'existserror') {
//show "file already exists" dialog
var original = result[0];
var replacement = data.files[0];
var fu = $(this).data('blueimp-fileupload') || $(this).data('fileupload');
OC.dialogs.fileexists(data, original, replacement, OC.Upload, fu);
} else {
OC.Upload.deleteSelectionUpload(selection, data.files[0].name);
} else if (result[0].status !== 'success') {
delete data.jqXHR;
data.textStatus = 'servererror';
data.errorThrown = t('files', result.data.message);
var fu = $(this).data('blueimp-fileupload') || $(this).data('fileupload');

View File

@ -224,6 +224,8 @@ var OCdialogs = {
var conflict = conflicts.find('.conflict.template').clone();
conflict.data('data',data);
conflict.find('.filename').text(original.name);
conflict.find('.original .size').text(humanFileSize(original.size));
conflict.find('.original .mtime').text(formatDate(original.mtime*1000));
@ -312,9 +314,8 @@ var OCdialogs = {
classes: 'continue',
click: function(){
self._fileexistsshown = false;
if ( typeof controller.onRename !== 'undefined') {
//TODO use autorename when repeat is checked
controller.onRename(data, $(dialog_id + ' #newname').val());
if ( typeof controller.onContinue !== 'undefined') {
controller.onContinue($(dialog_id + ' .conflict:not(.template)'));
}
$(dialog_id).ocdialog('close');
}