/******************************************************************* PHP Class : /Controller/MonitorController Description : Halaman Utama Display Monitor Created By : Siau Pheng (siaupheng@3fonia.com). Created Date : May 24th, 2010. Last Modified : October 20th, 2026. (c) 3FONIA Software; WWW.3FONIA.COM. *******************************************************************/ $(document).ready(() => { $("#preloader").remove(); MonJS.index(); }); var socket = io(window.location.host, { 'path': '/io' }); // MONITOR socket.on('monitor-data', (adata) => { //console.log('reply monitor-data', adata); if ($('#monContent').length === 0) socket.emit('monitor-done'); if (typeof(adata.data) === 'object') { if (parseInt(adata.data.total)==0) MonJS.IDLE_TIME++; else MonJS.IDLE_TIME = 0; var show_thank = (parseInt(adata.data.thank)==1) ? true : false; if (MonJS.IDLE_TIME === 0) { if (MonJS.ISSHOW_THANK) MonJS.data_query('close-thank'); if (!MonJS.ISSHOW_POS) MonJS.show_pos(); if (adata.data.total !== MonJS.TOTAL_SHOP) { if ($('#divShop').length) MonJS.data_query('info-shop'); MonJS.TOTAL_SHOP = adata.data.total; } } else { if (MonJS.ISSHOW_POS) MonJS.hide_pos(); if (MonJS.IDLE_TIME < MonJS.DEF_THANK_TIME) { if (show_thank && !MonJS.ISSHOW_THANK) { MonJS.show_thank(); MonJS.ISSHOW_THANK = true; } } else { if (MonJS.ISSHOW_THANK) MonJS.data_query('close-thank'); } } } }); var MonJS = { PHP: 'monitor', DEF_PROMO_DUR: 10,//not used DEF_THANK_TIME: 5, DEF_IDLE_TIME: 5,//not used IDLE_TIME: 0, ISSHOW_POS: false, ISSHOW_THANK: false, ID_CABANG: 0, TOTAL_SHOP: 0, index() { new Request({ url: this.PHP + '/index', onSuccess: (ajson) => { $('#monContent').html(ajson.html); this.data_query('config'); this.data_query('info-promo'); this.data_query('info-iklan'); this.hide_pos(); this.hide_thank(); } }).send(); }, hide_pos() { this.ISSHOW_POS = false; $('#divBanner').removeClass('d-none'); $('#divShop').addClass('d-none'); }, show_pos() { this.ISSHOW_POS = true; $('#divBanner').addClass('d-none'); $('#divShop').removeClass('d-none'); this.data_query('shop'); }, hide_thank() { $('#divBlur').addClass('d-none'); $('#divThank').addClass('d-none'); }, show_thank() { $('#divBlur').removeClass('d-none'); $('#divThank').removeClass('d-none'); this.data_query('thank'); }, data_query(tipe) { if (tipe == 'config'){ $.post(this.PHP + '/config', {}, (ajson) => { if (ajson.PROMO_DURASI) MonJS.DEF_PROMO_DUR = ajson.PROMO_DURASI; if (ajson.PROMO_IDLE) MonJS.DEF_IDLE_TIME = ajson.PROMO_IDLE; if (ajson.ID_CABANG) MonJS.ID_CABANG = ajson.ID_CABANG; if (ajson.BANNER_TEXT) $('#divBanner').html(ajson.BANNER_TEXT); if (socket.active) { socket.emit('monitor-done'); socket.emit('monitor-check', { 'UserID': FoniaJS.User.UID, 'CabID': MonJS.ID_CABANG }); } }, 'json'); } else if (tipe == 'info-iklan'){ $.post(this.PHP + '/info_iklan', {}, (ajson) => { $('#divIklan').html(ajson.html); const car_iklan = new bootstrap.Carousel('#divIklan', { //interval: MonJS.DEF_PROMO_DUR }); }); } else if (tipe == 'info-promo'){ $.post(this.PHP + '/info_promo', {}, (ajson) => { $('#divPromo').html(ajson.html); const car_iklan = new bootstrap.Carousel('#divPromo', { //interval: MonJS.DEF_PROMO_DUR }); }); /*} else if (tipe == 'count-delay'){ //todo: ganti ke socket-io $.post(this.PHP + '/count_delay', {}, (ajson) => { if (parseInt(ajson.total)==0) this.IDLE_TIME++; else this.IDLE_TIME = 0; this.ISSHOW_THANK = (parseInt(ajson.thank)==1) ? true : false; }, 'json');*/ } else if (tipe == 'shop'){ $.post(this.PHP + '/shop', {}, (ajson) => { $('#divShop').html(ajson.html); }); } else if (tipe == 'thank'){ $.post(this.PHP + '/thank', {}, (ajson) => { $('#divThank').html(ajson.html); this.TOTAL_SHOP = 0; }); } else if (tipe == 'close-thank'){ $.post(this.PHP + '/close_thank', {}, () => { this.ISSHOW_THANK = false; this.hide_thank(); }); } else if (tipe == 'info-shop'){ $.post(this.PHP + '/info_shop', {}, (ajson) => { $('#Total_Harga').html(ajson.Total_Harga); $('#Info_Qty').html(ajson.Info_Qty); $('#Info_Barang').html(ajson.Info_Barang); if (parseFloat($('#Total_Harga').html()) == 0) this.IDLE_TIME++; else this.IDLE_TIME = 0; }, 'json'); } } };