saimods new api stuff, fixes and improvements
This commit is contained in:
parent
5911867aa5
commit
1b3262974e
@ -7,7 +7,7 @@ class api {
|
||||
public static function run($verifyclassname,$apiclassname,$params,$group = self::DEFAULT_GROUP,$strict = true,$default = false){
|
||||
//Verify Class
|
||||
if(!class_exists($verifyclassname)){
|
||||
throw new \SYSTEM\LOG\ERROR("Verify Class given to the api does not exist.");}
|
||||
throw new \SYSTEM\LOG\ERROR("Verify Class given to the api does not exist: '".$verifyclassname."'");}
|
||||
|
||||
//API Class
|
||||
if(!class_exists($apiclassname)){
|
||||
@ -100,7 +100,7 @@ class api {
|
||||
//strict check
|
||||
if( $strict &&
|
||||
count($params) != (count($parameters) + count($commands)) ){
|
||||
throw new \SYSTEM\LOG\ERROR('Unhandled or misshandled parameters - api query is invalid');}
|
||||
throw new \SYSTEM\LOG\ERROR('Unhandled or misshandled parameters - api query is invalid: '.$_SERVER["REQUEST_URI"]);}
|
||||
|
||||
//Function Name
|
||||
$call_funcname = "";
|
||||
|
||||
@ -36,7 +36,7 @@ class saimod_sys_calls extends \SYSTEM\SAI\SaiModule {
|
||||
}
|
||||
}
|
||||
|
||||
public static function html_li_menu(){return '<li><a href="#" id=".SYSTEM.SAI.saimod_sys_calls">API Calls</a></li>';}
|
||||
public static function html_li_menu(){return '<li><a href="#" saimenu=".SYSTEM.SAI.saimod_sys_calls">API Calls</a></li>';}
|
||||
public static function right_public(){return false;}
|
||||
public static function right_right(){return \SYSTEM\SECURITY\Security::check(\SYSTEM\system::getSystemDBInfo(), \SYSTEM\SECURITY\RIGHTS::SYS_SAI);}
|
||||
|
||||
|
||||
@ -28,7 +28,7 @@ class saimod_sys_config extends \SYSTEM\SAI\SaiModule {
|
||||
|
||||
return $result;
|
||||
}
|
||||
public static function html_li_menu(){return '<li><a href="#" id=".SYSTEM.SAI.saimod_sys_config">Config</a></li>';}
|
||||
public static function html_li_menu(){return '<li><a href="#" saimenu=".SYSTEM.SAI.saimod_sys_config">Config</a></li>';}
|
||||
public static function right_public(){return false;}
|
||||
public static function right_right(){return \SYSTEM\SECURITY\Security::check(\SYSTEM\system::getSystemDBInfo(), \SYSTEM\SECURITY\RIGHTS::SYS_SAI);}
|
||||
|
||||
|
||||
@ -86,7 +86,7 @@ class saimod_sys_locale extends \SYSTEM\SAI\SaiModule {
|
||||
return $result;
|
||||
}
|
||||
|
||||
public static function html_li_menu(){return '<li><a href="#" id=".SYSTEM.SAI.saimod_sys_locale">DB Text</a></li>';}
|
||||
public static function html_li_menu(){return '<li><a href="#" saimenu=".SYSTEM.SAI.saimod_sys_locale">DB Text</a></li>';}
|
||||
public static function right_public(){return false;}
|
||||
public static function right_right(){return \SYSTEM\SECURITY\Security::check(\SYSTEM\system::getSystemDBInfo(), \SYSTEM\SECURITY\RIGHTS::SYS_SAI);}
|
||||
|
||||
|
||||
@ -9,7 +9,7 @@ function init__SYSTEM_SAI_saimod_sys_log() {
|
||||
if(data == 1){
|
||||
$('#info_box').html("deleting data...");
|
||||
$('#truncate_modal').modal('hide');
|
||||
$('#content-wrapper').load('./?action=developer&sai_mod=.SYSTEM.SAI.saimod_sys_log');
|
||||
$('#content-wrapper').load(SAI_ENDPOINT+'sai_mod=.SYSTEM.SAI.saimod_sys_log');
|
||||
}else{
|
||||
$('#info_box').html("You do not have the permission to truncate table!");
|
||||
}
|
||||
@ -23,7 +23,7 @@ function init__SYSTEM_SAI_saimod_sys_log() {
|
||||
|
||||
$('img#loader').show();
|
||||
|
||||
$('#content-wrapper').load('./?action=developer&sai_mod=.SYSTEM.SAI.saimod_sys_log');
|
||||
$('#content-wrapper').load(SAI_ENDPOINT+'sai_mod=.SYSTEM.SAI.saimod_sys_log');
|
||||
|
||||
setTimeout("$('img#loader').hide()", 1300);
|
||||
|
||||
@ -36,7 +36,7 @@ function init__SYSTEM_SAI_saimod_sys_log() {
|
||||
$(this).addClass('active');
|
||||
|
||||
|
||||
$('#table-wrapper').load('./?action=developer&sai_mod=.SYSTEM.SAI.saimod_sys_log&filter_error='+$(this).attr('id'));
|
||||
$('#table-wrapper').load(SAI_ENDPOINT+'sai_mod=.SYSTEM.SAI.saimod_sys_log&filter_error='+$(this).attr('id'));
|
||||
}));
|
||||
|
||||
};
|
||||
@ -122,7 +122,7 @@ class saimod_sys_log extends \SYSTEM\SAI\SaiModule {
|
||||
}
|
||||
}
|
||||
|
||||
public static function html_li_menu(){return '<li><a href="#" id=".SYSTEM.SAI.saimod_sys_log">Log</a></li>';}
|
||||
public static function html_li_menu(){return '<li><a href="#" saimenu=".SYSTEM.SAI.saimod_sys_log">Log</a></li>';}
|
||||
public static function right_public(){return false;}
|
||||
public static function right_right(){return \SYSTEM\SECURITY\Security::check(\SYSTEM\system::getSystemDBInfo(), \SYSTEM\SECURITY\RIGHTS::SYS_SAI);}
|
||||
|
||||
|
||||
@ -1,13 +1,102 @@
|
||||
<div class="masthead">
|
||||
<h3 class="muted">Logout</h3>
|
||||
<h4 class="text-info">You are logged in</a></h4>
|
||||
<h4 class="text-info">You are logged in.</h4>
|
||||
</div>
|
||||
<div>
|
||||
<table id="userDetailsTable" class="table table-striped">
|
||||
<tbody>
|
||||
<tr>
|
||||
<th style="width: 200px;">${ua_name}</th>
|
||||
<td><span id="user_username" /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>${ua_email}</th>
|
||||
<td>
|
||||
<span id="user_email" />
|
||||
<div class="control-group" id="change_user_email" style="display: none;">
|
||||
<div class="controls">
|
||||
<input type="email"
|
||||
size="30"
|
||||
style="margin-bottom: 15px; float: left;"
|
||||
id="user_email_input"
|
||||
data-validation-email-message="${ua_email_format_wrong}"
|
||||
required data-validation-required-message="${login_password_required}"/>
|
||||
</div>
|
||||
<div class="help-block" style="float: left; margin-top: 3px;"></div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>${ua_password}</th>
|
||||
<td>
|
||||
<span id="user_password">****</span>
|
||||
<div class="control-group" id="change_user_password" style="display: none;">
|
||||
<div class="control-group controls" id="control-group-password-old">
|
||||
<input type="password"
|
||||
size="30"
|
||||
style="margin-bottom: 15px; float: left;"
|
||||
id="user_old_password"
|
||||
placeholder="${ua_insert_password}"
|
||||
minlength="5" data-validation-minlength-message="${login_password_too_short}"
|
||||
required data-validation-required-message="${login_password_required}"/>
|
||||
<div id="help-block-old-password" class="help-block" style="float: left; margin-top: 3px;"></div>
|
||||
</div>
|
||||
<div class="control-group controls" style="clear: both">
|
||||
<input type="password"
|
||||
size="30"
|
||||
style="margin-bottom: 15px; float: left;"
|
||||
id="user_new_password1"
|
||||
name="user_new_password1"
|
||||
placeholder="${ua_new_password_first}"
|
||||
minlength="5" data-validation-minlength-message="${login_password_too_short}"/>
|
||||
<div class="help-block" style="float: left; margin-top: 3px;"></div>
|
||||
</div>
|
||||
<div class="control-group controls" style="clear: both">
|
||||
<input type="password"
|
||||
size="30"
|
||||
style="margin-bottom: 15px; float: left;"
|
||||
id="user_new_password2"
|
||||
name="user_new_password2"
|
||||
placeholder="${ua_new_password_second}"
|
||||
data-validation-matches-match="user_new_password1"
|
||||
data-validation-matches-message="${register_password_dont_math}"/>
|
||||
<div class="help-block" style="float: left; margin-top: 3px;"></div>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>${ua_last_active}</th>
|
||||
<td><span id="user_last_active"></span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>${ua_joindate}</th>
|
||||
<td><span id="user_joindate"></span></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>${ua_locale}</th>
|
||||
<td>
|
||||
<span id="user_locale"></span>
|
||||
<div id="change_user_locale" style="display: none;">
|
||||
<select size="1" id="change_user_locale_select">
|
||||
<option value="deDE">deDE</option>
|
||||
<option value="enUS">enUS</option>
|
||||
</select>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th style="width: 200px;">Admin Rights</th>
|
||||
<td><span id="user_adminrights" />${isadmin}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<form class="textbox" style="padding:10px" id="logout_form">
|
||||
<div class="control-group">
|
||||
<div class="help-block"></div>
|
||||
<input type="hidden" />
|
||||
<button class="btn btn-primary" style="clear: left; height: 32px; font-size: 13px;"
|
||||
type="submit"
|
||||
id="logout_submit">${logout}</button>
|
||||
<input type="hidden" />
|
||||
<button class="btn btn-primary" style="clear: left; height: 32px; font-size: 13px;" type="submit" id="logout_submit">${logout}</button>
|
||||
</div>
|
||||
</form>
|
||||
</form>
|
||||
|
||||
|
||||
@ -1,34 +1,43 @@
|
||||
function init__SYSTEM_SAI_saimod_sys_login() {
|
||||
//jqBootstrapValidation
|
||||
$("#login_form input").not("[type=submit]").jqBootstrapValidation({
|
||||
preventSubmit: true,
|
||||
submitError: function($form, event, errors) {},
|
||||
submitSuccess: function($form, event){
|
||||
$.get('./api.php?call=account&action=login&username='+$('#bt_login_user').val()+'&password_sha='+$.sha1($('#bt_login_password').val())+'&password_md5='+$.md5($('#bt_login_password').val()), function (data) {
|
||||
if(data == 1){
|
||||
$('.help-block').html("Login successfull.</br>");
|
||||
location.reload(true);
|
||||
} else {
|
||||
$('.help-block').html("Login not successfull.</br> User & Password combination wrong.")
|
||||
}
|
||||
});
|
||||
event.preventDefault();
|
||||
}
|
||||
});
|
||||
|
||||
$("#logout_form input").not("[type=submit]").jqBootstrapValidation({
|
||||
preventSubmit: true,
|
||||
submitError: function($form, event, errors) {},
|
||||
submitSuccess: function($form, event){
|
||||
$.get('./api.php?call=account&action=logout', function (data) {
|
||||
if(data == 1){
|
||||
$('.help-block').html("Logout successfull.</br>");
|
||||
location.reload(true);
|
||||
} else {
|
||||
$('.help-block').html("Logout not successfull.</br>")
|
||||
}
|
||||
});
|
||||
event.preventDefault();
|
||||
}
|
||||
});
|
||||
//jqBootstrapValidation
|
||||
$("#login_form input").not("[type=submit]").jqBootstrapValidation({
|
||||
preventSubmit: true,
|
||||
submitError: function($form, event, errors) {},
|
||||
submitSuccess: function($form, event){
|
||||
$.get(SAI_ENDPOINT+'sai_mod=.SYSTEM.SAI.saimod_sys_login&action=login&username='+$('#bt_login_user').val()+'&password_sha='+$.sha1($('#bt_login_password').val())+'&password_md5='+$.md5($('#bt_login_password').val()), function (data) {
|
||||
if(data == 1){
|
||||
$('.help-block').html("Login successfull.</br>");
|
||||
location.reload(true);
|
||||
} else {
|
||||
$('.help-block').html("Login not successfull.</br> User & Password combination wrong.")
|
||||
}
|
||||
});
|
||||
event.preventDefault();
|
||||
}
|
||||
});
|
||||
|
||||
$("#logout_form input").not("[type=submit]").jqBootstrapValidation({
|
||||
preventSubmit: true,
|
||||
submitError: function($form, event, errors) {},
|
||||
submitSuccess: function($form, event){
|
||||
$.get(SAI_ENDPOINT+'sai_mod=.SYSTEM.SAI.saimod_sys_login&action=logout', function (data) {
|
||||
if(data == 1){
|
||||
$('.help-block').html("Logout successfull.</br>");
|
||||
location.reload(true);
|
||||
} else {
|
||||
$('.help-block').html("Logout not successfull.</br>")
|
||||
}
|
||||
});
|
||||
event.preventDefault();
|
||||
}
|
||||
});
|
||||
|
||||
$.getJSON('./?module=user&action=area&getUserDetails=1', function(data){
|
||||
$('#user_email_input').attr('value', data.email);
|
||||
$('span#user_username').text(data.username);
|
||||
$('span#user_email').text(data.email);
|
||||
$('span#user_joindate').text(data.joindate);
|
||||
$('span#user_last_active').text(new Date(data.last_active * 1000).toString('yyyy-MM-dd h:mm:ss'));
|
||||
$('span#user_locale').text(data.locale);
|
||||
});
|
||||
};
|
||||
|
||||
@ -3,13 +3,7 @@
|
||||
namespace SYSTEM\SAI;
|
||||
|
||||
class saimod_sys_login extends \SYSTEM\SAI\SaiModule {
|
||||
public static function sai_mod__SYSTEM_SAI_saimod_sys_login(){
|
||||
/*
|
||||
if( isset($_POST['username']) && isset($_POST['password']) &&
|
||||
\SYSTEM\SECURITY\Security::login(\SYSTEM\system::getSystemDBInfo(), $_POST['username'], sha1($_POST['password']), md5($_POST['password']))){
|
||||
return \SYSTEM\PAGE\replace::replaceFile(\SYSTEM\WEBPATH(new \SYSTEM\PSAI(),'modules/saimod_sys_login/login_success.tpl'), array());}
|
||||
*/
|
||||
|
||||
public static function sai_mod__SYSTEM_SAI_saimod_sys_login(){
|
||||
$vars = array();
|
||||
$vars['login'] = 'Login';
|
||||
$vars['logout'] = 'Logout';
|
||||
@ -17,13 +11,21 @@ class saimod_sys_login extends \SYSTEM\SAI\SaiModule {
|
||||
$vars['loginPassword'] = 'Password';
|
||||
$vars['login_username_too_short'] = 'Username to short.';
|
||||
$vars['login_password_too_short'] = 'Password to short.';
|
||||
$vars['isadmin'] = \SYSTEM\SECURITY\Security::check(new \DBD\dasensePostgres(), \SYSTEM\SECURITY\RIGHTS::SYS_SAI) ? "yes" : "no";
|
||||
$vars = array_merge($vars, \SYSTEM\locale::getStrings(\DBD\locale_string::VALUE_CATEGORY_DASENSE_USERSTATISTICS));
|
||||
|
||||
if(\SYSTEM\SECURITY\Security::isLoggedIn()){
|
||||
return \SYSTEM\PAGE\replace::replaceFile(\SYSTEM\WEBPATH(new \SYSTEM\PSAI(),'modules/saimod_sys_login/logout.tpl'), $vars);
|
||||
} else {
|
||||
return \SYSTEM\PAGE\replace::replaceFile(\SYSTEM\WEBPATH(new \SYSTEM\PSAI(),'modules/saimod_sys_login/login.tpl'), $vars);}
|
||||
}
|
||||
public static function html_li_menu(){return '<li><a href="#" id=".SYSTEM.SAI.saimod_sys_login">Login</a></li>';}
|
||||
|
||||
public static function sai_mod__SYSTEM_SAI_saimod_sys_login_action_logout(){
|
||||
return \SYSTEM\SECURITY\Security::logout();}
|
||||
public static function sai_mod__SYSTEM_SAI_saimod_sys_login_action_login($username,$password_sha,$password_md5){
|
||||
return \SYSTEM\SECURITY\Security::login(new \DBD\dasensePostgres(), $username, $password_sha, $password_md5);}
|
||||
|
||||
public static function html_li_menu(){return '<li><a href="#" saimenu=".SYSTEM.SAI.saimod_sys_login">Login</a></li>';}
|
||||
public static function right_public(){return true;}
|
||||
public static function right_right(){return true;}
|
||||
|
||||
|
||||
@ -35,7 +35,7 @@ class saimod_sys_mod extends \SYSTEM\SAI\SaiModule {
|
||||
|
||||
}
|
||||
|
||||
public static function html_li_menu(){return '<li><a href="#" id=".SYSTEM.SAI.saimod_sys_mod">SAI Mods</a></li>';}
|
||||
public static function html_li_menu(){return '<li><a href="#" saimenu=".SYSTEM.SAI.saimod_sys_mod">SAI Mods</a></li>';}
|
||||
public static function right_public(){return false;}
|
||||
public static function right_right(){return \SYSTEM\SECURITY\Security::check(\SYSTEM\system::getSystemDBInfo(), \SYSTEM\SECURITY\RIGHTS::SYS_SAI);}
|
||||
|
||||
|
||||
@ -4,7 +4,7 @@ namespace SYSTEM\SAI;
|
||||
|
||||
class saimod_sys_sai extends \SYSTEM\SAI\SaiModule {
|
||||
public static function sai_mod__SYSTEM_SAI_saimod_sys_sai(){return \SYSTEM\PAGE\replace::replaceFile(\SYSTEM\WEBPATH(new \SYSTEM\PSAI(),'modules/saimod_sys_sai/carousel.tpl'), array());}
|
||||
public static function html_li_menu(){return '<li class="active"><a href="#" id=".SYSTEM.SAI.saimod_sys_sai">SYSTEM Admin Interface</a></li>';}
|
||||
public static function html_li_menu(){return '<li class="active"><a href="#" saimenu=".SYSTEM.SAI.saimod_sys_sai">SYSTEM Admin Interface</a></li>';}
|
||||
public static function right_public(){return true;}
|
||||
public static function right_right(){return true;}
|
||||
|
||||
|
||||
@ -65,7 +65,7 @@ class saimod_sys_security extends \SYSTEM\SAI\SaiModule {
|
||||
return 'error';
|
||||
}
|
||||
|
||||
public static function html_li_menu(){return '<li><a href="#" id=".SYSTEM.SAI.saimod_sys_security">Security</a></li>';}
|
||||
public static function html_li_menu(){return '<li><a href="#" saimenu=".SYSTEM.SAI.saimod_sys_security">Security</a></li>';}
|
||||
public static function right_public(){return false;}
|
||||
public static function right_right(){return \SYSTEM\SECURITY\Security::check(\SYSTEM\system::getSystemDBInfo(), \SYSTEM\SECURITY\RIGHTS::SYS_SAI);}
|
||||
|
||||
|
||||
@ -37,11 +37,11 @@ class default_page extends \SYSTEM\PAGE\Page {
|
||||
private function js(){
|
||||
$result = '<script src="'.\SYSTEM\WEBPATH(new \SYSTEM\PSAI(),'page/default_page/js/libs/jquery.min.js').'" type="text/javascript"></script>'.
|
||||
'<script src="'.\SYSTEM\WEBPATH(new \SYSTEM\PSAI(),'page/default_page/js/libs/bootstrap.min.js').'" type="text/javascript"></script>'.
|
||||
'<script src="'.\SYSTEM\WEBPATH(new \SYSTEM\PSAI(),'page/default_page/js/loadcssjs.js').'" type="text/javascript"></script>'.
|
||||
'<script src="'.\SYSTEM\WEBPATH(new \SYSTEM\PSAI(),'page/default_page/js/index.js').'" type="text/javascript"></script>';
|
||||
'<script src="'.\SYSTEM\WEBPATH(new \SYSTEM\PSAI(),'page/default_page/js/sai.js').'" type="text/javascript"></script>'.
|
||||
'<script src="https://www.google.com/jsapi" type="text/javascript"></script>'.
|
||||
'<script src="https://maps.google.com/maps/api/js?v=3&sensor=false" type="text/javascript"></script>'.
|
||||
'<script type="text/javascript">google.load("visualization", "1", {packages:["corechart"]});</script>';
|
||||
'<script type="text/javascript">google.load("visualization", "1", {packages:["corechart"]});</script>'.
|
||||
'<script type="text/javascript">var SAI_ENDPOINT = "'.\SYSTEM\CONFIG\config::get(\SYSTEM\CONFIG\config_ids::SYS_SAI_CONFIG_BASEURL).'";</script>';
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
@ -1,65 +0,0 @@
|
||||
|
||||
var last_id = '';
|
||||
var scripts_loaded = 0;
|
||||
var scripts_req = 0;
|
||||
/** jQuery on document ready */
|
||||
$(document).ready(function() {
|
||||
|
||||
// initialize content
|
||||
loadModuleContent('.SYSTEM.SAI.saimod_sys_sai');
|
||||
|
||||
//load content -> menu
|
||||
$('#sai_navbar ul li a, #project_navbar ul li a').click(function () {
|
||||
var id = $(this).attr("id");
|
||||
if(id !== undefined){
|
||||
console.log("Module: "+id);
|
||||
|
||||
$('#sai_navbar li, #project_navbar li').each(function(){
|
||||
$(this).removeClass('active');});
|
||||
$(this).parent().addClass('active');
|
||||
|
||||
loadModuleContent(id);
|
||||
}
|
||||
});
|
||||
|
||||
$('.brand').click(function(){
|
||||
location.reload();
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
function loadModuleContent(id){
|
||||
last_id = id;
|
||||
$('div#content-wrapper').load('./?action=developer&sai_mod='+id, function(){
|
||||
$.getJSON('./?action=developer&sai_mod='+id+'&css=1', function (data) {
|
||||
if(data){
|
||||
for(var i=0; i < data['result'].length; i++){
|
||||
loadCSS(data['result'][i]);}
|
||||
}
|
||||
});
|
||||
|
||||
$.getJSON('./?action=developer&sai_mod='+id+'&js=1', function (data) {
|
||||
if(data){
|
||||
scripts_req = data['result'].length;
|
||||
for(var i=0; i < data['result'].length; i++){
|
||||
loadJS(unescape(data['result'][i]));}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
function script_loaded(){
|
||||
scripts_loaded += 1;
|
||||
|
||||
if(scripts_loaded >= scripts_req){
|
||||
scripts_loaded = 0;
|
||||
func = 'init_'+last_id;
|
||||
//func = jssrc.substring(jssrc.lastIndexOf('/')+1);
|
||||
func = func.replace(/\./g,'_');
|
||||
if(typeof window[func] === 'function') {
|
||||
window[func]();
|
||||
console.log(func+' called');}
|
||||
}
|
||||
}
|
||||
@ -1,19 +0,0 @@
|
||||
function loadJS(jssrc) {
|
||||
if(jssrc){
|
||||
$.getScript(jssrc).done(function(script, textStatus) {
|
||||
console.log('Script: '+jssrc+' - '+textStatus );
|
||||
script_loaded();
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
function loadCSS(csssrc) {
|
||||
if(csssrc){
|
||||
var snode = document.createElement('link');
|
||||
snode.setAttribute('type','text/css');
|
||||
snode.setAttribute('rel', 'stylesheet');
|
||||
snode.setAttribute('href',csssrc);
|
||||
document.getElementsByTagName('head')[0].appendChild(snode);
|
||||
console.log('Css: '+csssrc+' loaded.');
|
||||
}
|
||||
}
|
||||
81
sai/page/default_page/js/sai.js
Normal file
81
sai/page/default_page/js/sai.js
Normal file
@ -0,0 +1,81 @@
|
||||
var last_id = '';
|
||||
var scripts_loaded = 0;
|
||||
var scripts_req = 0;
|
||||
/** jQuery on document ready */
|
||||
$(document).ready(function() {
|
||||
|
||||
// initialize content
|
||||
loadModuleContent('.SYSTEM.SAI.saimod_sys_sai');
|
||||
|
||||
//load content -> menu
|
||||
$('#sai_navbar ul li a, #project_navbar ul li a').click(function () {
|
||||
var id = $(this).attr("saimenu");
|
||||
if(id !== undefined){
|
||||
console.log("Module: "+id);
|
||||
$('#sai_navbar li, #project_navbar li').each(function(){
|
||||
$(this).removeClass('active');});
|
||||
$(this).parent().addClass('active');
|
||||
loadModuleContent(id);
|
||||
}
|
||||
});
|
||||
|
||||
$('.brand').click(function(){
|
||||
location.reload();
|
||||
});
|
||||
});
|
||||
|
||||
function loadModuleContent(id){
|
||||
last_id = id;
|
||||
$('div#content-wrapper').load(SAI_ENDPOINT+'sai_mod='+id, function(){
|
||||
$.getJSON(SAI_ENDPOINT+'sai_mod='+id+'&css=1', function (data) {
|
||||
if(data){
|
||||
for(var i=0; i < data['result'].length; i++){
|
||||
loadCSS(data['result'][i]);}
|
||||
}
|
||||
});
|
||||
|
||||
$.getJSON('./sai.php?sai_mod='+id+'&js=1', function (data) {
|
||||
if(data){
|
||||
scripts_req = data['result'].length;
|
||||
for(var i=0; i < data['result'].length; i++){
|
||||
loadJS(unescape(data['result'][i]));}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
function script_loaded(){
|
||||
scripts_loaded += 1;
|
||||
|
||||
if(scripts_loaded >= scripts_req){
|
||||
scripts_loaded = 0;
|
||||
func = 'init_'+last_id;
|
||||
//func = jssrc.substring(jssrc.lastIndexOf('/')+1);
|
||||
func = func.replace(/\./g,'_');
|
||||
if(typeof window[func] === 'function') {
|
||||
window[func]();
|
||||
console.log(func+' called');}
|
||||
}
|
||||
}
|
||||
|
||||
function loadJS(jssrc) {
|
||||
if(jssrc){
|
||||
$.getScript(jssrc).done(function(script, textStatus) {
|
||||
console.log('Script: '+jssrc+' - '+textStatus );
|
||||
script_loaded();
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
function loadCSS(csssrc) {
|
||||
if(csssrc){
|
||||
var snode = document.createElement('link');
|
||||
snode.setAttribute('type','text/css');
|
||||
snode.setAttribute('rel', 'stylesheet');
|
||||
snode.setAttribute('href',csssrc);
|
||||
document.getElementsByTagName('head')[0].appendChild(snode);
|
||||
console.log('Css: '+csssrc+' loaded.');
|
||||
}
|
||||
}
|
||||
@ -30,7 +30,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div id="content" style="float: left;">
|
||||
<div id="content-wrapper" style="clear: both; overflow: auto; width: 100%;"></div>
|
||||
<div id="content-wrapper" style="clear: both; overflow: auto; width: 100%; min-width:500px;"></div>
|
||||
<hr>
|
||||
<div class="footer"><p>${copyright}</p></div>
|
||||
</div>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user