Web UI for ARGUS server
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

335 lines
14 KiB

//<?php require_once('../../jscript_asm.php'); ?>
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<A.length;i++){
B = B+'|'+A[i];
};
Ext.Ajax.request({
url: 'lib/connector/json/chat_forwarding.php?UID='+UserID+'&SID='+SessionID+'&DID='+ CDevID,
success: function( response, opts ){
ChatForwardingWindow.hide();
},
failure: function( response, opts ){
},
headers: {
'hnodes': B
},
params: {
nodes: B
}
});
}
},{
text: 'Cancel',
handler: function(){
ChatForwardingWindow.hide();
}
}]
});
};
ChatForwardingWindow.show();
ChatForwardingWindow.getComponent(0).getRootNode().setText(DevNMS[CDevID]);
ChatForwardingWindow.getComponent(0).getLoader().dataUrl = 'lib/connector/json/chat_device_list.php?UID='+UserID+'&SID='+SessionID+'&DID='+CDevID;
ChatForwardingWindow.getComponent(0).getRootNode().reload();
};
function PopUpChat(){
if( !ChatPopUpWindow ){
ChatPopUpWindow = new Ext.Window({
title : "Chat History Window",
layout : 'fit',
width : 500,
height : 400,
closeAction :'hide',
listeners: {
hide: function(){
//ChatMode = 1;
//GetMesseges();
}
},
plain : false,
resizable : false,
items : [ new Ext.Panel({
id: 'chat_ext_module',
tbar: [ {xtype: 'tbspacer'}, { xtype: 'tbtext', id: 'pc_dev', text: '', style: 'color: white; font-weight: bold;' }, '->'/*, {
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: '<center>Are You Certain You Want To Do This ?<br/>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: '<table width="100%" border=0 height="300px"><tr><td id="chat_calendar_TD" valign="top" width="140px"></td><td><div id="chat_ext_div" class="chat_ext_chat_class" style="height: 300px;"><div style="text-align: center; height: ' + ( PanelH - 390 ) + 'px; width: 100%; font-size: 12px; font-weight: bold; vertical-align: middle;"><br /><br />Loading Data ... <img src="/style/img/wait.gif"></div></div></td></tr></table>'
}]
})],
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 = '<div class="chat_msg_in"><table width="100%" cellspacing=0 cellpadding=0 border=0><tr><td class="chat_msg_11"></td><td class="chat_msg_12"></td><td class="chat_msg_13"></td></tr><tr><td class="chat_msg_21"></td><td class="chat_msg_22">';
var begin_out = '<div class="chat_msg_out"><table width="100%" cellspacing=0 cellpadding=0 border=0><tr><td class="chat_msg_11"></td><td class="chat_msg_12"></td><td class="chat_msg_13"></td></tr><tr><td class="chat_msg_21"></td><td class="chat_msg_22">';
var end = '</td><td class="chat_msg_23"></td></tr><tr><td class="chat_msg_31"></td><td class="chat_msg_32"></td><td class="chat_msg_33"></td></tr></table></div><div style="height: 3px;"><div>';
cdiv.innerHTML = '';
for( i=0; i< obj.rows.length; i++ ){
if( obj.rows[i].src == 0 ){
if ( obj.rows[i].status == 'R' ){
status_t = '<img src="/style/img/wait.gif" title="Message Dispatched for Delivery">';
} else {
status_t = '<img src="/style/img/chat/new_g.gif" title="Message Was Sent to Device">';
};
cdiv.innerHTML += begin_out + '<div class="chat_msg_body"><img src="/style/img/chat/out.gif" title="Message to Device">' + DevNMS[ CDevID ]+ ' ' + obj.rows[i].ts + status_t + '<hr>' + obj.rows[i].body + '<br><br></div>' + 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: '<center>The device <b>' + DevNMS[ CDevID ] + '</b><br>Entered into Emergency Mode</center>',
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 = '<img src="/style/img/chat/new.gif">';
} else {
status_t = '<img src="/style/img/chat/new_g.gif">';
};
if( ( obj.rows[i].lat != 0 ) && ( obj.rows[i].lon != 0 ) ){
status_t += '&nbsp;<a href="#" onclick="BeginPreviewWP('+obj.rows[i].lon+','+obj.rows[i].lat+');" title="Show Position On Map"><img border=0 src="/style/img/chat/onmap.gif"></a>';
} else {
status_t += '&nbsp;<a href="#" title="No Position Information"><img src="/style/img/chat/onmap_g.gif"></a>';
};
cdiv.innerHTML += begin_in + '<div class="chat_msg_body"><img src="/style/img/chat/in.gif" title="Message from Device">' + DevNMS[ CDevID ] + ' ' + obj.rows[i].ts + status_t + '<hr>' + obj.rows[i].body + '<br><br></div>' + end;
};
};
};
ChatQueryBusy = false;
if ( ChatModuleEnabled ) MessegesIntervalHandler = window.setTimeout('GetMesseges();',20000);
},
failure: function( response, opts ){
ChatQueryBusy = false;
//Ext.Msg.alert('Status', 'Error Creating AJAX Connection.<br>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("<?=$Labels->GetLabel('_Loading_Histo_');?>","<?=$Labels->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 = '<div class="chat_msg_in"><table width="100%" cellspacing=0 cellpadding=0 border=0><tr><td class="chat_msg_11"></td><td class="chat_msg_12"></td><td class="chat_msg_13"></td></tr><tr><td class="chat_msg_21"></td><td class="chat_msg_22">';
var begin_out = '<div class="chat_msg_out"><table width="100%" cellspacing=0 cellpadding=0 border=0><tr><td class="chat_msg_11"></td><td class="chat_msg_12"></td><td class="chat_msg_13"></td></tr><tr><td class="chat_msg_21"></td><td class="chat_msg_22">';
var end = '</td><td class="chat_msg_23"></td></tr><tr><td class="chat_msg_31"></td><td class="chat_msg_32"></td><td class="chat_msg_33"></td></tr></table></div><div style="height: 3px;"><div>';
cdiv.innerHTML = '';
for( i=0; i< obj.rows.length; i++ ){
if( obj.rows[i].src == 0 ){
if ( obj.rows[i].status == 'R' ){
status_t = '<img src="/style/img/wait.gif" title="Message Dispatched for Delivery">';
} else {
status_t = '<img src="/style/img/chat/new_g.gif" title="Message Was Sent to Device">';
};
cdiv.innerHTML += begin_out + '<div class="chat_msg_body"><img src="/style/img/chat/out.gif" title="Message to Device">' + DevNMS[ CDevID ]+ ' ' + obj.rows[i].ts + status_t + '<hr>' + obj.rows[i].body + '<br><br></div>' + end;
} else {
if ( obj.rows[i].status == 'R' ){
status_t = '<img src="/style/img/chat/new.gif">';
} else {
status_t = '<img src="/style/img/chat/new_g.gif">';
};
cdiv.innerHTML += begin_in + '<div class="chat_msg_body"><img src="/style/img/chat/in.gif" title="Message from Device">' + DevNMS[ CDevID ] + ' ' + obj.rows[i].ts + status_t + '<hr>' + obj.rows[i].body + '<br><br></div>' + 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.<br>Code: CENDL00225');
//if ( ChatModuleEnabled ) MessegesIntervalHandler = window.setTimeout('GetMesseges();', 1000);
Ext.MessageBox.hide();
}
});
//};
};