mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-06 18:21:39 +09:00
Clean up error handling code in the auto upload plugin
This commit is contained in:
parent
5b530792e5
commit
633478710d
1 changed files with 18 additions and 7 deletions
|
|
@ -1,7 +1,10 @@
|
|||
'use strict';
|
||||
|
||||
/**
|
||||
* Upload plugin for Rhymix
|
||||
*/
|
||||
CKEDITOR.plugins.add('rx_upload', {
|
||||
|
||||
init: function(editor) {
|
||||
|
||||
/**
|
||||
|
|
@ -53,11 +56,15 @@ CKEDITOR.plugins.add('rx_upload', {
|
|||
data: form,
|
||||
dataType: 'json',
|
||||
success: function(data) {
|
||||
insertFile(upload_container, data);
|
||||
reloadFileList(upload_container, data);
|
||||
if (data.error == 0) {
|
||||
insertFile(upload_container, data);
|
||||
reloadFileList(upload_container, data);
|
||||
} else {
|
||||
displayError(8, data.message);
|
||||
}
|
||||
},
|
||||
error: function(jqXHR) {
|
||||
alert('Upload error: ' + jqXHR.responseText);
|
||||
displayError(9, jqXHR.responseText);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
|
@ -66,10 +73,6 @@ CKEDITOR.plugins.add('rx_upload', {
|
|||
* Insert file into editor.
|
||||
*/
|
||||
const insertFile = function(container, data) {
|
||||
if (data.error != 0) {
|
||||
alert(data.message);
|
||||
return;
|
||||
}
|
||||
|
||||
let temp_code = '';
|
||||
if(/\.(gif|jpe?g|png|webp)$/i.test(data.source_filename)) {
|
||||
|
|
@ -112,5 +115,13 @@ CKEDITOR.plugins.add('rx_upload', {
|
|||
container.data('instance').loadFilelist(container, true);
|
||||
};
|
||||
|
||||
/**
|
||||
* Display an error message.
|
||||
*/
|
||||
const displayError = function(type, message) {
|
||||
alert(window.xe.msg_file_upload_error + ' (Type ' + type + ")\n" + message);
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue