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

update variable declerations

This commit is contained in:
Cameron 2020-07-11 09:52:35 +01:00
parent 5a1e01c650
commit e31cae5af8
3 changed files with 54 additions and 57 deletions

View file

@ -8,14 +8,14 @@ import EmbyButtonPrototype from 'emby-button';
function addNotificationEvent(instance, name, handler) {
var localHandler = handler.bind(instance);
const localHandler = handler.bind(instance);
events.on(serverNotifications, name, localHandler);
instance[name] = localHandler;
}
function removeNotificationEvent(instance, name) {
var handler = instance[name];
const handler = instance[name];
if (handler) {
events.off(serverNotifications, name, handler);
instance[name] = null;
@ -29,13 +29,13 @@ import EmbyButtonPrototype from 'emby-button';
function onClick(e) {
var button = this;
var id = button.getAttribute('data-id');
var serverId = button.getAttribute('data-serverid');
var apiClient = connectionManager.getApiClient(serverId);
const button = this;
const id = button.getAttribute('data-id');
const serverId = button.getAttribute('data-serverid');
const apiClient = connectionManager.getApiClient(serverId);
var likes = this.getAttribute('data-likes');
var isFavorite = this.getAttribute('data-isfavorite') === 'true';
let likes = this.getAttribute('data-likes');
const isFavorite = this.getAttribute('data-isfavorite') === 'true';
if (likes === 'true') {
likes = true;
} else if (likes === 'false') {
@ -52,7 +52,7 @@ import EmbyButtonPrototype from 'emby-button';
function onUserDataChanged(e, apiClient, userData) {
var button = this;
const button = this;
if (userData.ItemId === button.getAttribute('data-id')) {
@ -62,7 +62,7 @@ import EmbyButtonPrototype from 'emby-button';
function setState(button, likes, isFavorite, updateAttribute) {
var icon = button.querySelector('.material-icons');
const icon = button.querySelector('.material-icons');
if (isFavorite) {
@ -111,7 +111,7 @@ import EmbyButtonPrototype from 'emby-button';
function setTitle(button) {
button.title = globalize.translate('Favorite');
var text = button.querySelector('.button-text');
const text = button.querySelector('.button-text');
if (text) {
text.innerHTML = button.title;
}
@ -131,7 +131,7 @@ import EmbyButtonPrototype from 'emby-button';
addNotificationEvent(button, 'UserDataChanged', onUserDataChanged);
}
var EmbyRatingButtonPrototype = Object.create(EmbyButtonPrototype);
const EmbyRatingButtonPrototype = Object.create(EmbyButtonPrototype);
EmbyRatingButtonPrototype.createdCallback = function () {
@ -148,12 +148,12 @@ import EmbyButtonPrototype from 'emby-button';
EmbyButtonPrototype.attachedCallback.call(this);
}
var itemId = this.getAttribute('data-id');
var serverId = this.getAttribute('data-serverid');
const itemId = this.getAttribute('data-id');
const serverId = this.getAttribute('data-serverid');
if (itemId && serverId) {
var likes = this.getAttribute('data-likes');
var isFavorite = this.getAttribute('data-isfavorite') === 'true';
let likes = this.getAttribute('data-likes');
const isFavorite = this.getAttribute('data-isfavorite') === 'true';
if (likes === 'true') {
likes = true;
} else if (likes === 'false') {
@ -186,7 +186,7 @@ import EmbyButtonPrototype from 'emby-button';
this.setAttribute('data-id', item.Id);
this.setAttribute('data-serverid', item.ServerId);
var userData = item.UserData || {};
const userData = item.UserData || {};
setState(this, userData.Likes, userData.IsFavorite);
bindEvents(this);

View file

@ -6,13 +6,13 @@ import 'paper-icon-button-light';
/* eslint-disable indent */
var EmbyScrollButtonsPrototype = Object.create(HTMLDivElement.prototype);
const EmbyScrollButtonsPrototype = Object.create(HTMLDivElement.prototype);
EmbyScrollButtonsPrototype.createdCallback = function () {};
function getScrollButtonHtml(direction) {
var html = '';
var icon = direction === 'left' ? 'chevron_left' : 'chevron_right';
let html = '';
const icon = direction === 'left' ? 'chevron_left' : 'chevron_right';
html += '<button type="button" is="paper-icon-button-light" data-ripple="false" data-direction="' + direction + '" class="emby-scrollbuttons-button">';
html += '<span class="material-icons ' + icon + '"></span>';
@ -50,7 +50,7 @@ import 'paper-icon-button-light';
scrollButtons.scrollButtonsLeft.disabled = true;
}
var scrollPosEnd = scrollPos + scrollSize;
const scrollPosEnd = scrollPos + scrollSize;
if (scrollWidth > 0 && scrollPosEnd >= scrollWidth) {
scrollButtons.scrollButtonsRight.disabled = true;
} else {
@ -59,18 +59,18 @@ import 'paper-icon-button-light';
}
function onScroll(e) {
var scrollButtons = this;
var scroller = this.scroller;
const scrollButtons = this;
const scroller = this.scroller;
var scrollSize = getScrollSize(scroller);
var scrollPos = getScrollPosition(scroller);
var scrollWidth = getScrollWidth(scroller);
const scrollSize = getScrollSize(scroller);
const scrollPos = getScrollPosition(scroller);
const scrollWidth = getScrollWidth(scroller);
updateScrollButtons(scrollButtons, scrollSize, scrollPos, scrollWidth);
}
function getStyleValue(style, name) {
var value = style.getPropertyValue(name);
let value = style.getPropertyValue(name);
if (!value) {
return 0;
}
@ -89,20 +89,20 @@ import 'paper-icon-button-light';
}
function getScrollSize(elem) {
var scrollSize = elem.offsetWidth;
var style = window.getComputedStyle(elem, null);
let scrollSize = elem.offsetWidth;
let style = window.getComputedStyle(elem, null);
var paddingLeft = getStyleValue(style, 'padding-left');
let paddingLeft = getStyleValue(style, 'padding-left');
if (paddingLeft) {
scrollSize -= paddingLeft;
}
var paddingRight = getStyleValue(style, 'padding-right');
let paddingRight = getStyleValue(style, 'padding-right');
if (paddingRight) {
scrollSize -= paddingRight;
}
var slider = elem.getScrollSlider();
const slider = elem.getScrollSlider();
style = window.getComputedStyle(slider, null);
paddingLeft = getStyleValue(style, 'padding-left');
@ -119,14 +119,14 @@ import 'paper-icon-button-light';
}
function onScrollButtonClick(e) {
var scroller = this.parentNode.nextSibling;
let scroller = this.parentNode.nextSibling;
var direction = this.getAttribute('data-direction');
var scrollSize = getScrollSize(scroller);
var scrollPos = getScrollPosition(scroller);
var scrollWidth = getScrollWidth(scroller);
const direction = this.getAttribute('data-direction');
const scrollSize = getScrollSize(scroller);
const scrollPos = getScrollPosition(scroller);
const scrollWidth = getScrollWidth(scroller);
var newPos;
let newPos;
if (direction === 'left') {
newPos = Math.max(0, scrollPos - scrollSize);
} else {
@ -137,21 +137,21 @@ import 'paper-icon-button-light';
}
EmbyScrollButtonsPrototype.attachedCallback = function () {
var scroller = this.nextSibling;
const scroller = this.nextSibling;
this.scroller = scroller;
var parent = this.parentNode;
const parent = this.parentNode;
parent.classList.add('emby-scroller-container');
this.innerHTML = getScrollButtonHtml('left') + getScrollButtonHtml('right');
var buttons = this.querySelectorAll('.emby-scrollbuttons-button');
const buttons = this.querySelectorAll('.emby-scrollbuttons-button');
buttons[0].addEventListener('click', onScrollButtonClick);
buttons[1].addEventListener('click', onScrollButtonClick);
this.scrollButtonsLeft = buttons[0];
this.scrollButtonsRight = buttons[1];
var scrollHandler = onScroll.bind(this);
const scrollHandler = onScroll.bind(this);
this.scrollHandler = scrollHandler;
scroller.addScrollEventListener(scrollHandler, {
capture: false,
@ -160,10 +160,10 @@ import 'paper-icon-button-light';
};
EmbyScrollButtonsPrototype.detachedCallback = function () {
var parent = this.scroller;
const parent = this.scroller;
this.scroller = null;
var scrollHandler = this.scrollHandler;
let scrollHandler = this.scrollHandler;
if (parent && scrollHandler) {
parent.removeScrollEventListener(scrollHandler, {
capture: false,

View file

@ -6,7 +6,7 @@ import 'registerElement';
/* eslint-disable indent */
var EmbySelectPrototype = Object.create(HTMLSelectElement.prototype);
const EmbySelectPrototype = Object.create(HTMLSelectElement.prototype);
function enableNativeMenu() {
@ -32,7 +32,7 @@ import 'registerElement';
}
function triggerChange(select) {
var evt = document.createEvent('HTMLEvents');
const evt = document.createEvent('HTMLEvents');
evt.initEvent('change', false, true);
select.dispatchEvent(evt);
}
@ -44,8 +44,8 @@ import 'registerElement';
function showActionSheet(select) {
var labelElem = getLabel(select);
var title = labelElem ? (labelElem.textContent || labelElem.innerText) : null;
const labelElem = getLabel(select);
const title = labelElem ? (labelElem.textContent || labelElem.innerText) : null;
actionsheet.show({
items: select.options,
@ -59,7 +59,7 @@ import 'registerElement';
}
function getLabel(select) {
var elem = select.previousSibling;
let elem = select.previousSibling;
while (elem && elem.tagName !== 'LABEL') {
elem = elem.previousSibling;
}
@ -67,21 +67,20 @@ import 'registerElement';
}
function onFocus(e) {
var label = getLabel(this);
const label = getLabel(this);
if (label) {
label.classList.add('selectLabelFocused');
}
}
function onBlur(e) {
var label = getLabel(this);
const label = getLabel(this);
if (label) {
label.classList.remove('selectLabelFocused');
}
}
function onMouseDown(e) {
// e.button=0 for primary (left) mouse button click
if (!e.button && !enableNativeMenu()) {
e.preventDefault();
@ -90,9 +89,7 @@ import 'registerElement';
}
function onKeyDown(e) {
switch (e.keyCode) {
case 13:
if (!enableNativeMenu()) {
e.preventDefault();
@ -112,7 +109,7 @@ import 'registerElement';
}
}
var inputId = 0;
let inputId = 0;
EmbySelectPrototype.createdCallback = function () {
@ -142,7 +139,7 @@ import 'registerElement';
this.classList.add('emby-select');
var label = this.ownerDocument.createElement('label');
const label = this.ownerDocument.createElement('label');
label.innerHTML = this.getAttribute('label') || '';
label.classList.add('selectLabel');
label.htmlFor = this.id;
@ -155,7 +152,7 @@ import 'registerElement';
EmbySelectPrototype.setLabel = function (text) {
var label = this.parentNode.querySelector('label');
const label = this.parentNode.querySelector('label');
label.innerHTML = text;
};