mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
Migration of activitylog and datetime to ES6 modules
This commit is contained in:
parent
fd853a180a
commit
1200617639
4 changed files with 37 additions and 20 deletions
|
@ -92,6 +92,7 @@
|
||||||
"test": [
|
"test": [
|
||||||
"src/components/accessSchedule/accessSchedule.js",
|
"src/components/accessSchedule/accessSchedule.js",
|
||||||
"src/components/actionSheet/actionSheet.js",
|
"src/components/actionSheet/actionSheet.js",
|
||||||
|
"src/components/activitylog.js",
|
||||||
"src/components/alphaPicker/alphaPicker.js",
|
"src/components/alphaPicker/alphaPicker.js",
|
||||||
"src/components/autoFocuser.js",
|
"src/components/autoFocuser.js",
|
||||||
"src/components/cardbuilder/cardBuilder.js",
|
"src/components/cardbuilder/cardBuilder.js",
|
||||||
|
@ -150,6 +151,7 @@
|
||||||
"src/plugins/bookPlayer/plugin.js",
|
"src/plugins/bookPlayer/plugin.js",
|
||||||
"src/plugins/bookPlayer/tableOfContents.js",
|
"src/plugins/bookPlayer/tableOfContents.js",
|
||||||
"src/plugins/photoPlayer/plugin.js",
|
"src/plugins/photoPlayer/plugin.js",
|
||||||
|
"src/scripts/datetime.js",
|
||||||
"src/scripts/deleteHelper.js",
|
"src/scripts/deleteHelper.js",
|
||||||
"src/scripts/dfnshelper.js",
|
"src/scripts/dfnshelper.js",
|
||||||
"src/scripts/dom.js",
|
"src/scripts/dom.js",
|
||||||
|
|
|
@ -1,5 +1,15 @@
|
||||||
define(['events', 'globalize', 'dom', 'date-fns', 'dfnshelper', 'userSettings', 'serverNotifications', 'connectionManager', 'emby-button', 'listViewStyle'], function (events, globalize, dom, datefns, dfnshelper, userSettings, serverNotifications, connectionManager) {
|
import events from 'events';
|
||||||
'use strict';
|
import globalize from 'globalize';
|
||||||
|
import dom from 'dom';
|
||||||
|
import * as datefns from 'date-fns';
|
||||||
|
import dfnshelper from 'dfnshelper';
|
||||||
|
import userSettings from 'userSettings';
|
||||||
|
import serverNotifications from 'serverNotifications';
|
||||||
|
import connectionManager from 'connectionManager';
|
||||||
|
import 'emby-button';
|
||||||
|
import 'listViewStyle';
|
||||||
|
|
||||||
|
/*eslint-disable indent */
|
||||||
|
|
||||||
function getEntryHtml(entry, apiClient) {
|
function getEntryHtml(entry, apiClient) {
|
||||||
var html = '';
|
var html = '';
|
||||||
|
@ -125,7 +135,9 @@ define(['events', 'globalize', 'dom', 'date-fns', 'dfnshelper', 'userSettings',
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function ActivityLog(options) {
|
class ActivityLog {
|
||||||
|
constructor(options) {
|
||||||
|
console.log(options)
|
||||||
this.options = options;
|
this.options = options;
|
||||||
var element = options.element;
|
var element = options.element;
|
||||||
element.classList.add('activityLogListWidget');
|
element.classList.add('activityLogListWidget');
|
||||||
|
@ -137,8 +149,7 @@ define(['events', 'globalize', 'dom', 'date-fns', 'dfnshelper', 'userSettings',
|
||||||
events.on(serverNotifications, 'ActivityLogEntry', onUpdate);
|
events.on(serverNotifications, 'ActivityLogEntry', onUpdate);
|
||||||
apiClient.sendMessage('ActivityLogEntryStart', '0,1500');
|
apiClient.sendMessage('ActivityLogEntryStart', '0,1500');
|
||||||
}
|
}
|
||||||
|
destroy() {
|
||||||
ActivityLog.prototype.destroy = function () {
|
|
||||||
var options = this.options;
|
var options = this.options;
|
||||||
|
|
||||||
if (options) {
|
if (options) {
|
||||||
|
@ -154,7 +165,9 @@ define(['events', 'globalize', 'dom', 'date-fns', 'dfnshelper', 'userSettings',
|
||||||
|
|
||||||
this.items = null;
|
this.items = null;
|
||||||
this.options = null;
|
this.options = null;
|
||||||
};
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return ActivityLog;
|
export default ActivityLog;
|
||||||
});
|
|
||||||
|
/*eslint-enable indent */
|
||||||
|
|
|
@ -14,7 +14,7 @@ define(['components/activitylog', 'globalize'], function (ActivityLog, globalize
|
||||||
|
|
||||||
view.addEventListener('viewshow', function () {
|
view.addEventListener('viewshow', function () {
|
||||||
if (!activityLog) {
|
if (!activityLog) {
|
||||||
activityLog = new ActivityLog({
|
activityLog = new ActivityLog.default({
|
||||||
serverId: ApiClient.serverId(),
|
serverId: ApiClient.serverId(),
|
||||||
element: view.querySelector('.activityItems')
|
element: view.querySelector('.activityItems')
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
define(['globalize'], function (globalize) {
|
import globalize from 'globalize';
|
||||||
'use strict';
|
|
||||||
|
|
||||||
function parseISO8601Date(s, toLocal) {
|
/*eslint-disable indent */
|
||||||
|
|
||||||
|
export function parseISO8601Date(s, toLocal) {
|
||||||
|
|
||||||
// parenthese matches:
|
// parenthese matches:
|
||||||
// year month day hours minutes seconds
|
// year month day hours minutes seconds
|
||||||
|
@ -58,7 +59,7 @@ define(['globalize'], function (globalize) {
|
||||||
return new Date(ms);
|
return new Date(ms);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getDisplayRunningTime(ticks) {
|
export function getDisplayRunningTime(ticks) {
|
||||||
var ticksPerHour = 36000000000;
|
var ticksPerHour = 36000000000;
|
||||||
var ticksPerMinute = 600000000;
|
var ticksPerMinute = 600000000;
|
||||||
var ticksPerSecond = 10000000;
|
var ticksPerSecond = 10000000;
|
||||||
|
@ -118,7 +119,7 @@ define(['globalize'], function (globalize) {
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
function toLocaleString(date, options) {
|
export function toLocaleString(date, options) {
|
||||||
|
|
||||||
if (!date) {
|
if (!date) {
|
||||||
throw new Error('date cannot be null');
|
throw new Error('date cannot be null');
|
||||||
|
@ -138,7 +139,7 @@ define(['globalize'], function (globalize) {
|
||||||
return date.toLocaleString();
|
return date.toLocaleString();
|
||||||
}
|
}
|
||||||
|
|
||||||
function toLocaleDateString(date, options) {
|
export function toLocaleDateString(date, options) {
|
||||||
|
|
||||||
if (!date) {
|
if (!date) {
|
||||||
throw new Error('date cannot be null');
|
throw new Error('date cannot be null');
|
||||||
|
@ -172,7 +173,7 @@ define(['globalize'], function (globalize) {
|
||||||
return date.toLocaleDateString();
|
return date.toLocaleDateString();
|
||||||
}
|
}
|
||||||
|
|
||||||
function toLocaleTimeString(date, options) {
|
export function toLocaleTimeString(date, options) {
|
||||||
|
|
||||||
if (!date) {
|
if (!date) {
|
||||||
throw new Error('date cannot be null');
|
throw new Error('date cannot be null');
|
||||||
|
@ -192,7 +193,7 @@ define(['globalize'], function (globalize) {
|
||||||
return date.toLocaleTimeString();
|
return date.toLocaleTimeString();
|
||||||
}
|
}
|
||||||
|
|
||||||
function getDisplayTime(date) {
|
export function getDisplayTime(date) {
|
||||||
|
|
||||||
if (!date) {
|
if (!date) {
|
||||||
throw new Error('date cannot be null');
|
throw new Error('date cannot be null');
|
||||||
|
@ -253,7 +254,7 @@ define(['globalize'], function (globalize) {
|
||||||
return time;
|
return time;
|
||||||
}
|
}
|
||||||
|
|
||||||
function isRelativeDay(date, offsetInDays) {
|
export function isRelativeDay(date, offsetInDays) {
|
||||||
|
|
||||||
if (!date) {
|
if (!date) {
|
||||||
throw new Error('date cannot be null');
|
throw new Error('date cannot be null');
|
||||||
|
@ -267,7 +268,7 @@ define(['globalize'], function (globalize) {
|
||||||
return date.getFullYear() === yesterday.getFullYear() && date.getMonth() === yesterday.getMonth() && date.getDate() === day;
|
return date.getFullYear() === yesterday.getFullYear() && date.getMonth() === yesterday.getMonth() && date.getDate() === day;
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
export default {
|
||||||
parseISO8601Date: parseISO8601Date,
|
parseISO8601Date: parseISO8601Date,
|
||||||
getDisplayRunningTime: getDisplayRunningTime,
|
getDisplayRunningTime: getDisplayRunningTime,
|
||||||
toLocaleDateString: toLocaleDateString,
|
toLocaleDateString: toLocaleDateString,
|
||||||
|
@ -279,4 +280,5 @@ define(['globalize'], function (globalize) {
|
||||||
return toLocaleTimeStringSupportsLocales;
|
return toLocaleTimeStringSupportsLocales;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
});
|
|
||||||
|
/*eslint-enable indent */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue