diff --git a/src/util/tooltip.js b/src/util/tooltip.js index 16c67792..4cabd99e 100644 --- a/src/util/tooltip.js +++ b/src/util/tooltip.js @@ -9,36 +9,48 @@ export function buildTooltip(bucket, e) { // WARNING: XSS risk, make sure to sanitize properly // FIXME: Not actually tested against XSS attacks, implementation needs to be verified in tests. let inner = 'Unknown bucket type'; + + // if same day, don't show date + let start = moment(e.timestamp); + let stop = moment(e.timestamp).add(e.duration, 'seconds'); + if (start.isSame(stop, 'day')) { + start = start.format('HH:mm:ss'); + stop = stop.format('HH:mm:ss'); + } else { + start = start.format('YYYY-MM-DD HH:mm:ss'); + stop = stop.format('YYYY-MM-DD HH:mm:ss'); + } + if (bucket.type == 'currentwindow') { inner = ` - App:${sanitize(e.data.app)} - Title:${sanitize(e.data.title)} + App${sanitize(e.data.app)} + Title${sanitize(e.data.title)} `; } else if (bucket.type == 'web.tab.current') { inner = ` - Title:${sanitize(e.data.title)} - URL:${sanitize(e.data.url)} + Title${sanitize(e.data.title)} + URL${sanitize(e.data.url)} `; } else if (bucket.type.startsWith('app.editor')) { inner = ` - Filename:${sanitize(_.last(e.data.file.split('/')))} - Path:${sanitize(e.data.file)} - Language:${sanitize(e.data.language)} + Filename${sanitize(_.last(e.data.file.split('/')))} + Path${sanitize(e.data.file)} + Language${sanitize(e.data.language)} `; } else if (bucket.type.startsWith('general.stopwatch')) { inner = ` - Label:${sanitize(e.data.label)} + Label${sanitize(e.data.label)} `; } else { inner = ` - Data:${sanitize(JSON.stringify(e.data))} + Data${sanitize(JSON.stringify(e.data))} `; } return ` - - - + + + ${inner}
Start:${moment(e.timestamp).format()}
Stop:${moment(e.timestamp).add(e.duration, 'seconds').format()}
Duration:${seconds_to_duration(e.duration)}
Start${start}
Stop${stop}
Duration ${seconds_to_duration(e.duration)}
`; }