pari: branch asterisknow r362 - /branches/asterisknow/config/setup/10.html

asterisk-gui-commits at lists.digium.com asterisk-gui-commits at lists.digium.com
Mon Feb 19 10:56:41 MST 2007


Author: pari
Date: Mon Feb 19 11:56:40 2007
New Revision: 362

URL: http://svn.digium.com/view/asterisk-gui?view=rev&rev=362
Log:
fixing problems with registration form

Modified:
    branches/asterisknow/config/setup/10.html

Modified: branches/asterisknow/config/setup/10.html
URL: http://svn.digium.com/view/asterisk-gui/branches/asterisknow/config/setup/10.html?view=diff&rev=362&r1=361&r2=362
==============================================================================
--- branches/asterisknow/config/setup/10.html (original)
+++ branches/asterisknow/config/setup/10.html Mon Feb 19 11:56:40 2007
@@ -8,10 +8,66 @@
 <SCRIPT LANGUAGE="JavaScript">
 <!--
 var rawman_url;
-var usercallbacks = new Object;
-var fieldnames = new Array( 'save','userbase','localextenlength');
+var custinfo_callbacks = new Object;
+var fieldnames = new Array( 'status', 'new', 'save', 'cancel','name','cust_firstName','cust_lastName','cust_title','cust_company','cust_industry','cust_URL','cust_email',
+'cust_phone','cust_street','cust_city','cust_state','cust_zip','cust_country');
 var widgets = new Array;
 var custinfo_filename = "contactinfo.conf" ;
+var custinfo_context = "Myinfo";
+
+function loadcustinfo(){
+		for (var x =0; x < fieldnames.length; x++ ) {
+			widgets[fieldnames[x]] = $(fieldnames[x]);
+			widgets[fieldnames[x]].disabled = true;
+		}
+		parent.astmanEngine.config2list( custinfo_filename, $('select_custinfo'), widgets, custinfo_callbacks);
+	
+}
+
+custinfo_callbacks.format = function(t){
+		if ( t.name == custinfo_context  )
+			return t.name;
+	return null;
+}
+
+
+custinfo_callbacks.loaded= function(){
+	// if there is no "Myinfo" - create a new context 
+		if( $('select_custinfo').length == 0 ){
+			$('new').click();
+			$('name').value = custinfo_context ;
+		}else{
+			$('select_custinfo').selectitem(0);
+		}
+		$('registration').style.display="";
+}
+
+custinfo_callbacks.savechanges= function(){
+			$('retURL').value = window.location.href + "?registered" ;
+			document.getElementById("form1").submit();
+			$('registration').style.display='none';
+			$('status_message').style.display= "";
+}
+
+function save_userdetails(){
+		var requiredfields = {'cust_firstName': "First Name", 'cust_lastName': "Last Name" , 'cust_email' : "Email" , 'cust_phone':"Phone" , 'cust_country' :"Country" } ;
+		for(var i in requiredfields ){
+				if( requiredfields.hasOwnProperty(i) && $(i).value == ""  ){
+						alert( " Please enter your " + requiredfields[i] );
+						$(i).focus();
+						return false;
+				}
+
+		}
+		if( $('save').disabled ){
+			$('registration').style.display='none';
+			$('status').innerHTML = "<i> No Changes made!! </i>";
+			parent.$('next').disabled = false;
+		}else{
+			$('save').click();
+		}
+}
+
 
 function localinit(){
 	parent.$('next').disabled = true;
@@ -47,61 +103,10 @@
 						$('registration').style.display='none';
 						$('usermessage').innerHTML = "You have been registered succesfully !! ";
 					}else{
-							parent.astmanEngine.run_tool("/bin/touch /etc/asterisk/"+custinfo_filename ,	function(){	 $('registration').style.display='';} );				
+						$('usermessage').innerHTML = "<A href=# onclick=\"$('registration').style.display='';\">Register AsteriskNOW</A>";
+							parent.astmanEngine.run_tool("/bin/touch /etc/asterisk/"+custinfo_filename ,	loadcustinfo );				
 					}
 			}
-}
-// submit to  using POST
-
-
-
-function post_userdetails(){
-
-	var requiredfields = [ 'cust_firstName', 'cust_lastName', 'cust_email', 'cust_phone', 'cust_country' ];
-	for(var i=0; i < requiredfields.length ; i++ ){
-		if ( $(requiredfields[i]).value == "" ){
-			alert( " Please enter your " + requiredfields[i] );
-			$(requiredfields[i]).focus();
-			return false;
-		}
-	}
-	parent.astmanEngine.run_tool("/bin/touch /etc/asterisk/"+custinfo_filename , save_info );
-}
-
-
-function save_info(){
-		
-		var opt = {
-			method: 'get',
-			asynchronous: true,
-			onSuccess: function(t) { 
-						$('retURL').value = window.location.href + "?registered" ;
-						document.getElementById("form1").submit();
-						$('registration').style.display='none';
-						$('status_message').style.display= "";
-			},
-			onFailure: function(t) {
-				alert("Config Error: " + t.status + ": " + t.statusText);
-			}
-		};
-		var p =0;
-		var uri = build_action('newcat', p, "MyInfo","", "");  p++;
-		uri += build_action('append', p, "MyInfo","cust_firstName", $('cust_firstName').value); p++;
-		uri += build_action('append', p, "MyInfo","cust_lastName", $('cust_lastName').value); p++;
-		uri += build_action('append', p, "MyInfo","cust_company", $('cust_company').value); p++;
-		uri += build_action('append', p, "MyInfo","cust_title", $('cust_title').value); p++;
-		uri += build_action('append', p, "MyInfo","cust_industry", $('cust_industry').value); p++;
-		uri += build_action('append', p, "MyInfo","cust_URL", $('cust_URL').value); p++;
-		uri += build_action('append', p, "MyInfo","cust_email", $('cust_email').value); p++;
-		uri += build_action('append', p, "MyInfo","cust_phone", $('cust_phone').value); p++;
-		uri += build_action('append', p, "MyInfo","cust_street", $('cust_street').value); p++;
-		uri += build_action('append', p, "MyInfo","cust_city", $('cust_city').value); p++;
-		uri += build_action('append', p, "MyInfo","cust_state", $('cust_state').value); p++;
-		uri += build_action('append', p, "MyInfo","cust_zip", $('cust_zip').value); p++;
-		uri += build_action('append', p, "MyInfo","cust_country", $('cust_country').value); p++;
-		
-		opt.parameters ="action=updateconfig&reload=yes&srcfilename=" + encodeURIComponent(custinfo_filename) + "&dstfilename=" + encodeURIComponent(custinfo_filename) + uri;
-		var tmp = new Ajax.Request(rawman_url, opt);
 }
 
 //-->
@@ -131,12 +136,13 @@
 				<div class="heading"> Finish</div>
 				<div class="subheading">
 				Congratulations You have sucessfully configured your Asterisk installation<BR></div>
+				
 <form id="form1" action="https://asterisknow.digium.com/register" method="POST">
 <div id="registration" STYLE="display:none; position: absolute; left: 180; top: 80; width:600; height:300;  background-color:#F4EFE5;   border-width: 1px; border-color: #7E5538; border-style: solid;z-index:5">
 	<table width="100%" cellpadding=0 cellspacing=0>
 		<TR bgcolor="#7E5538" >
 				<TD  onmousedown="startDrag(event , 'registration');" id="registration_title" style="cursor: move;color:#FFFFFF; font-size: 12px; font-weight:bold;" align="center">Register AsteriskNOW with Digium</TD>
-				<TD Height="20" width=15 align="center"  style="color:#FFFFFF; font-size: 12px; font-weight:bold;" onclick="$('cancel').click();">X</TD>
+				<TD Height="20" width=15 align="center"  style="color:#FFFFFF; font-size: 12px; font-weight:bold;" onclick="$('registration').style.display='none';">X</TD>
 		</TR>
 	</table>
 <TABLE width=590 cellpadding=1 cellspacing=2 border=0>
@@ -228,14 +234,22 @@
 		<input type="hidden" id="lead_source" name="lead_source" value="leadID"> 
 		<input type="button" value="Skip" onclick="parent.$('next').disabled = false; $('registration').style.display='none';">
 		&nbsp;&nbsp;
-		<input type="button" value="Register AsteriskNOW with Digium" onclick="post_userdetails()">
+		<input type="button" value="Register AsteriskNOW with Digium" onclick="save_userdetails()">
 	</TD>
 </TR>
 </TABLE>
 </div>
 </form>
 			<BR><BR><BR><DIV id="usermessage"></div>
-
+			<div id="status"></div>
+
+			<div style="display:none">
+				<select id="select_custinfo"></select>
+				<input type="button" id="new" value="New">
+				<input type="button" id="save" value="Save">
+				<input type="button" id="cancel" value="Cancel">
+				<input id="name">
+			</div>
 
 		<div ID="status_message"  STYLE="display:none; position: absolute; left: 170; top: 190; width:350; height:115;  background-color:#F4EFE5;   border-width: 1px; border-color: #7E5538; border-style: solid;">
 			<BR><BR>



More information about the asterisk-gui-commits mailing list