Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #94 - Clock format toggling doesn't rotate through options as expected #95

Merged
merged 2 commits into from
Nov 8, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions ait/gui/static/js/ait/format.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,13 @@ function time (obj, { h24 = true, gps = true, utc = false } = {}) {
}


function tz (obj, { utc = false, gps = true } = {}) {
function tz (obj, { utc = false, gps = true, local = false } = {}) {
if (gps) {
return 'GPS'
} else if (utc) {
return 'UTC'
return 'UTC'
} else if (local) {
return 'Local Time'
} else {
return timezone(obj)
}
Expand Down
27 changes: 18 additions & 9 deletions ait/gui/static/js/ait/gui/Clock.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ const Clock =
_h24: true,
_utc: false,
_gps: true,
_local: false,
_doy: false,
_utc_gps_offset: 0,

Expand All @@ -65,12 +66,19 @@ const Clock =
if (this._gps) {
this._gps = false
this._utc = true
this._local = false
} else if (this._utc) {
this._gps = false
this._utc = false
this._local = true
} else if (this._local) {
this._gps = true
this._utc = false
this._local = false
} else {
this._gps = true
this._utc = false
this._local = false
}
},
toggleDOY() { this._doy = !this._doy },
Expand All @@ -87,10 +95,11 @@ const Clock =
this._utc_gps_offset = data[data.length - 1][1]
})

this._h24 = attrs.h24 !== undefined ? attrs.h24 : Clock._h24
this._utc = attrs.utc !== undefined ? attrs.utc : Clock._utc
this._gps = attrs.gps !== undefined ? attrs.gps : Clock._gps
this._doy = attrs.doy !== undefined ? attrs.doy : Clock._doy
this._h24 = attrs.h24 !== undefined ? attrs.h24 : Clock._h24
this._utc = attrs.utc !== undefined ? attrs.utc : Clock._utc
this._gps = attrs.gps !== undefined ? attrs.gps : Clock._gps
this._local = attrs.local !== undefined ? attrs.local : Clock._local
this._doy = attrs.doy !== undefined ? attrs.doy : Clock._doy
this.update()
},

Expand All @@ -102,10 +111,11 @@ const Clock =

view (vnode) {
const opts = {
doy: this._doy,
h24: this._h24,
utc: this._utc,
gps: this._gps,
doy: this._doy,
h24: this._h24,
utc: this._utc,
gps: this._gps,
local: this._local,
utc_gps_offset: this._utc_gps_offset
}

Expand All @@ -118,7 +128,6 @@ const Clock =
const time = format.time(datetime, opts)
const tz = format.tz (datetime, opts)


return m('ait-clock', vnode.attrs, [
m('span.date', { onclick: Clock.toggleDOY.bind(this) }, date), ' ',
m('span.time', { onclick: Clock.toggleH24.bind(this) }, time), ' ',
Expand Down
Loading