-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathidle-screen.js
41 lines (32 loc) · 1.28 KB
/
idle-screen.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
function wikiaJWPlayerIdleScreen(playerInstance, i18n) {
function showDuration() {
var id = playerInstance.id,
playerElement = document.getElementById(id),
title = playerElement.querySelector('.jw-title'),
titlePrimary = playerElement.querySelector('.jw-title-primary'),
durationElement = document.createElement('div'),
durationWatchElement = document.createElement('span'),
durationTimeElement = document.createElement('span');
durationElement.className = 'wikia-jw-title-duration';
durationWatchElement.className = 'wikia-jw-title-duration-watch';
durationTimeElement.className = 'wikia-jw-title-duration-time';
durationWatchElement.innerText = i18n.watch;
durationTimeElement.innerText = getUserFriendlyDuration(playerInstance.getDuration());
durationElement.appendChild(durationWatchElement);
durationElement.appendChild(durationTimeElement);
title.insertBefore(durationElement, titlePrimary);
}
function getUserFriendlyDuration(duration) {
var minutes = Math.floor(duration / 60),
seconds = duration % 60;
if (seconds < 10) {
seconds = '0' + seconds;
}
if (minutes < 10) {
minutes = '0' + minutes;
}
return minutes + ':' + seconds;
}
playerInstance.on('ready', showDuration);
}
window.wikiaJWPlayerIdleScreen = wikiaJWPlayerIdleScreen;