jquery.leoweather.min.js 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  1. (function($) {
  2. $.fn.leoweather = function(opts) {
  3. var defaults = {
  4. city: '',
  5. format: '\u5c0a\u656c\u7684\u4f1a\u5458\uff0c\u007b\u65f6\u6bb5\u007d\u597d\uff01\u0020\u73b0\u5728\u662f\uff1a\u007b\u5e74\u007d\u002f\u007b\u6708\u007d\u002f\u007b\u65e5\u007d\u0020\u007b\u65f6\u007d\u003a\u007b\u5206\u007d\u003a\u007b\u79d2\u007d\u0020\u661f\u671f\u007b\u5468\u007d\u0020\u60a8\u6240\u5728\u7684\u57ce\u5e02\uff1a\u007b\u57ce\u5e02\u007d\u0020\u4eca\u5929\u007b\u663c\u591c\u007d\u7684\u5929\u6c14\u662f\uff1a\u007b\u5929\u6c14\u007d\u0020\u6c14\u6e29\uff1a\u007b\u6c14\u6e29\u007d\u0020\u98ce\u5411\uff1a\u007b\u98ce\u5411\u007d\u0020\u98ce\u7ea7\uff1a\u007b\u98ce\u7ea7\u007d\u0020\u56fe\u6807\uff1a\u007b\u56fe\u6807\u007d'
  6. };
  7. var options = $.extend(defaults, opts);
  8. return this.each(function() {
  9. var obj = $(this),
  10. weather = new Array(),
  11. format = UC8F6C6362(options.format),
  12. url = '\u0068\u0074\u0074\u0070\u003a\u002f\u002f\u0070\u0068\u0070\u002e\u0077\u0065\u0061\u0074\u0068\u0065\u0072\u002e\u0073\u0069\u006e\u0061\u002e\u0063\u006f\u006d\u002e\u0063\u006e\u002f\u0069\u0066\u0072\u0061\u006d\u0065\u002f\u0069\u006e\u0064\u0065\u0078\u002f\u0077\u005f\u0063\u006c\u002e\u0070\u0068\u0070\u003f\u0063\u006f\u0064\u0065\u003d\u006a\u0073\u0026\u0064\u0061\u0079\u003d\u0030\u0026\u0063\u0069\u0074\u0079\u003d';
  13. var model = format.match(/\{.*?\}/g),
  14. action = new Array();
  15. for (var i = 0; model.length > i; i++) {
  16. action[i] = 'UC' + escape(model[i]).replace(/%u/g, '').replace(/%7B/g, '').replace(/%7D/g, '')
  17. };
  18. var valid = action.toString();
  19. if (valid.indexOf('UC57CE5E02') > 0 || valid.indexOf('UC59296C14') > 0 || valid.indexOf('UC6C146E29') > 0 || valid.indexOf('UC98CE5411') > 0 || valid.indexOf('UC98CE7EA7') > 0 || valid.indexOf('UC57CE5E02') > 0 || valid.indexOf('UC56FE6807') > 0) {
  20. $.ajax({
  21. url: UC7F515740(url, options.city),
  22. dataType: "script",
  23. success: function() {
  24. for (s in SWther.w) {
  25. var data = SWther.w[s][0];
  26. weather['name'] = s;
  27. weather['d1'] = data['d1'];
  28. weather['p1'] = data['p1'];
  29. weather['s1'] = data['s1'];
  30. weather['t1'] = data['t1'];
  31. weather['f1'] = data['f1'];
  32. weather['d2'] = data['d2'];
  33. weather['p2'] = data['p2'];
  34. weather['s2'] = data['s2'];
  35. weather['t2'] = data['t2'];
  36. weather['f2'] = data['f2']
  37. };
  38. getcontent(obj, weather)
  39. }
  40. })
  41. } else {
  42. getcontent(obj, '')
  43. };
  44. function getcontent(o, w) {
  45. var d = new Date(),
  46. timer = 0;
  47. for (var i = 0; action.length > i; i++) {
  48. str = format.replace(/\{(.*?)\}/g,
  49. function(a, b) {
  50. var fun = 'UC' + escape(b).replace(/%u/g, '').replace(/%7B/g, '').replace(/%7D/g, '');
  51. return eval(fun + '(d,w)')
  52. })
  53. };
  54. if (action.toString().indexOf('UC65F6') > 0) {
  55. timer = 1000 * 60 * 60
  56. };
  57. if (action.toString().indexOf('UC5206') > 0) {
  58. timer = 1000 * 60
  59. };
  60. if (action.toString().indexOf('UC79D2') > 0) {
  61. timer = 1000
  62. };
  63. o.html(str);
  64. if (timer > 0) {
  65. var ClockTimer = setInterval(UC66F465B0SJ, timer)
  66. }
  67. }
  68. function UC66F465B0SJ() {
  69. var today = new Date();
  70. YY = today.getYear();
  71. if (YY < 1900) YY = YY + 1900;
  72. var MM = today.getMonth() + 1;
  73. if (MM < 10) MM = '0' + MM;
  74. var DD = today.getDate();
  75. if (DD < 10) DD = '0' + DD;
  76. var hh = today.getHours();
  77. if (hh < 10) hh = '0' + hh;
  78. var mm = today.getMinutes();
  79. if (mm < 10) mm = '0' + mm;
  80. var ss = today.getSeconds();
  81. if (ss < 10) ss = '0' + ss;
  82. var ww = today.getDay();
  83. if (ww == 0) ww = UC8F6C6362('\u65e5');
  84. if (ww == 1) ww = UC8F6C6362('\u4e00');
  85. if (ww == 2) ww = UC8F6C6362('\u4e8c');
  86. if (ww == 3) ww = UC8F6C6362('\u4e09');
  87. if (ww == 4) ww = UC8F6C6362('\u56db');
  88. if (ww == 5) ww = UC8F6C6362('\u4e94');
  89. if (ww == 6) ww = UC8F6C6362('\u516d');
  90. if (hh < 06) {
  91. xx = UC8F6C6362('\u51cc\u6668')
  92. } else if (hh < 09) {
  93. xx = UC8F6C6362('\u65e9\u4e0a')
  94. } else if (hh < 12) {
  95. xx = UC8F6C6362('\u4e0a\u5348')
  96. } else if (hh < 14) {
  97. xx = UC8F6C6362('\u4e2d\u5348')
  98. } else if (hh < 17) {
  99. xx = UC8F6C6362('\u4e0b\u5348')
  100. } else if (hh < 19) {
  101. xx = UC8F6C6362('\u508d\u665a')
  102. } else {
  103. xx = UC8F6C6362('\u665a\u4e0a')
  104. };
  105. $('#weather_YY').html(YY);
  106. $('#weather_MM').html(MM);
  107. $('#weather_DD').html(DD);
  108. $('#weather_hh').html(hh);
  109. $('#weather_mm').html(mm);
  110. $('#weather_ss').html(ss);
  111. $('#weather_ww').html(ww);
  112. $('#weather_xx').html(xx)
  113. }
  114. function UC5E74(today, weather) {
  115. YY = today.getYear();
  116. if (YY < 1900) YY = YY + 1900;
  117. return '<span id="weather_YY">' + YY + '</span>'
  118. }
  119. function UC6708(today, weather) {
  120. var MM = today.getMonth() + 1;
  121. if (MM < 10) MM = '0' + MM;
  122. return '<span id="weather_MM">' + MM + '</span>'
  123. }
  124. function UC65E5(today, weather) {
  125. var DD = today.getDate();
  126. if (DD < 10) DD = '0' + DD;
  127. return '<span id="weather_DD">' + DD + '</span>'
  128. }
  129. function UC65F6(today, weather) {
  130. var hh = today.getHours();
  131. if (hh < 10) hh = '0' + hh;
  132. return '<span id="weather_hh">' + hh + '</span>'
  133. }
  134. function UC5206(today, weather) {
  135. var mm = today.getMinutes();
  136. if (mm < 10) mm = '0' + mm;
  137. return '<span id="weather_mm">' + mm + '</span>'
  138. }
  139. function UC79D2(today, weather) {
  140. var ss = today.getSeconds();
  141. if (ss < 10) ss = '0' + ss;
  142. return '<span id="weather_ss">' + ss + '</span>'
  143. }
  144. function UC5468(today, weather) {
  145. var ww = today.getDay();
  146. if (ww == 0) ww = UC8F6C6362('\u65e5');
  147. if (ww == 1) ww = UC8F6C6362('\u4e00');
  148. if (ww == 2) ww = UC8F6C6362('\u4e8c');
  149. if (ww == 3) ww = UC8F6C6362('\u4e09');
  150. if (ww == 4) ww = UC8F6C6362('\u56db');
  151. if (ww == 5) ww = UC8F6C6362('\u4e94');
  152. if (ww == 6) ww = UC8F6C6362('\u516d');
  153. return '<span id="weather_ww">' + ww + '</span>'
  154. }
  155. function UC65F66BB5(today, weather) {
  156. var hh = today.getHours();
  157. if (hh < 06) {
  158. xx = UC8F6C6362('\u51cc\u6668')
  159. } else if (hh < 09) {
  160. xx = UC8F6C6362('\u65e9\u4e0a')
  161. } else if (hh < 12) {
  162. xx = UC8F6C6362('\u4e0a\u5348')
  163. } else if (hh < 14) {
  164. xx = UC8F6C6362('\u4e2d\u5348')
  165. } else if (hh < 17) {
  166. xx = UC8F6C6362('\u4e0b\u5348')
  167. } else if (hh < 19) {
  168. xx = UC8F6C6362('\u508d\u665a')
  169. } else {
  170. xx = UC8F6C6362('\u665a\u4e0a')
  171. };
  172. return '<span id="weather_xx">' + xx + '</span>'
  173. }
  174. function UC57CE5E02(today, weather) {
  175. return weather['name']
  176. }
  177. function UC59296C14(today, weather) {
  178. if (today.getHours() > 18 && today.getHours() < 8) {
  179. return UC591C95F459296C14(today, weather)
  180. } else {
  181. return UC767D592959296C14(today, weather)
  182. }
  183. }
  184. function UC767D592959296C14(today, weather) {
  185. return weather['s1']
  186. }
  187. function UC591C95F459296C14(today, weather) {
  188. return weather['s2']
  189. }
  190. function UC6C146E29(today, weather) {
  191. if (today.getHours() > 18 && today.getHours() < 8) {
  192. return UC591C95F46C146E29(today, weather)
  193. } else {
  194. return UC767D59296C146E29(today, weather)
  195. }
  196. }
  197. function UC767D59296C146E29(today, weather) {
  198. return weather['t1']
  199. }
  200. function UC591C95F46C146E29(today, weather) {
  201. return weather['t2']
  202. }
  203. function UC98CE5411(today, weather) {
  204. if (today.getHours() > 18 && today.getHours() < 8) {
  205. return UC591C95F498CE5411(today, weather)
  206. } else {
  207. return UC767D592998CE5411(today, weather)
  208. }
  209. }
  210. function UC767D592998CE5411(today, weather) {
  211. return weather['d1']
  212. }
  213. function UC591C95F498CE5411(today, weather) {
  214. return weather['d2']
  215. }
  216. function UC98CE7EA7(today, weather) {
  217. if (today.getHours() > 18 && today.getHours() < 8) {
  218. return UC591C95F498CE7EA7(today, weather)
  219. } else {
  220. return UC767D592998CE7EA7(today, weather)
  221. }
  222. }
  223. function UC767D592998CE7EA7(today, weather) {
  224. return weather['p1']
  225. }
  226. function UC591C95F498CE7EA7(today, weather) {
  227. return weather['p2']
  228. }
  229. function UC56FE6807(today, weather) {
  230. if (today.getHours() > 18 && today.getHours() < 8) {
  231. return UC591C95F456FE6807(today, weather)
  232. } else {
  233. return UC767D592956FE6807(today, weather)
  234. }
  235. }
  236. function UC767D592956FE6807(today, weather) {
  237. return weather['f1']
  238. }
  239. function UC591C95F456FE6807(today, weather) {
  240. return weather['f2']
  241. }
  242. function UC663C591C(today, weather) {
  243. if (today.getHours() > 18 && today.getHours() < 8) {
  244. return UC8F6C6362('\u591c\u95f4')
  245. } else {
  246. return UC8F6C6362('\u767d\u5929')
  247. }
  248. }
  249. function UC8F6C6362(string) {
  250. return unescape(string.replace(/\u/g, "%u"))
  251. }
  252. function UC7F515740(url, city) {
  253. return UC8F6C6362(url) + city + UC8F6C6362('\u0026\u0064\u0066\u0063\u003d\u0031\u0026\u0063\u0068\u0061\u0072\u0073\u0065\u0074\u003d\u0075\u0074\u0066\u002d\u0038').replace(/\%/g, '')
  254. }
  255. })
  256. }
  257. })(jQuery);