2018-07-13 18:39:55 +02:00
|
|
|
(function(global, $){
|
|
|
|
|
|
|
|
var codiad = global.codiad;
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
// Parse JSEND Formatted Returns
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
codiad.jsend = {
|
|
|
|
|
|
|
|
parse: function(d) { // (Data)
|
|
|
|
var obj = $.parseJSON(d);
|
2018-07-26 21:39:40 +02:00
|
|
|
|
|
|
|
if( obj !== undefined && obj !== null ) {
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-07-13 18:39:55 +02:00
|
|
|
if (obj.debug !== undefined && 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 {
|
|
|
|
return obj.data;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
})(this, jQuery);
|