index.html 63 KB

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