index.html 61 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8" />
  5. <link href="../lib/main.css" rel="stylesheet" />
  6. <script src="../public/js/jquery.js"></script>
  7. <script src="../public/js/comm.js"></script>
  8. <script src="jquery-3.3.1.min.js"></script>
  9. <script src="julian.js"></script>
  10. <script src="lune.js"></script>
  11. <script src="suncalc.js"></script>
  12. <script src="./planet_position/js/planet-positions.js"></script>
  13. <script src="city_15000.js"></script>
  14. <script src="../studio/js/fixedsticky.js"></script>
  15. <script src="../guide/guide.js"></script>
  16. <link type="text/css" rel="stylesheet" href="../guide/guide.css" />
  17. <script src="../public/js/marked.js"></script>
  18. <!--获取语言-->
  19. <script>
  20. var g_language = getCookie("language");
  21. </script>
  22. <!--语言包-->
  23. <script>
  24. var localString = new Array();
  25. localString["zh-cn"] = {
  26. and_another: "又 ",
  27. atitude: "纬度",
  28. BE: "佛历",
  29. bhumma: "周二",
  30. budha: "周三",
  31. canda: "周一",
  32. confirm: "确认",
  33. date: "日期",
  34. day: "日",
  35. days: "天 ",
  36. departure_in_detail: "起飞详情",
  37. dhamma_time: "会延续五千年的教法 ",
  38. eat: "进餐",
  39. gama_entry: "入村",
  40. guru: "周四",
  41. hori_ref_time: "蒙气差修正 ",
  42. kala: "适当的时间",
  43. language_select: "选择语言",
  44. left: "还剩下",
  45. loading: "载入中……",
  46. longitude: "经度",
  47. māsa: "月",
  48. mins: "分钟",
  49. month: "月 ",
  50. month_1: "月 ",
  51. months: "个月 ",
  52. my_loc: "我的位置",
  53. need_inform: "未告知其他比库",
  54. no_string: "不能",
  55. noon_time: "正午",
  56. noon_time: "正午",
  57. note: "注释",
  58. now_time: "现在",
  59. pacchā_māsa: "下个月",
  60. pakkha: "月相变化 ",
  61. past: "已过去",
  62. pubba_māsa: "上个月",
  63. ravi: "周日",
  64. saṃvacchara: "年",
  65. season: "季节 ",
  66. sec: "秒",
  67. sora: "周六",
  68. sukka: "周五",
  69. sun_height_degree: "正午太阳高度 ",
  70. time: "时间",
  71. twilight_time: "曙光",
  72. twilight_time: "曙光",
  73. vikala: "不适当的时间",
  74. week_day: "星期",
  75. year_0: "年",
  76. year_1: "年 ",
  77. years: "年 ",
  78. yes_string: "可以",
  79. timezone: "时区",
  80. local: "本地",
  81. loading: "载入中",
  82. sun_set: "日落",
  83. unknown: "未知",
  84. altitude: "海拔",
  85. today: "今天",
  86. week: "周",
  87. list: "列表",
  88. location: "所在地",
  89. city_name: "城市名",
  90. };
  91. localString["zh-tw"] = {
  92. and_another: "又 ",
  93. atitude: "緯度",
  94. BE: "佛曆",
  95. bhumma: "週二",
  96. budha: "週三",
  97. canda: "週一",
  98. confirm: "確認",
  99. date: "日期",
  100. day: "日",
  101. days: "天 ",
  102. departure_in_detail: "起飛詳情",
  103. dhamma_time: "會延續五千年的教法 ",
  104. eat: "進餐",
  105. gama_entry: "入村",
  106. guru: "週四",
  107. hori_ref_time: "蒙氣差修正 ",
  108. kala: "適當的時間",
  109. language_select: "選擇語言",
  110. left: "還剩下",
  111. loading: "載入中……",
  112. longitude: "經度",
  113. māsa: "月",
  114. mins: "分鐘",
  115. month: "月 ",
  116. month_1: "月 ",
  117. months: "個月 ",
  118. my_loc: "我的位置",
  119. need_inform: "未告知其他比庫",
  120. no_string: "不能",
  121. noon_time: "正午",
  122. noon_time: "正午",
  123. note: "註釋",
  124. now_time: "現在",
  125. pacchā_māsa: "下個月",
  126. pakkha: "月相變化 ",
  127. past: "已過去",
  128. pubba_māsa: "上個月",
  129. ravi: "週日",
  130. saṃvacchara: "年",
  131. season: "季節 ",
  132. sec: "秒",
  133. sora: "週六",
  134. sukka: "週五",
  135. sun_height_degree: "正午太陽高度 ",
  136. time: "時間",
  137. twilight_time: "曙光",
  138. twilight_time: "曙光",
  139. vikala: "不適當的時間",
  140. week_day: "星期",
  141. year_0: "年",
  142. year_1: "年 ",
  143. years: "年 ",
  144. yes_string: "可以",
  145. timezone: "時區",
  146. local: "本地",
  147. loading: "載入中",
  148. sun_set: "日落",
  149. unknown: "未知",
  150. altitude: "海拔",
  151. today: "今天",
  152. week: "周",
  153. list: "列表",
  154. location: "所在地",
  155. city_name: "城市名",
  156. };
  157. localString["default"] = {
  158. and_another: " and ",
  159. atitude: "Atitude",
  160. BE: "Buddhist Era ",
  161. bhumma: "Bhumma",
  162. budha: "Budha",
  163. canda: "Canda",
  164. confirm: "Confirm",
  165. date: "Date ",
  166. day: " day(s) ",
  167. days: " day(s) ",
  168. departure_in_detail: "departure in detail",
  169. dhamma_time: "5000 Years of the Buddha’s Dispensation ",
  170. eat: "eat",
  171. gama_entry: "entry the village",
  172. guru: "Guru",
  173. hori_ref_time: "horizontal refraction correct ",
  174. kala: "suitable time",
  175. language_select: "bhāsā",
  176. left: "Remains ",
  177. loading: "loading…",
  178. longitude: "Longitude",
  179. māsa: "māsa",
  180. mins: "(min)",
  181. month: "Month ",
  182. month_1: "- ",
  183. months: " month(s) ",
  184. my_loc: "attasmiṃ",
  185. need_inform: "without informing other Bhikkhu ",
  186. no_string: "cannot ",
  187. noon_time: "NOON",
  188. noon_time: "NOON",
  189. note: "Note",
  190. now_time: "NOW",
  191. pacchā_māsa: "pacchā-māsa",
  192. pakkha: "Lunar Phases ",
  193. past: "Passed ",
  194. pubba_māsa: "pubba-māsa",
  195. ravi: "Ravi",
  196. saṃvacchara: "saṃvacchara",
  197. season: "Season ",
  198. sec: "sec ",
  199. sora: "Sora",
  200. sukka: "Sukka",
  201. sun_height_degree: "Max solar altitude ",
  202. time: "Time",
  203. twilight_time: "dawn",
  204. twilight_time: "dawn",
  205. vikala: "unsuitable time",
  206. week_day: "Day",
  207. year_0: "saṃvacchara",
  208. year_1: "- ",
  209. years: " year(s) ",
  210. yes_string: "can ",
  211. timezone: "Timezone",
  212. local: "local",
  213. loading: "loading",
  214. sun_set: "sunset",
  215. unknown: "unknown",
  216. altitude: "Altitude",
  217. today: "today",
  218. week: "week",
  219. list: "list",
  220. location: "location",
  221. city_name: "city name",
  222. };
  223. localString["en"] = {
  224. and_another: " and ",
  225. atitude: "Atitude",
  226. BE: "Buddhist Era ",
  227. bhumma: "Bhumma",
  228. budha: "Budha",
  229. canda: "Canda",
  230. confirm: "Confirm",
  231. date: "Date",
  232. day: " day(s) ",
  233. days: " day(s) ",
  234. departure_in_detail: "departure in detail",
  235. dhamma_time: "5000 Years of the Buddha’s Dispensation ",
  236. eat: "eat",
  237. gama_entry: "entry the village",
  238. guru: "Guru",
  239. hori_ref_time: "horizontal refraction correct ",
  240. kala: "suitable time",
  241. language_select: "Language",
  242. left: "Remains ",
  243. loading: "loading…",
  244. longitude: "Longitude",
  245. māsa: "māsa",
  246. mins: "(min)",
  247. month: "Month ",
  248. month_1: "- ",
  249. months: " month(s) ",
  250. my_loc: "my location",
  251. need_inform: "without informing other Bhikkhu ",
  252. no_string: "cannot ",
  253. noon_time: "NOON",
  254. noon_time: "NOON",
  255. note: "Note",
  256. now_time: "NOW",
  257. pacchā_māsa: "pacchā-māsa",
  258. pakkha: "Lunar Phases ",
  259. past: "Passed ",
  260. pubba_māsa: "pubba-māsa",
  261. ravi: "Ravi",
  262. saṃvacchara: "saṃvacchara",
  263. season: "Season ",
  264. sec: "sec",
  265. sora: "Sora",
  266. sukka: "Sukka",
  267. sun_height_degree: "Max solar altitude ",
  268. time: "time",
  269. twilight_time: "dawn",
  270. twilight_time: "dawn",
  271. vikala: "unsuitable time",
  272. week_day: "Day",
  273. year_0: "year",
  274. year_1: "- ",
  275. years: " year(s) ",
  276. yes_string: "can ",
  277. timezone: "Timezone",
  278. local: "local",
  279. loading: "loading",
  280. sun_set: "sunset",
  281. unknown: "unknown",
  282. altitude: "Altitude",
  283. today: "today",
  284. week: "week",
  285. list: "list",
  286. location: "location",
  287. city_name: "city name",
  288. };
  289. localString["my"] = {
  290. and_another: " and ",
  291. atitude: "Atitude",
  292. BE: "Buddhist Era ",
  293. bhumma: "ဘုမ္မ",
  294. budha: "ဗုဓ",
  295. canda: "စန္ဒ",
  296. confirm: "Confirm",
  297. date: "Date ",
  298. day: " day(s) ",
  299. days: " day(s) ",
  300. departure_in_detail: "departure in detail",
  301. dhamma_time: "5000 Years of the Buddha’s Dispensation ",
  302. eat: "eat",
  303. gama_entry: "entry the village",
  304. guru: "ဂုရု",
  305. hori_ref_time: "horizontal refraction correct ",
  306. kala: "ကာလ",
  307. language_select: "ဘာသာ",
  308. left: "Remains ",
  309. loading: "loading…",
  310. longitude: "Longitude",
  311. māsa: "မာသ",
  312. mins: "(min)",
  313. month: "Month ",
  314. month_1: "- ",
  315. months: " month(s) ",
  316. my_loc: "အတ္တသ္မိံ",
  317. need_inform: "without informing other Bhikkhu ",
  318. no_string: "cannot ",
  319. noon_time: "မဇ္ဈန္ဟိက",
  320. noon_time: "မဇ္ဈန္ဟိက",
  321. note: "Note",
  322. now_time: "ပစ္စုပ္ပန္န",
  323. pacchā_māsa: "ပစ္ဆာ-မာသ",
  324. pakkha: "Lunar Phases ",
  325. past: "Passed ",
  326. pubba_māsa: "ပုဗ္ဗ-မာသ",
  327. ravi: "ရဝိ",
  328. saṃvacchara: "သံဝစ္ဆရ",
  329. season: "Season ",
  330. sec: "sec ",
  331. sora: "သောရ",
  332. sukka: "သုက္က",
  333. sun_height_degree: "Max solar altitude ",
  334. time: "Time",
  335. twilight_time: "အရုဏုဂ္ဂမန",
  336. twilight_time: "အရုဏုဂ္ဂမန",
  337. vikala: "ဝိကာလ",
  338. week_day: "Day",
  339. year_0: "year",
  340. year_1: "- ",
  341. years: " year(s) ",
  342. yes_string: "can ",
  343. timezone: "Timezone",
  344. local: "local",
  345. loading: "loading",
  346. sun_set: "sunset",
  347. unknown: "unknown",
  348. altitude: "Altitude",
  349. today: "today",
  350. week: "week",
  351. list: "list",
  352. location: "location",
  353. city_name: "city name",
  354. };
  355. localString["si"] = {
  356. and_another: " ච ",
  357. atitude: "Atitude",
  358. BE: "බුද්ධ වර්ෂය ",
  359. bhumma: "භුම්ම",
  360. budha: "බුධ",
  361. canda: "චන්ද",
  362. confirm: "Confirm",
  363. date: "දිවස ",
  364. day: " දිවසා(නි) ",
  365. days: " දිවසා(නි) ",
  366. departure_in_detail: "departure in detail",
  367. dhamma_time: "සම්මා සම්බුද්ධස්ස සාසනං පට්ච-වස්ස-සහස්සානි පවත්තිස්සති ",
  368. eat: "eat",
  369. gama_entry: "entry the village",
  370. guru: "ගු‍රු",
  371. hori_ref_time: "horizontal refraction correct ",
  372. kala: "කාල",
  373. language_select: "භාෂාව",
  374. left: "අවසිට්ඨ ",
  375. loading: "ප්‍රවේශනය වෙනවා ",
  376. longitude: "Longitude",
  377. māsa: "මාස",
  378. mins: "(min)",
  379. month: "මාස ",
  380. month_1: "- ",
  381. months: " මාසා(නි) ",
  382. my_loc: "අත‍්තස‍්මිං",
  383. need_inform: "without informing other Bhikkhu ",
  384. no_string: "cannot ",
  385. noon_time: "මජ්ඣන්හික",
  386. noon_time: "මජ්ඣන්හික",
  387. note: "නෝට්ටුව ",
  388. now_time: "පච්චුප්පන්න",
  389. pacchā_māsa: "පච්ඡා-මාස",
  390. pakkha: "පක්ඛ ",
  391. past: "අතික්කන්ත ",
  392. pubba_māsa: "පුබ්බ-මාස",
  393. ravi: "රවි",
  394. saṃvacchara: "සංවච්ඡ‍ර",
  395. season: "උතු ",
  396. sec: "sec",
  397. sora: "සො‍ර",
  398. sukka: "සුක්ක",
  399. sun_height_degree: "Max solar altitude ",
  400. time: "time",
  401. twilight_time: "අ‍රුණුග්ගමන",
  402. twilight_time: "අ‍රුණුග්ගමන",
  403. vikala: "විකාල",
  404. week_day: "වා‍ර ",
  405. year_0: "සංවච්ඡ‍ර",
  406. year_1: "- ",
  407. years: " සංවච්ඡ‍රා(නි) ",
  408. yes_string: "can ",
  409. timezone: "Timezone",
  410. local: "local",
  411. loading: "loading",
  412. sun_set: "sunset",
  413. unknown: "unknown",
  414. altitude: "Altitude",
  415. today: "today",
  416. week: "week",
  417. list: "list",
  418. location: "location",
  419. city_name: "city name",
  420. };
  421. var pali_month_name = [
  422. { id: "1", value: "jeṭṭha", season: "gimhāna", season_icon: "☀" }, //5.X-四-十五-心
  423. { id: "2", value: "asāḷha", season: "gimhāna", season_icon: "☀" }, //6.X-五-十五、十六-箕、斗
  424. { id: "3", value: "sāvana", season: "vassāna", season_icon: "☔" }, //7.X-六-十五-女
  425. { id: "4", value: "poṭṭhapāda", season: "vassāna", season_icon: "☔" }, //8.x-七-十五、十六-室、壁
  426. { id: "5", value: "assajuja", season: "vassāna", season_icon: "☔" }, //9.X-八-十五-樓
  427. { id: "6", value: "kattika", season: "vassāna", season_icon: "☔" }, //10.X-九-十五-昂
  428. { id: "7", value: "māgasira", season: "hemanta", season_icon: "❄" }, //11.X-十-十五-觜
  429. { id: "8", value: "phussa", season: "hemanta", season_icon: "❄" }, //12.X-十一-十五-鬼
  430. { id: "9", value: "māgha", season: "hemanta", season_icon: "❄" }, //1.X-十二-十五-星
  431. { id: "10", value: "phagguna", season: "hemanta", season_icon: "❄" }, //2.X-正月-十四、十五-張、異
  432. { id: "11", value: "citta", season: "gimhāna", season_icon: "☀" }, //3.X-二月-十五-角
  433. { id: "12", value: "vesākha", season: "gimhāna", season_icon: "☀" }, //4.X-三月-十五-氐
  434. ];
  435. var pali_nakkhatta_name = [
  436. { id: "0", value: "assayuja", name_zh: "娄宿" },
  437. { id: "1", value: "bharaṇī", name_zh: "胃宿" },
  438. { id: "2", value: "Kattikā", name_zh: "昂宿" },
  439. { id: "3", value: "rohiṇī", name_zh: "毕宿" },
  440. { id: "4", value: "magasira", name_zh: "觜宿" },
  441. { id: "5", value: "Addā", name_zh: "参宿" },
  442. { id: "6", value: "punabbasu", name_zh: "井宿" },
  443. { id: "7", value: "phussa", name_zh: "鬼宿" },
  444. { id: "8", value: "Asilesā", name_zh: "柳宿" },
  445. { id: "9", value: "maghā", name_zh: "星宿" },
  446. { id: "10", value: "pubbaphagguṇī", name_zh: "张宿" },
  447. { id: "11", value: "uttaraphagguṇī", name_zh: "翼宿" },
  448. { id: "12", value: "hattha", name_zh: "轸宿" },
  449. { id: "13", value: "cittā", name_zh: "角宿" },
  450. { id: "14", value: "sāti", name_zh: "亢宿" },
  451. { id: "15", value: "visākhā", name_zh: "氐宿" },
  452. { id: "16", value: "anurādhā", name_zh: "房宿" },
  453. { id: "17", value: "jeṭṭha", name_zh: "心宿" },
  454. { id: "18", value: "mūlā", name_zh: "尾宿" },
  455. { id: "19", value: "pubbāsāḷha", name_zh: "箕宿" },
  456. { id: "20", value: "uttarāsāḷha", name_zh: "斗宿" },
  457. { id: "21", value: "savaṇa", name_zh: "女宿" },
  458. { id: "22", value: "dhaniṭṭhā", name_zh: "虚宿" },
  459. { id: "23", value: "satabhisaja", name_zh: "危宿" },
  460. { id: "24", value: "pubbabhaddapadā", name_zh: "室宿" },
  461. { id: "25", value: "uttarabhaddapadā", name_zh: "壁宿" },
  462. { id: "26", value: "revatī", name_zh: "奎宿" },
  463. ];
  464. var horoscope_name = [
  465. { id: "0", value: "Aries", name_zh: "白羊", icon: "♈" },
  466. { id: "1", value: "Taurus", name_zh: "金牛", icon: "♉" },
  467. { id: "2", value: "Gemini", name_zh: "双子", icon: "♊" },
  468. { id: "3", value: "Cancer", name_zh: "巨蟹", icon: "♋" },
  469. { id: "4", value: "Leo", name_zh: "狮子", icon: "♌" },
  470. { id: "5", value: "Virgo", name_zh: "处女", icon: "♍" },
  471. { id: "6", value: "Libra", name_zh: "天秤", icon: "♎" },
  472. { id: "7", value: "Scorpio", name_zh: "天蝎", icon: "♏" },
  473. { id: "8", value: "Sagittarius", name_zh: "射手", icon: "♐" },
  474. { id: "9", value: "Capricornus", name_zh: "摩羯", icon: "♑" },
  475. { id: "10", value: "Aquarius", name_zh: "水瓶", icon: "♒" },
  476. { id: "11", value: "Pisces", name_zh: "双鱼", icon: "♓" },
  477. ];
  478. </script>
  479. <script>
  480. var current_phase = phase();
  481. console.log(current_phase); //输出到控制台
  482. //$("#title_text").html(localString[g_language].BE);
  483. var new_list = new Array(); //新月列表
  484. var first_list = new Array(); //上弦月列表
  485. var full_list = new Array(); //满月列表
  486. var last_list = new Array(); //下弦月列表
  487. var planets = new Array(); //
  488. var lunar_position = new Object();
  489. var g_coordinate_this = new Object();
  490. var g_now_date = new Date();
  491. var today = new Date();
  492. var start_day = new Date();
  493. var next_year = new Date();
  494. var sun_times = new Object();
  495. var curr_position="";
  496. curr_position = localStorage.getItem("local_position");
  497. if (curr_position) {
  498. g_coordinate_this.AT = curr_position.split("#")[0];
  499. g_coordinate_this.LT = curr_position.split("#")[1];
  500. g_coordinate_this.height = curr_position.split("#")[2];
  501. if (g_coordinate_this.AT >= 0) {
  502. var AT_string = angle_trans(g_coordinate_this.AT)[0]+"°" +angle_trans(g_coordinate_this.AT)[1] +
  503. "’" +
  504. angle_trans(g_coordinate_this.AT)[2] +
  505. "” N";
  506. } else {
  507. var AT_string = angle_trans(0-g_coordinate_this.AT)[0]+"°" +angle_trans(0-g_coordinate_this.AT)[1] +
  508. "’" +
  509. angle_trans(0-g_coordinate_this.AT)[2] +
  510. "” S";
  511. }
  512. if (g_coordinate_this.LT >= 0) {
  513. var LT_string = angle_trans(g_coordinate_this.LT)[0]+"°" +angle_trans(g_coordinate_this.LT)[1] +
  514. "’" +
  515. angle_trans(g_coordinate_this.LT)[2] +
  516. "” E";
  517. } else {
  518. var LT_string = angle_trans(0-g_coordinate_this.LT)[0]+"°" +angle_trans(0-g_coordinate_this.LT)[1] +
  519. "’" +
  520. angle_trans(0-g_coordinate_this.LT)[2] +
  521. "” W";
  522. }
  523. if (g_coordinate_this.height != "null") {
  524. var height_string = g_coordinate_this.height + "M";
  525. } else {
  526. var height_string = localString[g_language].unknown;
  527. }
  528. } else {
  529. getLocation();
  530. }
  531. function show_time() {
  532. if ($("#input_time").val()) {
  533. today = new Date($("#input_time").val());
  534. } else {
  535. today = g_now_date;
  536. }
  537. lunar_phase_list_refresh();
  538. get_position(today);
  539. let d_earth_to_moon =
  540. lunar_position.position.x ^
  541. (2 + lunar_position.position.y) ^
  542. (2 + lunar_position.position.z) ^
  543. 2 ^
  544. 0.5;
  545. let d_earth_to_moon_0 = phase(today).distance;
  546. sun_times = SunCalc.getTimes(
  547. today,
  548. g_coordinate_this.AT,
  549. g_coordinate_this.LT,
  550. g_coordinate_this.height / 1000
  551. );
  552. sun_position = SunCalc.getPosition(today, g_coordinate_this.AT, g_coordinate_this.LT);
  553. moon_position = SunCalc.getMoonPosition(today, g_coordinate_this.AT, g_coordinate_this.LT);
  554. moon_Illumination = SunCalc.getMoonIllumination(today);
  555. }
  556. //根据时间计算偏角,输出
  557. function get_position(date_time) {
  558. let planets_position = new Object();
  559. planets = window.lagrange.planet_positions.getPositions(date_time);
  560. //planets = global.planet_positions.getPositions(today);
  561. //console.log(planets)//输出到控制台
  562. earth_position = window.lagrange.planet_positions.getPositions(date_time)[3];
  563. lunar_position = window.lagrange.planet_positions.getPositions(date_time)[11];
  564. let lunar_position_angle = 0;
  565. let lunar_station = 0;
  566. let earth_position_angle = 0;
  567. let earth_station = 0;
  568. let earth_position_angle_round = 0;
  569. let lunar_position_angle_round = 0;
  570. //太阳相对地球的黄道偏角
  571. if (earth_position.position.y >= 0) {
  572. earth_position_angle = Math.atan2(earth_position.position.y, earth_position.position.x);
  573. } else {
  574. earth_position_angle =
  575. Math.PI * 2 + Math.atan2(earth_position.position.y, earth_position.position.x);
  576. }
  577. earth_position_angle_round = earth_position_angle / Math.PI / 2 + 0.5;
  578. earth_position_angle_round = earth_position_angle_round - Math.floor(earth_position_angle_round);
  579. earth_station = earth_position_angle_round * 12;
  580. planets_position.solar_station = earth_station;
  581. planets_position.solar_position_angle = earth_position_angle_round * Math.PI * 2;
  582. planets_position.solar_position_angle_round = earth_position_angle_round;
  583. //月球相对地球的黄道偏角——角度差算法
  584. lunar_position_angle_round = earth_position_angle_round + phase(date_time).phase;
  585. lunar_position_angle_round = lunar_position_angle_round - Math.floor(lunar_position_angle_round);
  586. lunar_position_angle = lunar_position_angle_round * Math.PI * 2;
  587. lunar_station = lunar_position_angle_round * 27;
  588. //月球相对地球的黄道偏角算法——向量差算法
  589. let lunar_to_earth = new Object();
  590. lunar_to_earth.y = lunar_position.position.y - earth_position.position.y;
  591. lunar_to_earth.x = lunar_position.position.x - earth_position.position.x;
  592. if (lunar_to_earth.y >= 0) {
  593. lunar_position_angle2 = Math.atan2(lunar_to_earth.y, lunar_to_earth.x);
  594. } else {
  595. lunar_position_angle2 = Math.PI * 2 + Math.atan2(lunar_to_earth.y, lunar_to_earth.x);
  596. }
  597. lunar_position_angle_round2 = lunar_position_angle2 / Math.PI / 2;
  598. //lunar_position_angle_round = lunar_position_angle_round - Math.floor(lunar_position_angle_round)
  599. lunar_position_angle2 = lunar_position_angle_round2 * Math.PI * 2;
  600. lunar_station2 = lunar_position_angle_round2 * 27;
  601. planets_position.lunar_station = lunar_station; //月站值【角度差算夹角】
  602. planets_position.lunar_position_angle = lunar_position_angle; //月站角【角度差算夹角】
  603. planets_position.lunar_position_angle_round = lunar_position_angle_round; //月站圆周比率【角度差算夹角】
  604. planets_position.lunar_station2 = lunar_station2; //月站值【矢量差算夹角】
  605. planets_position.lunar_position_angle2 = lunar_position_angle2; //月站角【矢量差算夹角】
  606. planets_position.lunar_position_angle_round2 = lunar_position_angle_round2; //月站圆周比率【矢量差算夹角】
  607. return planets_position;
  608. }
  609. //根据;
  610. function get_station_name(data_time) {
  611. //获取星象信息
  612. let solar_num = 0;
  613. let lunar_num = 0;
  614. solar_num = get_position(data_time).solar_station;
  615. solar_num = Math.floor(solar_num);
  616. lunar_num = get_position(data_time).lunar_station;
  617. lunar_num = Math.floor(lunar_num);
  618. let result = new Object();
  619. result.solar = horoscope_name[solar_num]; //黄道十二宫星象名称
  620. result.lunar = pali_nakkhatta_name[lunar_num]; //27星宿月站名称
  621. return result;
  622. }
  623. function show_position(){
  624. curr_position = localStorage.getItem("local_position");
  625. if (curr_position) {
  626. g_coordinate_this.AT = curr_position.split("#")[0];
  627. g_coordinate_this.LT = curr_position.split("#")[1];
  628. g_coordinate_this.height = curr_position.split("#")[2];
  629. if (g_coordinate_this.AT >= 0) {
  630. var AT_string = angle_trans(g_coordinate_this.AT).str;
  631. } else {
  632. var AT_string = angle_trans(0-g_coordinate_this.AT).str;
  633. }
  634. if (g_coordinate_this.LT >= 0) {
  635. var LT_string = angle_trans(g_coordinate_this.LT).str;
  636. } else {
  637. var LT_string = angle_trans(0-g_coordinate_this.LT).str;
  638. }
  639. if (g_coordinate_this.height != "null") {
  640. var height_string = g_coordinate_this.height + "M";
  641. } else {
  642. var height_string = localString[g_language].unknown;
  643. }
  644. } else {
  645. getLocation();
  646. }
  647. $("#AT_str").html(AT_string);
  648. $("#LT_str").html(LT_string);
  649. $("#altitude_string").html(height_string);
  650. if(g_coordinate_this.AT<0){
  651. $("#AT_°")[0].value = angle_trans(0-g_coordinate_this.AT).d;
  652. $("#AT_’")[0].value = angle_trans(0-g_coordinate_this.AT).m;
  653. $("#AT_”")[0].value = angle_trans(0-g_coordinate_this.AT).s;
  654. $("#NS")[0].value="-";
  655. }
  656. else{
  657. $("#AT_°")[0].value = angle_trans(g_coordinate_this.AT).d;
  658. $("#AT_’")[0].value = angle_trans(g_coordinate_this.AT).m;
  659. $("#AT_”")[0].value = angle_trans(g_coordinate_this.AT).s;
  660. $("#NS")[0].value="+";
  661. }
  662. if(g_coordinate_this.LT<0){
  663. $("#LT_°")[0].value = angle_trans(0-g_coordinate_this.LT).d;
  664. $("#LT_’")[0].value = angle_trans(0-g_coordinate_this.LT).m;
  665. $("#LT_”")[0].value = angle_trans(0-g_coordinate_this.LT).s;
  666. $("#WE")[0].value="-";
  667. }
  668. else{
  669. $("#LT_°")[0].value = angle_trans(g_coordinate_this.LT).d;
  670. $("#LT_’")[0].value = angle_trans(g_coordinate_this.LT).m;
  671. $("#LT_”")[0].value = angle_trans(g_coordinate_this.LT).s;
  672. $("#WE")[0].value="+";
  673. }
  674. $("#HT_M")[0].value = g_coordinate_this.height;
  675. $("#city_str").html(find_city(g_coordinate_this.AT,g_coordinate_this.LT).name);
  676. }
  677. //show_position();
  678. function getLocation() {
  679. //自动定位
  680. if (navigator.geolocation) {
  681. navigator.geolocation.getCurrentPosition(showPosition, showError);
  682. } else {
  683. $("#selected_position_string").html("Geolocation is not supported by this browser.");
  684. }
  685. }
  686. function showPosition(position) {
  687. alert("get cordinate success");
  688. g_coordinate_this.AT = position.coords.latitude; //纬度
  689. g_coordinate_this.LT = position.coords.longitude; //经度
  690. g_coordinate_this.height = position.coords.altitude; //海拔高度
  691. let position_string = g_coordinate_this.AT + "#" + g_coordinate_this.LT + "#" + g_coordinate_this.height;
  692. localStorage.setItem("local_position", position_string);
  693. }
  694. function position_input() {
  695. //手动输入
  696. var LT = Number($("#LT_°")[0].value);
  697. LT += Number($("#LT_’")[0].value) / 60;
  698. LT += Number($("#LT_”")[0].value) / 3600;
  699. LT = Number($("#WE")[0].value + LT);
  700. var AT = Number($("#AT_°")[0].value);
  701. AT += Number($("#AT_’")[0].value) / 60;
  702. AT += Number($("#AT_”")[0].value) / 3600;
  703. AT = Number($("#NS")[0].value + AT);
  704. if (AT != 0) {
  705. g_coordinate_this.LT = LT;
  706. g_coordinate_this.AT = AT;
  707. }
  708. }
  709. function showError(error) {
  710. switch (error.code) {
  711. case error.PERMISSION_DENIED:
  712. alert("定位失败,用户拒绝请求地理定位");
  713. break;
  714. case error.POSITION_UNAVAILABLE:
  715. alert("定位失败,位置信息是不可用");
  716. break;
  717. case error.TIMEOUT:
  718. alert("定位失败,请求获取用户位置超时");
  719. break;
  720. case error.UNKNOWN_ERROR:
  721. alert("定位失败,定位系统失效");
  722. break;
  723. }
  724. }
  725. function angle_trans(angle,type) {
  726. var angle_str = new Object;
  727. if(type=="L"){
  728. if(angle>=0){
  729. angle_str.suf="E";
  730. }else{
  731. angle_str.suf="W";
  732. }
  733. }
  734. else{
  735. if(angle>=0){
  736. angle_str.suf="N";
  737. }else{
  738. angle_str.suf="S";
  739. }
  740. }
  741. angle=Math.abs(angle);
  742. angle_str.d = Math.floor(angle);
  743. angle_str.m = Math.floor((angle - angle_str.d) * 60);
  744. angle_str.s = Math.round((angle - angle_str.d) * 60 - angle_str.m);
  745. angle_str.str=angle_str.d+"°"+angle_str.m+"’"+angle_str.s+"”"+angle_str.suf;
  746. return angle_str;
  747. }
  748. function input_position() {
  749. $("#position_input").show();
  750. }
  751. var g_event_list_arr = new Array();
  752. function get_event_arr() {
  753. let today = new Date();
  754. let date = new Date();
  755. for (i = -360; i < 360; i++) {
  756. date.setTime(today.getTime() + i * 3600 * 24 * 1000);
  757. let info_obj = new Object();
  758. info_obj.id = "dawn" + i;
  759. info_obj.title = localString[g_language].twilight_time;
  760. info_obj.start = SunCalc.getTimes(
  761. date,
  762. g_coordinate_this.AT,
  763. g_coordinate_this.LT,
  764. g_coordinate_this.height / 1000
  765. ).dawn;
  766. g_event_list_arr.push(info_obj);
  767. info_obj = new Object();
  768. info_obj.id = "noon" + i;
  769. info_obj.title = localString[g_language].noon_time;
  770. info_obj.start = SunCalc.getTimes(
  771. date,
  772. g_coordinate_this.AT,
  773. g_coordinate_this.LT,
  774. g_coordinate_this.height / 1000
  775. ).solarNoon;
  776. g_event_list_arr.push(info_obj);
  777. info_obj = new Object();
  778. info_obj.id = "sunset" + i;
  779. info_obj.title = localString[g_language].sun_set;
  780. info_obj.start = SunCalc.getTimes(
  781. date,
  782. g_coordinate_this.AT,
  783. g_coordinate_this.LT,
  784. g_coordinate_this.height / 1000
  785. ).sunset;
  786. g_event_list_arr.push(info_obj);
  787. }
  788. next_year.setDate(start_day.getDate() + 360);
  789. start_day.setDate(today.getDate() - 360);
  790. last_list = phaseRange(start_day, next_year, LAST); //获取下弦月列表
  791. for (i_last in last_list) {
  792. info_obj = new Object();
  793. info_obj.id = "last_moon" + i_last;
  794. info_obj.title = "🌗" + get_station_name(last_list[i_last]).lunar.value;
  795. info_obj.start = last_list[i_last];
  796. g_event_list_arr.push(info_obj);
  797. }
  798. new_list = phaseRange(start_day, next_year, NEW); //获取新月列表
  799. for (i_new in new_list) {
  800. info_obj = new Object();
  801. info_obj.id = "new_moon" + i_new;
  802. info_obj.title = "🌑" + get_station_name(new_list[i_new]).lunar.value;
  803. info_obj.start = new_list[i_new];
  804. g_event_list_arr.push(info_obj);
  805. }
  806. first_list = phaseRange(start_day, next_year, FIRST); //获取上弦月列表
  807. for (i_first in first_list) {
  808. info_obj = new Object();
  809. info_obj.id = "first_moon" + i_first;
  810. info_obj.title = "🌓" + get_station_name(first_list[i_first]).lunar.value;
  811. info_obj.start = first_list[i_first];
  812. g_event_list_arr.push(info_obj);
  813. }
  814. full_list = phaseRange(start_day, next_year, FULL); //获取满月列表
  815. for (i_full in full_list) {
  816. info_obj = new Object();
  817. info_obj.id = "full_moon" + i_full;
  818. info_obj.title = "🌕" + get_station_name(full_list[i_full]).lunar.value;
  819. info_obj.start = full_list[i_full];
  820. g_event_list_arr.push(info_obj);
  821. }
  822. /*console.log(last_list); //输出到控制台
  823. console.log(new_list); //输出到控制台
  824. console.log(first_list); //输出到控制台
  825. console.log(full_list); //输出到控制台*/
  826. }
  827. get_event_arr();
  828. </script>
  829. <script src="../lib/main.js"></script>
  830. <script>
  831. function getCookie(name) {
  832. var start = document.cookie.indexOf(name + "=");
  833. var len = start + name.length + 1;
  834. if (!start && name != document.cookie.substring(0, name.length)) {
  835. return null;
  836. }
  837. if (start == -1) return null;
  838. var end = document.cookie.indexOf(";", len);
  839. if (end == -1) end = document.cookie.length;
  840. return decodeURI(document.cookie.substring(len, end));
  841. }
  842. document.addEventListener("DOMContentLoaded", function () {
  843. var initialTimeZone = "local";
  844. var timeZoneSelectorEl = document.getElementById("time-zone-selector");
  845. var loadingEl = document.getElementById("loading");
  846. var calendarEl = document.getElementById("calendar");
  847. var calendar = new FullCalendar.Calendar(calendarEl, {
  848. timeZone: initialTimeZone,
  849. locale: getCookie("language"),
  850. headerToolbar: {
  851. left: "prev,next today",
  852. center: "title",
  853. right: "dayGridMonth,timeGridWeek,timeGridDay,listWeek",
  854. },
  855. //initialDate: "2020-12-12",
  856. navLinks: true, // can click day/week names to navigate views
  857. editable: true,
  858. selectable: true,
  859. dayMaxEvents: true, // allow "more" link when too many events
  860. //resources: g_event_list_arr,
  861. events: g_event_list_arr,
  862. defaultTimedEventDuration: "00:01",
  863. eventClick: function (info) {
  864. info.jsEvent.preventDefault(); // don't let the browser navigate
  865. if (info.event.url) {
  866. window.open(info.event.url);
  867. }
  868. },
  869. loading: function (bool) {
  870. if (bool) {
  871. loadingEl.style.display = "inline"; // show
  872. } else {
  873. loadingEl.style.display = "none"; // hide
  874. }
  875. },
  876. eventTimeFormat: { hour: "numeric", minute: "2-digit" },
  877. dateClick: function (arg) {
  878. console.log("dateClick", calendar.formatIso(arg.date));
  879. },
  880. select: function (arg) {
  881. console.log("select", calendar.formatIso(arg.start), calendar.formatIso(arg.end));
  882. },
  883. });
  884. calendar.render();
  885. // load the list of available timezones, build the <select> options
  886. // it's HIGHLY recommended to use a different library for network requests, not this internal util func
  887. FullCalendar.requestJson(
  888. "GET",
  889. "php/get-time-zones.php",
  890. {},
  891. function (timeZones) {
  892. timeZones.forEach(function (timeZone) {
  893. var optionEl;
  894. if (timeZone !== "UTC") {
  895. // UTC is already in the list
  896. optionEl = document.createElement("option");
  897. optionEl.value = timeZone;
  898. optionEl.innerText = timeZone;
  899. timeZoneSelectorEl.appendChild(optionEl);
  900. }
  901. });
  902. },
  903. function () {
  904. // TODO: handle error
  905. }
  906. );
  907. // when the timezone selector changes, dynamically change the calendar option
  908. timeZoneSelectorEl.addEventListener("change", function () {
  909. calendar.setOption("timeZone", this.value);
  910. });
  911. });
  912. </script>
  913. <style>
  914. body {
  915. margin: 0;
  916. padding: 0;
  917. font-family: Arial, Helvetica Neue, Helvetica, sans-serif;
  918. font-size: 14px;
  919. }
  920. #top {
  921. background: #eee;
  922. border-bottom: 1px solid #ddd;
  923. padding: 0 10px;
  924. line-height: 40px;
  925. font-size: 12px;
  926. }
  927. .left {
  928. float: left;
  929. }
  930. .right {
  931. float: right;
  932. }
  933. .clear {
  934. clear: both;
  935. }
  936. #script-warning,
  937. #loading {
  938. display: none;
  939. }
  940. #script-warning {
  941. font-weight: bold;
  942. color: red;
  943. }
  944. #calendar {
  945. max-width: 1100px;
  946. margin: 40px auto;
  947. padding: 0 10px;
  948. }
  949. .tzo {
  950. color: #000;
  951. }
  952. input[type="number" i] {
  953. width: 2.5em;
  954. }
  955. </style>
  956. </head>
  957. <body>
  958. <div id="top" style="display: inline-flex;width: 100vw;">
  959. <div class="left" style="display: inline-flex;height: 5vh;margin: auto 1em;">
  960. <span style="line-height: 5vh;white-space: nowrap;">
  961. <script>
  962. document.write(localString[g_language].timezone + ":");
  963. </script>
  964. </span>
  965. <select id="time-zone-selector">
  966. <option value="local" selected>
  967. <script>
  968. document.write(localString[g_language].local);
  969. </script>
  970. </option>
  971. <option value="UTC">UTC</option>
  972. </select>
  973. </div>
  974. <div style="display: inline-block;margin-left:5%; justify-content: center; width: 25em">
  975. <div style="line-height: 2em; margin-top: 7px">
  976. <script>
  977. document.write(localString[g_language].atitude);
  978. </script>
  979. <span id="AT_str" onclick="show_ele(this)"></span>
  980. <span class="coordinate_input" style="flex: 7; white-space: nowrap; display: none">
  981. <input id="AT_°" type="number" min="0" max="89" /> °
  982. <input id="AT_’" type="number" min="0" max="59" /> ’
  983. <input id="AT_”" type="number" min="0" max="59" /> ”
  984. <select id="NS">
  985. <option value="+">N</option>
  986. <option value="-">S</option>
  987. </select>
  988. <button onclick="coordinate_confirm('AT')">
  989. <script>
  990. document.write(localString[g_language].confirm);
  991. </script>
  992. </button>
  993. </span>
  994. </div>
  995. <div style="line-height: 2em">
  996. <script>
  997. document.write(localString[g_language].longitude);
  998. </script>
  999. <span id="LT_str" onclick="show_ele(this)"></span>
  1000. <span
  1001. class="coordinate_input"
  1002. onblur="show_ele(this)"
  1003. style="flex: 7; white-space: nowrap; display: none"
  1004. >
  1005. <input id="LT_°" type="number" min="0" max="179" style="width: 3em" /> °
  1006. <input id="LT_’" type="number" min="0" max="59" /> ’
  1007. <input id="LT_”" type="number" min="0" max="59" /> ”
  1008. <select id="WE">
  1009. <option value="+">E</option>
  1010. <option value="-">W</option>
  1011. </select>
  1012. <button onclick="coordinate_confirm('LT')">
  1013. <script>
  1014. document.write(localString[g_language].confirm);
  1015. </script>
  1016. </button>
  1017. </span>
  1018. </div>
  1019. <div style="line-height: 2em">
  1020. <script>
  1021. document.write(localString[g_language].altitude);
  1022. </script>
  1023. <span id="altitude_string" onclick="show_ele(this)"></span>
  1024. <span class="coordinate_input" style="flex: 7; white-space: nowrap; display: none">
  1025. <input id="HT_M" type="number" min="0" max="19999" style="width: 4em" /> M
  1026. <button onclick="coordinate_confirm('HT')">
  1027. <script>
  1028. document.write(localString[g_language].confirm);
  1029. </script>
  1030. </button>
  1031. </span>
  1032. </div>
  1033. </div>
  1034. <div style="display: inline-block; width: 50%; justify-content: center;">
  1035. <script>
  1036. document.write(localString[g_language].location);
  1037. </script>
  1038. <span id="city_str" onclick=""></span>
  1039. <span id="city_info" ></span>
  1040. <input class="cityinput" id="citySelect" value="" style="display: none;">
  1041. <div class="citySelector" style="position: absolute; left: 8px; top: 25.6px; z-index: 999999;">
  1042. <div class="cityBox hide" id="cityBox"></div>
  1043. </div>
  1044. </div>
  1045. <div class="right">
  1046. <span id="loading">
  1047. <script>
  1048. document.write(localString[g_language].loading + "…");
  1049. </script>
  1050. </span>
  1051. <span id="script-warning"><code>php/get-events.php</code> must be running.</span>
  1052. </div>
  1053. <div class="clear"></div>
  1054. </div>
  1055. <div id="calendar"></div>
  1056. </body>
  1057. <script>
  1058. $("#citySelect")[0].value=localString[g_language].city_name;
  1059. function position_modify() {
  1060. var LT = Number($("#LT_°")[0].value);
  1061. LT += Number($("#LT_’")[0].value) / 60;
  1062. LT += Number($("#LT_”")[0].value) / 3600;
  1063. LT = Number($("#WE")[0].value + LT);
  1064. var AT = Number($("#AT_°")[0].value);
  1065. AT += Number($("#AT_’")[0].value) / 60;
  1066. AT += Number($("#AT_”")[0].value) / 3600;
  1067. AT = Number($("#NS")[0].value + AT);
  1068. if (AT != 0 || LT!=0) {
  1069. g_coordinate_this.LT = LT;
  1070. g_coordinate_this.AT = AT;
  1071. }
  1072. g_coordinate_this.height=Number($("#HT_M")[0].value);
  1073. //将新的坐标数据存到localStorage
  1074. let position_string = g_coordinate_this.AT + "#" + g_coordinate_this.LT + "#" + g_coordinate_this.height;
  1075. localStorage.setItem("local_position", position_string);
  1076. show_position();
  1077. }
  1078. function position_modify_confirm(obj) {
  1079. position_modify();
  1080. show_ele(obj);
  1081. }
  1082. function show_ele(obj) {
  1083. if ($(obj).siblings("span").css("display") == "none") {
  1084. $(obj).hide();
  1085. $(obj).siblings("span").show();
  1086. } else {
  1087. $(obj).show();
  1088. $(obj).siblings("span").hide();
  1089. }
  1090. }
  1091. function getLocation() {
  1092. //自动定位
  1093. if (navigator.geolocation) {
  1094. navigator.geolocation.getCurrentPosition(showPosition, showError);
  1095. } else {
  1096. $("#selected_position_string").html("Geolocation is not supported by this browser.");
  1097. }
  1098. }
  1099. function showPosition(position) {
  1100. alert("get cordinate success");
  1101. g_coordinate_this.AT = position.coords.latitude; //纬度
  1102. g_coordinate_this.LT = position.coords.longitude; //经度
  1103. g_coordinate_this.height = position.coords.altitude; //海拔高度
  1104. }
  1105. function position_input() {
  1106. //手动输入
  1107. var LT = Number($("#LT_°")[0].value);
  1108. LT += Number($("#LT_’")[0].value) / 60;
  1109. LT += Number($("#LT_”")[0].value) / 3600;
  1110. LT = Number($("#WE")[0].value + LT);
  1111. var AT = Number($("#AT_°")[0].value);
  1112. AT += Number($("#AT_’")[0].value) / 60;
  1113. AT += Number($("#AT_”")[0].value) / 3600;
  1114. AT = Number($("#NS")[0].value + AT);
  1115. if (AT != 0) {
  1116. g_coordinate_this.LT = LT;
  1117. g_coordinate_this.AT = AT;
  1118. }
  1119. }
  1120. function showError(error) {
  1121. switch (error.code) {
  1122. case error.PERMISSION_DENIED:
  1123. alert("定位失败,用户拒绝请求地理定位");
  1124. break;
  1125. case error.POSITION_UNAVAILABLE:
  1126. alert("定位失败,位置信息是不可用");
  1127. break;
  1128. case error.TIMEOUT:
  1129. alert("定位失败,请求获取用户位置超时");
  1130. break;
  1131. case error.UNKNOWN_ERROR:
  1132. alert("定位失败,定位系统失效");
  1133. break;
  1134. }
  1135. }
  1136. function coordinate_confirm(type){
  1137. switch(type){
  1138. case "AT":
  1139. show_ele('#AT_str');
  1140. break;
  1141. case "LT":
  1142. show_ele('#LT_str');
  1143. break;
  1144. case "HT":
  1145. show_ele('#altitude_string');
  1146. break;
  1147. }
  1148. position_modify();
  1149. }
  1150. function show_position(){
  1151. curr_position = localStorage.getItem("local_position");
  1152. if (curr_position) {
  1153. g_coordinate_this.AT = curr_position.split("#")[0];
  1154. g_coordinate_this.LT = curr_position.split("#")[1];
  1155. g_coordinate_this.height = curr_position.split("#")[2];
  1156. if (g_coordinate_this.AT >= 0) {
  1157. var AT_string = angle_trans(g_coordinate_this.AT).str;
  1158. } else {
  1159. var AT_string = angle_trans(0-g_coordinate_this.AT).str;
  1160. }
  1161. if (g_coordinate_this.LT >= 0) {
  1162. var LT_string = angle_trans(g_coordinate_this.LT).str;
  1163. } else {
  1164. var LT_string = angle_trans(0-g_coordinate_this.LT).str;
  1165. }
  1166. if (g_coordinate_this.height != "null") {
  1167. var height_string = g_coordinate_this.height + "M";
  1168. } else {
  1169. var height_string = localString[g_language].unknown;
  1170. }
  1171. } else {
  1172. getLocation();
  1173. }
  1174. $("#AT_str").html(AT_string);
  1175. $("#LT_str").html(LT_string);
  1176. $("#altitude_string").html(height_string);
  1177. if(g_coordinate_this.AT<0){
  1178. $("#AT_°")[0].value = angle_trans(0-g_coordinate_this.AT).d;
  1179. $("#AT_’")[0].value = angle_trans(0-g_coordinate_this.AT).m;
  1180. $("#AT_”")[0].value = angle_trans(0-g_coordinate_this.AT).s;
  1181. $("#NS")[0].value="-";
  1182. }
  1183. else{
  1184. $("#AT_°")[0].value = angle_trans(g_coordinate_this.AT).d;
  1185. $("#AT_’")[0].value = angle_trans(g_coordinate_this.AT).m;
  1186. $("#AT_”")[0].value = angle_trans(g_coordinate_this.AT).s;
  1187. $("#NS")[0].value="+";
  1188. }
  1189. if(g_coordinate_this.LT<0){
  1190. $("#LT_°")[0].value = angle_trans(0-g_coordinate_this.LT).d;
  1191. $("#LT_’")[0].value = angle_trans(0-g_coordinate_this.LT).m;
  1192. $("#LT_”")[0].value = angle_trans(0-g_coordinate_this.LT).s;
  1193. $("#WE")[0].value="-";
  1194. }
  1195. else{
  1196. $("#LT_°")[0].value = angle_trans(g_coordinate_this.LT).d;
  1197. $("#LT_’")[0].value = angle_trans(g_coordinate_this.LT).m;
  1198. $("#LT_”")[0].value = angle_trans(g_coordinate_this.LT).s;
  1199. $("#WE")[0].value="+";
  1200. }
  1201. $("#HT_M")[0].value = g_coordinate_this.height;
  1202. $("#city_str").html(find_city(g_coordinate_this.AT,g_coordinate_this.LT).name);
  1203. }
  1204. show_position();
  1205. $(document).ready(function () {
  1206. $("button").each(function () {
  1207. if ($(this).html() == "today") {
  1208. $(this).html(localString[g_language].today);
  1209. }
  1210. if ($(this).html() == "list") {
  1211. $(this).html(localString[g_language].list);
  1212. }
  1213. if ($(this).html() == "week") {
  1214. $(this).html(localString[g_language].week);
  1215. }
  1216. if ($(this).html() == "month") {
  1217. $(this).html(localString[g_language].month);
  1218. }
  1219. if ($(this).html() == "day") {
  1220. $(this).html(localString[g_language].day);
  1221. }
  1222. });
  1223. });
  1224. $(document).ready(function () {
  1225. $("button").click(function () {
  1226. $("button").each(function () {
  1227. if ($(this).html().indexOf("today") != -1) {
  1228. $(this).html(localString[g_language].today);
  1229. }
  1230. if ($(this).html().indexOf("list") != -1) {
  1231. $(this).html(localString[g_language].list);
  1232. }
  1233. if ($(this).html().indexOf("week") != -1) {
  1234. $(this).html(localString[g_language].week);
  1235. }
  1236. if ($(this).html().indexOf("month") != -1) {
  1237. $(this).html(localString[g_language].month);
  1238. }
  1239. if ($(this).html().indexOf("day") != -1 && $(this).html().indexOf("today") == -1) {
  1240. $(this).html(localString[g_language].day);
  1241. }
  1242. });
  1243. });
  1244. });
  1245. $(document).ready(function () {
  1246. $("div").click(function () {
  1247. $("button").each(function () {
  1248. if ($(this).html().indexOf("today") != -1) {
  1249. $(this).html(localString[g_language].today);
  1250. }
  1251. if ($(this).html().indexOf("list") != -1) {
  1252. $(this).html(localString[g_language].list);
  1253. }
  1254. if ($(this).html().indexOf("week") != -1) {
  1255. $(this).html(localString[g_language].week);
  1256. }
  1257. if ($(this).html().indexOf("month") != -1) {
  1258. $(this).html(localString[g_language].month);
  1259. }
  1260. if ($(this).html().indexOf("day") != -1 && $(this).html().indexOf("today") == -1) {
  1261. $(this).html(localString[g_language].day);
  1262. }
  1263. });
  1264. });
  1265. });
  1266. //给出两个经纬度坐标直接的距离
  1267. function distance(x, y) {
  1268. var toRadians = function(num) {
  1269. return num * Math.PI / 180;
  1270. };
  1271. var lat1 = x.latitude;
  1272. var lon1 = x.longitude;
  1273. var lat2 = y.latitude;
  1274. var lon2 = y.longitude;
  1275. var R = 6371; // km
  1276. var φ1 = toRadians(lat1);//纬度弧度1
  1277. var φ2 = toRadians(lat2);//纬度弧度2
  1278. var Δφ = toRadians(lat2 - lat1);//纬度弧度差
  1279. var Δλ = toRadians(lon2 - lon1);//经度弧度差
  1280. var a = Math.sin(Δφ / 2) * Math.sin(Δφ / 2) +
  1281. Math.cos(φ1) * Math.cos(φ2) *
  1282. Math.sin(Δλ / 2) * Math.sin(Δλ / 2);
  1283. var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
  1284. return R * c;
  1285. }
  1286. function find_city(latitude,longitude){
  1287. var point=new Object;
  1288. var point_X=new Object;
  1289. var city_info=new Object;
  1290. var min_S=10000
  1291. point.latitude=latitude;
  1292. point.longitude=longitude;
  1293. for(i in city_list){
  1294. point_X.latitude=city_list[i].latitude;
  1295. point_X.longitude=city_list[i].longitude;
  1296. if(distance(point,point_X)<min_S){
  1297. city_info=city_list[i];
  1298. min_S=distance(point,point_X);
  1299. }
  1300. }
  1301. if(min_S==10000){
  1302. city_info.name=localString[g_language].unknown;
  1303. city_info.asciiName=localString[g_language].unknown;
  1304. }
  1305. return(city_info);
  1306. }
  1307. </script>
  1308. <style type="text/css">
  1309. .demo{width:220px;margin:20px auto;}
  1310. /* citySelector */
  1311. .citySelector{font:12px/1.5 tahoma,arial,\5b8b\4f53;background:#fff;text-align:left;}
  1312. .cityslide{width:250px;list-style:none;margin:0;padding:0;border:1px solid #85BEE5;border-right-color:#3485C0;border-bottom-color:#3485C0;box-shadow:2px 2px 3px rgba(0,0,0,0.3);margin-top:-2px;}
  1313. .cityslide li{list-style:none;overflow:hidden;height:16px;padding:4px 5px;}
  1314. .cityslide li.on{background:#9CD9FF;color:#fff;}
  1315. .cityslide li b{font-weight:normal;}
  1316. .cityslide li.empty{background:#fff2e8;color:#666;}
  1317. .cityslide li.empty em{color:red;font-style:normal;}
  1318. .cityname{float:left;}
  1319. .cityspell{float:right;}
  1320. .cityBox{width:320px;border:1px solid #85BEE5;overflow:hidden;box-shadow:2px 2px 3px rgba(0,0,0,0.3);}
  1321. .cityBox ul{margin:0;padding:0;overflow:hidden;}
  1322. .cityBox ul li{float:left;list-style:none;padding:2px 4px;border:1px solid #85BEE5;cursor:pointer;margin-left:4px;display:inline;background:#E1EFFE;}
  1323. .cityBox ul li.on{background:#fff;border-bottom-color:#fff;position:relative;}
  1324. .hide{display:none;}
  1325. p.tip{color:#666;line-height:20px;padding:5px;margin:0;text-indent:3px;}
  1326. .hotCity{border-top:1px solid #85BEE5;margin-top:-1px;clear:left;overflow:hidden;padding-bottom:5px;padding-top:5px;_margin-bottom:8px;}
  1327. .cityTab{overflow:hidden;}
  1328. .cityTab dl{margin:0;padding:0;overflow:hidden;}
  1329. .cityTab dl dt{float:left;padding-left:3px;color:#F30;text-indent:5px;font-family:"Lucida console","consolas","courier new";line-height:22px;font-size:14px;width:20px;}
  1330. .cityTab dl dd{margin-left:2px;float:left;width:290px;}
  1331. .cityTab dl dd a{padding-left:5px;width:66px;line-height:22px;display:inline-block;color:#000;text-decoration:none;}
  1332. .cityTab dl dd a:hover{text-decoration:underline;color:red}
  1333. .cityinput{ font-size: 12px; padding-left: 2px; background: url(T1EPyLXm0hXXXXXXXX-200-100.png) no-repeat 150px 5px; border: 1px solid #D8D8D8; }
  1334. </style>
  1335. <script type="text/javascript">
  1336. /* *
  1337. * ---------------------------------------- *
  1338. * 城市选择组件 v1.0
  1339. * Author: VVG
  1340. * QQ: 83816819
  1341. * Mail: mysheller@163.com
  1342. * http://www.cnblogs.com/NNUF/
  1343. * ---------------------------------------- *
  1344. * Date: 2012-07-10
  1345. * ---------------------------------------- *
  1346. * */
  1347. /* *
  1348. * 全局空间 Vcity
  1349. * */
  1350. var Vcity = {};
  1351. /* *
  1352. * 静态方法集
  1353. * @name _m
  1354. * */
  1355. Vcity._m = {
  1356. /* 选择元素 */
  1357. $:function (arg, context) {
  1358. var tagAll, n, eles = [], i, sub = arg.substring(1);
  1359. context = context || document;
  1360. if (typeof arg == 'string') {
  1361. switch (arg.charAt(0)) {
  1362. case '#':
  1363. return document.getElementById(sub);
  1364. break;
  1365. case '.':
  1366. if (context.getElementsByClassName) return context.getElementsByClassName(sub);
  1367. tagAll = Vcity._m.$('*', context);
  1368. n = tagAll.length;
  1369. for (i = 0; i < n; i++) {
  1370. if (tagAll[i].className.indexOf(sub) > -1) eles.push(tagAll[i]);
  1371. }
  1372. return eles;
  1373. break;
  1374. default:
  1375. return context.getElementsByTagName(arg);
  1376. break;
  1377. }
  1378. }
  1379. },
  1380. /* 绑定事件 */
  1381. on:function (node, type, handler) {
  1382. node.addEventListener ? node.addEventListener(type, handler, false) : node.attachEvent('on' + type, handler);
  1383. },
  1384. /* 获取事件 */
  1385. getEvent:function(event){
  1386. return event || window.event;
  1387. },
  1388. /* 获取事件目标 */
  1389. getTarget:function(event){
  1390. return event.target || event.srcElement;
  1391. },
  1392. /* 获取元素位置 */
  1393. getPos:function (node) {
  1394. var scrollx = document.documentElement.scrollLeft || document.body.scrollLeft,
  1395. scrollt = document.documentElement.scrollTop || document.body.scrollTop;
  1396. var pos = node.getBoundingClientRect();
  1397. return {top:pos.top + scrollt, right:pos.right + scrollx, bottom:pos.bottom + scrollt, left:pos.left + scrollx }
  1398. },
  1399. /* 添加样式名 */
  1400. addClass:function (c, node) {
  1401. if(!node)return;
  1402. node.className = Vcity._m.hasClass(c,node) ? node.className : node.className + ' ' + c ;
  1403. },
  1404. /* 移除样式名 */
  1405. removeClass:function (c, node) {
  1406. var reg = new RegExp("(^|\\s+)" + c + "(\\s+|$)", "g");
  1407. if(!Vcity._m.hasClass(c,node))return;
  1408. node.className = reg.test(node.className) ? node.className.replace(reg, '') : node.className;
  1409. },
  1410. /* 是否含有CLASS */
  1411. hasClass:function (c, node) {
  1412. if(!node || !node.className)return false;
  1413. return node.className.indexOf(c)>-1;
  1414. },
  1415. /* 阻止冒泡 */
  1416. stopPropagation:function (event) {
  1417. event = event || window.event;
  1418. event.stopPropagation ? event.stopPropagation() : event.cancelBubble = true;
  1419. },
  1420. /* 去除两端空格 */
  1421. trim:function (str) {
  1422. return str.replace(/^\s+|\s+$/g,'');
  1423. }
  1424. };
  1425. /* 所有城市数据,可以按照格式自行添加(北京|beijing|bj),前16条为热门城市 */
  1426. Vcity.allCity = ['北京|beijing|bj','上海|shanghai|sh', '重庆|chongqing|cq', '深圳|shenzhen|sz', '广州|guangzhou|gz', '杭州|hangzhou|hz',
  1427. '南京|nanjing|nj', '苏州|shuzhou|sz', '天津|tianjin|tj', '成都|chengdu|cd', '南昌|nanchang|nc', '三亚|sanya|sy','青岛|qingdao|qd',
  1428. '厦门|xiamen|xm', '西安|xian|xa','长沙|changsha|cs'];
  1429. var city_str_nex=""
  1430. for(i in city_list){
  1431. city_str_nex=city_list[i].name+"|"+city_list[i].asciiName+"|"+city_list[i].asciiName.slice(0,2);
  1432. Vcity.allCity.push(city_str_nex);
  1433. }
  1434. /* 正则表达式 筛选中文城市名、拼音、首字母 */
  1435. Vcity.regEx = /^([\u4E00-\u9FA5\uf900-\ufa2d]+)\|(\w+)\|(\w)\w*$/i;
  1436. Vcity.regExChiese = /([\u4E00-\u9FA5\uf900-\ufa2d]+)/;
  1437. /* *
  1438. * 格式化城市数组为对象oCity,按照a-h,i-p,q-z,hot热门城市分组:
  1439. * {HOT:{hot:[]},ABCDEFGH:{a:[1,2,3],b:[1,2,3]},IJKLMNOP:{i:[1.2.3],j:[1,2,3]},QRSTUVWXYZ:{}}
  1440. * */
  1441. (function () {
  1442. var citys = Vcity.allCity, match, letter,
  1443. regEx = Vcity.regEx,
  1444. reg2 = /^[a-h]$/i, reg3 = /^[i-p]$/i, reg4 = /^[q-z]$/i;
  1445. if (!Vcity.oCity) {
  1446. Vcity.oCity = {hot:{},ABCDEFGH:{}, IJKLMNOP:{}, QRSTUVWXYZ:{}};
  1447. //console.log(citys.length);
  1448. for (var i = 0, n = citys.length; i < n; i++) {
  1449. match = regEx.exec(citys[i]);
  1450. letter = match[3].toUpperCase();
  1451. if (reg2.test(letter)) {
  1452. if (!Vcity.oCity.ABCDEFGH[letter]) Vcity.oCity.ABCDEFGH[letter] = [];
  1453. Vcity.oCity.ABCDEFGH[letter].push(match[1]);
  1454. } else if (reg3.test(letter)) {
  1455. if (!Vcity.oCity.IJKLMNOP[letter]) Vcity.oCity.IJKLMNOP[letter] = [];
  1456. Vcity.oCity.IJKLMNOP[letter].push(match[1]);
  1457. } else if (reg4.test(letter)) {
  1458. if (!Vcity.oCity.QRSTUVWXYZ[letter]) Vcity.oCity.QRSTUVWXYZ[letter] = [];
  1459. Vcity.oCity.QRSTUVWXYZ[letter].push(match[1]);
  1460. }
  1461. /* 热门城市 前16条 */
  1462. if(i<16){
  1463. if(!Vcity.oCity.hot['hot']) Vcity.oCity.hot['hot'] = [];
  1464. Vcity.oCity.hot['hot'].push(match[1]);
  1465. }
  1466. }
  1467. }
  1468. })();
  1469. /* 城市HTML模板 */
  1470. Vcity._template = [
  1471. '<p class="tip">热门城市(支持汉字/拼音)</p>',
  1472. '<ul>',
  1473. '<li class="on">热门城市</li>',
  1474. '<li>A~H</li>',
  1475. '<li>I~P</li>',
  1476. '<li>Q~Z</li>',
  1477. '</ul>'
  1478. ];
  1479. /* *
  1480. * 城市控件构造函数
  1481. * @CitySelector
  1482. * */
  1483. Vcity.CitySelector = function () {
  1484. this.initialize.apply(this, arguments);
  1485. };
  1486. Vcity.CitySelector.prototype = {
  1487. constructor:Vcity.CitySelector,
  1488. /* 初始化 */
  1489. initialize :function (options) {
  1490. var input = options.input;
  1491. this.input = Vcity._m.$('#'+ input);
  1492. this.inputEvent();
  1493. },
  1494. /* *
  1495. * @createWarp
  1496. * 创建城市BOX HTML 框架
  1497. * */
  1498. createWarp:function(){
  1499. var inputPos = Vcity._m.getPos(this.input);
  1500. var div = this.rootDiv = document.createElement('div');
  1501. var that = this;
  1502. // 设置DIV阻止冒泡
  1503. Vcity._m.on(this.rootDiv,'click',function(event){
  1504. Vcity._m.stopPropagation(event);
  1505. });
  1506. // 设置点击文档隐藏弹出的城市选择框
  1507. Vcity._m.on(document, 'click', function (event) {
  1508. event = Vcity._m.getEvent(event);
  1509. var target = Vcity._m.getTarget(event);
  1510. if(target == that.input) return false;
  1511. //console.log(target.className);
  1512. if (that.cityBox)Vcity._m.addClass('hide', that.cityBox);
  1513. if (that.ul)Vcity._m.addClass('hide', that.ul);
  1514. if(that.myIframe)Vcity._m.addClass('hide',that.myIframe);
  1515. });
  1516. div.className = 'citySelector';
  1517. div.style.position = 'absolute';
  1518. div.style.left = inputPos.left + 'px';
  1519. div.style.top = inputPos.bottom + 'px';
  1520. div.style.zIndex = 999999;
  1521. // 判断是否IE6,如果是IE6需要添加iframe才能遮住SELECT框
  1522. var isIe = (document.all) ? true : false;
  1523. var isIE6 = this.isIE6 = isIe && !window.XMLHttpRequest;
  1524. if(isIE6){
  1525. var myIframe = this.myIframe = document.createElement('iframe');
  1526. myIframe.frameborder = '0';
  1527. myIframe.src = 'about:blank';
  1528. myIframe.style.position = 'absolute';
  1529. myIframe.style.zIndex = '-1';
  1530. this.rootDiv.appendChild(this.myIframe);
  1531. }
  1532. var childdiv = this.cityBox = document.createElement('div');
  1533. childdiv.className = 'cityBox';
  1534. childdiv.id = 'cityBox';
  1535. childdiv.innerHTML = Vcity._template.join('');
  1536. var hotCity = this.hotCity = document.createElement('div');
  1537. hotCity.className = 'hotCity';
  1538. childdiv.appendChild(hotCity);
  1539. div.appendChild(childdiv);
  1540. this.createHotCity();
  1541. },
  1542. /* *
  1543. * @createHotCity
  1544. * TAB下面DIV:hot,a-h,i-p,q-z 分类HTML生成,DOM操作
  1545. * {HOT:{hot:[]},ABCDEFGH:{a:[1,2,3],b:[1,2,3]},IJKLMNOP:{},QRSTUVWXYZ:{}}
  1546. **/
  1547. createHotCity:function(){
  1548. var odiv,odl,odt,odd,odda=[],str,key,ckey,sortKey,regEx = Vcity.regEx,
  1549. oCity = Vcity.oCity;
  1550. for(key in oCity){
  1551. odiv = this[key] = document.createElement('div');
  1552. // 先设置全部隐藏hide
  1553. odiv.className = key + ' ' + 'cityTab hide';
  1554. sortKey=[];
  1555. for(ckey in oCity[key]){
  1556. sortKey.push(ckey);
  1557. // ckey按照ABCDEDG顺序排序
  1558. sortKey.sort();
  1559. }
  1560. for(var j=0,k = sortKey.length;j<k;j++){
  1561. odl = document.createElement('dl');
  1562. odt = document.createElement('dt');
  1563. odd = document.createElement('dd');
  1564. odt.innerHTML = sortKey[j] == 'hot'?'&nbsp;':sortKey[j];
  1565. odda = [];
  1566. for(var i=0,n=oCity[key][sortKey[j]].length;i<n;i++){
  1567. str = '<a href="#">' + oCity[key][sortKey[j]][i] + '</a>';
  1568. odda.push(str);
  1569. }
  1570. odd.innerHTML = odda.join('');
  1571. odl.appendChild(odt);
  1572. odl.appendChild(odd);
  1573. odiv.appendChild(odl);
  1574. }
  1575. // 移除热门城市的隐藏CSS
  1576. Vcity._m.removeClass('hide',this.hot);
  1577. this.hotCity.appendChild(odiv);
  1578. }
  1579. document.body.appendChild(this.rootDiv);
  1580. /* IE6 */
  1581. this.changeIframe();
  1582. this.tabChange();
  1583. this.linkEvent();
  1584. },
  1585. /* *
  1586. * tab按字母顺序切换
  1587. * @ tabChange
  1588. * */
  1589. tabChange:function(){
  1590. var lis = Vcity._m.$('li',this.cityBox);
  1591. var divs = Vcity._m.$('div',this.hotCity);
  1592. var that = this;
  1593. for(var i=0,n=lis.length;i<n;i++){
  1594. lis[i].index = i;
  1595. lis[i].onclick = function(){
  1596. for(var j=0;j<n;j++){
  1597. Vcity._m.removeClass('on',lis[j]);
  1598. Vcity._m.addClass('hide',divs[j]);
  1599. }
  1600. Vcity._m.addClass('on',this);
  1601. Vcity._m.removeClass('hide',divs[this.index]);
  1602. /* IE6 改变TAB的时候 改变Iframe 大小*/
  1603. that.changeIframe();
  1604. };
  1605. }
  1606. },
  1607. /* *
  1608. * 城市LINK事件
  1609. * @linkEvent
  1610. * */
  1611. linkEvent:function(){
  1612. var links = Vcity._m.$('a',this.hotCity);
  1613. var that = this;
  1614. for(var i=0,n=links.length;i<n;i++){
  1615. links[i].onclick = function(){
  1616. that.input.value = this.innerHTML;
  1617. Vcity._m.addClass('hide',that.cityBox);
  1618. /* 点击城市名的时候隐藏myIframe */
  1619. Vcity._m.addClass('hide',that.myIframe);
  1620. }
  1621. }
  1622. },
  1623. /* *
  1624. * INPUT城市输入框事件
  1625. * @inputEvent
  1626. * */
  1627. inputEvent:function(){
  1628. var that = this;
  1629. Vcity._m.on(this.input,'click',function(event){
  1630. event = event || window.event;
  1631. if(!that.cityBox){
  1632. that.createWarp();
  1633. }else if(!!that.cityBox && Vcity._m.hasClass('hide',that.cityBox)){
  1634. // slideul 不存在或者 slideul存在但是是隐藏的时候 两者不能共存
  1635. if(!that.ul || (that.ul && Vcity._m.hasClass('hide',that.ul))){
  1636. Vcity._m.removeClass('hide',that.cityBox);
  1637. /* IE6 移除iframe 的hide 样式 */
  1638. //alert('click');
  1639. Vcity._m.removeClass('hide',that.myIframe);
  1640. that.changeIframe();
  1641. }
  1642. }
  1643. });
  1644. Vcity._m.on(this.input,'focus',function(){
  1645. that.input.select();
  1646. if(that.input.value == localString[g_language].city_name) that.input.value = '';
  1647. });
  1648. Vcity._m.on(this.input,'blur',function(){
  1649. if(that.input.value == '') that.input.value = localString[g_language].city_name;
  1650. });
  1651. Vcity._m.on(this.input,'keyup',function(event){
  1652. event = event || window.event;
  1653. var keycode = event.keyCode;
  1654. Vcity._m.addClass('hide',that.cityBox);
  1655. that.createUl();
  1656. /* 移除iframe 的hide 样式 */
  1657. Vcity._m.removeClass('hide',that.myIframe);
  1658. // 下拉菜单显示的时候捕捉按键事件
  1659. if(that.ul && !Vcity._m.hasClass('hide',that.ul) && !that.isEmpty){
  1660. that.KeyboardEvent(event,keycode);
  1661. }
  1662. });
  1663. },
  1664. /* *
  1665. * 生成下拉选择列表
  1666. * @ createUl
  1667. * */
  1668. createUl:function () {
  1669. //console.log('createUL');
  1670. var str;
  1671. var value = Vcity._m.trim(this.input.value);
  1672. // 当value不等于空的时候执行
  1673. if (value !== '') {
  1674. var reg = new RegExp("^" + value + "|\\|" + value, 'gi');
  1675. // 此处需设置中文输入法也可用onpropertychange
  1676. var searchResult = [];
  1677. for (var i = 0, n = Vcity.allCity.length; i < n; i++) {
  1678. if (reg.test(Vcity.allCity[i])) {
  1679. var match = Vcity.regEx.exec(Vcity.allCity[i]);
  1680. if (searchResult.length !== 0) {
  1681. str = '<li><b class="cityname">' + match[1] + '</b><b class="cityspell">' + match[2] + '</b></li>';
  1682. } else {
  1683. str = '<li class="on"><b class="cityname">' + match[1] + '</b><b class="cityspell">' + match[2] + '</b></li>';
  1684. }
  1685. searchResult.push(str);
  1686. }
  1687. }
  1688. this.isEmpty = false;
  1689. // 如果搜索数据为空
  1690. if (searchResult.length == 0) {
  1691. this.isEmpty = true;
  1692. str = '<li class="empty">对不起,没有找到数据 "<em>' + value + '</em>"</li>';
  1693. searchResult.push(str);
  1694. }
  1695. // 如果slideul不存在则添加ul
  1696. if (!this.ul) {
  1697. var ul = this.ul = document.createElement('ul');
  1698. ul.className = 'cityslide';
  1699. this.rootDiv && this.rootDiv.appendChild(ul);
  1700. // 记录按键次数,方向键
  1701. this.count = 0;
  1702. } else if (this.ul && Vcity._m.hasClass('hide', this.ul)) {
  1703. this.count = 0;
  1704. Vcity._m.removeClass('hide', this.ul);
  1705. }
  1706. this.ul.innerHTML = searchResult.join('');
  1707. /* IE6 */
  1708. this.changeIframe();
  1709. // 绑定Li事件
  1710. this.liEvent();
  1711. }else{
  1712. Vcity._m.addClass('hide',this.ul);
  1713. Vcity._m.removeClass('hide',this.cityBox);
  1714. Vcity._m.removeClass('hide',this.myIframe);
  1715. this.changeIframe();
  1716. }
  1717. },
  1718. /* IE6的改变遮罩SELECT 的 IFRAME尺寸大小 */
  1719. changeIframe:function(){
  1720. if(!this.isIE6)return;
  1721. this.myIframe.style.width = this.rootDiv.offsetWidth + 'px';
  1722. this.myIframe.style.height = this.rootDiv.offsetHeight + 'px';
  1723. },
  1724. /* *
  1725. * 特定键盘事件,上、下、Enter键
  1726. * @ KeyboardEvent
  1727. * */
  1728. KeyboardEvent:function(event,keycode){
  1729. var lis = Vcity._m.$('li',this.ul);
  1730. var len = lis.length;
  1731. switch(keycode){
  1732. case 40: //向下箭头↓
  1733. this.count++;
  1734. if(this.count > len-1) this.count = 0;
  1735. for(var i=0;i<len;i++){
  1736. Vcity._m.removeClass('on',lis[i]);
  1737. }
  1738. Vcity._m.addClass('on',lis[this.count]);
  1739. break;
  1740. case 38: //向上箭头↑
  1741. this.count--;
  1742. if(this.count<0) this.count = len-1;
  1743. for(i=0;i<len;i++){
  1744. Vcity._m.removeClass('on',lis[i]);
  1745. }
  1746. Vcity._m.addClass('on',lis[this.count]);
  1747. break;
  1748. case 13: // enter键
  1749. this.input.value = Vcity.regExChiese.exec(lis[this.count].innerHTML)[0];
  1750. Vcity._m.addClass('hide',this.ul);
  1751. Vcity._m.addClass('hide',this.ul);
  1752. /* IE6 */
  1753. Vcity._m.addClass('hide',this.myIframe);
  1754. break;
  1755. default:
  1756. break;
  1757. }
  1758. },
  1759. /* *
  1760. * 下拉列表的li事件
  1761. * @ liEvent
  1762. * */
  1763. liEvent:function(){
  1764. var that = this;
  1765. var lis = Vcity._m.$('li',this.ul);
  1766. for(var i = 0,n = lis.length;i < n;i++){
  1767. Vcity._m.on(lis[i],'click',function(event){
  1768. event = Vcity._m.getEvent(event);
  1769. var target = Vcity._m.getTarget(event);
  1770. that.input.value = Vcity.regExChiese.exec(target.innerHTML)[0];
  1771. Vcity._m.addClass('hide',that.ul);
  1772. /* IE6 下拉菜单点击事件 */
  1773. Vcity._m.addClass('hide',that.myIframe);
  1774. });
  1775. Vcity._m.on(lis[i],'mouseover',function(event){
  1776. event = Vcity._m.getEvent(event);
  1777. var target = Vcity._m.getTarget(event);
  1778. Vcity._m.addClass('on',target);
  1779. });
  1780. Vcity._m.on(lis[i],'mouseout',function(event){
  1781. event = Vcity._m.getEvent(event);
  1782. var target = Vcity._m.getTarget(event);
  1783. Vcity._m.removeClass('on',target);
  1784. })
  1785. }
  1786. }
  1787. };
  1788. var test=new Vcity.CitySelector({input:'citySelect'});
  1789. var test2=new Vcity.CitySelector({input:'citySelect1'});
  1790. </script>
  1791. </body>
  1792. </html>