80 lines
2.7 KiB
JavaScript
80 lines
2.7 KiB
JavaScript
/*******************************************************************
|
|
|
|
Module : /apps/js/index.js
|
|
Desc. : JS - Halaman Utama Desktop
|
|
Created By : Siau Pheng ([email protected]).
|
|
Created Date : May 24th, 2010.
|
|
Last Modified : March 21st, 2023.
|
|
|
|
(c) 2010 - 2023, 3FONIA Software; WWW.3FONIA.COM.
|
|
|
|
*******************************************************************/
|
|
|
|
$(document).ready(function(){
|
|
jQuery("#preloader").remove();
|
|
loadSidebar();
|
|
IndexJS.loading();
|
|
//if ('undefined' !== typeof qz) startConnection();
|
|
});
|
|
|
|
var IndexJS = {
|
|
Auto_Event: null,
|
|
Item_Update: 0,
|
|
|
|
loading: function(){
|
|
new Request.JSON({
|
|
url: FoniaJS.WEB_PATH+'apps/php/index.php',
|
|
sendParam: ['data=default'],
|
|
onSuccess: function(ares){
|
|
$('#pageContent').html(ares.content);
|
|
$('#pageToolbarTop').html('');
|
|
$('#pageToolbarBot').html('');
|
|
//this.loadSMS10();
|
|
this.loadBarChart();
|
|
}.bind(this)
|
|
}).send();
|
|
},
|
|
|
|
loadBarChart: function(){
|
|
if (!$('#barChart').length) return;
|
|
new Request.JSON({
|
|
url: FoniaJS.WEB_PATH+'apps/php/index.php',
|
|
sendParam: ['data=jual-chart'],
|
|
onSuccess: function(ares){
|
|
if (ares.tipe=='chart') {
|
|
var ctx = Chart.getChart('barChart');
|
|
if (typeof ctx !== 'undefined') ctx.destroy();
|
|
var myChart = new Chart($('#barChart'), {
|
|
type: ares.chart.type,
|
|
data: ares.chart.data,
|
|
options: ares.chart.options
|
|
});
|
|
}
|
|
}
|
|
}).send();
|
|
}
|
|
|
|
};
|
|
|
|
function loadSidebar(){
|
|
const mySidebar = document.getElementById('sidebarMain');
|
|
mySidebar.addEventListener('shown.bs.modal', () => {
|
|
document.querySelectorAll('.sidebar .nav-link').forEach((element) => {
|
|
element.addEventListener('click', (e) => {
|
|
let nextEl = element.nextElementSibling, parentEl = element.parentElement;
|
|
if (nextEl){
|
|
e.preventDefault();
|
|
let mycollapse = new bootstrap.Collapse(nextEl);
|
|
if (nextEl.classList.contains('show')){
|
|
mycollapse.hide();
|
|
} else {
|
|
mycollapse.show();
|
|
var opened_submenu = parentEl.parentElement.querySelector('.submenu.show');
|
|
if (opened_submenu){ new bootstrap.Collapse(opened_submenu); }
|
|
}
|
|
}
|
|
});
|
|
})
|
|
});
|
|
}
|