From e99bd3245f07340143e022cdadb7675657e0e6ea Mon Sep 17 00:00:00 2001 From: Yanzhen Yu Date: Wed, 17 Oct 2018 19:10:45 +0800 Subject: [PATCH] add player controller --- src/App.html | 3 -- src/Controller.html | 108 +++++++++++++++++++++++++++++++++++++++++ src/Player.html | 114 +++++++++++++++++++++++++------------------- src/util.js | 7 --- src/utils.js | 33 +++++++++++++ 5 files changed, 206 insertions(+), 59 deletions(-) create mode 100644 src/Controller.html delete mode 100644 src/util.js create mode 100644 src/utils.js diff --git a/src/App.html b/src/App.html index c54fde62..f19586f4 100644 --- a/src/App.html +++ b/src/App.html @@ -1,6 +1,3 @@ -

- rrweb player playground -

\ No newline at end of file diff --git a/src/Player.html b/src/Player.html index 1d5a5617..b47fe52a 100644 --- a/src/Player.html +++ b/src/Player.html @@ -1,10 +1,65 @@
+ {#if replayer} + + {/if}
+ + - - \ No newline at end of file + \ No newline at end of file diff --git a/src/util.js b/src/util.js deleted file mode 100644 index da07ec19..00000000 --- a/src/util.js +++ /dev/null @@ -1,7 +0,0 @@ -export function inlineCss(cssObj) { - let style = ''; - Object.keys(cssObj).forEach(key => { - style += `${key}: ${cssObj[key]};`; - }); - return style; -} diff --git a/src/utils.js b/src/utils.js new file mode 100644 index 00000000..b19c4603 --- /dev/null +++ b/src/utils.js @@ -0,0 +1,33 @@ +export function inlineCss(cssObj) { + let style = ''; + Object.keys(cssObj).forEach(key => { + style += `${key}: ${cssObj[key]};`; + }); + return style; +} + +function padZero(num, len = 2) { + const threshold = Math.pow(10, len - 1); + if (num < threshold) { + num = String(num); + while (String(threshold).length > num.length) { + num = '0' + num; + } + } + return num; +} + +const SECOND = 1000; +const MINUTE = 60 * SECOND; +const HOUR = 60 * MINUTE; +export function formatTime(ms) { + const hour = Math.floor(ms / HOUR); + ms = ms % HOUR; + const minute = Math.floor(ms / MINUTE); + ms = ms % MINUTE; + const second = Math.floor(ms / SECOND); + if (hour) { + return `${padZero(hour)}:${padZero(minute)}:${padZero(minute)}`; + } + return `${padZero(hour)}:${padZero(second)}`; +}