$(function(){$.ajaxSetup({async:false,cache:false});$.ajaxSetup({async:true});CSWebApp.WebMain();});var CSWebApp={WebMain:function(){CSWebApp.InitEvent();CSWebApp.InitPage();CSWebApp.PreloadImg();},InitEvent:function(){CSWebApp.m_itemTemplate=$("#TR_Item_Template");CSWebApp.m_objTimer=$("#Span_TaskTimer");$("#Btn_StartSpeed").mouseover(function(){$(this).attr("src","images/button_hover.png");}).mouseout((function(){$(this).attr("src","images/button_normal.png");})).mousedown((function(){$(this).attr("src","images/button_down.png");})).mouseup((function(){$(this).attr("src","images/button_hover.png");})).click(CSWebApp.StartTest);$("#A_Top_Menu img").eq(1).hover(function(){$(this).attr("src","images/tab_hover_05.png");},function(){$(this).attr("src","images/tab_normal_05.png");});$("#A_Top_Menu img").eq(2).hover(function(){$(this).attr("src","images/tab_hover_07.png");},function(){$(this).attr("src","images/tab_normal_07.png");});$("#A_Top_Menu img").eq(3).hover(function(){$(this).attr("src","images/tab_hover_09.png");},function(){$(this).attr("src","images/tab_normal_09.png");});$(window).unload(CSWebApp.Unload);},InitPage:function(){},Unload:function(){},PreloadImg:function(){},StartTest:function(){var url=$.trim($("#Text_TestUrl").val());var bUrl=CSWebApp.CheckUrl(url);if(!bUrl){alert("请输入有效的网址！");$("#Text_TestUrl").focus().select();return;}$("#Table_Test_Index").hide();$("#Table_Test_Page").show();$("#TR_Loading").show();$("#TR_Finished").hide().next().hide();$("#Btn_StartSpeed").attr("disabled","true").attr("src","images/button_bky.png");$("#Text_TestUrl").attr("disabled","true");CSWebApp.m_itemCount=0;CSWebApp.m_timeSecond=0;CSWebApp.m_itemTemplate.prevAll("[name=datalist]").remove();CSWebApp.m_timerId=setInterval(CSWebApp.TaskTimer,100);},TaskTimer:function(){if(CSWebApp.m_timeSecond>=CSWebApp.m_timerMax){clearInterval(CSWebApp.m_timerId);CSWebApp.m_timerId=0;CSWebApp.StopTest();}if(0==((CSWebApp.m_timeSecond*10)%parseInt(Math.random()*10))){var newTR=CSWebApp.m_itemTemplate.clone();if(CSWebApp.m_itemCount%2){newTR.children(1).css("background-color","#f1f4ff");}else{newTR.children(1).css("background-color","#f7f8fb");}newTR.find("tbody").eq(0).children().eq(1).children().eq(0).html(++CSWebApp.m_itemCount);newTR.find("tbody").eq(0).children().eq(1).children().eq(6).find("a").click(CSWebApp.MoreMessage);CSWebApp.m_itemTemplate.before(newTR);newTR.show();}CSWebApp.m_timeSecond+=0.1;CSWebApp.m_objTimer.html(CSWebApp.m_timeSecond.toFixed(1));},StopTest:function(){$("#TR_Loading").hide();$("#TR_Finished").show().next().show();$("#Btn_StartSpeed").removeAttr("disabled").attr("src","images/button_normal.png");$("#Text_TestUrl").removeAttr("disabled");alert("未能收集到有效数据，请先使用“测速快车”进行单点测速！");document.location="software.php";},CheckUrl:function(url){if(((0!=url.indexOf("http://"))&&(0!=url.indexOf("https://")))||(url.length<11)){return false;}else{return true;}},MoreMessage:function(){var objMsg=$(this).parent().parent().next();if("none"==objMsg.css("display")){$(this).html("隐藏");}else{$(this).html("查看");}objMsg.toggle();},m_itemTemplate:{},m_itemCount:0,m_timerMax:10,m_timerId:0,m_timeSecond:0,m_objTimer:{}}
