function loading(msg="")
{
if(msg=="")
{
msg="正在處理中...";
}
$.blockUI({ message: '
'+msg+'
' });
}
function unLoading()
{
$.unblockUI();
}
function updateTotalPrice()
{
var r = /^\+?[1-9][0-9]*$/;
var product_num=$("#product_num").val();
if(!r.test(product_num))
{
alert("數量請輸入正整數");
return;
}
$("#total_price").html(product_price*parseInt(product_num));
$("#points_sum").html(points_num*parseInt(product_num));
}
function updateTotalPriceEn()
{
var r = /^\+?[1-9][0-9]*$/;
var product_num=$("#product_num").val();
if(!r.test(product_num))
{
alert("數量請輸入正整數");
return;
}
var price=product_price/exchangeRate;
$("#total_price").html(Math.round(price * 10) / 10*parseInt(product_num));
$("#points_sum").html(product_price*parseInt(product_num));
}
function upgradeFunction( ecu_number,function_id)
{
loading("正在處理中...");
$.post("/en/member/upgrade-ecu.html",{"ecu_number":ecu_number,"function_id":function_id, "_csrf": $("#crsf_token_id").val()},function(data){
$.unblockUI();
if(data.msg!="點數不足,需要充值")
alert(data.msg);
unLoading();
if(data.status==1)
{
//location.reload();
location.href="/en/update_successed.html";
}
if(data.status==0 && data.msg=="點數不足,需要充值")
{
// $.colorbox.close();
$("#rest_points").html(data.rest_points);
$.colorbox({inline:true, href:$("#confirm_buy_box")});
}
},"json")
}
function confirmUpgrade(ecu_number,function_id,point_num,product_name,functionStr)
{
$.get("/member/is-active.html",function(data){
var json=eval("("+data+")");
if(json.is_active==0)
{
alert("Please check the email in your mailbox to activate your account!");
}
if(json.is_active==1)
{
if(member_point_num>=point_num)
{
$("#buy_ecu_number").html(ecu_number);
$("#need_points").html(point_num);
$("#buy_prodict_name").html(product_name);
$("#buy_function_desc").html(decodeURI(functionStr));
$("#confirm_to_upgrade_btn").html(' ');
$.colorbox({inline:true, href:$("#confirm_to_upgrade"),"overlayClose":false});
}
else
{
$("#rest_points").html(point_num-member_point_num);
$.colorbox({"overlayClose":false,inline:true, href:$("#confirm_buy_box")});
}
}
});
}
//00
function addFunction()
{
var function_ids=($("#function_id").val());
if(function_ids=="" || function_ids==null)
{
alert("請選擇要增加的功能");
return;
}
function_ids=function_ids+"";
if(function_ids!="")
{
var arr=function_ids.split(',');
for(var i=0;i");
}
}
$("#search_form").append("");
$("#search_form").submit();
}
}
function removeThisFunction(obj)
{
$(obj).parent().remove();
$("#search_form").append("");
$("#search_form").submit();
}