Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.
 
 
 
 
 

206 rindas
5.6 KiB

  1. // body onload
  2. var area1="";
  3. var area2="";
  4. var endspan="";
  5. function init_page(){
  6. area1 = getPar('area1');
  7. area2 = getPar('area2');
  8. endspan=getPar('endspan');
  9. // 清空按钮的样式
  10. for (var i=1;i<=9;i++) {
  11. var idname = 'li'+i;
  12. var libutton = document.getElementById(idname);
  13. libutton.style.color='#808080';
  14. libutton.style.backgroundColor='#FFFFFF';
  15. libutton.borderColor='#e2e2e2';
  16. libutton.borderWidth='2px';
  17. }
  18. var span=null;
  19. if(endspan!=""&&endspan!="false"){
  20. span = document.getElementById(endspan);
  21. }else{
  22. span = document.getElementById("li1");
  23. }
  24. span.style.color='#FFFFFF';
  25. span.style.backgroundColor='#00cc9c';
  26. span.style.borderColor='#00cc9c';
  27. span.style.borderStyle='solid';
  28. get_focus();
  29. }
  30. // 选中一个城市
  31. function m_get_target_area(li_id,area){
  32. area2 = area;
  33. // 用一个新的页面打开
  34. var listURL = "../index.html?area1="+area1+"&area2="+area2+'&endspan='+li_id;
  35. // 跳转前将URL编码
  36. listURL = encodeURI(listURL);
  37. window.location.href = listURL;
  38. }
  39. // 从上一页的链接上获取参数
  40. function getPar(par){
  41. //获取当前URL
  42. var local_url = document.location.href;
  43. // 接收的时候将URL 解码
  44. local_url = decodeURI(local_url);
  45. //获取要取得的get参数位置
  46. var get = local_url.indexOf(par +"=");
  47. if(get == -1){
  48. return false;
  49. }
  50. //截取字符串
  51. var get_par = local_url.slice(par.length + get + 1);
  52. //判断截取后的字符串是否还有其他get参数
  53. var nextPar = get_par.indexOf("&");
  54. if(nextPar != -1){
  55. get_par = get_par.slice(0, nextPar);
  56. }
  57. return get_par;
  58. }
  59. /*======================目的地的JS=======================*/
  60. // 文本框获得焦点
  61. function get_focus(){
  62. var search = document.getElementById("xsearch");
  63. search.focus();
  64. var m_cancel = document.getElementById("m_cancel");
  65. m_cancel.style.display='block';
  66. }
  67. // 改变了文本框的值
  68. function m_destination_change(){
  69. var destTextValue = document.getElementById("xsearch").value;
  70. var sy_destination = document.getElementById("sy_destination");
  71. var xreset = document.getElementById("xreset");
  72. // 如果是空格则返回
  73. if(destTextValue.trim().length==0){
  74. sy_destination.style.display = 'none';
  75. xreset.style.display='none';
  76. }else{
  77. xreset.style.display='block';
  78. sy_destination.style.display = 'block';
  79. var url = "http://xmwxc.zhizhuchuxing.cn/core/area_target.asp?keyword="+destTextValue;
  80. get_virtual_user_list(url);
  81. }
  82. }
  83. // 加载检索的
  84. function reload_sy_input(httpData){
  85. var sy_destination = document.getElementById("sy_destination");
  86. // 得到数据中的数据
  87. var area_list = httpData.area_list;
  88. var htmlStr = "";
  89. for (var i=0;i<area_list.length;i++) {
  90. htmlStr +='<div class="div_input" onclick="click_select('+'\''+area_list[i].area+'\''+')">'+area_list[i].area+'</div>';
  91. }
  92. sy_destination.innerHTML = htmlStr;
  93. }
  94. // 点击了检索的值
  95. function click_select(area){
  96. m_get_target_area(null,area);
  97. }
  98. // 点击了取消按钮
  99. function click_m_cancel(){
  100. // var dest = document.getElementById("m_destination");
  101. // dest.value = "";
  102. // var sy_destination = document.getElementById("sy_destination");
  103. // sy_destination.style.display = 'none';
  104. var listURL = "../index.html?area1="+area1+"&area2="+area2;
  105. // 跳转前将URL编码
  106. listURL = encodeURI(listURL);
  107. window.location.href = listURL;
  108. }
  109. /*======================网络请求的Ajax的代码=======================*/
  110. // 创建一个Ajax对象
  111. if (window.ActiveXObject){
  112. var myreq = new ActiveXObject("Microsoft.XMLHTTP");
  113. }else{
  114. var myreq = new XMLHttpRequest();
  115. }
  116. var isHot = true;
  117. // 请求方法,传入URL
  118. function get_virtual_user_list(myURL)
  119. {
  120. var tnowtime = getDateTime(4);
  121. // m_url = 接口
  122. // var myURL = m_url + 'op=userlink&vuser=' + cvuserid + '&tt=' + tnowtime;
  123. // var myURL = "http://xmwxc.zhizhuchuxing.cn/core/area_target.asp?keyword=";
  124. myreq.open("get",myURL,true);
  125. // 接收的数据交给哪个函数处理
  126. myreq.onreadystatechange = show_user_list;
  127. myreq.send();
  128. }
  129. function show_user_list()
  130. {
  131. if (myreq.readyState == 4)
  132. {
  133. // newstr 就是接收到的数据
  134. var newstr = myreq.responseText;
  135. var httpData=JSON.parse(newstr);
  136. reload_sy_input(httpData);
  137. }
  138. }
  139. function getDateTime(nTypeFlag)
  140. {
  141. var tNowTime = new Date();
  142. var myYear = ';' + tNowTime.getFullYear() + ';';
  143. var myMonth = ';' + (tNowTime.getMonth()+1-0) + ';';
  144. var myDay = ';' + tNowTime.getDate()+ ';';
  145. var myHour = ';' + tNowTime.getHours()+ ';';
  146. var myMinu = ';' + tNowTime.getMinutes()+ ';';
  147. var mySecond = ';' + tNowTime.getSeconds()+ ';';
  148. if (myMonth.length < 4) myMonth = '0' + myMonth;
  149. if (myDay.length < 4) myDay = '0' + myDay;
  150. if (myHour.length < 4) myHour = '0' + myHour;
  151. if (myMinu.length < 4) myMinu = '0' + myMinu;
  152. if (mySecond.length < 4) mySecond = '0' + mySecond;
  153. var cNewTimeStr;
  154. //alert(tNowTime);
  155. switch (nTypeFlag+1-1)
  156. {
  157. case 0:
  158. cNewTimeStr = myYear + '-' + myMonth + '-' + myDay;
  159. break;
  160. case 1:
  161. cNewTimeStr = myYear + myMonth + myDay;
  162. break;
  163. case 2:
  164. cNewTimeStr = myHour + ':' + myMinu + ':' + mySecond;
  165. break;
  166. case 3:
  167. cNewTimeStr = myHour + myMinu + mySecond;
  168. break;
  169. case 4:
  170. cNewTimeStr = myYear + myMonth + myDay + myHour + myMinu + mySecond;
  171. break;
  172. case 5:
  173. cNewTimeStr = myYear + '年' + myMonth + '月' + myDay + '日';
  174. break;
  175. case 6:
  176. cNewTimeStr = myYear;
  177. break;
  178. case 7:
  179. cNewTimeStr = myYear + '-' + myMonth;
  180. break;
  181. default:
  182. cNewTimeStr = myYear + '-' + myMonth + '-' + myDay + ' ' + myHour + ':' + myMinu + ':' + mySecond;
  183. break;
  184. }
  185. cNewTimeStr = cNewTimeStr.replace(/;/g,"");
  186. return cNewTimeStr;
  187. }