diff --git a/assets/App.vue b/assets/App.vue index 187e28e..69440fc 100644 --- a/assets/App.vue +++ b/assets/App.vue @@ -3,22 +3,26 @@
- {{ today_time | str_time }} + {{ today_time.toStr() }}
Закончить Начать
- Всего {{ total_time | str_time }} + Всего + + {{ total_time.toStr() }} +

Профиль: {{ profileId }}

diff --git a/assets/TimeSpan.js b/assets/TimeSpan.js new file mode 100644 index 0000000..1fb52af --- /dev/null +++ b/assets/TimeSpan.js @@ -0,0 +1,24 @@ +const STATUS_OVERTIME = 'overtime'; + +class TimeSpan { + static fromObject({ hours, minutes, status }) { + return new TimeSpan(hours, minutes, status); + } + + constructor(hours, minutes, status) { + this.hours = hours; + this.minutes = minutes; + this.status = status; + } + + isOvertime() { + return this.status === STATUS_OVERTIME; + } + + toStr() { + const sign = this.isOvertime() ? '+' : ''; + return sign + this.hours + ':' + String(this.minutes).padStart(2, '0'); + } +} + +export default TimeSpan; diff --git a/assets/helpers.js b/assets/helpers.js index db1fa37..5f89bda 100644 --- a/assets/helpers.js +++ b/assets/helpers.js @@ -7,7 +7,6 @@ function extract_profile_id() { const q = haystack.substring(haystack.indexOf('?') + 1, haystack.length); const query = qs.parse(q); const profile = query[PROFILE_QUERY] || ''; - // console.log('PROFILE', query, profile); return profile; } @@ -18,7 +17,6 @@ async function get_status(profileId) { method: 'GET', }); const data = await response.json(); - // console.log('DATA', data); return data; }