|
- // body onload
-
- var area1="";
- var area2="";
- var endspan="";
- function init_page(){
- area1 = getPar('area1');
- area2 = getPar('area2');
- endspan=getPar('endspan');
-
- // 清空按钮的样式
- for (var i=1;i<=9;i++) {
- var idname = 'li'+i;
- var libutton = document.getElementById(idname);
- libutton.style.color='#808080';
- libutton.style.backgroundColor='#FFFFFF';
- libutton.borderColor='#e2e2e2';
- libutton.borderWidth='2px';
- }
-
- var span=null;
- if(endspan!=""&&endspan!="false"){
- span = document.getElementById(endspan);
- }else{
- span = document.getElementById("li1");
- }
- span.style.color='#FFFFFF';
- span.style.backgroundColor='#00cc9c';
- span.style.borderColor='#00cc9c';
- span.style.borderStyle='solid';
-
- get_focus();
-
- }
- // 选中一个城市
- function m_get_target_area(li_id,area){
- area2 = area;
- // 用一个新的页面打开
- var listURL = "../index.html?area1="+area1+"&area2="+area2+'&endspan='+li_id;
- // 跳转前将URL编码
- listURL = encodeURI(listURL);
- window.location.href = listURL;
- }
- // 从上一页的链接上获取参数
- function getPar(par){
- //获取当前URL
- var local_url = document.location.href;
- // 接收的时候将URL 解码
- local_url = decodeURI(local_url);
- //获取要取得的get参数位置
- var get = local_url.indexOf(par +"=");
- if(get == -1){
- return false;
- }
- //截取字符串
- var get_par = local_url.slice(par.length + get + 1);
- //判断截取后的字符串是否还有其他get参数
- var nextPar = get_par.indexOf("&");
- if(nextPar != -1){
- get_par = get_par.slice(0, nextPar);
- }
- return get_par;
- }
-
- /*======================目的地的JS=======================*/
- // 文本框获得焦点
- function get_focus(){
- var search = document.getElementById("xsearch");
- search.focus();
- var m_cancel = document.getElementById("m_cancel");
- m_cancel.style.display='block';
- }
- // 改变了文本框的值
- function m_destination_change(){
- var destTextValue = document.getElementById("xsearch").value;
- var sy_destination = document.getElementById("sy_destination");
- var xreset = document.getElementById("xreset");
-
- // 如果是空格则返回
- if(destTextValue.trim().length==0){
- sy_destination.style.display = 'none';
- xreset.style.display='none';
- }else{
- xreset.style.display='block';
- sy_destination.style.display = 'block';
- var url = "http://xmwxc.zhizhuchuxing.cn/core/area_target.asp?keyword="+destTextValue;
- get_virtual_user_list(url);
- }
- }
- // 加载检索的
- function reload_sy_input(httpData){
- var sy_destination = document.getElementById("sy_destination");
- // 得到数据中的数据
- var area_list = httpData.area_list;
- var htmlStr = "";
- for (var i=0;i<area_list.length;i++) {
- htmlStr +='<div class="div_input" onclick="click_select('+'\''+area_list[i].area+'\''+')">'+area_list[i].area+'</div>';
- }
- sy_destination.innerHTML = htmlStr;
- }
- // 点击了检索的值
- function click_select(area){
- m_get_target_area(null,area);
- }
- // 点击了取消按钮
- function click_m_cancel(){
- // var dest = document.getElementById("m_destination");
- // dest.value = "";
- // var sy_destination = document.getElementById("sy_destination");
- // sy_destination.style.display = 'none';
- var listURL = "../index.html?area1="+area1+"&area2="+area2;
- // 跳转前将URL编码
- listURL = encodeURI(listURL);
- window.location.href = listURL;
-
-
- }
-
-
- /*======================网络请求的Ajax的代码=======================*/
-
- // 创建一个Ajax对象
- if (window.ActiveXObject){
- var myreq = new ActiveXObject("Microsoft.XMLHTTP");
- }else{
- var myreq = new XMLHttpRequest();
- }
- var isHot = true;
- // 请求方法,传入URL
- function get_virtual_user_list(myURL)
- {
- var tnowtime = getDateTime(4);
- // m_url = 接口
-
- // var myURL = m_url + 'op=userlink&vuser=' + cvuserid + '&tt=' + tnowtime;
- // var myURL = "http://xmwxc.zhizhuchuxing.cn/core/area_target.asp?keyword=";
- myreq.open("get",myURL,true);
- // 接收的数据交给哪个函数处理
- myreq.onreadystatechange = show_user_list;
- myreq.send();
- }
- function show_user_list()
- {
- if (myreq.readyState == 4)
- {
- // newstr 就是接收到的数据
- var newstr = myreq.responseText;
- var httpData=JSON.parse(newstr);
- reload_sy_input(httpData);
- }
- }
- function getDateTime(nTypeFlag)
- {
- var tNowTime = new Date();
- var myYear = ';' + tNowTime.getFullYear() + ';';
- var myMonth = ';' + (tNowTime.getMonth()+1-0) + ';';
- var myDay = ';' + tNowTime.getDate()+ ';';
- var myHour = ';' + tNowTime.getHours()+ ';';
- var myMinu = ';' + tNowTime.getMinutes()+ ';';
- var mySecond = ';' + tNowTime.getSeconds()+ ';';
-
- if (myMonth.length < 4) myMonth = '0' + myMonth;
- if (myDay.length < 4) myDay = '0' + myDay;
- if (myHour.length < 4) myHour = '0' + myHour;
- if (myMinu.length < 4) myMinu = '0' + myMinu;
- if (mySecond.length < 4) mySecond = '0' + mySecond;
-
- var cNewTimeStr;
- //alert(tNowTime);
- switch (nTypeFlag+1-1)
- {
- case 0:
- cNewTimeStr = myYear + '-' + myMonth + '-' + myDay;
- break;
- case 1:
- cNewTimeStr = myYear + myMonth + myDay;
- break;
- case 2:
- cNewTimeStr = myHour + ':' + myMinu + ':' + mySecond;
- break;
- case 3:
- cNewTimeStr = myHour + myMinu + mySecond;
- break;
- case 4:
- cNewTimeStr = myYear + myMonth + myDay + myHour + myMinu + mySecond;
- break;
- case 5:
- cNewTimeStr = myYear + '年' + myMonth + '月' + myDay + '日';
- break;
- case 6:
- cNewTimeStr = myYear;
- break;
- case 7:
- cNewTimeStr = myYear + '-' + myMonth;
- break;
- default:
- cNewTimeStr = myYear + '-' + myMonth + '-' + myDay + ' ' + myHour + ':' + myMinu + ':' + mySecond;
- break;
- }
-
- cNewTimeStr = cNewTimeStr.replace(/;/g,"");
-
- return cNewTimeStr;
-
- }
|