2018-07-13 18:39:55 +02:00
|
|
|
/*
|
|
|
|
* Copyright (c) Codiad & Kent Safranski (codiad.com), distributed
|
|
|
|
* as-is and without warranty under the MIT License. See
|
|
|
|
* [root]/license.txt for more. This information must remain intact.
|
|
|
|
*/
|
|
|
|
|
|
|
|
(function(global, $){
|
|
|
|
|
|
|
|
var codiad = global.codiad = {};
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
// loadScript instead of getScript (checks and balances and shit...)
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
$.loadScript = function(url, arg1, arg2) {
|
|
|
|
var cache = true,
|
|
|
|
callback = null;
|
|
|
|
//arg1 and arg2 can be interchangable
|
|
|
|
if ($.isFunction(arg1)) {
|
|
|
|
callback = arg1;
|
|
|
|
cache = arg2 || cache;
|
|
|
|
} else {
|
|
|
|
cache = arg1 || cache;
|
|
|
|
callback = arg2 || callback;
|
|
|
|
}
|
|
|
|
|
|
|
|
var load = true;
|
|
|
|
//check all existing script tags in the page for the url
|
|
|
|
jQuery('script[type="text/javascript"]')
|
|
|
|
.each(function() {
|
|
|
|
return load = (url != $(this)
|
|
|
|
.attr('src'));
|
|
|
|
});
|
|
|
|
if (load) {
|
|
|
|
//didn't find it in the page, so load it
|
|
|
|
jQuery.ajax({
|
|
|
|
type: 'GET',
|
|
|
|
url: url,
|
|
|
|
success: callback,
|
|
|
|
dataType: 'script',
|
|
|
|
cache: cache
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
//already loaded so just call the callback
|
|
|
|
if (jQuery.isFunction(callback)) {
|
|
|
|
callback.call(this);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
// Init
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
$(function() {
|
|
|
|
// Console fix for IE
|
|
|
|
if (typeof(console) === 'undefined') {
|
|
|
|
console = {}
|
|
|
|
console.log = console.error = console.info = console.debug = console.warn = console.trace = console.dir = console.dirxml = console.group = console.groupEnd = console.time = console.timeEnd = console.assert = console.profile = function () {};
|
|
|
|
}
|
|
|
|
|
|
|
|
// Sliding sidebars
|
|
|
|
codiad.sidebars.init();
|
|
|
|
var handleWidth = 10;
|
|
|
|
|
|
|
|
// Messages
|
|
|
|
codiad.message.init();
|
|
|
|
|
|
|
|
$(window)
|
|
|
|
.on('load resize', function() {
|
|
|
|
|
|
|
|
var marginL, reduction;
|
|
|
|
if ($("#sb-left")
|
|
|
|
.css('left') !== 0 && !codiad.sidebars.leftLock) {
|
|
|
|
marginL = handleWidth;
|
|
|
|
reduction = 2 * handleWidth;
|
|
|
|
} else {
|
|
|
|
marginL = $("#sb-left")
|
|
|
|
.width();
|
|
|
|
reduction = marginL + handleWidth;
|
|
|
|
}
|
|
|
|
$('#editor-region')
|
|
|
|
.css({
|
|
|
|
'margin-left': marginL + 'px',
|
|
|
|
'height': ($('body')
|
|
|
|
.outerHeight()) + 'px'
|
|
|
|
});
|
|
|
|
$('#root-editor-wrapper')
|
|
|
|
.css({
|
|
|
|
'height': ($('body')
|
|
|
|
.outerHeight() - 60) + 'px' // TODO Adjust '75' in function of the final tabs height.
|
|
|
|
});
|
|
|
|
|
|
|
|
// Run resize command to fix render issues
|
2018-07-24 04:03:13 +02:00
|
|
|
// Add a check to see if it is not undefined due to an
|
|
|
|
// error being generated on the login page.
|
2018-07-26 21:39:40 +02:00
|
|
|
if ( codiad.editor !== undefined && codiad.editor !== null ) {
|
2018-07-24 04:03:13 +02:00
|
|
|
|
|
|
|
codiad.editor.resize();
|
|
|
|
codiad.active.updateTabDropdownVisibility();
|
|
|
|
}
|
2018-07-13 18:39:55 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
$('#settings').click(function(){
|
|
|
|
codiad.settings.show();
|
|
|
|
});
|
|
|
|
});
|
2019-04-12 18:11:27 +02:00
|
|
|
|
|
|
|
$(function() {
|
|
|
|
|
|
|
|
codiad.system.init();
|
|
|
|
});
|
|
|
|
|
|
|
|
codiad.system = {
|
|
|
|
|
|
|
|
controller: 'components/system/controller.php',
|
|
|
|
session_id: '',
|
|
|
|
site_id: '',
|
|
|
|
|
|
|
|
init: function() {
|
|
|
|
|
|
|
|
let _this = this;
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
create_default_tables: function() {
|
|
|
|
|
|
|
|
jQuery.ajax({
|
2019-07-04 07:50:29 +02:00
|
|
|
|
2019-04-12 18:11:27 +02:00
|
|
|
url: this.controller,
|
|
|
|
type: "POST",
|
|
|
|
dataType: 'html',
|
|
|
|
data: {
|
|
|
|
action: 'create_default_tables'
|
|
|
|
},
|
|
|
|
success: function( data ) {
|
|
|
|
|
2019-04-30 18:56:08 +02:00
|
|
|
console.log( data );
|
2019-04-12 18:11:27 +02:00
|
|
|
},
|
|
|
|
error: function(jqXHR, textStatus, errorThrown) {
|
|
|
|
|
2019-04-13 05:18:27 +02:00
|
|
|
codiad.message.error( i18n( 'Error Creating Default Tables' ) );
|
2019-04-12 18:11:27 +02:00
|
|
|
console.log('jqXHR:');
|
|
|
|
console.log(jqXHR);
|
|
|
|
console.log('textStatus:');
|
|
|
|
console.log(textStatus);
|
|
|
|
console.log('errorThrown:');
|
|
|
|
console.log(errorThrown);
|
|
|
|
},
|
|
|
|
});
|
|
|
|
},
|
2019-12-12 14:22:43 +01:00
|
|
|
|
|
|
|
get_ini_setting: async function( option ) {
|
|
|
|
|
|
|
|
let i = null;
|
|
|
|
let result = await jQuery.ajax({
|
|
|
|
|
|
|
|
url: this.controller,
|
|
|
|
type: "POST",
|
|
|
|
dataType: 'html',
|
|
|
|
data: {
|
|
|
|
action: 'get_ini_setting',
|
|
|
|
option: option,
|
|
|
|
},
|
|
|
|
success: function( data ) {
|
|
|
|
|
|
|
|
console.log( data );
|
|
|
|
},
|
|
|
|
error: function(jqXHR, textStatus, errorThrown) {
|
|
|
|
|
|
|
|
codiad.message.error( i18n( 'Error Creating Default Tables' ) );
|
|
|
|
console.log('jqXHR:');
|
|
|
|
console.log(jqXHR);
|
|
|
|
console.log('textStatus:');
|
|
|
|
console.log(textStatus);
|
|
|
|
console.log('errorThrown:');
|
|
|
|
console.log(errorThrown);
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
let data = JSON.parse( result );
|
|
|
|
i = data.value;
|
|
|
|
} catch( e ) {
|
|
|
|
|
|
|
|
console.log( e, result );
|
|
|
|
}
|
|
|
|
return i;
|
|
|
|
}
|
2019-04-12 18:11:27 +02:00
|
|
|
};
|
2018-07-13 18:39:55 +02:00
|
|
|
|
|
|
|
})(this, jQuery);
|
|
|
|
|