Download this file
| 1 | /* zone.js — tells Equipo the person's time zone, quietly: the browser's |
| 2 | own (Intl), posted once a session, and again when it changes (a laptop |
| 3 | that travelled). Equipo words every reset and resume time in it. |
| 4 | With scripts off nothing is sent and Equipo keeps the last zone it |
| 5 | heard, Europe/Dublin until it has heard one. */ |
| 6 | (function () { |
| 7 | "use strict"; |
| 8 | var zone; |
| 9 | try { |
| 10 | zone = Intl.DateTimeFormat().resolvedOptions().timeZone; |
| 11 | } catch (e) { |
| 12 | return; |
| 13 | } |
| 14 | if (!zone) return; |
| 15 | try { |
| 16 | if (sessionStorage.getItem("equipo-zone") === zone) return; |
| 17 | } catch (e) { |
| 18 | /* No session storage: post it each page; the server keeps one. */ |
| 19 | } |
| 20 | fetch("/conversation/settings/time-zone", { |
| 21 | method: "POST", |
| 22 | credentials: "same-origin", |
| 23 | headers: { Accept: "application/json" }, |
| 24 | body: new URLSearchParams({ time_zone: zone }) |
| 25 | }).then(function (r) { |
| 26 | if (!r.ok) return; |
| 27 | try { |
| 28 | sessionStorage.setItem("equipo-zone", zone); |
| 29 | } catch (e) { |
| 30 | /* Nothing to remember it in. */ |
| 31 | } |
| 32 | }).catch(function () {}); |
| 33 | })(); |
| 34 | |