1
0
Fork 0
mirror of https://github.com/jellyfin/jellyfin-web synced 2025-03-30 19:56:21 +00:00

Merge pull request #458 from dkanada/site

Refactor several files and methods
This commit is contained in:
dkanada 2019-09-25 23:52:49 +09:00 committed by GitHub
commit 0286cc60d5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
34 changed files with 122 additions and 11259 deletions

View file

@ -1,7 +1,7 @@
define(["datetime"], function(datetime) {
"use strict";
function humane_date(date_str) {
function humaneDate(date_str) {
var format, time_formats = [
[90, "a minute"],
[3600, "minutes", 60],
@ -24,5 +24,37 @@ define(["datetime"], function(datetime) {
if (seconds < format[0]) return 2 == format.length ? format[1] + " ago" : Math.round(seconds / format[2]) + " " + format[1] + " ago";
return seconds > 47304e5 ? Math.round(seconds / 47304e5) + " centuries ago" : date_str
}
return window.humane_date = humane_date, humane_date
function humaneElapsed(firstDateStr, secondDateStr) {
// TODO replace this whole script with a library or something
var dateOne = new Date(firstDateStr);
var dateTwo = new Date(secondDateStr);
var delta = (dateTwo.getTime() - dateOne.getTime()) / 1e3;
var days = Math.floor(delta % 31536e3 / 86400);
var hours = Math.floor(delta % 31536e3 % 86400 / 3600);
var minutes = Math.floor(delta % 31536e3 % 86400 % 3600 / 60);
var seconds = Math.round(delta % 31536e3 % 86400 % 3600 % 60);
var elapsed = "";
elapsed += 1 == days ? days + " day " : "";
elapsed += days > 1 ? days + " days " : "";
elapsed += 1 == hours ? hours + " hour " : "";
elapsed += hours > 1 ? hours + " hours " : "";
elapsed += 1 == minutes ? minutes + " minute " : "";
elapsed += minutes > 1 ? minutes + " minutes " : "";
elapsed += elapsed.length > 0 ? "and " : "";
elapsed += 1 == seconds ? seconds + " second" : "";
elapsed += 0 == seconds || seconds > 1 ? seconds + " seconds" : "";
return elapsed;
}
window.humaneDate = humaneDate;
window.humaneElapsed = humaneElapsed;
return {
humaneDate: humaneDate,
humaneElapsed: humaneElapsed
}
});

View file

@ -5,7 +5,6 @@ define(['playbackManager', 'focusManager', 'appRouter', 'dom'], function (playba
function notify() {
lastInputTime = new Date().getTime();
handleCommand('unknown');
}
@ -18,27 +17,22 @@ define(['playbackManager', 'focusManager', 'appRouter', 'dom'], function (playba
}
function select(sourceElement) {
sourceElement.click();
}
var eventListenerCount = 0;
function on(scope, fn) {
eventListenerCount++;
dom.addEventListener(scope, 'command', fn, {
});
if (eventListenerCount) {
eventListenerCount++;
}
dom.addEventListener(scope, 'command', fn, {});
}
function off(scope, fn) {
if (eventListenerCount) {
eventListenerCount--;
}
dom.removeEventListener(scope, 'command', fn, {
});
dom.removeEventListener(scope, 'command', fn, {});
}
var commandTimes = {};
@ -85,7 +79,6 @@ define(['playbackManager', 'focusManager', 'appRouter', 'dom'], function (playba
}
switch (name) {
case 'up':
focusManager.moveUp(sourceElement);
break;
@ -119,6 +112,7 @@ define(['playbackManager', 'focusManager', 'appRouter', 'dom'], function (playba
case 'end':
break;
case 'menu':
break;
case 'info':
break;
case 'nextchapter':
@ -214,53 +208,9 @@ define(['playbackManager', 'focusManager', 'appRouter', 'dom'], function (playba
case 'toggledisplaymirror':
playbackManager.toggleDisplayMirroring();
break;
case 'togglestats':
//playbackManager.toggleStats();
break;
case 'movies':
// TODO
appRouter.goHome();
break;
case 'music':
// TODO
appRouter.goHome();
break;
case 'tv':
// TODO
appRouter.goHome();
break;
case 'nowplaying':
appRouter.showNowPlaying();
break;
case 'save':
break;
case 'screensaver':
// TODO
break;
case 'refresh':
// TODO
break;
case 'changebrightness':
// TODO
break;
case 'red':
// TODO
break;
case 'green':
// TODO
break;
case 'yellow':
// TODO
break;
case 'blue':
// TODO
break;
case 'grey':
// TODO
break;
case 'brown':
// TODO
break;
case 'repeatnone':
playbackManager.setRepeatMode('RepeatNone');
break;
@ -288,4 +238,4 @@ define(['playbackManager', 'focusManager', 'appRouter', 'dom'], function (playba
on: on,
off: off
};
});
});

View file

@ -3846,7 +3846,6 @@ define(['events', 'datetime', 'appSettings', 'itemHelper', 'pluginManager', 'pla
player = player || this._currentPlayer || { isLocalPlayer: true };
if (player.isLocalPlayer) {
// https://github.com/jellyfin/jellyfin/blob/master/MediaBrowser.Model/Session/GeneralCommandType.cs
var list = [
"GoHome",
"GoToSettings",
@ -3974,7 +3973,6 @@ define(['events', 'datetime', 'appSettings', 'itemHelper', 'pluginManager', 'pla
};
PlaybackManager.prototype.sendCommand = function (cmd, player) {
// https://github.com/jellyfin/jellyfin/blob/master/MediaBrowser.Model/Session/GeneralCommandType.cs
console.log('MediaController received command: ' + cmd.Name);
switch (cmd.Name) {
case 'SetRepeatMode':

View file

@ -0,0 +1,210 @@
.nowPlayingInfoContainer {
display: -webkit-box;
display: -webkit-flex;
display: flex;
-webkit-box-orient: horizontal;
-webkit-box-direction: normal;
-webkit-flex-direction: row;
flex-direction: row
}
.nowPlayingPageTitle {
margin: 0 0 .5em .5em
}
.nowPlayingPositionSliderContainer {
margin: .7em 0 .7em 1em
}
.nowPlayingInfoButtons {
display: -webkit-box;
display: -webkit-flex;
display: flex;
-webkit-box-align: center;
-webkit-align-items: center;
align-items: center;
-webkit-flex-wrap: wrap;
flex-wrap: wrap
}
.nowPlayingInfoControls,
.nowPlayingTime {
display: -webkit-box;
display: -webkit-flex
}
.nowPlayingPageImageContainer {
width: 20%;
margin-right: .25em;
position: relative;
-webkit-flex-shrink: 0;
flex-shrink: 0
}
@media all and (min-width:50em) {
.nowPlayingPageImageContainer {
width: 16%
}
}
.nowPlayingInfoControls {
-webkit-box-flex: 1;
-webkit-flex-grow: 1;
flex-grow: 1;
display: flex;
-webkit-box-orient: vertical;
-webkit-box-direction: normal;
-webkit-flex-direction: column;
flex-direction: column;
-webkit-box-pack: center;
-webkit-justify-content: center;
justify-content: center
}
.nowPlayingPageImage {
bottom: 0;
left: 0;
right: 0;
width: 100%;
-webkit-box-shadow: 0 0 1.9vh #000;
box-shadow: 0 0 1.9vh #000;
border: .1em solid #222;
user-drag: none;
user-select: none;
-moz-user-select: none;
-webkit-user-drag: none;
-webkit-user-select: none;
-ms-user-select: none
}
@media all and (orientation:portrait) and (max-width:50em) {
.nowPlayingInfoContainer {
-webkit-box-orient: vertical !important;
-webkit-box-direction: normal !important;
-webkit-flex-direction: column !important;
flex-direction: column !important;
-webkit-box-align: center;
-webkit-align-items: center;
align-items: center
}
.nowPlayingPageTitle {
text-align: center;
margin: .5em 0 .75em
}
.nowPlayingPositionSliderContainer {
margin: .7em 1em
}
.nowPlayingInfoButtons {
-webkit-box-pack: center;
-webkit-justify-content: center;
justify-content: center
}
.nowPlayingPageImageContainer {
width: auto;
margin-right: 0
}
.nowPlayingInfoControls {
margin-top: 1em;
max-width: 100%
}
.nowPlayingPageImage {
width: auto;
height: 36vh
}
}
@media all and (orientation:portrait) and (max-width:40em) {
.nowPlayingPageImage {
height: 30vh
}
}
.nowPlayingTime {
display: flex;
-webkit-box-align: center;
-webkit-align-items: center;
align-items: center;
margin: 0 1em
}
.nowPlayingSecondaryButtons {
display: -webkit-box;
display: -webkit-flex;
display: flex;
-webkit-box-align: center;
-webkit-align-items: center;
align-items: center;
-webkit-flex-wrap: wrap;
flex-wrap: wrap;
-webkit-box-pack: center;
-webkit-justify-content: center;
justify-content: center
}
@media all and (min-width:50em) {
.nowPlayingSecondaryButtons {
-webkit-box-flex: 1;
-webkit-flex-grow: 1;
flex-grow: 1;
-webkit-box-pack: end;
-webkit-justify-content: flex-end;
justify-content: flex-end
}
}
@media all and (min-width:80em) {
.nowPlayingPageImageContainer {
margin-right: .75em
}
}
.nowPlayingNavButtonContainer {
width: 30em
}
.smallBackdropPosterItem .cardOverlayInner>div {
white-space: nowrap;
-o-text-overflow: ellipsis;
text-overflow: ellipsis;
overflow: hidden
}
.playlistIndexIndicatorImage {
-webkit-background-size: initial initial !important;
background-size: initial !important;
background-image: url(../../img/equalizer.gif) !important;
}
.hideVideoButtons .videoButton {
display: none
}
.nowPlayingVolumeSliderContainer {
width: 9em
}
@media all and (max-width:50em) {
.nowPlayingInfoButtons .nowPlayingPageUserDataButtons {
display: none !important
}
}
@media all and (max-width:47em) {
.nowPlayingInfoButtons .repeatToggleButton {
display: none !important
}
}
@media all and (max-width:34em) {
.nowPlayingInfoButtons .btnNowPlayingFastForward,
.nowPlayingInfoButtons .btnNowPlayingRewind,
.nowPlayingInfoButtons .playlist .listItemMediaInfo {
display: none !important
}
}

View file

@ -1,4 +1,4 @@
define(["browser", "datetime", "backdrop", "libraryBrowser", "listView", "imageLoader", "playbackManager", "nowPlayingHelper", "events", "connectionManager", "apphost", "globalize", "cardStyle", "emby-itemscontainer", "css!css/nowplaying.css", "emby-ratingbutton"], function (browser, datetime, backdrop, libraryBrowser, listView, imageLoader, playbackManager, nowPlayingHelper, events, connectionManager, appHost, globalize) {
define(["browser", "datetime", "backdrop", "libraryBrowser", "listView", "imageLoader", "playbackManager", "nowPlayingHelper", "events", "connectionManager", "apphost", "globalize", "cardStyle", "emby-itemscontainer", "css!./remotecontrol.css", "emby-ratingbutton"], function (browser, datetime, backdrop, libraryBrowser, listView, imageLoader, playbackManager, nowPlayingHelper, events, connectionManager, appHost, globalize) {
"use strict";
function showAudioMenu(context, player, button, item) {
@ -156,10 +156,6 @@ define(["browser", "datetime", "backdrop", "libraryBrowser", "listView", "imageL
}
}
function buttonEnabled(btn, enabled) {
btn.disabled = !enabled;
}
function buttonVisible(btn, enabled) {
if (enabled) {
btn.classList.remove("hide");
@ -172,7 +168,8 @@ define(["browser", "datetime", "backdrop", "libraryBrowser", "listView", "imageL
var all = context.querySelectorAll(".btnCommand");
for (var i = 0, length = all.length; i < length; i++) {
buttonEnabled(all[i], -1 != commands.indexOf(all[i].getAttribute("data-command")));
var enableButton = -1 !== commands.indexOf(all[i].getAttribute("data-command"));
all[i].disabled = !enableButton;
}
}

View file

@ -39,7 +39,6 @@ define(['connectionManager', 'playbackManager', 'events', 'inputManager', 'focus
}
function processGeneralCommand(cmd, apiClient) {
// https://github.com/jellyfin/jellyfin/blob/master/MediaBrowser.Model/Session/GeneralCommandType.cs
console.log('Received command: ' + cmd.Name);
switch (cmd.Name) {
case 'Select':