pari: trunk r16 - /trunk/config/status.html
asterisk-gui-commits at lists.digium.internal
asterisk-gui-commits at lists.digium.internal
Wed Sep 6 18:34:22 CDT 2006
Author: pari
Date: Wed Sep 6 18:34:22 2006
New Revision: 16
URL: http://svn.digium.com/view/asterisk-gui?rev=16&view=rev
Log:
status.html revised
Modified:
trunk/config/status.html
Modified: trunk/config/status.html
URL: http://svn.digium.com/view/asterisk-gui/trunk/config/status.html?rev=16&r1=15&r2=16&view=diff
==============================================================================
--- trunk/config/status.html (original)
+++ trunk/config/status.html Wed Sep 6 18:34:22 2006
@@ -24,44 +24,119 @@
<link href="stylesheets/rico.css" media="all" rel="Stylesheet" type="text/css" />
<link href="stylesheets/schwing.css" media="all" rel="Stylesheet" type="text/css" />
<script>
+ var logins = new Object;
+ var logoffs = new Object;
var channels = new Object;
var pongs = new Object;
+ var loggedon = -1;
var selectedchan = null;
var hungupchan = "";
var transferedchan = "";
-
-
-function showmsg(){
- $('status').innerHTML = "Transferred " + transferredchan;
-}
-
-
-// Have to do the following ... but on what event !!
-// selectedchan = target;
-// updateButtons();
-
-
-function doStatus(){
- $('status').innerHTML = "<i>Updating channel status...</i>";
- astmanEngine.channelClear();
- $('channellist').innerHTML = astmanEngine.channelTable();
- $('status').innerHTML = "";
-}
-
-function updateButtons()
-{
- if ($(selectedchan)) {
- $('transfer').disabled = 0;
- $('hangup').disabled = 0;
- } else {
- $('transfer').disabled = 1;
- $('hangup').disabled = 1;
+
+ var activechannels = new Object;
+
+ function loggedOn() {
+ if (loggedon == 1)
+ return;
+ loggedon = 1;
+ updateButtons();
+ $('status').innerHTML = "<i>Retrieving channel status...</i>";
+ parent.astmanEngine.pollEvents();
+ parent.astmanEngine.sendRequest('action=status', activechannels.channels);
+ }
+
+ function clearChannelList() {
+ $('channellist').innerHTML = "<i class='light'>Not connected</i>";
+ $('transfer').disabled = 1;
+ $('hangup').disabled = 1;
+ $('refresh').disabled = 1;
+ }
+
+ function loggedOff() {
+ loggedon = 0;
selectedchan = null;
- }
-}
-
-function doTransfer() {
- var channel = astmanEngine.channelInfo(selectedchan);
+ parent.astmanEngine.channelClear();
+ clearChannelList();
+ }
+
+ function updateButtons()
+ {
+ if ($(selectedchan)) {
+ $('transfer').disabled = 0;
+ $('hangup').disabled = 0;
+ } else {
+ $('transfer').disabled = 1;
+ $('hangup').disabled = 1;
+ selectedchan = null;
+ }
+ if (loggedon) {
+ $('refresh').disabled = 0;
+ } else {
+ $('transfer').disabled = 1;
+ $('hangup').disabled = 1;
+ $('refresh').disabled = 1;
+ }
+ }
+
+ activechannels.channelCallback = function(target) {
+ selectedchan = target;
+ updateButtons();
+ }
+
+ activechannels.channels = function(msgs) {
+ resp = msgs[0].headers['response'];
+ if (resp == "Success") {
+ loggedOn();
+ } else
+ loggedOff();
+
+ for (i=1;i<msgs.length - 1;i++)
+ parent.astmanEngine.channelUpdate(msgs[i]);
+ $('channellist').innerHTML = parent.astmanEngine.channelTable(activechannels.channelCallback);
+ $('status').innerHTML = "Ready";
+ }
+
+ activechannels.logins = function(msgs) {
+ $('status').innerHTML = msgs[0].headers['message'];
+ resp = msgs[0].headers['response'];
+ if (resp == "Success")
+ loggedOn();
+ else
+ loggedOff();
+ };
+
+
+ activechannels.logoffs = function(msgs) {
+ $('status').innerHTML = msgs[0].headers['message'];
+ loggedOff();
+ };
+
+ activechannels.hungup = function(msgs) {
+ $('status').innerHTML = "Hungup " + hungupchan;
+ }
+
+ activechannels.transferred = function(msgs) {
+ $('status').innerHTML = "Transferred " + transferredchan;
+ }
+
+ function doHangup() {
+ hungupchan = selectedchan;
+ parent.astmanEngine.sendRequest('action=hangup&channel=' + selectedchan, activechannels.hungup);
+ }
+
+ function doStatus() {
+ $('status').innerHTML = "<i>Updating channel status...</i>";
+ parent.astmanEngine.channelClear();
+ parent.astmanEngine.sendRequest('action=status', activechannels.channels);
+ }
+
+ function doLogin() {
+ $('status').innerHTML = "<i>Logging in...</i>";
+ parent.astmanEngine.sendRequest('action=login&username=' + $('username').value + "&secret=" + $('secret').value, activechannels.logins);
+ }
+
+ function doTransfer() {
+ var channel = parent.astmanEngine.channelInfo(selectedchan);
var exten = prompt("Enter new extension for " + selectedchan);
var altchan;
if (exten) {
@@ -71,26 +146,47 @@
}
if (altchan) {
transferredchan = selectedchan + " and " + altchan + " to " + exten;
- astmanEngine.sendRequest('action=redirect&channel=' + selectedchan + "&priority=1&extrachannel=" + altchan + "&exten=" + exten, Showmsg);
+ parent.astmanEngine.sendRequest('action=redirect&channel=' + selectedchan + "&priority=1&extrachannel=" + altchan + "&exten=" + exten, activechannels.transferred);
} else {
transferredchan = selectedchan + " to " + exten;
- astmanEngine.sendRequest('action=redirect&channel=' + selectedchan + "&priority=1&exten=" + exten, Showmsg);
+ parent.astmanEngine.sendRequest('action=redirect&channel=' + selectedchan + "&priority=1&exten=" + exten, activechannels.transferred);
}
}
-}
-
-function doHangup(){
- hungupchan = selectedchan;
- astmanEngine.sendRequest('action=hangup&channel=' + selectedchan, demo.hungup);
-}
+ }
+
+ function doLogoff() {
+ $('status').innerHTML = "<i>Logging off...</i>";
+ parent.astmanEngine.sendRequest('action=logoff', activechannels.logoffs);
+ }
+
+ activechannels.pongs = function(msgs) {
+ resp = msgs[0].headers['response'];
+ if (resp == "Pong") {
+ loggedOn();
+ } else {
+ alert ("GetAway");
+ $('status').innerHTML = "<i>Please login...</i>";
+ loggedOff();
+ }
+ }
+
+ activechannels.eventcb = function(msgs) {
+ var x;
+ if (loggedon) {
+ for (i=1;i<msgs.length - 1;i++) {
+ parent.astmanEngine.channelUpdate(msgs[i]);
+ }
+ $('channellist').innerHTML = parent.astmanEngine.channelTable(activechannels.channelCallback);
+ parent.astmanEngine.pollEvents();
+ }
+ updateButtons();
+ }
function localajaxinit(){
- parent.loadscreen(this);
- $('status').innerHTML = "<i>Updating channel status...</i>";
- astmanEngine.channelClear();
- $('channellist').innerHTML = astmanEngine.channelTable();
- updateButtons();
- $('status').innerHTML = "";
+ parent.astmanEngine.setEventCallback(activechannels.eventcb);
+ clearChannelList();
+ parent.astmanEngine.sendRequest('action=ping', activechannels.pongs);
+ parent.loadscreen(this);
}
</script>
<body id="foo" onload="localajaxinit()">
@@ -102,7 +198,7 @@
<table class="mainscreenTable" align="center">
<tr valign="top" height="18">
<td>
- Active Channels: <div style="height:15px" id='status'></div>
+ Active Channels: <div id='status'></div>
</td>
</tr>
<tr height=32 valign="middle">
More information about the asterisk-gui-commits
mailing list