mirror of
https://github.com/jellyfin/jellyfin-web.git
synced 2024-11-17 19:08:18 -07:00
Merge pull request #3548 from thornbill/url-utils
Remove some functions from the global scope
This commit is contained in:
commit
e0ed86935e
@ -193,8 +193,6 @@ module.exports = {
|
||||
'DlnaProfilePage': 'writable',
|
||||
'DashboardPage': 'writable',
|
||||
'Emby': 'readonly',
|
||||
'getParameterByName': 'writable',
|
||||
'getWindowLocationSearch': 'writable',
|
||||
'Globalize': 'writable',
|
||||
'Hls': 'writable',
|
||||
'dfnshelper': 'writable',
|
||||
|
@ -120,7 +120,7 @@ class AppRouter {
|
||||
const regexS = '[\\?&]' + name + '=([^&#]*)';
|
||||
const regex = new RegExp(regexS, 'i');
|
||||
|
||||
const results = regex.exec(url || getWindowLocationSearch());
|
||||
const results = regex.exec(url || window.location.search);
|
||||
if (results == null) {
|
||||
return '';
|
||||
} else {
|
||||
@ -678,19 +678,6 @@ class AppRouter {
|
||||
};
|
||||
}
|
||||
|
||||
getWindowLocationSearch() {
|
||||
const currentPath = this.currentRouteInfo ? (this.currentRouteInfo.path || '') : '';
|
||||
|
||||
const index = currentPath.indexOf('?');
|
||||
let search = '';
|
||||
|
||||
if (index !== -1) {
|
||||
search = currentPath.substring(index);
|
||||
}
|
||||
|
||||
return search || '';
|
||||
}
|
||||
|
||||
showGuide() {
|
||||
Dashboard.navigate('livetv.html?tab=1');
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ import { appHost } from './apphost';
|
||||
import imageLoader from './images/imageLoader';
|
||||
import globalize from '../scripts/globalize';
|
||||
import layoutManager from './layoutManager';
|
||||
import { getParameterByName } from '../utils/url.ts';
|
||||
import '../assets/css/scrollstyles.scss';
|
||||
import '../elements/emby-itemscontainer/emby-itemscontainer';
|
||||
|
||||
|
@ -3,6 +3,7 @@ import dom from '../../../scripts/dom';
|
||||
import '../../../elements/emby-input/emby-input';
|
||||
import '../../../elements/emby-button/emby-button';
|
||||
import Dashboard from '../../../scripts/clientUtils';
|
||||
import { getParameterByName } from '../../../utils/url.ts';
|
||||
|
||||
/* eslint-disable indent */
|
||||
|
||||
|
@ -9,6 +9,7 @@ import '../../../elements/emby-checkbox/emby-checkbox';
|
||||
import '../../../components/listview/listview.scss';
|
||||
import Dashboard from '../../../scripts/clientUtils';
|
||||
import toast from '../../../components/toast/toast';
|
||||
import { getParameterByName } from '../../../utils/url.ts';
|
||||
|
||||
/* eslint-disable indent */
|
||||
|
||||
|
@ -2,6 +2,7 @@ import escapeHtml from 'escape-html';
|
||||
import 'jquery';
|
||||
import '../../../../elements/emby-checkbox/emby-checkbox';
|
||||
import Dashboard from '../../../../scripts/clientUtils';
|
||||
import { getParameterByName } from '../../../../utils/url.ts';
|
||||
|
||||
function fillItems(elem, items, cssClass, idPrefix, currentList, isEnabledList) {
|
||||
let html = '<div class="checkboxList paperList" style="padding: .5em 1em;">';
|
||||
|
@ -7,6 +7,7 @@ import '../../../elements/emby-input/emby-input';
|
||||
import '../../../elements/emby-button/emby-button';
|
||||
import '../../../elements/emby-select/emby-select';
|
||||
import confirm from '../../../components/confirm/confirm';
|
||||
import { getParameterByName } from '../../../utils/url.ts';
|
||||
|
||||
/* eslint-disable indent */
|
||||
|
||||
|
@ -2,6 +2,7 @@ import { Events } from 'jellyfin-apiclient';
|
||||
import loading from '../components/loading/loading';
|
||||
import globalize from '../scripts/globalize';
|
||||
import Dashboard, { pageIdOn } from '../scripts/clientUtils';
|
||||
import { getParameterByName } from '../utils/url.ts';
|
||||
|
||||
function onListingsSubmitted() {
|
||||
Dashboard.navigate('livetvstatus.html');
|
||||
|
@ -6,6 +6,7 @@ import '../elements/emby-button/emby-button';
|
||||
import '../elements/emby-checkbox/emby-checkbox';
|
||||
import '../elements/emby-select/emby-select';
|
||||
import Dashboard from '../scripts/clientUtils';
|
||||
import { getParameterByName } from '../utils/url.ts';
|
||||
|
||||
function isM3uVariant(type) {
|
||||
return ['nextpvr'].indexOf(type || '') !== -1;
|
||||
|
@ -112,7 +112,7 @@ export function navigate(url, preserveQueryString) {
|
||||
throw new Error('url cannot be null or empty');
|
||||
}
|
||||
|
||||
const queryString = getWindowLocationSearch();
|
||||
const queryString = window.location.search;
|
||||
|
||||
if (preserveQueryString && queryString) {
|
||||
url += queryString;
|
||||
|
@ -3,6 +3,7 @@ import 'jquery';
|
||||
import globalize from './globalize';
|
||||
import 'material-design-icons-iconfont';
|
||||
import Dashboard from './clientUtils';
|
||||
import { getParameterByName } from '../utils/url.ts';
|
||||
|
||||
/* eslint-disable indent */
|
||||
|
||||
@ -299,9 +300,9 @@ import Dashboard from './clientUtils';
|
||||
if (itemId) {
|
||||
return itemId;
|
||||
}
|
||||
const url = window.location.hash || window.location.href;
|
||||
return getParameterByName('id', url);
|
||||
return getParameterByName('id');
|
||||
}
|
||||
|
||||
let nodesToLoad = [];
|
||||
let selectedNodeId;
|
||||
$(document).on('itemsaved', '.metadataEditorPage', function (e, item) {
|
||||
|
@ -19,6 +19,7 @@ import '../assets/css/flexstyles.scss';
|
||||
import Dashboard, { pageClassOn } from './clientUtils';
|
||||
import ServerConnections from '../components/ServerConnections';
|
||||
import Headroom from 'headroom.js';
|
||||
import { getParameterByName } from '../utils/url.ts';
|
||||
|
||||
/* eslint-disable indent */
|
||||
|
||||
|
@ -41,35 +41,6 @@ import SyncPlayHtmlAudioPlayer from '../components/syncPlay/ui/players/HtmlAudio
|
||||
import { currentSettings } from './settings/userSettings';
|
||||
import taskButton from './taskbutton';
|
||||
|
||||
// TODO: Move this elsewhere
|
||||
window.getWindowLocationSearch = function(win) {
|
||||
let search = (win || window).location.search;
|
||||
|
||||
if (!search) {
|
||||
const index = window.location.href.indexOf('?');
|
||||
|
||||
if (index != -1) {
|
||||
search = window.location.href.substring(index);
|
||||
}
|
||||
}
|
||||
|
||||
return search || '';
|
||||
};
|
||||
|
||||
// TODO: Move this elsewhere
|
||||
window.getParameterByName = function(name, url) {
|
||||
name = name.replace(/[[]/, '\\[').replace(/[\]]/, '\\]');
|
||||
const regexS = '[\\?&]' + name + '=([^&#]*)';
|
||||
const regex = new RegExp(regexS, 'i');
|
||||
const results = regex.exec(url || getWindowLocationSearch());
|
||||
|
||||
if (results == null) {
|
||||
return '';
|
||||
}
|
||||
|
||||
return decodeURIComponent(results[1].replace(/\+/g, ' '));
|
||||
};
|
||||
|
||||
function loadCoreDictionary() {
|
||||
const languages = ['af', 'ar', 'be-by', 'bg-bg', 'bn_bd', 'ca', 'cs', 'da', 'de', 'el', 'en-gb', 'en-us', 'eo', 'es', 'es-419', 'es-ar', 'es_do', 'es-mx', 'fa', 'fi', 'fil', 'fr', 'fr-ca', 'gl', 'gsw', 'he', 'hi-in', 'hr', 'hu', 'id', 'it', 'ja', 'kk', 'ko', 'lt-lt', 'mr', 'ms', 'nb', 'nl', 'pl', 'pr', 'pt', 'pt-br', 'pt-pt', 'ro', 'ru', 'sk', 'sl-si', 'sq', 'sv', 'ta', 'th', 'tr', 'uk', 'ur_pk', 'vi', 'zh-cn', 'zh-hk', 'zh-tw'];
|
||||
const translations = languages.map(function (language) {
|
||||
|
8
src/utils/url.ts
Normal file
8
src/utils/url.ts
Normal file
@ -0,0 +1,8 @@
|
||||
export const getParameterByName = (name: string, url?: string | null | undefined) => {
|
||||
if (!url) {
|
||||
url = window.location.search;
|
||||
}
|
||||
|
||||
// eslint-disable-next-line compat/compat
|
||||
return new URLSearchParams(url).get(name) || '';
|
||||
};
|
Loading…
Reference in New Issue
Block a user