index.html 61 KB

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