index.html 62 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927
  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)[0]+"°" +angle_trans(g_coordinate_this.AT)[1] +
  631. "’" +
  632. angle_trans(g_coordinate_this.AT)[2] +
  633. "” N";
  634. } else {
  635. var AT_string = angle_trans(0-g_coordinate_this.AT)[0]+"°" +angle_trans(0-g_coordinate_this.AT)[1] +
  636. "’" +
  637. angle_trans(0-g_coordinate_this.AT)[2] +
  638. "” S";
  639. }
  640. if (g_coordinate_this.LT >= 0) {
  641. var LT_string = angle_trans(g_coordinate_this.LT)[0]+"°" +angle_trans(g_coordinate_this.LT)[1] +
  642. "’" +
  643. angle_trans(g_coordinate_this.LT)[2] +
  644. "” E";
  645. } else {
  646. var LT_string = angle_trans(0-g_coordinate_this.LT)[0]+"°" +angle_trans(0-g_coordinate_this.LT)[1] +
  647. "’" +
  648. angle_trans(0-g_coordinate_this.LT)[2] +
  649. "” W";
  650. }
  651. if (g_coordinate_this.height != "null") {
  652. var height_string = g_coordinate_this.height + "M";
  653. } else {
  654. var height_string = localString[g_language].unknown;
  655. }
  656. } else {
  657. getLocation();
  658. }
  659. $("#AT_str").html(AT_string);
  660. $("#LT_str").html(LT_string);
  661. $("#altitude_string").html(height_string);
  662. if(g_coordinate_this.AT<0){
  663. $("#AT_°")[0].value = angle_trans(0-g_coordinate_this.AT)[0];
  664. $("#AT_’")[0].value = angle_trans(0-g_coordinate_this.AT)[1];
  665. $("#AT_”")[0].value = angle_trans(0-g_coordinate_this.AT)[2];
  666. $("#NS")[0].value="-";
  667. }
  668. else{
  669. $("#AT_°")[0].value = angle_trans(g_coordinate_this.AT)[0];
  670. $("#AT_’")[0].value = angle_trans(g_coordinate_this.AT)[1];
  671. $("#AT_”")[0].value = angle_trans(g_coordinate_this.AT)[2];
  672. $("#NS")[0].value="+";
  673. }
  674. if(g_coordinate_this.LT<0){
  675. $("#LT_°")[0].value = angle_trans(0-g_coordinate_this.LT)[0];
  676. $("#LT_’")[0].value = angle_trans(0-g_coordinate_this.LT)[1];
  677. $("#LT_”")[0].value = angle_trans(0-g_coordinate_this.LT)[2];
  678. $("#WE")[0].value="-";
  679. }
  680. else{
  681. $("#LT_°")[0].value = angle_trans(g_coordinate_this.LT)[0];
  682. $("#LT_’")[0].value = angle_trans(g_coordinate_this.LT)[1];
  683. $("#LT_”")[0].value = angle_trans(g_coordinate_this.LT)[2];
  684. $("#WE")[0].value="+";
  685. }
  686. $("#HT_M")[0].value = g_coordinate_this.height;
  687. $("#city_str").html(find_city(g_coordinate_this.AT,g_coordinate_this.LT).name);
  688. }
  689. show_position();
  690. function getLocation() {
  691. //自动定位
  692. if (navigator.geolocation) {
  693. navigator.geolocation.getCurrentPosition(showPosition, showError);
  694. } else {
  695. $("#selected_position_string").html("Geolocation is not supported by this browser.");
  696. }
  697. }
  698. function showPosition(position) {
  699. alert("get cordinate success");
  700. g_coordinate_this.AT = position.coords.latitude; //纬度
  701. g_coordinate_this.LT = position.coords.longitude; //经度
  702. g_coordinate_this.height = position.coords.altitude; //海拔高度
  703. let position_string = g_coordinate_this.AT + "#" + g_coordinate_this.LT + "#" + g_coordinate_this.height;
  704. localStorage.setItem("local_position", position_string);
  705. }
  706. function position_input() {
  707. //手动输入
  708. var LT = Number($("#LT_°")[0].value);
  709. LT += Number($("#LT_’")[0].value) / 60;
  710. LT += Number($("#LT_”")[0].value) / 3600;
  711. LT = Number($("#WE")[0].value + LT);
  712. var AT = Number($("#AT_°")[0].value);
  713. AT += Number($("#AT_’")[0].value) / 60;
  714. AT += Number($("#AT_”")[0].value) / 3600;
  715. AT = Number($("#NS")[0].value + AT);
  716. if (AT != 0) {
  717. g_coordinate_this.LT = LT;
  718. g_coordinate_this.AT = AT;
  719. }
  720. }
  721. function showError(error) {
  722. switch (error.code) {
  723. case error.PERMISSION_DENIED:
  724. alert("定位失败,用户拒绝请求地理定位");
  725. break;
  726. case error.POSITION_UNAVAILABLE:
  727. alert("定位失败,位置信息是不可用");
  728. break;
  729. case error.TIMEOUT:
  730. alert("定位失败,请求获取用户位置超时");
  731. break;
  732. case error.UNKNOWN_ERROR:
  733. alert("定位失败,定位系统失效");
  734. break;
  735. }
  736. }
  737. function angle_trans(angle,type) {
  738. var angle_str = new Object;
  739. if(type=="L"){
  740. if(angle>=0){
  741. angle_str.suf="E";
  742. }else{
  743. angle_str.suf="W";
  744. }
  745. }
  746. else{
  747. if(angle>=0){
  748. angle_str.suf="N";
  749. }else{
  750. angle_str.suf="S";
  751. }
  752. }
  753. angle=Math.abs(angle);
  754. angle_str.d = Math.floor(angle);
  755. angle_str.m = Math.floor((angle - angle_str.d) * 60);
  756. angle_str.s = Math.round((angle - angle_str.d) * 60 - angle_str.m);
  757. angle_str.str=angle_str.d+"°"+angle_str.m+"’"+angle_str.s+"”"+angle_str.suf;
  758. return angle_str;
  759. }
  760. function input_position() {
  761. $("#position_input").show();
  762. }
  763. var g_event_list_arr = new Array();
  764. function get_event_arr() {
  765. let today = new Date();
  766. let date = new Date();
  767. for (i = -360; i < 360; i++) {
  768. date.setTime(today.getTime() + i * 3600 * 24 * 1000);
  769. let info_obj = new Object();
  770. info_obj.id = "dawn" + i;
  771. info_obj.title = localString[g_language].twilight_time;
  772. info_obj.start = SunCalc.getTimes(
  773. date,
  774. g_coordinate_this.AT,
  775. g_coordinate_this.LT,
  776. g_coordinate_this.height / 1000
  777. ).dawn;
  778. g_event_list_arr.push(info_obj);
  779. info_obj = new Object();
  780. info_obj.id = "noon" + i;
  781. info_obj.title = localString[g_language].noon_time;
  782. info_obj.start = SunCalc.getTimes(
  783. date,
  784. g_coordinate_this.AT,
  785. g_coordinate_this.LT,
  786. g_coordinate_this.height / 1000
  787. ).solarNoon;
  788. g_event_list_arr.push(info_obj);
  789. info_obj = new Object();
  790. info_obj.id = "sunset" + i;
  791. info_obj.title = localString[g_language].sun_set;
  792. info_obj.start = SunCalc.getTimes(
  793. date,
  794. g_coordinate_this.AT,
  795. g_coordinate_this.LT,
  796. g_coordinate_this.height / 1000
  797. ).sunset;
  798. g_event_list_arr.push(info_obj);
  799. }
  800. next_year.setDate(start_day.getDate() + 360);
  801. start_day.setDate(today.getDate() - 360);
  802. last_list = phaseRange(start_day, next_year, LAST); //获取下弦月列表
  803. for (i_last in last_list) {
  804. info_obj = new Object();
  805. info_obj.id = "last_moon" + i_last;
  806. info_obj.title = "🌗" + get_station_name(last_list[i_last]).lunar.value;
  807. info_obj.start = last_list[i_last];
  808. g_event_list_arr.push(info_obj);
  809. }
  810. new_list = phaseRange(start_day, next_year, NEW); //获取新月列表
  811. for (i_new in new_list) {
  812. info_obj = new Object();
  813. info_obj.id = "new_moon" + i_new;
  814. info_obj.title = "🌑" + get_station_name(new_list[i_new]).lunar.value;
  815. info_obj.start = new_list[i_new];
  816. g_event_list_arr.push(info_obj);
  817. }
  818. first_list = phaseRange(start_day, next_year, FIRST); //获取上弦月列表
  819. for (i_first in first_list) {
  820. info_obj = new Object();
  821. info_obj.id = "first_moon" + i_first;
  822. info_obj.title = "🌓" + get_station_name(first_list[i_first]).lunar.value;
  823. info_obj.start = first_list[i_first];
  824. g_event_list_arr.push(info_obj);
  825. }
  826. full_list = phaseRange(start_day, next_year, FULL); //获取满月列表
  827. for (i_full in full_list) {
  828. info_obj = new Object();
  829. info_obj.id = "full_moon" + i_full;
  830. info_obj.title = "🌕" + get_station_name(full_list[i_full]).lunar.value;
  831. info_obj.start = full_list[i_full];
  832. g_event_list_arr.push(info_obj);
  833. }
  834. /*console.log(last_list); //输出到控制台
  835. console.log(new_list); //输出到控制台
  836. console.log(first_list); //输出到控制台
  837. console.log(full_list); //输出到控制台*/
  838. }
  839. get_event_arr();
  840. </script>
  841. <script src="../lib/main.js"></script>
  842. <script>
  843. function getCookie(name) {
  844. var start = document.cookie.indexOf(name + "=");
  845. var len = start + name.length + 1;
  846. if (!start && name != document.cookie.substring(0, name.length)) {
  847. return null;
  848. }
  849. if (start == -1) return null;
  850. var end = document.cookie.indexOf(";", len);
  851. if (end == -1) end = document.cookie.length;
  852. return decodeURI(document.cookie.substring(len, end));
  853. }
  854. document.addEventListener("DOMContentLoaded", function () {
  855. var initialTimeZone = "local";
  856. var timeZoneSelectorEl = document.getElementById("time-zone-selector");
  857. var loadingEl = document.getElementById("loading");
  858. var calendarEl = document.getElementById("calendar");
  859. var calendar = new FullCalendar.Calendar(calendarEl, {
  860. timeZone: initialTimeZone,
  861. locale: getCookie("language"),
  862. headerToolbar: {
  863. left: "prev,next today",
  864. center: "title",
  865. right: "dayGridMonth,timeGridWeek,timeGridDay,listWeek",
  866. },
  867. //initialDate: "2020-12-12",
  868. navLinks: true, // can click day/week names to navigate views
  869. editable: true,
  870. selectable: true,
  871. dayMaxEvents: true, // allow "more" link when too many events
  872. //resources: g_event_list_arr,
  873. events: g_event_list_arr,
  874. defaultTimedEventDuration: "00:01",
  875. eventClick: function (info) {
  876. info.jsEvent.preventDefault(); // don't let the browser navigate
  877. if (info.event.url) {
  878. window.open(info.event.url);
  879. }
  880. },
  881. loading: function (bool) {
  882. if (bool) {
  883. loadingEl.style.display = "inline"; // show
  884. } else {
  885. loadingEl.style.display = "none"; // hide
  886. }
  887. },
  888. eventTimeFormat: { hour: "numeric", minute: "2-digit" },
  889. dateClick: function (arg) {
  890. console.log("dateClick", calendar.formatIso(arg.date));
  891. },
  892. select: function (arg) {
  893. console.log("select", calendar.formatIso(arg.start), calendar.formatIso(arg.end));
  894. },
  895. });
  896. calendar.render();
  897. // load the list of available timezones, build the <select> options
  898. // it's HIGHLY recommended to use a different library for network requests, not this internal util func
  899. FullCalendar.requestJson(
  900. "GET",
  901. "php/get-time-zones.php",
  902. {},
  903. function (timeZones) {
  904. timeZones.forEach(function (timeZone) {
  905. var optionEl;
  906. if (timeZone !== "UTC") {
  907. // UTC is already in the list
  908. optionEl = document.createElement("option");
  909. optionEl.value = timeZone;
  910. optionEl.innerText = timeZone;
  911. timeZoneSelectorEl.appendChild(optionEl);
  912. }
  913. });
  914. },
  915. function () {
  916. // TODO: handle error
  917. }
  918. );
  919. // when the timezone selector changes, dynamically change the calendar option
  920. timeZoneSelectorEl.addEventListener("change", function () {
  921. calendar.setOption("timeZone", this.value);
  922. });
  923. });
  924. </script>
  925. <style>
  926. body {
  927. margin: 0;
  928. padding: 0;
  929. font-family: Arial, Helvetica Neue, Helvetica, sans-serif;
  930. font-size: 14px;
  931. }
  932. #top {
  933. background: #eee;
  934. border-bottom: 1px solid #ddd;
  935. padding: 0 10px;
  936. line-height: 40px;
  937. font-size: 12px;
  938. }
  939. .left {
  940. float: left;
  941. }
  942. .right {
  943. float: right;
  944. }
  945. .clear {
  946. clear: both;
  947. }
  948. #script-warning,
  949. #loading {
  950. display: none;
  951. }
  952. #script-warning {
  953. font-weight: bold;
  954. color: red;
  955. }
  956. #calendar {
  957. max-width: 1100px;
  958. margin: 40px auto;
  959. padding: 0 10px;
  960. }
  961. .tzo {
  962. color: #000;
  963. }
  964. input[type="number" i] {
  965. width: 2.5em;
  966. }
  967. </style>
  968. </head>
  969. <body>
  970. <div id="top" style="display: inline-flex;width: 100vw;">
  971. <div class="left" style="display: inline-flex;height: 5vh;margin: auto 1em;">
  972. <span style="line-height: 5vh;white-space: nowrap;">
  973. <script>
  974. document.write(localString[g_language].timezone + ":");
  975. </script>
  976. </span>
  977. <select id="time-zone-selector">
  978. <option value="local" selected>
  979. <script>
  980. document.write(localString[g_language].local);
  981. </script>
  982. </option>
  983. <option value="UTC">UTC</option>
  984. </select>
  985. </div>
  986. <div style="display: inline-block;margin-left:5%; justify-content: center; width: 25em">
  987. <div style="line-height: 2em; margin-top: 7px">
  988. <script>
  989. document.write(localString[g_language].atitude);
  990. </script>
  991. <span id="AT_str" onclick="show_ele(this)"></span>
  992. <span class="coordinate_input" style="flex: 7; white-space: nowrap; display: none">
  993. <input id="AT_°" type="number" min="0" max="89" /> °
  994. <input id="AT_’" type="number" min="0" max="59" /> ’
  995. <input id="AT_”" type="number" min="0" max="59" /> ”
  996. <select id="NS">
  997. <option value="+">N</option>
  998. <option value="-">S</option>
  999. </select>
  1000. <button onclick="coordinate_confirm('AT')">
  1001. <script>
  1002. document.write(localString[g_language].confirm);
  1003. </script>
  1004. </button>
  1005. </span>
  1006. </div>
  1007. <div style="line-height: 2em">
  1008. <script>
  1009. document.write(localString[g_language].longitude);
  1010. </script>
  1011. <span id="LT_str" onclick="show_ele(this)"></span>
  1012. <span
  1013. class="coordinate_input"
  1014. onblur="show_ele(this)"
  1015. style="flex: 7; white-space: nowrap; display: none"
  1016. >
  1017. <input id="LT_°" type="number" min="0" max="179" style="width: 3em" /> °
  1018. <input id="LT_’" type="number" min="0" max="59" /> ’
  1019. <input id="LT_”" type="number" min="0" max="59" /> ”
  1020. <select id="WE">
  1021. <option value="+">E</option>
  1022. <option value="-">W</option>
  1023. </select>
  1024. <button onclick="coordinate_confirm('LT')">
  1025. <script>
  1026. document.write(localString[g_language].confirm);
  1027. </script>
  1028. </button>
  1029. </span>
  1030. </div>
  1031. <div style="line-height: 2em">
  1032. <script>
  1033. document.write(localString[g_language].altitude);
  1034. </script>
  1035. <span id="altitude_string" onclick="show_ele(this)"></span>
  1036. <span class="coordinate_input" style="flex: 7; white-space: nowrap; display: none">
  1037. <input id="HT_M" type="number" min="0" max="19999" style="width: 4em" /> M
  1038. <button onclick="coordinate_confirm('HT')">
  1039. <script>
  1040. document.write(localString[g_language].confirm);
  1041. </script>
  1042. </button>
  1043. </span>
  1044. </div>
  1045. </div>
  1046. <div style="display: inline-block; width: 50%; justify-content: center;">
  1047. <script>
  1048. document.write(localString[g_language].location);
  1049. </script>
  1050. <span id="city_str" onclick=""></span>
  1051. <span id="city_info" ></span>
  1052. <input class="cityinput" id="citySelect" value="" style="display: none;">
  1053. <div class="citySelector" style="position: absolute; left: 8px; top: 25.6px; z-index: 999999;">
  1054. <div class="cityBox hide" id="cityBox"></div>
  1055. </div>
  1056. </div>
  1057. <div class="right">
  1058. <span id="loading">
  1059. <script>
  1060. document.write(localString[g_language].loading + "…");
  1061. </script>
  1062. </span>
  1063. <span id="script-warning"><code>php/get-events.php</code> must be running.</span>
  1064. </div>
  1065. <div class="clear"></div>
  1066. </div>
  1067. <div id="calendar"></div>
  1068. </body>
  1069. <script>
  1070. $("#citySelect")[0].value=localString[g_language].city_name;
  1071. function position_modify() {
  1072. var LT = Number($("#LT_°")[0].value);
  1073. LT += Number($("#LT_’")[0].value) / 60;
  1074. LT += Number($("#LT_”")[0].value) / 3600;
  1075. LT = Number($("#WE")[0].value + LT);
  1076. var AT = Number($("#AT_°")[0].value);
  1077. AT += Number($("#AT_’")[0].value) / 60;
  1078. AT += Number($("#AT_”")[0].value) / 3600;
  1079. AT = Number($("#NS")[0].value + AT);
  1080. if (AT != 0 || LT!=0) {
  1081. g_coordinate_this.LT = LT;
  1082. g_coordinate_this.AT = AT;
  1083. }
  1084. g_coordinate_this.height=Number($("#HT_M")[0].value);
  1085. //将新的坐标数据存到localStorage
  1086. let position_string = g_coordinate_this.AT + "#" + g_coordinate_this.LT + "#" + g_coordinate_this.height;
  1087. localStorage.setItem("local_position", position_string);
  1088. show_position();
  1089. }
  1090. function position_modify_confirm(obj) {
  1091. position_modify();
  1092. show_ele(obj);
  1093. }
  1094. function show_ele(obj) {
  1095. if ($(obj).siblings("span").css("display") == "none") {
  1096. $(obj).hide();
  1097. $(obj).siblings("span").show();
  1098. } else {
  1099. $(obj).show();
  1100. $(obj).siblings("span").hide();
  1101. }
  1102. }
  1103. function getLocation() {
  1104. //自动定位
  1105. if (navigator.geolocation) {
  1106. navigator.geolocation.getCurrentPosition(showPosition, showError);
  1107. } else {
  1108. $("#selected_position_string").html("Geolocation is not supported by this browser.");
  1109. }
  1110. }
  1111. function showPosition(position) {
  1112. alert("get cordinate success");
  1113. g_coordinate_this.AT = position.coords.latitude; //纬度
  1114. g_coordinate_this.LT = position.coords.longitude; //经度
  1115. g_coordinate_this.height = position.coords.altitude; //海拔高度
  1116. }
  1117. function position_input() {
  1118. //手动输入
  1119. var LT = Number($("#LT_°")[0].value);
  1120. LT += Number($("#LT_’")[0].value) / 60;
  1121. LT += Number($("#LT_”")[0].value) / 3600;
  1122. LT = Number($("#WE")[0].value + LT);
  1123. var AT = Number($("#AT_°")[0].value);
  1124. AT += Number($("#AT_’")[0].value) / 60;
  1125. AT += Number($("#AT_”")[0].value) / 3600;
  1126. AT = Number($("#NS")[0].value + AT);
  1127. if (AT != 0) {
  1128. g_coordinate_this.LT = LT;
  1129. g_coordinate_this.AT = AT;
  1130. }
  1131. }
  1132. function showError(error) {
  1133. switch (error.code) {
  1134. case error.PERMISSION_DENIED:
  1135. alert("定位失败,用户拒绝请求地理定位");
  1136. break;
  1137. case error.POSITION_UNAVAILABLE:
  1138. alert("定位失败,位置信息是不可用");
  1139. break;
  1140. case error.TIMEOUT:
  1141. alert("定位失败,请求获取用户位置超时");
  1142. break;
  1143. case error.UNKNOWN_ERROR:
  1144. alert("定位失败,定位系统失效");
  1145. break;
  1146. }
  1147. }
  1148. function coordinate_confirm(type){
  1149. switch(type){
  1150. case "AT":
  1151. show_ele('#AT_str');
  1152. break;
  1153. case "LT":
  1154. show_ele('#LT_str');
  1155. break;
  1156. case "HT":
  1157. show_ele('#altitude_string');
  1158. break;
  1159. }
  1160. position_modify();
  1161. }
  1162. function show_position(){
  1163. curr_position = localStorage.getItem("local_position");
  1164. if (curr_position) {
  1165. g_coordinate_this.AT = curr_position.split("#")[0];
  1166. g_coordinate_this.LT = curr_position.split("#")[1];
  1167. g_coordinate_this.height = curr_position.split("#")[2];
  1168. if (g_coordinate_this.AT >= 0) {
  1169. var AT_string = angle_trans(g_coordinate_this.AT)[0]+"°" +angle_trans(g_coordinate_this.AT)[1] +
  1170. "’" +
  1171. angle_trans(g_coordinate_this.AT)[2] +
  1172. "” N";
  1173. } else {
  1174. var AT_string = angle_trans(0-g_coordinate_this.AT)[0]+"°" +angle_trans(0-g_coordinate_this.AT)[1] +
  1175. "’" +
  1176. angle_trans(0-g_coordinate_this.AT)[2] +
  1177. "” S";
  1178. }
  1179. if (g_coordinate_this.LT >= 0) {
  1180. var LT_string = angle_trans(g_coordinate_this.LT)[0]+"°" +angle_trans(g_coordinate_this.LT)[1] +
  1181. "’" +
  1182. angle_trans(g_coordinate_this.LT)[2] +
  1183. "” E";
  1184. } else {
  1185. var LT_string = angle_trans(0-g_coordinate_this.LT)[0]+"°" +angle_trans(0-g_coordinate_this.LT)[1] +
  1186. "’" +
  1187. angle_trans(0-g_coordinate_this.LT)[2] +
  1188. "” W";
  1189. }
  1190. if (g_coordinate_this.height != "null") {
  1191. var height_string = g_coordinate_this.height + "M";
  1192. } else {
  1193. var height_string = localString[g_language].unknown;
  1194. }
  1195. } else {
  1196. getLocation();
  1197. }
  1198. $("#AT_str").html(AT_string);
  1199. $("#LT_str").html(LT_string);
  1200. $("#altitude_string").html(height_string);
  1201. if(g_coordinate_this.AT<0){
  1202. $("#AT_°")[0].value = angle_trans(0-g_coordinate_this.AT)[0];
  1203. $("#AT_’")[0].value = angle_trans(0-g_coordinate_this.AT)[1];
  1204. $("#AT_”")[0].value = angle_trans(0-g_coordinate_this.AT)[2];
  1205. $("#NS")[0].value="-";
  1206. }
  1207. else{
  1208. $("#AT_°")[0].value = angle_trans(g_coordinate_this.AT)[0];
  1209. $("#AT_’")[0].value = angle_trans(g_coordinate_this.AT)[1];
  1210. $("#AT_”")[0].value = angle_trans(g_coordinate_this.AT)[2];
  1211. $("#NS")[0].value="+";
  1212. }
  1213. if(g_coordinate_this.LT<0){
  1214. $("#LT_°")[0].value = angle_trans(0-g_coordinate_this.LT)[0];
  1215. $("#LT_’")[0].value = angle_trans(0-g_coordinate_this.LT)[1];
  1216. $("#LT_”")[0].value = angle_trans(0-g_coordinate_this.LT)[2];
  1217. $("#WE")[0].value="-";
  1218. }
  1219. else{
  1220. $("#LT_°")[0].value = angle_trans(g_coordinate_this.LT)[0];
  1221. $("#LT_’")[0].value = angle_trans(g_coordinate_this.LT)[1];
  1222. $("#LT_”")[0].value = angle_trans(g_coordinate_this.LT)[2];
  1223. $("#WE")[0].value="+";
  1224. }
  1225. $("#HT_M")[0].value = g_coordinate_this.height;
  1226. $("#city_str").html(find_city(g_coordinate_this.AT,g_coordinate_this.LT).name);
  1227. }
  1228. show_position();
  1229. $(document).ready(function () {
  1230. $("button").each(function () {
  1231. if ($(this).html() == "today") {
  1232. $(this).html(localString[g_language].today);
  1233. }
  1234. if ($(this).html() == "list") {
  1235. $(this).html(localString[g_language].list);
  1236. }
  1237. if ($(this).html() == "week") {
  1238. $(this).html(localString[g_language].week);
  1239. }
  1240. if ($(this).html() == "month") {
  1241. $(this).html(localString[g_language].month);
  1242. }
  1243. if ($(this).html() == "day") {
  1244. $(this).html(localString[g_language].day);
  1245. }
  1246. });
  1247. });
  1248. $(document).ready(function () {
  1249. $("button").click(function () {
  1250. $("button").each(function () {
  1251. if ($(this).html().indexOf("today") != -1) {
  1252. $(this).html(localString[g_language].today);
  1253. }
  1254. if ($(this).html().indexOf("list") != -1) {
  1255. $(this).html(localString[g_language].list);
  1256. }
  1257. if ($(this).html().indexOf("week") != -1) {
  1258. $(this).html(localString[g_language].week);
  1259. }
  1260. if ($(this).html().indexOf("month") != -1) {
  1261. $(this).html(localString[g_language].month);
  1262. }
  1263. if ($(this).html().indexOf("day") != -1 && $(this).html().indexOf("today") == -1) {
  1264. $(this).html(localString[g_language].day);
  1265. }
  1266. });
  1267. });
  1268. });
  1269. $(document).ready(function () {
  1270. $("div").click(function () {
  1271. $("button").each(function () {
  1272. if ($(this).html().indexOf("today") != -1) {
  1273. $(this).html(localString[g_language].today);
  1274. }
  1275. if ($(this).html().indexOf("list") != -1) {
  1276. $(this).html(localString[g_language].list);
  1277. }
  1278. if ($(this).html().indexOf("week") != -1) {
  1279. $(this).html(localString[g_language].week);
  1280. }
  1281. if ($(this).html().indexOf("month") != -1) {
  1282. $(this).html(localString[g_language].month);
  1283. }
  1284. if ($(this).html().indexOf("day") != -1 && $(this).html().indexOf("today") == -1) {
  1285. $(this).html(localString[g_language].day);
  1286. }
  1287. });
  1288. });
  1289. });
  1290. //给出两个经纬度坐标直接的距离
  1291. function distance(x, y) {
  1292. var toRadians = function(num) {
  1293. return num * Math.PI / 180;
  1294. };
  1295. var lat1 = x.latitude;
  1296. var lon1 = x.longitude;
  1297. var lat2 = y.latitude;
  1298. var lon2 = y.longitude;
  1299. var R = 6371; // km
  1300. var φ1 = toRadians(lat1);//纬度弧度1
  1301. var φ2 = toRadians(lat2);//纬度弧度2
  1302. var Δφ = toRadians(lat2 - lat1);//纬度弧度差
  1303. var Δλ = toRadians(lon2 - lon1);//经度弧度差
  1304. var a = Math.sin(Δφ / 2) * Math.sin(Δφ / 2) +
  1305. Math.cos(φ1) * Math.cos(φ2) *
  1306. Math.sin(Δλ / 2) * Math.sin(Δλ / 2);
  1307. var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));
  1308. return R * c;
  1309. }
  1310. function find_city(latitude,longitude){
  1311. var point=new Object;
  1312. var point_X=new Object;
  1313. var city_info=new Object;
  1314. var min_S=10000
  1315. point.latitude=latitude;
  1316. point.longitude=longitude;
  1317. for(i in city_list){
  1318. point_X.latitude=city_list[i].latitude;
  1319. point_X.longitude=city_list[i].longitude;
  1320. if(distance(point,point_X)<min_S){
  1321. city_info=city_list[i];
  1322. min_S=distance(point,point_X);
  1323. }
  1324. }
  1325. if(min_S==10000){
  1326. city_info.name=localString[g_language].unknown;
  1327. city_info.asciiName=localString[g_language].unknown;
  1328. }
  1329. return(city_info);
  1330. }
  1331. </script>
  1332. <style type="text/css">
  1333. .demo{width:220px;margin:20px auto;}
  1334. /* citySelector */
  1335. .citySelector{font:12px/1.5 tahoma,arial,\5b8b\4f53;background:#fff;text-align:left;}
  1336. .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;}
  1337. .cityslide li{list-style:none;overflow:hidden;height:16px;padding:4px 5px;}
  1338. .cityslide li.on{background:#9CD9FF;color:#fff;}
  1339. .cityslide li b{font-weight:normal;}
  1340. .cityslide li.empty{background:#fff2e8;color:#666;}
  1341. .cityslide li.empty em{color:red;font-style:normal;}
  1342. .cityname{float:left;}
  1343. .cityspell{float:right;}
  1344. .cityBox{width:320px;border:1px solid #85BEE5;overflow:hidden;box-shadow:2px 2px 3px rgba(0,0,0,0.3);}
  1345. .cityBox ul{margin:0;padding:0;overflow:hidden;}
  1346. .cityBox ul li{float:left;list-style:none;padding:2px 4px;border:1px solid #85BEE5;cursor:pointer;margin-left:4px;display:inline;background:#E1EFFE;}
  1347. .cityBox ul li.on{background:#fff;border-bottom-color:#fff;position:relative;}
  1348. .hide{display:none;}
  1349. p.tip{color:#666;line-height:20px;padding:5px;margin:0;text-indent:3px;}
  1350. .hotCity{border-top:1px solid #85BEE5;margin-top:-1px;clear:left;overflow:hidden;padding-bottom:5px;padding-top:5px;_margin-bottom:8px;}
  1351. .cityTab{overflow:hidden;}
  1352. .cityTab dl{margin:0;padding:0;overflow:hidden;}
  1353. .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;}
  1354. .cityTab dl dd{margin-left:2px;float:left;width:290px;}
  1355. .cityTab dl dd a{padding-left:5px;width:66px;line-height:22px;display:inline-block;color:#000;text-decoration:none;}
  1356. .cityTab dl dd a:hover{text-decoration:underline;color:red}
  1357. .cityinput{ font-size: 12px; padding-left: 2px; background: url(T1EPyLXm0hXXXXXXXX-200-100.png) no-repeat 150px 5px; border: 1px solid #D8D8D8; }
  1358. </style>
  1359. <script type="text/javascript">
  1360. /* *
  1361. * ---------------------------------------- *
  1362. * 城市选择组件 v1.0
  1363. * Author: VVG
  1364. * QQ: 83816819
  1365. * Mail: mysheller@163.com
  1366. * http://www.cnblogs.com/NNUF/
  1367. * ---------------------------------------- *
  1368. * Date: 2012-07-10
  1369. * ---------------------------------------- *
  1370. * */
  1371. /* *
  1372. * 全局空间 Vcity
  1373. * */
  1374. var Vcity = {};
  1375. /* *
  1376. * 静态方法集
  1377. * @name _m
  1378. * */
  1379. Vcity._m = {
  1380. /* 选择元素 */
  1381. $:function (arg, context) {
  1382. var tagAll, n, eles = [], i, sub = arg.substring(1);
  1383. context = context || document;
  1384. if (typeof arg == 'string') {
  1385. switch (arg.charAt(0)) {
  1386. case '#':
  1387. return document.getElementById(sub);
  1388. break;
  1389. case '.':
  1390. if (context.getElementsByClassName) return context.getElementsByClassName(sub);
  1391. tagAll = Vcity._m.$('*', context);
  1392. n = tagAll.length;
  1393. for (i = 0; i < n; i++) {
  1394. if (tagAll[i].className.indexOf(sub) > -1) eles.push(tagAll[i]);
  1395. }
  1396. return eles;
  1397. break;
  1398. default:
  1399. return context.getElementsByTagName(arg);
  1400. break;
  1401. }
  1402. }
  1403. },
  1404. /* 绑定事件 */
  1405. on:function (node, type, handler) {
  1406. node.addEventListener ? node.addEventListener(type, handler, false) : node.attachEvent('on' + type, handler);
  1407. },
  1408. /* 获取事件 */
  1409. getEvent:function(event){
  1410. return event || window.event;
  1411. },
  1412. /* 获取事件目标 */
  1413. getTarget:function(event){
  1414. return event.target || event.srcElement;
  1415. },
  1416. /* 获取元素位置 */
  1417. getPos:function (node) {
  1418. var scrollx = document.documentElement.scrollLeft || document.body.scrollLeft,
  1419. scrollt = document.documentElement.scrollTop || document.body.scrollTop;
  1420. var pos = node.getBoundingClientRect();
  1421. return {top:pos.top + scrollt, right:pos.right + scrollx, bottom:pos.bottom + scrollt, left:pos.left + scrollx }
  1422. },
  1423. /* 添加样式名 */
  1424. addClass:function (c, node) {
  1425. if(!node)return;
  1426. node.className = Vcity._m.hasClass(c,node) ? node.className : node.className + ' ' + c ;
  1427. },
  1428. /* 移除样式名 */
  1429. removeClass:function (c, node) {
  1430. var reg = new RegExp("(^|\\s+)" + c + "(\\s+|$)", "g");
  1431. if(!Vcity._m.hasClass(c,node))return;
  1432. node.className = reg.test(node.className) ? node.className.replace(reg, '') : node.className;
  1433. },
  1434. /* 是否含有CLASS */
  1435. hasClass:function (c, node) {
  1436. if(!node || !node.className)return false;
  1437. return node.className.indexOf(c)>-1;
  1438. },
  1439. /* 阻止冒泡 */
  1440. stopPropagation:function (event) {
  1441. event = event || window.event;
  1442. event.stopPropagation ? event.stopPropagation() : event.cancelBubble = true;
  1443. },
  1444. /* 去除两端空格 */
  1445. trim:function (str) {
  1446. return str.replace(/^\s+|\s+$/g,'');
  1447. }
  1448. };
  1449. /* 所有城市数据,可以按照格式自行添加(北京|beijing|bj),前16条为热门城市 */
  1450. Vcity.allCity = ['北京|beijing|bj','上海|shanghai|sh', '重庆|chongqing|cq', '深圳|shenzhen|sz', '广州|guangzhou|gz', '杭州|hangzhou|hz',
  1451. '南京|nanjing|nj', '苏州|shuzhou|sz', '天津|tianjin|tj', '成都|chengdu|cd', '南昌|nanchang|nc', '三亚|sanya|sy','青岛|qingdao|qd',
  1452. '厦门|xiamen|xm', '西安|xian|xa','长沙|changsha|cs'];
  1453. var city_str_nex=""
  1454. for(i in city_list){
  1455. city_str_nex=city_list[i].name+"|"+city_list[i].asciiName+"|"+city_list[i].asciiName.slice(0,2);
  1456. Vcity.allCity.push(city_str_nex);
  1457. }
  1458. /* 正则表达式 筛选中文城市名、拼音、首字母 */
  1459. Vcity.regEx = /^([\u4E00-\u9FA5\uf900-\ufa2d]+)\|(\w+)\|(\w)\w*$/i;
  1460. Vcity.regExChiese = /([\u4E00-\u9FA5\uf900-\ufa2d]+)/;
  1461. /* *
  1462. * 格式化城市数组为对象oCity,按照a-h,i-p,q-z,hot热门城市分组:
  1463. * {HOT:{hot:[]},ABCDEFGH:{a:[1,2,3],b:[1,2,3]},IJKLMNOP:{i:[1.2.3],j:[1,2,3]},QRSTUVWXYZ:{}}
  1464. * */
  1465. (function () {
  1466. var citys = Vcity.allCity, match, letter,
  1467. regEx = Vcity.regEx,
  1468. reg2 = /^[a-h]$/i, reg3 = /^[i-p]$/i, reg4 = /^[q-z]$/i;
  1469. if (!Vcity.oCity) {
  1470. Vcity.oCity = {hot:{},ABCDEFGH:{}, IJKLMNOP:{}, QRSTUVWXYZ:{}};
  1471. //console.log(citys.length);
  1472. for (var i = 0, n = citys.length; i < n; i++) {
  1473. match = regEx.exec(citys[i]);
  1474. letter = match[3].toUpperCase();
  1475. if (reg2.test(letter)) {
  1476. if (!Vcity.oCity.ABCDEFGH[letter]) Vcity.oCity.ABCDEFGH[letter] = [];
  1477. Vcity.oCity.ABCDEFGH[letter].push(match[1]);
  1478. } else if (reg3.test(letter)) {
  1479. if (!Vcity.oCity.IJKLMNOP[letter]) Vcity.oCity.IJKLMNOP[letter] = [];
  1480. Vcity.oCity.IJKLMNOP[letter].push(match[1]);
  1481. } else if (reg4.test(letter)) {
  1482. if (!Vcity.oCity.QRSTUVWXYZ[letter]) Vcity.oCity.QRSTUVWXYZ[letter] = [];
  1483. Vcity.oCity.QRSTUVWXYZ[letter].push(match[1]);
  1484. }
  1485. /* 热门城市 前16条 */
  1486. if(i<16){
  1487. if(!Vcity.oCity.hot['hot']) Vcity.oCity.hot['hot'] = [];
  1488. Vcity.oCity.hot['hot'].push(match[1]);
  1489. }
  1490. }
  1491. }
  1492. })();
  1493. /* 城市HTML模板 */
  1494. Vcity._template = [
  1495. '<p class="tip">热门城市(支持汉字/拼音)</p>',
  1496. '<ul>',
  1497. '<li class="on">热门城市</li>',
  1498. '<li>A~H</li>',
  1499. '<li>I~P</li>',
  1500. '<li>Q~Z</li>',
  1501. '</ul>'
  1502. ];
  1503. /* *
  1504. * 城市控件构造函数
  1505. * @CitySelector
  1506. * */
  1507. Vcity.CitySelector = function () {
  1508. this.initialize.apply(this, arguments);
  1509. };
  1510. Vcity.CitySelector.prototype = {
  1511. constructor:Vcity.CitySelector,
  1512. /* 初始化 */
  1513. initialize :function (options) {
  1514. var input = options.input;
  1515. this.input = Vcity._m.$('#'+ input);
  1516. this.inputEvent();
  1517. },
  1518. /* *
  1519. * @createWarp
  1520. * 创建城市BOX HTML 框架
  1521. * */
  1522. createWarp:function(){
  1523. var inputPos = Vcity._m.getPos(this.input);
  1524. var div = this.rootDiv = document.createElement('div');
  1525. var that = this;
  1526. // 设置DIV阻止冒泡
  1527. Vcity._m.on(this.rootDiv,'click',function(event){
  1528. Vcity._m.stopPropagation(event);
  1529. });
  1530. // 设置点击文档隐藏弹出的城市选择框
  1531. Vcity._m.on(document, 'click', function (event) {
  1532. event = Vcity._m.getEvent(event);
  1533. var target = Vcity._m.getTarget(event);
  1534. if(target == that.input) return false;
  1535. //console.log(target.className);
  1536. if (that.cityBox)Vcity._m.addClass('hide', that.cityBox);
  1537. if (that.ul)Vcity._m.addClass('hide', that.ul);
  1538. if(that.myIframe)Vcity._m.addClass('hide',that.myIframe);
  1539. });
  1540. div.className = 'citySelector';
  1541. div.style.position = 'absolute';
  1542. div.style.left = inputPos.left + 'px';
  1543. div.style.top = inputPos.bottom + 'px';
  1544. div.style.zIndex = 999999;
  1545. // 判断是否IE6,如果是IE6需要添加iframe才能遮住SELECT框
  1546. var isIe = (document.all) ? true : false;
  1547. var isIE6 = this.isIE6 = isIe && !window.XMLHttpRequest;
  1548. if(isIE6){
  1549. var myIframe = this.myIframe = document.createElement('iframe');
  1550. myIframe.frameborder = '0';
  1551. myIframe.src = 'about:blank';
  1552. myIframe.style.position = 'absolute';
  1553. myIframe.style.zIndex = '-1';
  1554. this.rootDiv.appendChild(this.myIframe);
  1555. }
  1556. var childdiv = this.cityBox = document.createElement('div');
  1557. childdiv.className = 'cityBox';
  1558. childdiv.id = 'cityBox';
  1559. childdiv.innerHTML = Vcity._template.join('');
  1560. var hotCity = this.hotCity = document.createElement('div');
  1561. hotCity.className = 'hotCity';
  1562. childdiv.appendChild(hotCity);
  1563. div.appendChild(childdiv);
  1564. this.createHotCity();
  1565. },
  1566. /* *
  1567. * @createHotCity
  1568. * TAB下面DIV:hot,a-h,i-p,q-z 分类HTML生成,DOM操作
  1569. * {HOT:{hot:[]},ABCDEFGH:{a:[1,2,3],b:[1,2,3]},IJKLMNOP:{},QRSTUVWXYZ:{}}
  1570. **/
  1571. createHotCity:function(){
  1572. var odiv,odl,odt,odd,odda=[],str,key,ckey,sortKey,regEx = Vcity.regEx,
  1573. oCity = Vcity.oCity;
  1574. for(key in oCity){
  1575. odiv = this[key] = document.createElement('div');
  1576. // 先设置全部隐藏hide
  1577. odiv.className = key + ' ' + 'cityTab hide';
  1578. sortKey=[];
  1579. for(ckey in oCity[key]){
  1580. sortKey.push(ckey);
  1581. // ckey按照ABCDEDG顺序排序
  1582. sortKey.sort();
  1583. }
  1584. for(var j=0,k = sortKey.length;j<k;j++){
  1585. odl = document.createElement('dl');
  1586. odt = document.createElement('dt');
  1587. odd = document.createElement('dd');
  1588. odt.innerHTML = sortKey[j] == 'hot'?'&nbsp;':sortKey[j];
  1589. odda = [];
  1590. for(var i=0,n=oCity[key][sortKey[j]].length;i<n;i++){
  1591. str = '<a href="#">' + oCity[key][sortKey[j]][i] + '</a>';
  1592. odda.push(str);
  1593. }
  1594. odd.innerHTML = odda.join('');
  1595. odl.appendChild(odt);
  1596. odl.appendChild(odd);
  1597. odiv.appendChild(odl);
  1598. }
  1599. // 移除热门城市的隐藏CSS
  1600. Vcity._m.removeClass('hide',this.hot);
  1601. this.hotCity.appendChild(odiv);
  1602. }
  1603. document.body.appendChild(this.rootDiv);
  1604. /* IE6 */
  1605. this.changeIframe();
  1606. this.tabChange();
  1607. this.linkEvent();
  1608. },
  1609. /* *
  1610. * tab按字母顺序切换
  1611. * @ tabChange
  1612. * */
  1613. tabChange:function(){
  1614. var lis = Vcity._m.$('li',this.cityBox);
  1615. var divs = Vcity._m.$('div',this.hotCity);
  1616. var that = this;
  1617. for(var i=0,n=lis.length;i<n;i++){
  1618. lis[i].index = i;
  1619. lis[i].onclick = function(){
  1620. for(var j=0;j<n;j++){
  1621. Vcity._m.removeClass('on',lis[j]);
  1622. Vcity._m.addClass('hide',divs[j]);
  1623. }
  1624. Vcity._m.addClass('on',this);
  1625. Vcity._m.removeClass('hide',divs[this.index]);
  1626. /* IE6 改变TAB的时候 改变Iframe 大小*/
  1627. that.changeIframe();
  1628. };
  1629. }
  1630. },
  1631. /* *
  1632. * 城市LINK事件
  1633. * @linkEvent
  1634. * */
  1635. linkEvent:function(){
  1636. var links = Vcity._m.$('a',this.hotCity);
  1637. var that = this;
  1638. for(var i=0,n=links.length;i<n;i++){
  1639. links[i].onclick = function(){
  1640. that.input.value = this.innerHTML;
  1641. Vcity._m.addClass('hide',that.cityBox);
  1642. /* 点击城市名的时候隐藏myIframe */
  1643. Vcity._m.addClass('hide',that.myIframe);
  1644. }
  1645. }
  1646. },
  1647. /* *
  1648. * INPUT城市输入框事件
  1649. * @inputEvent
  1650. * */
  1651. inputEvent:function(){
  1652. var that = this;
  1653. Vcity._m.on(this.input,'click',function(event){
  1654. event = event || window.event;
  1655. if(!that.cityBox){
  1656. that.createWarp();
  1657. }else if(!!that.cityBox && Vcity._m.hasClass('hide',that.cityBox)){
  1658. // slideul 不存在或者 slideul存在但是是隐藏的时候 两者不能共存
  1659. if(!that.ul || (that.ul && Vcity._m.hasClass('hide',that.ul))){
  1660. Vcity._m.removeClass('hide',that.cityBox);
  1661. /* IE6 移除iframe 的hide 样式 */
  1662. //alert('click');
  1663. Vcity._m.removeClass('hide',that.myIframe);
  1664. that.changeIframe();
  1665. }
  1666. }
  1667. });
  1668. Vcity._m.on(this.input,'focus',function(){
  1669. that.input.select();
  1670. if(that.input.value == localString[g_language].city_name) that.input.value = '';
  1671. });
  1672. Vcity._m.on(this.input,'blur',function(){
  1673. if(that.input.value == '') that.input.value = localString[g_language].city_name;
  1674. });
  1675. Vcity._m.on(this.input,'keyup',function(event){
  1676. event = event || window.event;
  1677. var keycode = event.keyCode;
  1678. Vcity._m.addClass('hide',that.cityBox);
  1679. that.createUl();
  1680. /* 移除iframe 的hide 样式 */
  1681. Vcity._m.removeClass('hide',that.myIframe);
  1682. // 下拉菜单显示的时候捕捉按键事件
  1683. if(that.ul && !Vcity._m.hasClass('hide',that.ul) && !that.isEmpty){
  1684. that.KeyboardEvent(event,keycode);
  1685. }
  1686. });
  1687. },
  1688. /* *
  1689. * 生成下拉选择列表
  1690. * @ createUl
  1691. * */
  1692. createUl:function () {
  1693. //console.log('createUL');
  1694. var str;
  1695. var value = Vcity._m.trim(this.input.value);
  1696. // 当value不等于空的时候执行
  1697. if (value !== '') {
  1698. var reg = new RegExp("^" + value + "|\\|" + value, 'gi');
  1699. // 此处需设置中文输入法也可用onpropertychange
  1700. var searchResult = [];
  1701. for (var i = 0, n = Vcity.allCity.length; i < n; i++) {
  1702. if (reg.test(Vcity.allCity[i])) {
  1703. var match = Vcity.regEx.exec(Vcity.allCity[i]);
  1704. if (searchResult.length !== 0) {
  1705. str = '<li><b class="cityname">' + match[1] + '</b><b class="cityspell">' + match[2] + '</b></li>';
  1706. } else {
  1707. str = '<li class="on"><b class="cityname">' + match[1] + '</b><b class="cityspell">' + match[2] + '</b></li>';
  1708. }
  1709. searchResult.push(str);
  1710. }
  1711. }
  1712. this.isEmpty = false;
  1713. // 如果搜索数据为空
  1714. if (searchResult.length == 0) {
  1715. this.isEmpty = true;
  1716. str = '<li class="empty">对不起,没有找到数据 "<em>' + value + '</em>"</li>';
  1717. searchResult.push(str);
  1718. }
  1719. // 如果slideul不存在则添加ul
  1720. if (!this.ul) {
  1721. var ul = this.ul = document.createElement('ul');
  1722. ul.className = 'cityslide';
  1723. this.rootDiv && this.rootDiv.appendChild(ul);
  1724. // 记录按键次数,方向键
  1725. this.count = 0;
  1726. } else if (this.ul && Vcity._m.hasClass('hide', this.ul)) {
  1727. this.count = 0;
  1728. Vcity._m.removeClass('hide', this.ul);
  1729. }
  1730. this.ul.innerHTML = searchResult.join('');
  1731. /* IE6 */
  1732. this.changeIframe();
  1733. // 绑定Li事件
  1734. this.liEvent();
  1735. }else{
  1736. Vcity._m.addClass('hide',this.ul);
  1737. Vcity._m.removeClass('hide',this.cityBox);
  1738. Vcity._m.removeClass('hide',this.myIframe);
  1739. this.changeIframe();
  1740. }
  1741. },
  1742. /* IE6的改变遮罩SELECT 的 IFRAME尺寸大小 */
  1743. changeIframe:function(){
  1744. if(!this.isIE6)return;
  1745. this.myIframe.style.width = this.rootDiv.offsetWidth + 'px';
  1746. this.myIframe.style.height = this.rootDiv.offsetHeight + 'px';
  1747. },
  1748. /* *
  1749. * 特定键盘事件,上、下、Enter键
  1750. * @ KeyboardEvent
  1751. * */
  1752. KeyboardEvent:function(event,keycode){
  1753. var lis = Vcity._m.$('li',this.ul);
  1754. var len = lis.length;
  1755. switch(keycode){
  1756. case 40: //向下箭头↓
  1757. this.count++;
  1758. if(this.count > len-1) this.count = 0;
  1759. for(var i=0;i<len;i++){
  1760. Vcity._m.removeClass('on',lis[i]);
  1761. }
  1762. Vcity._m.addClass('on',lis[this.count]);
  1763. break;
  1764. case 38: //向上箭头↑
  1765. this.count--;
  1766. if(this.count<0) this.count = len-1;
  1767. for(i=0;i<len;i++){
  1768. Vcity._m.removeClass('on',lis[i]);
  1769. }
  1770. Vcity._m.addClass('on',lis[this.count]);
  1771. break;
  1772. case 13: // enter键
  1773. this.input.value = Vcity.regExChiese.exec(lis[this.count].innerHTML)[0];
  1774. Vcity._m.addClass('hide',this.ul);
  1775. Vcity._m.addClass('hide',this.ul);
  1776. /* IE6 */
  1777. Vcity._m.addClass('hide',this.myIframe);
  1778. break;
  1779. default:
  1780. break;
  1781. }
  1782. },
  1783. /* *
  1784. * 下拉列表的li事件
  1785. * @ liEvent
  1786. * */
  1787. liEvent:function(){
  1788. var that = this;
  1789. var lis = Vcity._m.$('li',this.ul);
  1790. for(var i = 0,n = lis.length;i < n;i++){
  1791. Vcity._m.on(lis[i],'click',function(event){
  1792. event = Vcity._m.getEvent(event);
  1793. var target = Vcity._m.getTarget(event);
  1794. that.input.value = Vcity.regExChiese.exec(target.innerHTML)[0];
  1795. Vcity._m.addClass('hide',that.ul);
  1796. /* IE6 下拉菜单点击事件 */
  1797. Vcity._m.addClass('hide',that.myIframe);
  1798. });
  1799. Vcity._m.on(lis[i],'mouseover',function(event){
  1800. event = Vcity._m.getEvent(event);
  1801. var target = Vcity._m.getTarget(event);
  1802. Vcity._m.addClass('on',target);
  1803. });
  1804. Vcity._m.on(lis[i],'mouseout',function(event){
  1805. event = Vcity._m.getEvent(event);
  1806. var target = Vcity._m.getTarget(event);
  1807. Vcity._m.removeClass('on',target);
  1808. })
  1809. }
  1810. }
  1811. };
  1812. var test=new Vcity.CitySelector({input:'citySelect'});
  1813. var test2=new Vcity.CitySelector({input:'citySelect1'});
  1814. </script>
  1815. </body>
  1816. </html>