
﻿
lebi.chaxun.index={title:"实用查询工具大全",cookieName:"lebi_chaxun_index",order:["item_sjgsd","item_tq","item_hcp","item_sfz","item_ipdz","item_zxfy"],initialize:function(){var text=$("#txt_google_source").val();if(!$.trim(text)){alert("请输入内容");$("#txt_google_source").focus();return false;}
var maxLen=1402,prefix="";if(encodeURIComponent(text).length>maxLen)prefix="由于您输入的内容过多，部分翻译内容被截断，以下是翻译的正文：\n\n";(function(){try{encodeText=encodeURIComponent(text).substr(0,maxLen)
text=decodeURIComponent(encodeText);}catch(e){maxLen--;arguments.callee();}})();var sel_google_source=$("#sel_google_source").val();var sel_google_result=$("#sel_google_result").val();google.language.translate(text,sel_google_source,sel_google_result,function(result){var translated=$("#txt_google_result");if(result.translation){translated.val(prefix+result.translation);$("#btnSubmit1").removeAttr("disabled").val("翻译");}});},_setOrder:function(order){var _this=this,doms=[];for(var key in order){doms.push($("#"+order[key]).clone(true));$("#"+order[key]).remove();}
for(var dom in doms){$("#right .footbt").before(doms[dom]);}
$("#right .s1").show();$("#stloading").hide();},_getOrder:function(){var re=[];$("#right .s1").each(function(){re.push($(this).attr("id"));});return re;},_saveOrder:function(){lebi.chaxun.setCookie(this.cookieName,lebi.chaxun.obj2str(this._getOrder()));},bindEvents:function(){var _this=this;google.load("language","1");$("#btnSubmit1").click(function(){$(this).attr("disabled",true).val("翻译中..");_this.initialize();});$("#right .godown").click(function(){var $sItem=$(this).parents(".s1");var $currItem=$sItem.clone(true);var $next=$sItem.next(".s1");if($next.length){$next.after($currItem);$sItem.remove();_this._saveOrder();}
return false;});$("#right .goup").click(function(){var $sItem=$(this).parents(".s1");var $currItem=$sItem.clone(true);var $prev=$sItem.prev(".s1");if($prev.length){$prev.before($currItem);$sItem.remove();_this._saveOrder();}
return false;});$(_this.order).each(function(){$("#"+this+" form").bind("submit",function(){var re=true,list=$(this).find(".required");for(var i=0;i<list.length;i++){var v=$.trim($(list[i]).val());if(!v){alert("请输入内容");$(list[i]).focus();re=false;break;}}
return re;});});$(".btnChakan").click(function(){var url="http://chaxun.lebi.cn/weather.htm?city=";url+=encodeURIComponent($(this).prev("select").val());window.open(url);});$("#btnSubmit_ip").click(function(){$("#auswer_ip .answer").empty();var v=$.trim($("#txt_ip").val());if(!v){$("#auswer_ip .answer:eq(0)").html(lebi.chaxun.errorText("请输入IP地址或域名"));return false;}
$("#auswer_ip .answer:eq(0)").html("正在查询……");$.getScript("http://chaxun.1616.net/s.php?type=ip&v="+encodeURIComponent(v)+"&output=json&callback=lebi.chaxun.index.callback_ip");});$("#txt_ip").keyup(function(e){e=e||window.event;if(e.keyCode==13){$("#btnSubmit_ip").click();}});$("#google_huhuan").click(function(){var from=[$("#sel_google_source").text(),$("#sel_google_source").val()],to=[$("#sel_google_result").text(),$("#sel_google_result").val()];$("#sel_google_source option").removeAttr("selected");$("#sel_google_source option[value="+to[1]+"]").attr("selected","selected");$("#sel_google_result option").removeAttr("selected");$("#sel_google_result option[value="+from[1]+"]").attr("selected","selected");});},fillData_ip:function(j,k){if(k){$("#auswer_ip .answer:eq(0)").html(j.Ip+"["+k+"]");}else{$("#auswer_ip .answer:eq(0)").html(j.Ip);}
$("#auswer_ip .answer:eq(1)").html(j.Isp);},callback_ip:function(j){switch(j.QueryResult){case 0:$("#auswer_ip .answer:eq(0)").html(lebi.chaxun.errorText("请输入正确的IP地址或域名"));break;case 1:this.fillData_ip(j);break;case 2:$("#auswer_ip .answer:eq(0)").html(lebi.chaxun.errorText("火星IP或域名，没找到"));break;case 3:$("#auswer_ip .answer:eq(0)").html(lebi.chaxun.errorText("内部错误，请重试"));break;case 4:$("#auswer_ip .answer:eq(0)").html(lebi.chaxun.errorText("发生错误，请重试"));break;}},callback_ip_:function(j){switch(j.QueryResult){case 0:$("#auswer_ip .answer:eq(0)").html(lebi.chaxun.errorText("请输入正确的IP地址或域名"));break;case 1:this.fillData_ip(j,"本机地址");break;case 2:$("#auswer_ip .answer:eq(0)").html(lebi.chaxun.errorText("火星IP或域名，没找到"));break;case 3:$("#auswer_ip .answer:eq(0)").html(lebi.chaxun.errorText("内部错误，请重试"));break;case 4:$("#auswer_ip .answer:eq(0)").html(lebi.chaxun.errorText("发生错误，请重试"));break;}},weatherInit:function(){var $citys=$(lebi_weather_citys);_fillSel($citys.filter(function(){return(this.i===0)}),$citys.filter(function(){return(this.i===1)}));function _makeProvinces($items){var provs={};$items.each(function(){var t=this.pv[0],q=this.pv[1];if(typeof provs[t]=='undefined')
provs[t]=q;});for(var key in provs){var s=provs[key];provs[key]=[$items.filter(function(){return this.pv[0]==key}),s];}
var newProvs={},i=0,tmpArr=[];for(var k in provs){tmpArr[i]=[k,provs[k]];i++;}
tmpArr.sort(function(a,b){return a[1][1].charCodeAt(0)-b[1][1].charCodeAt(0)});$(tmpArr).each(function(){newProvs[this[0]]=this[1];});return newProvs;}
function _makeContinents($items){var provs={};$items.each(function(){var t=this.ct;if(typeof provs[t]=='undefined')
provs[t]=1;});for(var key in provs){provs[key]=[$items.filter(function(){return this.ct==key}),""];}
return provs;}
function _fillSel($citys,$continents){var a="",b="",c="",d="",tmps1=_makeProvinces($citys),tmps2=_makeContinents($continents);for(var key in tmps1){a+="<option value=\""+key+"\" "+(key=="直辖市"?"selected=\"true\"":"")+">"+tmps1[key][1]+" "+key+"</option>"};$(tmps1["直辖市"][0]).each(function(){b+="<option value='"+this.n+"'>"+this.py.substr(0,1)+" "+this.n+"</option>"});for(var key in tmps2){c+="<option value=\""+key+"\" "+(key=="亚洲"?"selected=\"selected\"":"")+">"+tmps2[key][1]+" "+key+"</option>"};$(tmps2["亚洲"][0]).each(function(){d+="<option value='"+this.n+"'>"+this.py.substr(0,1)+" "+this.n+"</option>"});$('.unOverSeas_province').html(a);setTimeout(function(){$('.unOverSeas_province').find("option[value='直辖市']").attr("selected","selected");},1);$('.unOverSeas_city').html(b);$('.overSeas_continent').html(c);$('.overSeas_city').html(d);$('.unOverSeas_province').bind("change",function(){_s(tmps1,$(this))});$('.overSeas_continent').bind("change",function(){_s(tmps2,$(this))});function _s(tmps,$this){var t=tmps[$this.val()][0];var d="";for(var i=0;i<t.length;i++){d+="<option value='"+t[i].n+"'>"+t[i].py.substr(0,1)+" "+t[i].n+"</option>";}
$this.next("select").html(d);}}},init:function(){if(lebi.chaxun.getCookie(this.cookieName))
this.order=lebi.chaxun.str2obj(lebi.chaxun.getCookie(this.cookieName));$.getScript("http://chaxun.1616.net/s.php?type=ip&v=&output=json&callback=lebi.chaxun.index.callback_ip_");this.weatherInit();this.bindEvents();this._setOrder(this.order);}};lebi.chaxun.index.init();