cleanup dead code
This commit is contained in:
parent
03ddf8da80
commit
8a7e26b268
|
@ -157,25 +157,6 @@ 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 self = this;
|
||||||
var deleted = false;
|
var deleted = false;
|
||||||
|
@ -244,24 +225,48 @@ OC.Upload = {
|
||||||
});
|
});
|
||||||
return total;
|
return total;
|
||||||
},
|
},
|
||||||
onCancel:function(data){
|
onCancel:function(data) {
|
||||||
//TODO cancel all uploads of this selection
|
//TODO cancel all uploads of this selection
|
||||||
|
|
||||||
var selection = this.getSelection(data.originalFiles);
|
var selection = this.getSelection(data.originalFiles);
|
||||||
OC.Upload.deleteSelection(selection.selectionKey);
|
OC.Upload.deleteSelection(selection.selectionKey);
|
||||||
//FIXME hide progressbar
|
//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){
|
onSkip:function(data){
|
||||||
var selection = this.getSelection(data.originalFiles);
|
OC.Upload.logStatus('skip', null, data);
|
||||||
selection.loadedBytes += data.loaded;
|
//var selection = this.getSelection(data.originalFiles);
|
||||||
this.nextUpload();
|
//selection.loadedBytes += data.loaded;
|
||||||
|
//this.nextUpload();
|
||||||
|
//TODO trigger skip? what about progress?
|
||||||
},
|
},
|
||||||
onReplace:function(data){
|
onReplace:function(data){
|
||||||
|
OC.Upload.logStatus('replace', null, data);
|
||||||
data.data.append('replace', true);
|
data.data.append('replace', true);
|
||||||
data.submit();
|
data.submit();
|
||||||
},
|
},
|
||||||
onRename:function(data, newName){
|
onAutorename:function(data){
|
||||||
data.data.append('newname', newName);
|
OC.Upload.logStatus('autorename', null, data);
|
||||||
|
data.data.append('autorename', true);
|
||||||
data.submit();
|
data.submit();
|
||||||
},
|
},
|
||||||
logStatus:function(caption, e, data) {
|
logStatus:function(caption, e, data) {
|
||||||
|
@ -446,16 +451,19 @@ $(document).ready(function() {
|
||||||
var result=$.parseJSON(response);
|
var result=$.parseJSON(response);
|
||||||
//var selection = OC.Upload.getSelection(data.originalFiles);
|
//var selection = OC.Upload.getSelection(data.originalFiles);
|
||||||
|
|
||||||
if(typeof result[0] !== 'undefined'
|
if(typeof result[0] === 'undefined') {
|
||||||
&& result[0].status === 'existserror'
|
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
|
//show "file already exists" dialog
|
||||||
var original = result[0];
|
var original = result[0];
|
||||||
var replacement = data.files[0];
|
var replacement = data.files[0];
|
||||||
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 if (result[0].status !== 'success') {
|
||||||
OC.Upload.deleteSelectionUpload(selection, data.files[0].name);
|
delete data.jqXHR;
|
||||||
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');
|
||||||
|
|
|
@ -224,6 +224,8 @@ var OCdialogs = {
|
||||||
|
|
||||||
var conflict = conflicts.find('.conflict.template').clone();
|
var conflict = conflicts.find('.conflict.template').clone();
|
||||||
|
|
||||||
|
conflict.data('data',data);
|
||||||
|
|
||||||
conflict.find('.filename').text(original.name);
|
conflict.find('.filename').text(original.name);
|
||||||
conflict.find('.original .size').text(humanFileSize(original.size));
|
conflict.find('.original .size').text(humanFileSize(original.size));
|
||||||
conflict.find('.original .mtime').text(formatDate(original.mtime*1000));
|
conflict.find('.original .mtime').text(formatDate(original.mtime*1000));
|
||||||
|
@ -312,9 +314,8 @@ var OCdialogs = {
|
||||||
classes: 'continue',
|
classes: 'continue',
|
||||||
click: function(){
|
click: function(){
|
||||||
self._fileexistsshown = false;
|
self._fileexistsshown = false;
|
||||||
if ( typeof controller.onRename !== 'undefined') {
|
if ( typeof controller.onContinue !== 'undefined') {
|
||||||
//TODO use autorename when repeat is checked
|
controller.onContinue($(dialog_id + ' .conflict:not(.template)'));
|
||||||
controller.onRename(data, $(dialog_id + ' #newname').val());
|
|
||||||
}
|
}
|
||||||
$(dialog_id).ocdialog('close');
|
$(dialog_id).ocdialog('close');
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue