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,15 +1,6 @@
define(["datetime", "events", "itemHelper", "serverNotifications", "dom", "globalize", "loading", "connectionManager", "playMethodHelper", "cardBuilder", "imageLoader", "components/activitylog", "scripts/imagehelper", "indicators", "humanedate", "listViewStyle", "emby-button", "flexStyles", "emby-button", "emby-itemscontainer"], function (datetime, events, itemHelper, serverNotifications, dom, globalize, loading, connectionManager, playMethodHelper, cardBuilder, imageLoader, ActivityLog, imageHelper, indicators) {
"use strict";
function buttonEnabled(elem, enabled) {
if (enabled) {
elem.setAttribute("disabled", "");
elem.removeAttribute("disabled");
} else {
elem.setAttribute("disabled", "disabled");
}
}
function showPlaybackInfo(btn, session) {
require(["alert"], function (alert) {
var title;
@ -455,7 +446,7 @@ define(["datetime", "events", "itemHelper", "serverNotifications", "dom", "globa
if (!nowPlayingItem) {
return {
html: "Last seen " + humane_date(session.LastActivityDate),
html: "Last seen " + humaneDate(session.LastActivityDate),
image: imgUrl
};
}
@ -700,8 +691,8 @@ define(["datetime", "events", "itemHelper", "serverNotifications", "dom", "globa
primary: "delete"
}).then(function () {
var page = dom.parentWithClass(btn, "page");
buttonEnabled(page.querySelector("#btnRestartServer"), false);
buttonEnabled(page.querySelector("#btnShutdown"), false);
page.querySelector("#btnRestartServer").disabled = true;
page.querySelector("#btnShutdown").disabled = true;
ApiClient.restartServer();
});
});
@ -715,8 +706,8 @@ define(["datetime", "events", "itemHelper", "serverNotifications", "dom", "globa
primary: "delete"
}).then(function () {
var page = dom.parentWithClass(btn, "page");
buttonEnabled(page.querySelector("#btnRestartServer"), false);
buttonEnabled(page.querySelector("#btnShutdown"), false);
page.querySelector("#btnRestartServer").disabled = true;
page.querySelector("#btnShutdown").disabled = true;
ApiClient.shutdownServer();
});
});

View file

@ -86,7 +86,7 @@ define(["loading", "dom", "libraryMenu", "globalize", "scripts/imagehelper", "hu
deviceHtml += "<div class='cardText cardText-secondary'>";
if (device.LastUserName) {
deviceHtml += device.LastUserName;
deviceHtml += ", " + humane_date(device.DateLastActivity);
deviceHtml += ", " + humaneDate(device.DateLastActivity);
}
deviceHtml += "&nbsp;";
deviceHtml += "</div>";

View file

@ -217,7 +217,7 @@ define(["jQuery", "apphost", "scripts/taskbutton", "loading", "libraryMenu", "gl
}, {
name: globalize.translate("FolderTypeMusic"),
value: "music",
message: getLink("MovieLibraryHelp", "https://jellyfin.readthedocs.io/en/latest/media/music/")
message: getLink("MusicLibraryHelp", "https://jellyfin.readthedocs.io/en/latest/media/music/")
}, {
name: globalize.translate("FolderTypeTvShows"),
value: "tvshows",
@ -225,7 +225,7 @@ define(["jQuery", "apphost", "scripts/taskbutton", "loading", "libraryMenu", "gl
}, {
name: globalize.translate("FolderTypeBooks"),
value: "books",
message: getLink("BookLibraryHelp", "https://web.archive.org/web/20181216120305/https://github.com/MediaBrowser/Wiki/wiki/Book-naming")
message: getLink("BookLibraryHelp", "https://jellyfin.readthedocs.io/en/latest/media/books/")
}, {
name: globalize.translate("OptionHomeVideos"),
value: "homevideos"

View file

@ -1,4 +1,4 @@
define(["components/remotecontrol", "libraryMenu", "emby-button"], function(remotecontrolFactory, libraryMenu) {
define(["components/remotecontrol/remotecontrol", "libraryMenu", "emby-button"], function(remotecontrolFactory, libraryMenu) {
"use strict";
return function(view, params) {
var remoteControl = new remotecontrolFactory;

View file

@ -62,23 +62,11 @@ define(["jQuery", "loading", "events", "globalize", "serverNotifications", "huma
page.querySelector(".divScheduledTasks").innerHTML = html;
}
function humane_elapsed(firstDateStr, secondDateStr) {
var dt1 = new Date(firstDateStr),
dt2 = new Date(secondDateStr),
seconds = (dt2.getTime() - dt1.getTime()) / 1e3,
numdays = Math.floor(seconds % 31536e3 / 86400),
numhours = Math.floor(seconds % 31536e3 % 86400 / 3600),
numminutes = Math.floor(seconds % 31536e3 % 86400 % 3600 / 60),
numseconds = Math.round(seconds % 31536e3 % 86400 % 3600 % 60),
elapsedStr = "";
return elapsedStr += 1 == numdays ? numdays + " day " : "", elapsedStr += numdays > 1 ? numdays + " days " : "", elapsedStr += 1 == numhours ? numhours + " hour " : "", elapsedStr += numhours > 1 ? numhours + " hours " : "", elapsedStr += 1 == numminutes ? numminutes + " minute " : "", elapsedStr += numminutes > 1 ? numminutes + " minutes " : "", elapsedStr += elapsedStr.length > 0 ? "and " : "", elapsedStr += 1 == numseconds ? numseconds + " second" : "", elapsedStr += 0 == numseconds || numseconds > 1 ? numseconds + " seconds" : ""
}
function getTaskProgressHtml(task) {
var html = "";
if (task.State === "Idle") {
if (task.LastExecutionResult) {
html += globalize.translate("LabelScheduledTaskLastRan").replace("{0}", humane_date(task.LastExecutionResult.EndTimeUtc)).replace("{1}", humane_elapsed(task.LastExecutionResult.StartTimeUtc, task.LastExecutionResult.EndTimeUtc));
html += globalize.translate("LabelScheduledTaskLastRan").replace("{0}", humaneDate(task.LastExecutionResult.EndTimeUtc)).replace("{1}", humaneElapsed(task.LastExecutionResult.StartTimeUtc, task.LastExecutionResult.EndTimeUtc));
if (task.LastExecutionResult.Status === "Failed") {
html += " <span style='color:#FF0000;'>(" + globalize.translate("LabelFailed") + ")</span>";
} else if (task.LastExecutionResult.Status === "Cancelled") {

View file

@ -128,7 +128,7 @@ define(["loading", "dom", "globalize", "humanedate", "paper-icon-button-light",
function getLastSeenText(lastActivityDate) {
if (lastActivityDate) {
return "Last seen " + humane_date(lastActivityDate);
return "Last seen " + humaneDate(lastActivityDate);
}
return "";