Advertisement
Guest User

ke

a guest
Mar 2nd, 2016
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 24.66 KB | None | 0 0
  1. Some source from login.js
  2.  
  3. "use strict";
  4. var FADE_DURATION = .45;
  5. var FADE_DELAY = 20;
  6. var AJAX_TIMEOUT = 3e4;
  7. var LOCALE_FADES = [];
  8. var HAS_CSS_OPACITY = "opacity" in document.body.style;
  9. var login_form = DOM.get("login_form");
  10. var login_username_el = DOM.get("user");
  11. var login_password_el = DOM.get("pass");
  12. var login_submit_el = DOM.get("login_submit");
  13. var goto_app = DOM.get("goto_app");
  14. var goto_uri = DOM.get("goto_uri");
  15. var div_cache = {
  16. "login-page": DOM.get("login-page") || false,
  17. "locale-container": DOM.get("locale-container") || false,
  18. "login-container": DOM.get("login-container") || false,
  19. "locale-footer": DOM.get("locale-footer") || false,
  20. "content-cell": DOM.get("content-container") || false,
  21. invalid: DOM.get("invalid") || false
  22. };
  23. var content_cell = div_cache["content-cell"];
  24. if (div_cache["locale-footer"]) div_cache["locale-footer"].style.display = "block";
  25. var reset_form = DOM.get("reset_form");
  26. var reset_username_el = DOM.get("reset_pass_username");
  27. var RESET_FADES = [];
  28. var show_reset = function() {
  29. if (!reset_username_el.value) reset_username_el.value = login_username_el.value;
  30. while (RESET_FADES.length) clearInterval(RESET_FADES.shift());
  31. RESET_FADES.push(fade_in(reset_form));
  32. RESET_FADES.push(fade_out(login_form));
  33. reset_username_el.focus()
  34. };
  35. var hide_reset = function() {
  36. while (RESET_FADES.length) clearInterval(RESET_FADES.shift());
  37. RESET_FADES.push(fade_in(login_form));
  38. RESET_FADES.push(fade_out(reset_form));
  39. login_username_el.focus()
  40. };
  41.  
  42. function toggle_locales(show_locales) {
  43. while (LOCALE_FADES.length) clearInterval(LOCALE_FADES.shift());
  44. var newly_shown = div_cache[show_locales ? "locale-container" : "login-container"];
  45. set_opacity(newly_shown, 0);
  46. if (HAS_CSS_OPACITY) {
  47. content_cell.replaceChild(newly_shown, content_cell.children[0])
  48. } else {
  49. var old = content_cell.children[0];
  50. content_cell.insertBefore(newly_shown, old);
  51. newly_shown.style.display = "";
  52. old.style.display = "none"
  53. }
  54. LOCALE_FADES.push(fade_in(newly_shown));
  55. LOCALE_FADES.push((show_locales ? fade_out : fade_in)("locale-footer"))
  56. }
  57. if (HAS_CSS_OPACITY) {
  58. var set_opacity = function set_opacity(el, opacity) {
  59. el.style.opacity = opacity
  60. }
  61. } else {
  62. var filter_regex = /(DXImageTransform\.Microsoft\.Alpha\()[^)]*\)/;
  63. var set_opacity = function set_opacity(el, opacity) {
  64. var filter_text = el.currentStyle.filter;
  65. if (!filter_text) {
  66. el.style.filter = "progid:DXImageTransform.Microsoft.Alpha(enabled=true)"
  67. } else if (!filter_regex.test(filter_text)) {
  68. el.style.filter += " progid:DXImageTransform.Microsoft.Alpha(enabled=true)"
  69. } else {
  70. var new_filter = filter_text.replace(filter_regex, "$1enabled=true)");
  71. if (new_filter !== filter_text) el.style.filter = new_filter
  72. }
  73. try {
  74. el.filters.item("DXImageTransform.Microsoft.Alpha").opacity = opacity * 100
  75. } catch (e) {
  76. try {
  77. el.filters.item("alpha").opacity = opacity * 100
  78. } catch (error) {}
  79. }
  80. }
  81. }
  82.  
  83. function fade_in(el, duration, _fade_out_instead) {
  84. el = div_cache[el] || DOM.get(el) || el;
  85. var style_obj = el.style;
  86. var interval;
  87. var cur_style = window.getComputedStyle ? getComputedStyle(el, null) : el.currentStyle;
  88. var visibility = cur_style.visibility;
  89. var start_opacity;
  90. if (el.offsetWidth && visibility !== "hidden") {
  91. if (window.getComputedStyle) {
  92. start_opacity = Number(cur_style.opacity)
  93. } else {
  94. try {
  95. start_opacity = el.filters.item("DXImageTransform.Microsoft.Alpha").opacity
  96. } catch (e) {
  97. try {
  98. start_opacity = el.filters("alpha").opacity
  99. } catch (error) {
  100. start_opacity = 100
  101. }
  102. }
  103. start_opacity /= 100
  104. }
  105. if (!start_opacity) start_opacity = 0
  106. } else {
  107. start_opacity = 0;
  108. set_opacity(el, 0)
  109. }
  110. if (_fade_out_instead && start_opacity < .01) {
  111. if (start_opacity) set_opacity(el, 0);
  112. return
  113. }
  114. if (!duration) duration = FADE_DURATION;
  115. var duration_ms = duration * 1e3;
  116. var start = new Date;
  117. var end;
  118. if (_fade_out_instead) {
  119. end = duration_ms + start.getTime()
  120. } else {
  121. style_obj.visibility = "visible"
  122. }
  123. var fader = function() {
  124. var opacity;
  125. if (_fade_out_instead) {
  126. opacity = start_opacity * (end - new Date) / duration_ms;
  127. if (opacity <= 0) {
  128. opacity = 0;
  129. clearInterval(interval);
  130. style_obj.visibility = "hidden"
  131. }
  132. } else {
  133. opacity = start_opacity + (1 - start_opacity) * (new Date - start) / duration_ms;
  134. if (opacity >= 1) {
  135. opacity = 1;
  136. clearInterval(interval)
  137. }
  138. }
  139. set_opacity(el, opacity)
  140. };
  141. fader();
  142. interval = setInterval(fader, FADE_DELAY);
  143. return interval
  144. }
  145.  
  146. function fade_out(el, timeout) {
  147. return fade_in(el, timeout, true)
  148. }
  149.  
  150. function ajaxObject(url, callbackFunction) {
  151. this._url = url;
  152. this._callback = callbackFunction || function() {}
  153. }
  154. ajaxObject.prototype.updating = false;
  155. ajaxObject.prototype.abort = function() {
  156. if (this.updating) {
  157. this.AJAX.abort();
  158. delete this.AJAX
  159. }
  160. };
  161. ajaxObject.prototype.update = function(passData, postMethod) {
  162. if (this.AJAX) return false;
  163. var ajax = null;
  164. if (window.XMLHttpRequest) {
  165. ajax = new XMLHttpRequest
  166. } else if (window.ActiveXObject) {
  167. ajax = new ActiveXObject("Microsoft.XMLHTTP")
  168. } else {
  169. return false
  170. }
  171. var timeout;
  172. var that = this;
  173. ajax.onreadystatechange = function() {
  174. if (ajax.readyState == 4) {
  175. clearTimeout(timeout);
  176. that.updating = false;
  177. that._callback(ajax);
  178. delete that.AJAX
  179. }
  180. };
  181. try {
  182. var uri;
  183. timeout = setTimeout(function() {
  184. that.abort();
  185. show_status(MESSAGES.ajax_timeout, "error")
  186. }, AJAX_TIMEOUT);
  187. if (/post/i.test(postMethod)) {
  188. uri = this._url + "?login_only=1";
  189. ajax.open("POST", uri, true);
  190. ajax.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  191. ajax.send(passData)
  192. } else {
  193. uri = this._url + "?" + passData + "&timestamp=" + (new Date).getTime();
  194. ajax.open("GET", uri, true);
  195. ajax.send(null)
  196. }
  197. this.AJAX = ajax;
  198. this.updating = true
  199. } catch (e) {
  200. login_form.submit()
  201. }
  202. return true
  203. };
  204. var _text_content = "textContent" in document.body ? "textContent" : "innerText";
  205.  
  206. function login_results(ajax_obj) {
  207. var result;
  208. try {
  209. result = JSON.parse(ajax_obj && ajax_obj.responseText)
  210. } catch (e) {
  211. result = null
  212. }
  213. var response_status = ajax_obj.status;
  214. if (response_status === 200) {
  215. if (result) {
  216. var final_uri;
  217. var login_url_regex = /^\/(?:logout|login|openid_connect_callback)\/?/;
  218. if (result.redirect && !login_url_regex.test(result.redirect)) {
  219. final_uri = result.redirect
  220. }
  221. var location_obj_to_redirect;
  222. if (/^(?:\/cpsess[^\/]+)\/$/.test(final_uri)) {
  223. location_obj_to_redirect = top.location
  224. } else {
  225. if (result.security_token && top !== window) {
  226. for (var f = 0; f < top.frames.length; f++) {
  227. if (top.frames[f] !== window) {
  228. var href = top.frames[f].location.href.replace(/\/cpsess[.\d]+/, result.security_token);
  229. top.frames[f].location.href = href
  230. }
  231. }
  232. }
  233. location_obj_to_redirect = location
  234. }
  235. var redirector = function() {
  236. location_obj_to_redirect.href = final_uri
  237. };
  238. if (result.notices && result.notices.length) {
  239. show_status(MESSAGES.read_below, "warn");
  240. var click_form = DOM.get("clickthrough_form");
  241. var container = click_form.querySelector(".notices");
  242. for (n = 0; n < result.notices.length; n++) {
  243. var new_p = document.createElement("p");
  244. new_p.textContent = result.notices[n].content;
  245. container.appendChild(new_p)
  246. }
  247. click_form.onsubmit = redirector;
  248. fade_out(login_form);
  249. fade_in(click_form)
  250. } else {
  251. show_status(MESSAGES.success, "success");
  252. fade_out("content-container", FADE_DURATION / 2);
  253. redirector()
  254. }
  255. } else {
  256. login_form.submit()
  257. }
  258. return
  259. } else {
  260. if (parseInt(response_status / 100, 10) === 4) {
  261. var msg_code = result && result.message;
  262. show_status(MESSAGES[msg_code || "invalid_login"] || MESSAGES.invalid_login, "error");
  263. set_status_timeout()
  264. } else {
  265. show_status(MESSAGES.network_error, "error")
  266. }
  267. show_links(document.body);
  268. login_button.release();
  269. return
  270. }
  271. }
  272. var level_classes = {
  273. info: "info-notice",
  274. error: "error-notice",
  275. success: "success-notice",
  276. warn: "warn-notice"
  277. };
  278. var levels_regex = "";
  279. for (var lv in level_classes) levels_regex += "|" + level_classes[lv];
  280. levels_regex = new RegExp("\\b(?:" + levels_regex.slice(1) + ")\\b");
  281.  
  282. function show_status(message, level) {
  283. DOM.get("login-status-message")[_text_content] = message;
  284. var container = DOM.get("login-status");
  285. var this_class = level && level_classes[level] || level_classes.info;
  286. var el_class = container.className.replace(levels_regex, this_class);
  287. container.className = el_class;
  288. fade_in(container);
  289. reset_status_timeout()
  290. }
  291. var STATUS_TIMEOUT = null;
  292.  
  293. function reset_status_timeout() {
  294. clearTimeout(STATUS_TIMEOUT);
  295. STATUS_TIMEOUT = null
  296. }
  297.  
  298. function set_status_timeout(delay) {
  299. STATUS_TIMEOUT = setTimeout(function() {
  300. fade_out("login-status")
  301. }, delay || 8e3)
  302. }
  303. var LOGIN_SUBMIT_OK = true;
  304. document.body.onkeyup = function() {
  305. LOGIN_SUBMIT_OK = true
  306. };
  307. document.body.onmousedown = function() {
  308. LOGIN_SUBMIT_OK = true
  309. };
  310.  
  311. function do_login() {
  312. if (LOGIN_SUBMIT_OK) {
  313. LOGIN_SUBMIT_OK = false;
  314. hide_links(document.body);
  315. login_button.suppress();
  316. show_status(MESSAGES.authenticating, "info");
  317. var goto_app_query = goto_app && goto_app.value ? "&goto_app=" + encodeURIComponent(goto_app.value) : "";
  318. var goto_uri_query = goto_uri && goto_uri.value ? "&goto_uri=" + encodeURIComponent(goto_uri.value) : "";
  319. var ajax_login = new ajaxObject(login_form.action, login_results);
  320. ajax_login.update("user=" + encodeURIComponent(login_username_el.value) + "&pass=" + encodeURIComponent(login_password_el.value) + goto_app_query + goto_uri_query, "POST")
  321. }
  322. return false
  323. }
  324.  
  325. function _set_links_style(el, prop, val) {
  326. var links = el.getElementsByTagName("a");
  327. for (var lk = links.length - 1; lk >= 0; lk--) {
  328. links[lk].style[prop] = val
  329. }
  330. }
  331.  
  332. function hide_links(el) {
  333. _set_links_style(el, "visibility", "hidden")
  334. }
  335.  
  336. function show_links(el) {
  337. _set_links_style(el, "visibility", "")
  338. }
  339. var login_button = {
  340. button: login_submit_el,
  341. _suppressed_disabled: null,
  342. suppress: function() {
  343. if (this._suppressed_disabled === null) {
  344. this._suppressed_disabled = this.button.disabled;
  345. this.button.disabled = true
  346. }
  347. },
  348. release: function() {
  349. if (this._suppressed_disabled !== null) {
  350. this.button.disabled = this._suppressed_disabled;
  351. this._suppressed_disabled = null
  352. }
  353. },
  354. queue_disabled: function(state) {
  355. if (this._suppressed_disabled === null) {
  356. this.button.disabled = state
  357. } else {
  358. this._suppressed_disabled = state
  359. }
  360. }
  361. };
  362. if (!window.JSON) {
  363. login_button.suppress();
  364. var new_script = document.createElement("script");
  365. new_script.onreadystatechange = function() {
  366. if (this.readyState === "loaded" || this.readyState === "complete") {
  367. this.onreadystatechange = null;
  368. window.JSON = {
  369. parse: window.jsonParse
  370. };
  371. window.jsonParse = undefined;
  372. login_button.release()
  373. }
  374. };
  375. new_script.src = "/unprotected/json-minified.js";
  376. document.getElementsByTagName("head")[0].appendChild(new_script)
  377. }
  378. try {
  379. login_form.onsubmit = do_login;
  380. set_opacity(DOM.get("login-wrapper"), 0);
  381. LOCALE_FADES.push(fade_in("login-wrapper"));
  382. var preload = document.createElement("div");
  383. preload.id = "preload_images";
  384. document.body.insertBefore(preload, document.body.firstChild);
  385. if (window.IS_LOGOUT) {
  386. set_status_timeout(1e4)
  387. } else if (/(?:\?|&)locale=[^&]/.test(location.search)) {
  388. show_status(MESSAGES.session_locale)
  389. }
  390. setTimeout(function() {
  391. login_username_el.focus()
  392. }, 100)
  393. } catch (e) {
  394. if (window.console) console.warn(e)
  395. }
  396. //jstz.min.js
  397. /*! jstz - v1.0.4 - 2012-12-18 */
  398. (function(e) {
  399. var t = function() {
  400. "use strict";
  401. var e = "s",
  402. n = function(e) {
  403. var t = -e.getTimezoneOffset();
  404. return t !== null ? t : 0
  405. },
  406. r = function(e, t, n) {
  407. var r = new Date;
  408. return e !== undefined && r.setFullYear(e), r.setDate(n), r.setMonth(t), r
  409. },
  410. i = function(e) {
  411. return n(r(e, 0, 2))
  412. },
  413. s = function(e) {
  414. return n(r(e, 5, 2))
  415. },
  416. o = function(e) {
  417. var t = e.getMonth() > 7 ? s(e.getFullYear()) : i(e.getFullYear()),
  418. r = n(e);
  419. return t - r !== 0
  420. },
  421. u = function() {
  422. var t = i(),
  423. n = s(),
  424. r = i() - s();
  425. return r < 0 ? t + ",1" : r > 0 ? n + ",1," + e : t + ",0"
  426. },
  427. a = function() {
  428. var e = u();
  429. return new t.TimeZone(t.olson.timezones[e])
  430. },
  431. f = function(e) {
  432. var t = new Date(2010, 6, 15, 1, 0, 0, 0),
  433. n = {
  434. "America/Denver": new Date(2011, 2, 13, 3, 0, 0, 0),
  435. "America/Mazatlan": new Date(2011, 3, 3, 3, 0, 0, 0),
  436. "America/Chicago": new Date(2011, 2, 13, 3, 0, 0, 0),
  437. "America/Mexico_City": new Date(2011, 3, 3, 3, 0, 0, 0),
  438. "America/Asuncion": new Date(2012, 9, 7, 3, 0, 0, 0),
  439. "America/Santiago": new Date(2012, 9, 3, 3, 0, 0, 0),
  440. "America/Campo_Grande": new Date(2012, 9, 21, 5, 0, 0, 0),
  441. "America/Montevideo": new Date(2011, 9, 2, 3, 0, 0, 0),
  442. "America/Sao_Paulo": new Date(2011, 9, 16, 5, 0, 0, 0),
  443. "America/Los_Angeles": new Date(2011, 2, 13, 8, 0, 0, 0),
  444. "America/Santa_Isabel": new Date(2011, 3, 5, 8, 0, 0, 0),
  445. "America/Havana": new Date(2012, 2, 10, 2, 0, 0, 0),
  446. "America/New_York": new Date(2012, 2, 10, 7, 0, 0, 0),
  447. "Asia/Beirut": new Date(2011, 2, 27, 1, 0, 0, 0),
  448. "Europe/Helsinki": new Date(2011, 2, 27, 4, 0, 0, 0),
  449. "Europe/Istanbul": new Date(2011, 2, 28, 5, 0, 0, 0),
  450. "Asia/Damascus": new Date(2011, 3, 1, 2, 0, 0, 0),
  451. "Asia/Jerusalem": new Date(2011, 3, 1, 6, 0, 0, 0),
  452. "Asia/Gaza": new Date(2009, 2, 28, 0, 30, 0, 0),
  453. "Africa/Cairo": new Date(2009, 3, 25, 0, 30, 0, 0),
  454. "Pacific/Auckland": new Date(2011, 8, 26, 7, 0, 0, 0),
  455. "Pacific/Fiji": new Date(2010, 11, 29, 23, 0, 0, 0),
  456. "America/Halifax": new Date(2011, 2, 13, 6, 0, 0, 0),
  457. "America/Goose_Bay": new Date(2011, 2, 13, 2, 1, 0, 0),
  458. "America/Miquelon": new Date(2011, 2, 13, 5, 0, 0, 0),
  459. "America/Godthab": new Date(2011, 2, 27, 1, 0, 0, 0),
  460. "Europe/Moscow": t,
  461. "Asia/Yekaterinburg": t,
  462. "Asia/Omsk": t,
  463. "Asia/Krasnoyarsk": t,
  464. "Asia/Irkutsk": t,
  465. "Asia/Yakutsk": t,
  466. "Asia/Vladivostok": t,
  467. "Asia/Kamchatka": t,
  468. "Europe/Minsk": t,
  469. "Australia/Perth": new Date(2008, 10, 1, 1, 0, 0, 0)
  470. };
  471. return n[e]
  472. };
  473. return {
  474. determine: a,
  475. date_is_dst: o,
  476. dst_start_for: f
  477. }
  478. }();
  479. t.TimeZone = function(e) {
  480. "use strict";
  481. var n = {
  482. "America/Denver": ["America/Denver", "America/Mazatlan"],
  483. "America/Chicago": ["America/Chicago", "America/Mexico_City"],
  484. "America/Santiago": ["America/Santiago", "America/Asuncion", "America/Campo_Grande"],
  485. "America/Montevideo": ["America/Montevideo", "America/Sao_Paulo"],
  486. "Asia/Beirut": ["Asia/Beirut", "Europe/Helsinki", "Europe/Istanbul", "Asia/Damascus", "Asia/Jerusalem", "Asia/Gaza"],
  487. "Pacific/Auckland": ["Pacific/Auckland", "Pacific/Fiji"],
  488. "America/Los_Angeles": ["America/Los_Angeles", "America/Santa_Isabel"],
  489. "America/New_York": ["America/Havana", "America/New_York"],
  490. "America/Halifax": ["America/Goose_Bay", "America/Halifax"],
  491. "America/Godthab": ["America/Miquelon", "America/Godthab"],
  492. "Asia/Dubai": ["Europe/Moscow"],
  493. "Asia/Dhaka": ["Asia/Yekaterinburg"],
  494. "Asia/Jakarta": ["Asia/Omsk"],
  495. "Asia/Shanghai": ["Asia/Krasnoyarsk", "Australia/Perth"],
  496. "Asia/Tokyo": ["Asia/Irkutsk"],
  497. "Australia/Brisbane": ["Asia/Yakutsk"],
  498. "Pacific/Noumea": ["Asia/Vladivostok"],
  499. "Pacific/Tarawa": ["Asia/Kamchatka"],
  500. "Africa/Johannesburg": ["Asia/Gaza", "Africa/Cairo"],
  501. "Asia/Baghdad": ["Europe/Minsk"]
  502. },
  503. r = e,
  504. i = function() {
  505. var e = n[r],
  506. i = e.length,
  507. s = 0,
  508. o = e[0];
  509. for (; s < i; s += 1) {
  510. o = e[s];
  511. if (t.date_is_dst(t.dst_start_for(o))) {
  512. r = o;
  513. return
  514. }
  515. }
  516. },
  517. s = function() {
  518. return typeof n[r] != "undefined"
  519. };
  520. return s() && i(), {
  521. name: function() {
  522. return r
  523. }
  524. }
  525. }, t.olson = {}, t.olson.timezones = {
  526. "-720,0": "Etc/GMT+12",
  527. "-660,0": "Pacific/Pago_Pago",
  528. "-600,1": "America/Adak",
  529. "-600,0": "Pacific/Honolulu",
  530. "-570,0": "Pacific/Marquesas",
  531. "-540,0": "Pacific/Gambier",
  532. "-540,1": "America/Anchorage",
  533. "-480,1": "America/Los_Angeles",
  534. "-480,0": "Pacific/Pitcairn",
  535. "-420,0": "America/Phoenix",
  536. "-420,1": "America/Denver",
  537. "-360,0": "America/Guatemala",
  538. "-360,1": "America/Chicago",
  539. "-360,1,s": "Pacific/Easter",
  540. "-300,0": "America/Bogota",
  541. "-300,1": "America/New_York",
  542. "-270,0": "America/Caracas",
  543. "-240,1": "America/Halifax",
  544. "-240,0": "America/Santo_Domingo",
  545. "-240,1,s": "America/Santiago",
  546. "-210,1": "America/St_Johns",
  547. "-180,1": "America/Godthab",
  548. "-180,0": "America/Argentina/Buenos_Aires",
  549. "-180,1,s": "America/Montevideo",
  550. "-120,0": "Etc/GMT+2",
  551. "-120,1": "Etc/GMT+2",
  552. "-60,1": "Atlantic/Azores",
  553. "-60,0": "Atlantic/Cape_Verde",
  554. "0,0": "Etc/UTC",
  555. "0,1": "Europe/London",
  556. "60,1": "Europe/Berlin",
  557. "60,0": "Africa/Lagos",
  558. "60,1,s": "Africa/Windhoek",
  559. "120,1": "Asia/Beirut",
  560. "120,0": "Africa/Johannesburg",
  561. "180,0": "Asia/Baghdad",
  562. "180,1": "Europe/Moscow",
  563. "210,1": "Asia/Tehran",
  564. "240,0": "Asia/Dubai",
  565. "240,1": "Asia/Baku",
  566. "270,0": "Asia/Kabul",
  567. "300,1": "Asia/Yekaterinburg",
  568. "300,0": "Asia/Karachi",
  569. "330,0": "Asia/Kolkata",
  570. "345,0": "Asia/Kathmandu",
  571. "360,0": "Asia/Dhaka",
  572. "360,1": "Asia/Omsk",
  573. "390,0": "Asia/Rangoon",
  574. "420,1": "Asia/Krasnoyarsk",
  575. "420,0": "Asia/Jakarta",
  576. "480,0": "Asia/Shanghai",
  577. "480,1": "Asia/Irkutsk",
  578. "525,0": "Australia/Eucla",
  579. "525,1,s": "Australia/Eucla",
  580. "540,1": "Asia/Yakutsk",
  581. "540,0": "Asia/Tokyo",
  582. "570,0": "Australia/Darwin",
  583. "570,1,s": "Australia/Adelaide",
  584. "600,0": "Australia/Brisbane",
  585. "600,1": "Asia/Vladivostok",
  586. "600,1,s": "Australia/Sydney",
  587. "630,1,s": "Australia/Lord_Howe",
  588. "660,1": "Asia/Kamchatka",
  589. "660,0": "Pacific/Noumea",
  590. "690,0": "Pacific/Norfolk",
  591. "720,1,s": "Pacific/Auckland",
  592. "720,0": "Pacific/Tarawa",
  593. "765,1,s": "Pacific/Chatham",
  594. "780,0": "Pacific/Tongatapu",
  595. "780,1,s": "Pacific/Apia",
  596. "840,0": "Pacific/Kiritimati"
  597. }, typeof exports != "undefined" ? exports.jstz = t : e.jstz = t
  598. })(this);
  599. //cptimezone_optimized.js
  600. (function(window) {
  601. "use strict";
  602. var JSTZ_RELATIVE_PATH = "sharedjs/jstz.min.js";
  603. var TIMEZONE_COOKIE = "timezone";
  604. var COOKIE_TIMEZONE_MISMATCH_CLASS = "if-timezone-cookie-needs-update";
  605. var DETECTED_TZ_CLASS = "detected-timezone";
  606. var SHOWN_CLASS = "shown";
  607.  
  608. function _get_cookie(sKey) {
  609. return decodeURIComponent(document.cookie.replace(new RegExp("(?:(?:^|.*;)\\s*" + encodeURIComponent(sKey).replace(/[\-\.\+\*]/g, "\\$&") + "\\s*\\=\\s*([^;]*).*$)|^.*$"), "$1")) || null
  610. }
  611.  
  612. function _detect_timezone() {
  613. return window.jstz.determine().name()
  614. }
  615.  
  616. function reset_timezone_and_reload() {
  617. return reset_timezone(location.reload.bind(location))
  618. }
  619.  
  620. function _set_cookie(callback) {
  621. document.cookie = TIMEZONE_COOKIE + "=" + _detect_timezone() + "; path=/";
  622. if (callback) {
  623. callback()
  624. }
  625. }
  626.  
  627. function set_timezone_if_unset(on_success) {
  628. return !_get_cookie(TIMEZONE_COOKIE) && reset_timezone(on_success)
  629. }
  630.  
  631. function reset_timezone(on_success) {
  632. _set_cookie(on_success);
  633. return true
  634. }
  635.  
  636. function set_timezone_and_reload_if_unset() {
  637. return set_timezone_if_unset(location.reload.bind(location))
  638. }
  639.  
  640. function show_cookie_timezone_mismatch_nodes() {
  641. var detected_tz = _detect_timezone();
  642. if (detected_tz !== _get_cookie(TIMEZONE_COOKIE)) {
  643. var detected_nodes = document.querySelectorAll("." + DETECTED_TZ_CLASS);
  644. [].forEach.call(detected_nodes, function(n) {
  645. n.textContent = detected_tz
  646. });
  647. var show_nodes = document.querySelectorAll("." + COOKIE_TIMEZONE_MISMATCH_CLASS);
  648. [].forEach.call(show_nodes, function(n) {
  649. n.className += " " + SHOWN_CLASS
  650. })
  651. }
  652. }
  653. window.CPTimezone = {
  654. show_cookie_timezone_mismatch_nodes: show_cookie_timezone_mismatch_nodes,
  655. reset_timezone_and_reload: reset_timezone_and_reload,
  656. reset_timezone: reset_timezone,
  657. set_timezone_and_reload_if_unset: set_timezone_and_reload_if_unset
  658. }
  659. })(window);
  660. CPTimezone.reset_timezone();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement