rbrindley: branch rbrindley/welcome_revamp r4317 - /team/rbrindley/welcome_re...

SVN commits to the Asterisk-GUI project asterisk-gui-commits at lists.digium.com
Tue Dec 9 08:57:44 CST 2008


Author: rbrindley
Date: Tue Dec  9 08:57:41 2008
New Revision: 4317

URL: http://svn.digium.com/view/asterisk-gui?view=rev&rev=4317
Log:

- improved all parseInt funcs to including a radix argument of '10' to ensure the string will be parsed
  in base 10. This resolves the issue of the count_up and count_down funcs going from 08 to 01.
- added ringing and ring in use cases to loadQueues switch case
- changed agent count to allow increment when an agent isn't logged off
- updateAgent func now updates agent count
- addQueueCall and removeQueueCall now update calls count
- 2nd return condition in html2secs now also checks if html[1] == '00' (as well as '0')


Modified:
    team/rbrindley/welcome_revamp/config/js/welcome2.js

Modified: team/rbrindley/welcome_revamp/config/js/welcome2.js
URL: http://svn.digium.com/view/asterisk-gui/team/rbrindley/welcome_revamp/config/js/welcome2.js?view=diff&rev=4317&r1=4316&r2=4317
==============================================================================
--- team/rbrindley/welcome_revamp/config/js/welcome2.js (original)
+++ team/rbrindley/welcome_revamp/config/js/welcome2.js Tue Dec  9 08:57:41 2008
@@ -317,7 +317,6 @@
 			//Callers line will either be 'Callers:' or 'No Callers'
 			while (!lines[line_index].contains('Callers')) {
 				var agent = agent_template.clone();
-				agent_cnt++;
 
 				//      Agent/6000 (Busy) has taken no calls yet
 				line = lines[line_index].trim();
@@ -325,14 +324,20 @@
 				var a_status = line.match('[\\s\\w][\\s\\w]*(?=\\))').toString();
 
 				switch(a_status.toLowerCase()) {
+					case 'ringing':
+					case 'ring in use':
+						var a_status_img = 'images/agent_ringing.png';
+						agent_cnt++;
+						break;
 					case 'busy':
+					case 'in use':
 						var a_status_img = 'images/agent_busy.png';
+						agent_cnt++;
 						break;
 					case 'available':
-						var a_status_img = 'images/agent_loggedin.png';
-						break;
 					case 'not in use':
 						var a_status_img = 'images/agent_loggedin.png';
+						agent_cnt++;
 						break;
 					default:
 						var a_status_img = 'images/agent_loggedout.png';
@@ -381,7 +386,7 @@
 						var waittime = sections[i+1].replace(/,/,'');
 
 						var wt_tmp = waittime.split(':');
-						var secs = (parseInt(wt_tmp[0]) * 60) + parseInt(wt_tmp[1]);
+						var secs = (parseInt(wt_tmp[0], 10) * 60) + parseInt(wt_tmp[1], 10);
 						if (secs > 30) {
 							var call_class = 'old';
 						} else if (secs > 120) {
@@ -456,14 +461,14 @@
 		if (active_conferences[conf_room]) {
 	/* Existing Conf */
 			var conf = active_conferences[conf_room];
-			var tmp_dur = parseInt(chan[10]);
+			var tmp_dur = parseInt(chan[10], 10);
 			conf.duration = conf.duration < tmp_dur ? tmp_dur : conf.duration;
 		} else {
 	/* New Conf */
 			var conf = {};
 			conf.id = conf_room;
 			conf.count = 0;
-			conf.duration = parseInt(chan[10]);
+			conf.duration = parseInt(chan[10], 10);
 			conf.users = new Array();
 		}
 		
@@ -730,6 +735,11 @@
 		alert('updateAgent: '+event.toString());
 		break;
 	}
+
+	agent_locs.parents('.queue').find('.users_agents').each( function() {
+		var agents = $(this).parents('.queue').find(".status_icon[src!='images/agent_loggedout.png']").length - 1 /* template */;
+		this.innerHTML = this.innerHTML.replace(/[0-9][0-9]*(?= agents)/,agents);
+	});
 };
 
 manager_events.addQueueCall = function (queue, exten, position) {
@@ -745,20 +755,28 @@
 	$("<td></td>").html('0:00').addClass('count_html_up').appendTo(new_row);
 
 	calls_tbody.append(new_row);
+
+	var calls = calls_tbody.children('tr').length;
+	var innerHTML = $('#queue_'+queue.toString()+' .users_agents').html();
+	$('#queue_'+queue.toString()+' .users_agents').html(innerHTML.replace(/[0-9][0-9]*(?= calls,)/,calls));
 };
 
 manager_events.removeQueueCall = function (queue, exten) {
 	var calls_tbody = $('#queue_'+queue.toString()+' .calls > .list > tbody');
+	var calls;
 
 	$('#'+queue.toString()+'_call_'+exten.toString()).remove();
 
-	if (calls_tbody.children('tr').length == 0) {
+	if ( (calls = calls_tbody.children('tr').length) == 0) {
 		calls_tbody.append(
 			$('<tr></tr>').append(
 				$('<td></td>').attr('colspan','3').html('No Calls')
 			)
 		);
 	}
+
+	var innerHTML = $('#queue_'+queue.toString()+' .users_agents').html();
+	$('#queue_'+queue.toString()+' .users_agents').html(innerHTML.replace(/[0-9][0-9]*(?= calls,)/,calls));
 };
 
 manager_events.updateExtension = function(exten, context, status) {
@@ -879,7 +897,7 @@
 		conf = $('#conf_'+meetme.toString());
 		var status = conf.contents().find('.status').html();
 		status = status.split(' ')[0];
-		status = parseInt(status)+1;
+		status = parseInt(status, 10)+1;
 		conf.find('.status').html(status+' Users');
 	}
 
@@ -899,7 +917,7 @@
 		conf = $('#conf_'+meetme.toString());
 		var status = conf.contents().find('.status').html();
 		status = status.split(' ')[0];
-		status = parseInt(status)-1;
+		status = parseInt(status, 10)-1;
 		conf.find('.status').html(status+' Users');
 	}
 };
@@ -931,19 +949,19 @@
 var countHtml = function() {
 	$('.count_html_up').each( function(i) {
 		var old_time = this.innerHTML;
-		old_time = html2secs(old_time.toString());
-
-		var new_time = parseInt(old_time)+1;
-		new_time = secs2html(new_time);
-
-		this.innerHTML = new_time;
+		var old_time_secs = html2secs(old_time.toString());
+
+		var new_time = 1+old_time_secs;
+		var new_time_html = secs2html(new_time);
+
+		this.innerHTML = new_time_html;
 	});
 
 	$('.count_html_down').each( function(i) {
 		var old_time = this.innerHTML;
 		old_time = html2secs(old_time.toString());
 
-		var new_time = parseInt(old_time)-1;
+		var new_time = parseInt(old_time, 10)-1;
 		new_time = secs2html(new_time);
 
 		this.innerHTML = new_time;
@@ -954,11 +972,11 @@
 
 var countSecs = function() {
 	$('.count_up').each( function(i) {
-		this.innerHTML = parseInt(this.innerHTML)+1;
+		this.innerHTML = parseInt(this.innerHTML, 10)+1;
 	});
 
 	$('.count_down').each( function(i) {
-		this.innerHTML = parseInt(this.innerHTML)-1;
+		this.innerHTML = parseInt(this.innerHTML, 10)-1;
 	});
 
 	setTimeout('countSecs()',1000);
@@ -968,23 +986,24 @@
 	html = html.trim().split(':');
 
 	if (html.length == 3) {
-		return (parseInt(html[0]) * 60*60) + (parseInt(html[1]) * 60) + parseInt(html[2]);
-	} else if (html[0].toString() != '00') {
-		return ((parseInt(html[0])*60)+parseInt(html[1]));
+		return (parseInt(html[0], 10) * 60*60) + (parseInt(html[1], 10) * 60) + parseInt(html[2], 10);
+	} else if (html[0].toString() != '0' && html[0].toString() != '00') {
+		return ((parseInt(html[0], 10)*60)+parseInt(html[1], 10));
 	} else {
-		return parseInt(html[1]);
+		return parseInt(html[1], 10);
 	}
 };
 
 var secs2html = function(secs) {
+	var tmp = secs;
 	var mins = Math.floor(secs/60);
 	var hrs = Math.floor(mins/60);
 	mins = mins % 60;
 	secs = secs % 60;
 	if (hrs != 0) {
-		return (''+hrs.toString()+':'+mins.toString()+':'+(secs<10?'0':'')+secs.toString());
+		return ''+hrs.toString()+':'+mins.toString()+':'+(secs<10 ?'0':'')+secs.toString();
 	} else {
-		return (''+mins.toString()+':'+(secs<10?'0':'')+secs.toString());
+		return ''+mins.toString()+':'+(secs<10?'0':'')+secs.toString();
 	}
 };
 




More information about the asterisk-gui-commits mailing list