1
0
Fork 0
mirror of https://github.com/xevidos/codiad.git synced 2025-03-14 04:28:48 +01:00
codiad/js/jsend.js
xevidos 6b9918acde * Added file selector functions
* Added initial archive management
* Added new Permissions system
* Added new file upload systems
* Recoded most of Filemanager componant
* Removed long IDs from database tables
* Updated commonly used settings to default
2020-03-30 17:57:38 +00:00

49 lines
1.1 KiB
JavaScript
Executable file

( function( global, $ ) {
let codiad = global.codiad;
//////////////////////////////////////////////////////////////////////
// Parse JSEND Formatted Returns
//////////////////////////////////////////////////////////////////////
codiad.jsend = {
parse: function( d ) {
// (Data)
let obj = $.parseJSON( d );
if ( obj === undefined || obj === null ) {
return 'error';
}
if ( obj !== undefined && obj !== null && Array.isArray( obj.debug ) ) {
var debug = obj.debug.join('\nDEBUG: ');
if( debug !== '' ) {
debug = 'DEBUG: ' + debug;
}
console.log( debug );
}
if ( obj.status == 'error' ) {
codiad.message.error( obj.message );
return 'error';
} else if( obj.status == 'warning' ) {
codiad.message.warning( obj.message );
return 'warning';
} else if( obj.status == 'notice' ) {
codiad.message.notice( obj.message );
return 'notice';
} else {
return obj.data;
}
}
};
})(this, jQuery);