// var ChatModule; var ChatModuleEnabled = false; var ChatMode = 1; var SoundEnabled = true; var MessegesIntervalHandler; var WiFiNetworksWindow; var ChatPopUpWindow; var ChatForwardingWindow; var ChatQueryBusy = false; var ChatForwardingLoader; function PopUpChatForwarding(){ if( !ChatForwardingLoader ){ ChatForwardingLoader = new Ext.tree.TreeLoader({ dataUrl: 'lib/connector/json/chat_device_list.php?UID='+UserID+'&SID='+SessionID+'&DID='+CDevID, baseAttrs:{ expanded: true }, listeners:{ load: function( tre, tnode, response ){ //alert('lib/connector/json/tracking_device_list.php?UID='+UserID+'&SID='+SessionID); //GMapToolbox.doLayout(); //GMapToolbox.expand(); if ( tnode.getPath() == InitTreeNodePath ){ tnode.select(); }; } } }); }; if( !ChatForwardingWindow ){ ChatForwardingWindow = new Ext.Window({ title : "Forward Device Messeges", layout : 'fit', width : 300, height : 440, closeAction :'hide', items: new Ext.tree.TreePanel({ id:'chat-dev-tree', title: "Chat Enabled Devices", frame: true, loader: ChatForwardingLoader, rootVisible: true, lines: true, autoScroll:true, root: new Ext.tree.AsyncTreeNode({ text: '****', expanded: true }) }), buttons: [{ text: 'Apply Changes', handler: function(){ A=ChatForwardingWindow.getComponent(0).getChecked('device_db_id'); B=''; for(i=0;i'/*, { id: 'dis_ext_sound', text: '', iconCls: (( SoundEnabled )?'chat_mute_on_icon':'chat_mute_off_icon'), tooltip: 'Mute Sound Notification', handler: function(){ if ( SoundEnabled ){ Ext.Msg.show({ title:'Disable Sound Notification', width: 500, msg: '
Are You Certain You Want To Do This ?
The Emergency Event and Ne', buttons: Ext.Msg.YESNOCANCEL, fn: function(btn, text){ if (btn == 'yes'){ SoundEnabled = false; Ext.getCmp('dis_sound').setIconClass('chat_mute_off_icon'); Ext.getCmp('dis_ext_sound').setIconClass('chat_mute_off_icon'); } else { SoundEnabled = true; }; }, //animEl: 'elId', icon: Ext.MessageBox.QUESTION }); if ( SoundEnabled ){ niftyplayer('niftyPlayer1').loadAndPlay('/resources/sound/que.mp3'); }; } else { SoundEnabled = true; Ext.getCmp('dis_sound').setIconClass('chat_mute_on_icon'); Ext.getCmp('dis_ext_sound').setIconClass('chat_mute_on_icon'); }; } } */], items: [{ html: '


Loading Data ...
' }] })], buttonAlign: 'right', buttons: [ { id: 'chat_ffwd_wnd', text: 'Configure Forwaring', handler: function(){ PopUpChatForwarding(); } }] }); }; //ChatMode = 2; ChatPopUpWindow.show(); Ext.getCmp('pc_dev').setText( DevNMS[CDevID] ); StartCCalendarSession(); //GetMesseges(); }; var PreviewTimer = null; var PreviewLP; var PreviewLZ; var PreviewICO = null; var PreviewMarker = null; function BeginPreviewWP(a,b){ if( PreviewTimer ){ window.clearTimeout( PreviewTimer ); }; if( !PreviewICO ){ PreviewICO = new GIcon(); PreviewICO.image = "resources/markers/pos.gif"; PreviewICO.iconSize = new GSize(32,32); PreviewICO.iconAnchor = new GPoint(16,26); PreviewICO.infoWindowAnchor = new GPoint (0,16); }; if( PreviewMarker ){ map.removeOverlay( PreviewMarker ); PreviewMarker = null; }; PreviewMarker = new GMarker( new GLatLng( b/1000000, a/1000000 ) , { icon: PreviewICO, zIndexProcess: function(){ return 281250; } }); map.addOverlay( PreviewMarker ); PreviewLP = map.getCenter(); PreviewLZ = map.getZoom(); map.setCenter( new GLatLng( b/1000000, a/1000000 ) , PreviewLZ ); map.checkResize(); //alert( ' coords:'+a+'x'+b ); PreviewTimer = window.setTimeout('EndPreviewWP();', 5000 ); // 5Sec; }; function EndPreviewWP(){ window.clearTimeout( PreviewTimer ); map.removeOverlay( PreviewMarker ); PreviewMarker = null; map.setCenter( PreviewLP, PreviewLZ ); PreviewTimer = null; }; function GetMesseges(){ if( !ChatQueryBusy ){ ChatQueryBusy = true; window.clearTimeout( MessegesIntervalHandler ); Ext.Ajax.abort(); Ext.MessageBox.hide(); Ext.Ajax.request({ url: 'lib/connector/json/get_messages.php?UID='+UserID+'&SID='+SessionID+'&DID='+ CDevID +'&mode='+ChatMode, success: function( response, opts ){ var obj = Ext.decode( response.responseText ); if ( ChatMode == 1 ){ var cdiv = document.getElementById('chat_div'); } else { var cdiv = document.getElementById('chat_ext_div'); }; if ( cdiv ){ var i = 0; var begin_in = '
'; var begin_out = '
'; var end = '
'; cdiv.innerHTML = ''; for( i=0; i< obj.rows.length; i++ ){ if( obj.rows[i].src == 0 ){ if ( obj.rows[i].status == 'R' ){ status_t = ''; } else { status_t = ''; }; cdiv.innerHTML += begin_out + '
' + DevNMS[ CDevID ]+ ' ' + obj.rows[i].ts + status_t + '
' + obj.rows[i].body + '

' + end; } else { if ( obj.rows[i].status == 'R' ){ if ( obj.rows[i].body == 'Emergency !!!') { if ( SoundEnabled ) niftyplayer('niftyPlayer1').loadAndPlay('/resources/sound/beep.mp3'); Ext.Msg.show({ title:'Emergency !!', msg: '
The device ' + DevNMS[ CDevID ] + '
Entered into Emergency Mode
', buttons: Ext.Msg.OK, width: 500, fn: function(){ if ( SoundEnabled ){ niftyplayer('niftyPlayer1').stop(); }; }, //animEl: 'elId', icon: Ext.MessageBox.WARNING }); } else { if ( SoundEnabled ) niftyplayer('niftyPlayer1').loadAndPlay('/resources/sound/ndr.mp3'); }; status_t = ''; } else { status_t = ''; }; if( ( obj.rows[i].lat != 0 ) && ( obj.rows[i].lon != 0 ) ){ status_t += ' '; } else { status_t += ' '; }; cdiv.innerHTML += begin_in + '
' + DevNMS[ CDevID ] + ' ' + obj.rows[i].ts + status_t + '
' + obj.rows[i].body + '

' + end; }; }; }; ChatQueryBusy = false; if ( ChatModuleEnabled ) MessegesIntervalHandler = window.setTimeout('GetMesseges();',20000); }, failure: function( response, opts ){ ChatQueryBusy = false; //Ext.Msg.alert('Status', 'Error Creating AJAX Connection.
Code: CENDL00225'); if ( ChatModuleEnabled ) MessegesIntervalHandler = window.setTimeout('GetMesseges();', 1000); }/*, headers: { 'my-header': 'foo' }, params: { foo: 'bar' }*/ }); }; }; function GetHistoryMesseges(){ //if( !ChatQueryBusy ){ //ChatQueryBusy = true; //window.clearTimeout( MessegesIntervalHandler ); Ext.Ajax.abort(); Ext.MessageBox.hide(); Ext.MessageBox.wait("GetLabel('_Loading_Histo_');?>","GetLabel('_Please_Wait_');?>",{ width: '100%', hidden: true, progress: true, closable: false }); Ext.Ajax.request({ url: 'lib/connector/json/get_messages_history.php?UID='+UserID+'&SID='+SessionID+'&DID='+ CDevID +'&mode='+ChatMode + '&M=' + SM + '&D=' + SD + '&Y=' + SY, success: function( response, opts ){ var obj = Ext.decode( response.responseText ); var cdiv = document.getElementById('chat_ext_div'); if ( cdiv ){ var i = 0; var begin_in = '
'; var begin_out = '
'; var end = '
'; cdiv.innerHTML = ''; for( i=0; i< obj.rows.length; i++ ){ if( obj.rows[i].src == 0 ){ if ( obj.rows[i].status == 'R' ){ status_t = ''; } else { status_t = ''; }; cdiv.innerHTML += begin_out + '
' + DevNMS[ CDevID ]+ ' ' + obj.rows[i].ts + status_t + '
' + obj.rows[i].body + '

' + end; } else { if ( obj.rows[i].status == 'R' ){ status_t = ''; } else { status_t = ''; }; cdiv.innerHTML += begin_in + '
' + DevNMS[ CDevID ] + ' ' + obj.rows[i].ts + status_t + '
' + obj.rows[i].body + '

' + end; }; }; }; //ChatQueryBusy = false; //if ( ChatModuleEnabled ) MessegesIntervalHandler = window.setTimeout('GetMesseges();',20000); Ext.MessageBox.hide(); }, failure: function( response, opts ){ //ChatQueryBusy = false; //Ext.Msg.alert('Status', 'Error Creating AJAX Connection.
Code: CENDL00225'); //if ( ChatModuleEnabled ) MessegesIntervalHandler = window.setTimeout('GetMesseges();', 1000); Ext.MessageBox.hide(); } }); //}; };