pari: trunk r297 - in /trunk/config: setup/4.html trunks.html
asterisk-gui-commits at lists.digium.com
asterisk-gui-commits at lists.digium.com
Mon Jan 29 17:00:24 MST 2007
Author: pari
Date: Mon Jan 29 18:00:23 2007
New Revision: 297
URL: http://svn.digium.com/view/asterisk-gui?view=rev&rev=297
Log:
Field Validations in Service Providers - changed from callbacks.checkparams to callbacks.beforeSaving as callbacks.beforeSaving is extecuted first and also that it is better to do Field Validations before we update dids_array
Modified:
trunk/config/setup/4.html
trunk/config/trunks.html
Modified: trunk/config/setup/4.html
URL: http://svn.digium.com/view/asterisk-gui/trunk/config/setup/4.html?view=diff&rev=297&r1=296&r2=297
==============================================================================
--- trunk/config/setup/4.html (original)
+++ trunk/config/setup/4.html Mon Jan 29 18:00:23 2007
@@ -223,10 +223,52 @@
}
callbacks.beforeSaving = function(){
+ if ($('trunkstylevoip').checked && !$('username').value.length ) {
+ alert("When using VoIP, the username must not be empty!");
+ return false;
+ }
+ if ($('trunkstyleanalog').checked ) {
+ if( $('zapchan').options.length == 0 ){
+ alert("No analog line hardware installed on the system");
+ return false;
+ }
+
+ if (!$('zapchan').value) {
+ alert("When using Analog, at least one port must be selected.");
+ return false;
+ }
+ }
+ if ($('trunkstylecustomvoip').checked ) {
+ if( $('customvoip_name').value.length == 0 ){
+ alert("Please enter a Comment for this Service Provider");
+ $('customvoip_name').focus();
+ return false;
+ }
+
+ if ( !$('customvoip_host').value ) {
+ alert("Please enter a host name");
+ $('customvoip_host').focus();
+ return false;
+ }
+ if ( !$('customvoip_username').value ) {
+ alert("Please enter a Username");
+ $('customvoip_username').focus();
+ return false;
+ }
+ }
+
+ if(!$('trunkstylevoip').checked && !$('trunkstyleanalog').checked && !$('trunkstylecustomvoip').checked ){
+ alert("A trunk must be Analog or VoIP or Custom VOIP");
+ return false;
+ }
if(isnewtrunk ==1){
+ try{
provider = $('provider').stored_config.catbyname[$('provider').value];
if( typeof provider.fieldbyname['trunk_username'] != "undefined" && $('trunkstylevoip').checked ){
$('name').value = provider.fieldbyname['trunk_username'];
+ }
+ }catch(e){
+
}
dids_array.push($('name').value );
}else{
@@ -284,10 +326,6 @@
$('hasexten').value = 'no';
$('context').value = asterisk_guiTDPrefix + $('name').value ;
if ($('trunkstylevoip').checked) {
- if (!$('username').value.length) {
- alert("When using VoIP, the username must not be empty!");
- return true;
- }
provider = $('provider').stored_config.catbyname[$('provider').value];
$('trunkname').value = $('provider').options[$('provider').selectedIndex].innerHTML + " - " + $('username').value;
$('hassip').value = provider.fieldbyname['hassip'];
@@ -333,15 +371,6 @@
$('group').value = '';
} else if ($('trunkstyleanalog').checked) {
// Analog
- if( $('zapchan').options.length ==0){
- alert("No analog line hardware installed on the system");
- return true;
- }
-
- if (!$('zapchan').value) {
- alert("When using Analog, at least one port must be selected.");
- return true;
- }
$('provider').selectedIndex = -1;
count = 0;
$('trunkname').value = "";
@@ -401,11 +430,7 @@
$('zapchan').options[x].selected = false;
$('zapchan').value = '';
$('group').value = '';
- }else{
- alert("A trunk must be Analog or VoIP or Custom VOIP");
- return true;
- }
-
+ }
return false;
}
callbacks.newcategory = function() {
Modified: trunk/config/trunks.html
URL: http://svn.digium.com/view/asterisk-gui/trunk/config/trunks.html?view=diff&rev=297&r1=296&r2=297
==============================================================================
--- trunk/config/trunks.html (original)
+++ trunk/config/trunks.html Mon Jan 29 18:00:23 2007
@@ -196,10 +196,52 @@
}
callbacks.beforeSaving = function(){
+ if ($('trunkstylevoip').checked && !$('username').value.length ) {
+ alert("When using VoIP, the username must not be empty!");
+ return false;
+ }
+ if ($('trunkstyleanalog').checked ) {
+ if( $('zapchan').options.length == 0 ){
+ alert("No analog line hardware installed on the system");
+ return false;
+ }
+
+ if (!$('zapchan').value) {
+ alert("When using Analog, at least one port must be selected.");
+ return false;
+ }
+ }
+ if ($('trunkstylecustomvoip').checked ) {
+ if( $('customvoip_name').value.length == 0 ){
+ alert("Please enter a Comment for this Service Provider");
+ $('customvoip_name').focus();
+ return false;
+ }
+
+ if ( !$('customvoip_host').value ) {
+ alert("Please enter a host name");
+ $('customvoip_host').focus();
+ return false;
+ }
+ if ( !$('customvoip_username').value ) {
+ alert("Please enter a Username");
+ $('customvoip_username').focus();
+ return false;
+ }
+ }
+
+ if(!$('trunkstylevoip').checked && !$('trunkstyleanalog').checked && !$('trunkstylecustomvoip').checked ){
+ alert("A trunk must be Analog or VoIP or Custom VOIP");
+ return false;
+ }
if(isnewtrunk ==1){
+ try{
provider = $('provider').stored_config.catbyname[$('provider').value];
if( typeof provider.fieldbyname['trunk_username'] != "undefined" && $('trunkstylevoip').checked ){
$('name').value = provider.fieldbyname['trunk_username'];
+ }
+ }catch(e){
+
}
dids_array.push($('name').value );
}else{
@@ -259,10 +301,6 @@
$('hasexten').value = 'no';
$('context').value = asterisk_guiTDPrefix + $('name').value ;
if ($('trunkstylevoip').checked) {
- if (!$('username').value.length) {
- alert("When using VoIP, the username must not be empty!");
- return true;
- }
provider = $('provider').stored_config.catbyname[$('provider').value];
$('trunkname').value = $('provider').options[$('provider').selectedIndex].innerHTML + " - " + $('username').value;
$('hassip').value = provider.fieldbyname['hassip'];
@@ -308,15 +346,6 @@
$('group').value = '';
} else if ($('trunkstyleanalog').checked) {
// Analog
- if( $('zapchan').options.length ==0){
- alert("No analog line hardware installed on the system");
- return true;
- }
-
- if (!$('zapchan').value) {
- alert("When using Analog, at least one port must be selected.");
- return true;
- }
$('provider').selectedIndex = -1;
count = 0;
$('trunkname').value = "";
@@ -376,9 +405,6 @@
$('zapchan').options[x].selected = false;
$('zapchan').value = '';
$('group').value = '';
- }else{
- alert("A trunk must be Analog or VoIP or Custom VOIP");
- return true;
}
return false;
More information about the asterisk-gui-commits
mailing list