点击'save'按钮触发net_connect_pro_operate()函数
function net_connect_pro_operate()
{
var ck_sign = /^[^\<\>\'\",\\]{1,30}$/; //"Invalid characters, it must without , < > \" \' \\"
if(E("net_pro_whicih_op").value == "edit" || E("net_pro_whicih_op").value == "new")
{
if(E("net_connect_profile_name").value.length == 0)
{
E("net_connect_profile_name").focus();
alert(net_no_profile_name_alert);
return false;
}
var profile_name = E("net_connect_profile_name").value;
if (!ck_sign.test(profile_name)) //如果字符串 string 中含有与 RegExpObject 匹配的文本,则返回 true,
{
E("net_connect_profile_name").focus();
alert(net_invalid_profile_name_alert);
return false;
}
if(E("net_connect_user_name").value.length != 0)
{
var user_name = E("net_connect_user_name").value;
if (!ck_sign.test(user_name))
{
E("net_connect_user_name").focus();
alert(net_invalid_profile_name_alert);
return false;
}
}
if(E("net_connect_password").value.length != 0)
{
var user_password = E("net_connect_password").value;
if (!ck_sign.test(user_password))
{
E("net_connect_password").focus();
alert(net_invalid_profile_name_alert);
return false;
}
}
if(E("net_connect_apn").value.length == 0)
{
E("net_connect_apn").focus();
alert(net_no_profile_apn_alert);
return false;
}
var con_apn = E("net_connect_apn").value;
if (!ck_sign.test(con_apn))
{
E("net_connect_apn").focus();
alert(net_invalid_profile_name_alert);
return false;
}
if(!upkey_profile(E("net_connect_profile_name").value))
{
E("net_connect_profile_name").focus();
return false;
}
if(!upkey_user(E("net_connect_user_name").value))
{
E("net_connect_user_name").focus();
return false;
}
if(!upkey_password(E("net_connect_password").value))
{
E("net_connect_password").focus();
return false;
}
if(!upkey_apn(E("net_connect_apn").value))
{
E("net_connect_apn").focus();
return false;
}
E("probutton").disabled = true;
/* if(!checkNC(E("net_connect_user_name").value))
{
E("net_connect_user_name").focus();
return false;
}
if(!checkNC(E("net_connect_password").value))
{
E("net_connect_password").focus();
return false;
}
*/
/*
if(!checkAPN(E("net_connect_apn").value))
{
E("net_connect_apn").focus();
E("probutton").disabled = false;
return false;
}
*/
}
Home_ajax_submit("internet_ajax_pro_form"); //把数据提交给服务器submit
}
var options = {
beforeSubmit: showRequest,
success: showResponse //回调函数,
}
function Home_ajax_submit(which_form) //
{
$('#'+which_form).ajaxForm(options);
$('#'+which_form).submit(); //ajax数据提交
}
function showRequest(formData, jqForm, options)
{
$("#hide_div_show").show();
$('#net_pro_window').fadeOut(500);
$("#busy_show_txt").html(net_mode_operatprocess);
$("#busy_show_picture").fadeIn(2);
$("#busy_rndcontainer").fadeIn(2)
var queryString = $.param(formData);
return true;
}
function showResponse(responseText, statusText) //回调函数,当服务器返回数据完毕后,触发的函数
{
if(responseText == "ok")
{
$("#busy_show_txt").html(updateprofile);
clear_table_tr();
updage_prolist(); //更新APN列表
}
else if(responseText == "error")
{
$("#busy_show_txt").html(operatefaild);
$("#busy_show_picture").fadeOut(2);
//setTimeout('init_hoid_div()',2000);
setTimeout('clear_table_tr();updage_prolist();',2000);
}
else
{
alert(responseText);
$("#busy_show_txt").html(operateexit);
$("#busy_show_picture").fadeOut(2);
//setTimeout('init_hoid_div()',2000);
setTimeout('clear_table_tr();updage_prolist();',2000);
}
}
function updage_prolist() //从服务器中得到APN数据
{
$.ajax({
url: 'ajax_request?ajax_get_net_profile_list',
type: 'post',
complete: function (xhr) {
if(xhr.responseText == "" && xhr.responseText!=null)
{
$("#busy_show_txt").html(net_mode_noexpandapn);
$("#busy_show_picture").fadeOut(2);
setTimeout('init_hoid_div()',2000);
}
else if(xhr.responseText != ""&& xhr.responseText!=null)
{
$("#busy_rndcontainer").fadeOut(200)
$("#hide_div_show").hide(2);
nvram.net_pro_list = xhr.responseText; //得到从服务器得到的数据:"a,0,1,b,c,1234,4>a,0,1,b,c,1234,4"
int_pro_list(); //初始化APN列表
}
else
{
$("#busy_show_txt").html(net_mode_requestfaild);
$("#busy_show_picture").fadeOut(2);
setTimeout('init_hoid_div()',2000);
}
}
});
}
function int_pro_list() //初始化APN列表
{
var iapn = 0;
$("#tb_con_pro_list tr").removeClass("tr_tr_select");
$("#tb_con_pro_list tr").addClass("tr_tr_unselect");
$("#por_list_edit").removeClass("wwz_button_other");
$("#por_list_delete").removeClass("wwz_button_other");
$("#por_list_setdefault").removeClass("wwz_button_other");
$("#por_list_new").removeClass("wwz_button_other");
$("#por_list_edit").removeClass("wwz_button_disable");
$("#por_list_delete").removeClass("wwz_button_disable");
$("#por_list_setdefault").removeClass("wwz_button_disable");
$("#por_list_new").removeClass("wwz_button_disable");
$("#por_list_edit").addClass("wwz_button_disable");
$("#por_list_delete").addClass("wwz_button_disable");
$("#por_list_setdefault").addClass("wwz_button_disable");
$("#por_list_new").addClass("wwz_button_disable");
$("#por_list_edit").attr("disabled",true);
$("#por_list_setdefault").attr("disabled",true);
$("#por_list_delete").attr("disabled",true);
$("#por_list_new").attr("disabled",true);
var s = nvram.net_pro_list.split('>');
for (var i = 0; i < s.length; ++i)
{
var t = s[i].split(',');
if (t.length == 7)
{
iapn++;
var id = "pro_"+t[1]+"_"+t[2];
if(t[1] == "1")
{
E("net_pro_selseted").value = t[2];
}
var css = "tr_tr_unselect";
var img_d = "";
var img_s = "";
if(t[1] == "1")
{
css = "tr_tr_select";
img_d = "<img src=\"../images/duihao.png\" width=\"20\" height=\"20\" />";
$("#por_list_edit").removeClass("wwz_button_disable");
$("#por_list_edit").addClass("wwz_button_other");
$("#por_list_edit").attr("disabled",false);
}
t[0] = img_s + t[0] ;
insert_to_table(img_d,t[0],id,css,t[7]); //增加一条新tr
}
}
if(iapn < apn_nunmber)
{
$("#por_list_new").removeClass("wwz_button_disable");
$("#por_list_new").addClass("wwz_button_other");
$("#por_list_new").attr("disabled",false);
}
}
function insert_to_table(t1,t2,id,css)
{
var table_html = "<tr class=\""+css+"\" οnclick=\"selset_pro(this)\" id=\""+id+"\"><td width=\"25%\" align=\"center\" >"+t1+"</td><td width=\"75%\" align=\"left\">"+t2+"</td></tr>";
$("#tb_con_pro_list").append(table_html);
}