mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
Fix some code smells
This commit is contained in:
parent
d4fbbea991
commit
ac060e1270
4 changed files with 24 additions and 44 deletions
|
@ -72,12 +72,12 @@ define(['dialogHelper', 'datetime', 'globalize', 'emby-select', 'paper-icon-butt
|
||||||
reject();
|
reject();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
dlg.querySelector('.btnCancel').addEventListener('click', function (e) {
|
dlg.querySelector('.btnCancel').addEventListener('click', function () {
|
||||||
dialogHelper.close(dlg);
|
dialogHelper.close(dlg);
|
||||||
});
|
});
|
||||||
dlg.querySelector('form').addEventListener('submit', function (e) {
|
dlg.querySelector('form').addEventListener('submit', function (event) {
|
||||||
submitSchedule(dlg, options);
|
submitSchedule(dlg, options);
|
||||||
e.preventDefault();
|
event.preventDefault();
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
@ -11,20 +11,10 @@ define(['dialogHelper', 'layoutManager', 'globalize', 'browser', 'dom', 'emby-bu
|
||||||
}
|
}
|
||||||
|
|
||||||
var box;
|
var box;
|
||||||
var elem;
|
for (let [index, elem] of elems) {
|
||||||
|
box = elem.getBoundingClientRect();
|
||||||
|
|
||||||
for (var i = 0, length = elems.length; i < length; i++) {
|
results[index] = {
|
||||||
|
|
||||||
elem = elems[i];
|
|
||||||
// Support: BlackBerry 5, iOS 3 (original iPhone)
|
|
||||||
// If we don't have gBCR, just use 0,0 rather than error
|
|
||||||
if (elem.getBoundingClientRect) {
|
|
||||||
box = elem.getBoundingClientRect();
|
|
||||||
} else {
|
|
||||||
box = { top: 0, left: 0 };
|
|
||||||
}
|
|
||||||
|
|
||||||
results[i] = {
|
|
||||||
top: box.top,
|
top: box.top,
|
||||||
left: box.left,
|
left: box.left,
|
||||||
width: box.width,
|
width: box.width,
|
||||||
|
@ -96,13 +86,11 @@ define(['dialogHelper', 'layoutManager', 'globalize', 'browser', 'dom', 'emby-bu
|
||||||
scrollY: false
|
scrollY: false
|
||||||
};
|
};
|
||||||
|
|
||||||
var backButton = false;
|
|
||||||
var isFullscreen;
|
var isFullscreen;
|
||||||
|
|
||||||
if (layoutManager.tv) {
|
if (layoutManager.tv) {
|
||||||
dialogOptions.size = 'fullscreen';
|
dialogOptions.size = 'fullscreen';
|
||||||
isFullscreen = true;
|
isFullscreen = true;
|
||||||
backButton = true;
|
|
||||||
dialogOptions.autoFocus = true;
|
dialogOptions.autoFocus = true;
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
@ -139,16 +127,10 @@ define(['dialogHelper', 'layoutManager', 'globalize', 'browser', 'dom', 'emby-bu
|
||||||
style += 'min-width:' + minWidth + 'px;';
|
style += 'min-width:' + minWidth + 'px;';
|
||||||
}
|
}
|
||||||
|
|
||||||
var i;
|
|
||||||
var length;
|
|
||||||
var option;
|
|
||||||
var renderIcon = false;
|
var renderIcon = false;
|
||||||
var icons = [];
|
var icons = [];
|
||||||
var itemIcon;
|
var itemIcon;
|
||||||
for (i = 0, length = options.items.length; i < length; i++) {
|
for (let option of options.items) {
|
||||||
|
|
||||||
option = options.items[i];
|
|
||||||
|
|
||||||
itemIcon = option.icon || (option.selected ? 'check' : null);
|
itemIcon = option.icon || (option.selected ? 'check' : null);
|
||||||
|
|
||||||
if (itemIcon) {
|
if (itemIcon) {
|
||||||
|
@ -206,10 +188,7 @@ define(['dialogHelper', 'layoutManager', 'globalize', 'browser', 'dom', 'emby-bu
|
||||||
menuItemClass += ' actionsheet-xlargeFont';
|
menuItemClass += ' actionsheet-xlargeFont';
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0, length = options.items.length; i < length; i++) {
|
for (let [index, option] of options) {
|
||||||
|
|
||||||
option = options.items[i];
|
|
||||||
|
|
||||||
if (option.divider) {
|
if (option.divider) {
|
||||||
|
|
||||||
html += '<div class="actionsheetDivider"></div>';
|
html += '<div class="actionsheetDivider"></div>';
|
||||||
|
@ -222,7 +201,7 @@ define(['dialogHelper', 'layoutManager', 'globalize', 'browser', 'dom', 'emby-bu
|
||||||
var optionId = option.id == null || option.id === '' ? option.value : option.id;
|
var optionId = option.id == null || option.id === '' ? option.value : option.id;
|
||||||
html += '<button' + autoFocus + ' is="emby-button" type="button" class="' + menuItemClass + '" data-id="' + optionId + '">';
|
html += '<button' + autoFocus + ' is="emby-button" type="button" class="' + menuItemClass + '" data-id="' + optionId + '">';
|
||||||
|
|
||||||
itemIcon = icons[i];
|
itemIcon = icons[index];
|
||||||
|
|
||||||
if (itemIcon) {
|
if (itemIcon) {
|
||||||
|
|
||||||
|
|
|
@ -34,10 +34,14 @@ define(['events', 'globalize', 'dom', 'date-fns', 'dfnshelper', 'userSettings',
|
||||||
html += '</div>';
|
html += '</div>';
|
||||||
|
|
||||||
if (entry.Overview) {
|
if (entry.Overview) {
|
||||||
html += '<button type="button" is="paper-icon-button-light" class="btnEntryInfo" data-id="' + entry.Id + '" title="' + globalize.translate('Info') + '"><span class="material-icons info"></span></button>';
|
html += `<button type="button" is="paper-icon-button-light" class="btnEntryInfo" data-id="${entry.Id}" title="${globalize.translate('Info')}">
|
||||||
|
<span class="material-icons info"></span>
|
||||||
|
</button>`;
|
||||||
}
|
}
|
||||||
|
|
||||||
return html += '</div>';
|
html += '</div>';
|
||||||
|
|
||||||
|
return html;
|
||||||
}
|
}
|
||||||
|
|
||||||
function renderList(elem, apiClient, result, startIndex, limit) {
|
function renderList(elem, apiClient, result, startIndex, limit) {
|
||||||
|
|
|
@ -26,11 +26,11 @@ define(['loading', 'globalize', 'events', 'viewManager', 'layoutManager', 'skinM
|
||||||
connectionManager.connect({
|
connectionManager.connect({
|
||||||
enableAutoLogin: appSettings.enableAutoLogin()
|
enableAutoLogin: appSettings.enableAutoLogin()
|
||||||
}).then(function (result) {
|
}).then(function (result) {
|
||||||
handleConnectionResult(result, loading);
|
handleConnectionResult(result);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleConnectionResult(result, loading) {
|
function handleConnectionResult(result) {
|
||||||
switch (result.State) {
|
switch (result.State) {
|
||||||
case 'SignedIn':
|
case 'SignedIn':
|
||||||
loading.hide();
|
loading.hide();
|
||||||
|
@ -246,13 +246,11 @@ define(['loading', 'globalize', 'events', 'viewManager', 'layoutManager', 'skinM
|
||||||
}
|
}
|
||||||
|
|
||||||
if (setQuality) {
|
if (setQuality) {
|
||||||
|
var quality;
|
||||||
var quality = 100;
|
|
||||||
|
|
||||||
var type = options.type || 'Primary';
|
var type = options.type || 'Primary';
|
||||||
|
|
||||||
if (browser.tv || browser.slow) {
|
if (browser.tv || browser.slow) {
|
||||||
|
// TODO: wtf
|
||||||
if (browser.chrome) {
|
if (browser.chrome) {
|
||||||
// webp support
|
// webp support
|
||||||
quality = type === 'Primary' ? 40 : 50;
|
quality = type === 'Primary' ? 40 : 50;
|
||||||
|
@ -384,7 +382,7 @@ define(['loading', 'globalize', 'events', 'viewManager', 'layoutManager', 'skinM
|
||||||
|
|
||||||
if (firstResult.State !== 'SignedIn' && !route.anonymous) {
|
if (firstResult.State !== 'SignedIn' && !route.anonymous) {
|
||||||
|
|
||||||
handleConnectionResult(firstResult, loading);
|
handleConnectionResult(firstResult);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -463,7 +461,6 @@ define(['loading', 'globalize', 'events', 'viewManager', 'layoutManager', 'skinM
|
||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
var isHandlingBackToDefault;
|
|
||||||
var isDummyBackToHome;
|
var isDummyBackToHome;
|
||||||
|
|
||||||
function loadContent(ctx, route, html, request) {
|
function loadContent(ctx, route, html, request) {
|
||||||
|
@ -589,8 +586,7 @@ define(['loading', 'globalize', 'events', 'viewManager', 'layoutManager', 'skinM
|
||||||
path = '/' + path;
|
path = '/' + path;
|
||||||
}
|
}
|
||||||
|
|
||||||
var baseRoute = baseUrl();
|
path = path.replace(baseUrl(), '');
|
||||||
path = path.replace(baseRoute, '');
|
|
||||||
|
|
||||||
if (currentRouteInfo && currentRouteInfo.path === path) {
|
if (currentRouteInfo && currentRouteInfo.path === path) {
|
||||||
// can't use this with home right now due to the back menu
|
// can't use this with home right now due to the back menu
|
||||||
|
@ -621,10 +617,11 @@ define(['loading', 'globalize', 'events', 'viewManager', 'layoutManager', 'skinM
|
||||||
}
|
}
|
||||||
|
|
||||||
function showItem(item, serverId, options) {
|
function showItem(item, serverId, options) {
|
||||||
|
// TODO: Refactor this so it only gets items, not strings.
|
||||||
if (typeof (item) === 'string') {
|
if (typeof (item) === 'string') {
|
||||||
var apiClient = serverId ? connectionManager.getApiClient(serverId) : connectionManager.currentApiClient();
|
var apiClient = serverId ? connectionManager.getApiClient(serverId) : connectionManager.currentApiClient();
|
||||||
apiClient.getItem(apiClient.getCurrentUserId(), item).then(function (item) {
|
apiClient.getItem(apiClient.getCurrentUserId(), item).then(function (itemObject) {
|
||||||
appRouter.showItem(item, options);
|
appRouter.showItem(itemObject, options);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
if (arguments.length === 2) {
|
if (arguments.length === 2) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue