mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
Remove string replaceAll implementations
This commit is contained in:
parent
b008f2db30
commit
8536fe4610
6 changed files with 8 additions and 38 deletions
|
@ -5,11 +5,6 @@ import globalize from '../scripts/globalize';
|
||||||
|
|
||||||
/* eslint-disable indent */
|
/* eslint-disable indent */
|
||||||
|
|
||||||
function replaceAll(originalString, strReplace, strWith) {
|
|
||||||
const reg = new RegExp(strReplace, 'ig');
|
|
||||||
return originalString.replace(reg, strWith);
|
|
||||||
}
|
|
||||||
|
|
||||||
function useNativeAlert() {
|
function useNativeAlert() {
|
||||||
// webOS seems to block modals
|
// webOS seems to block modals
|
||||||
// Tizen 2.x seems to block modals
|
// Tizen 2.x seems to block modals
|
||||||
|
@ -33,7 +28,7 @@ import globalize from '../scripts/globalize';
|
||||||
await appRouter.ready();
|
await appRouter.ready();
|
||||||
|
|
||||||
if (useNativeAlert()) {
|
if (useNativeAlert()) {
|
||||||
alert(replaceAll(options.text || '', '<br/>', '\n'));
|
alert((options.text || '').replaceAll('<br/>', '\n'));
|
||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
} else {
|
} else {
|
||||||
const items = [];
|
const items = [];
|
||||||
|
|
|
@ -63,23 +63,13 @@ function getDeviceProfile(item) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function escapeRegExp(str) {
|
|
||||||
return str.replace(/([.*+?^=!:${}()|[\]/\\])/g, '\\$1');
|
|
||||||
}
|
|
||||||
|
|
||||||
function replaceAll(originalString, strReplace, strWith) {
|
|
||||||
const strReplace2 = escapeRegExp(strReplace);
|
|
||||||
const reg = new RegExp(strReplace2, 'ig');
|
|
||||||
return originalString.replace(reg, strWith);
|
|
||||||
}
|
|
||||||
|
|
||||||
function generateDeviceId() {
|
function generateDeviceId() {
|
||||||
const keys = [];
|
const keys = [];
|
||||||
|
|
||||||
keys.push(navigator.userAgent);
|
keys.push(navigator.userAgent);
|
||||||
keys.push(new Date().getTime());
|
keys.push(new Date().getTime());
|
||||||
if (window.btoa) {
|
if (window.btoa) {
|
||||||
return replaceAll(btoa(keys.join('|')), '=', '1');
|
return btoa(keys.join('|')).replaceAll('=', '1');
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Date().getTime();
|
return new Date().getTime();
|
||||||
|
|
|
@ -3,10 +3,6 @@ import browser from '../../scripts/browser';
|
||||||
import dialog from '../dialog/dialog';
|
import dialog from '../dialog/dialog';
|
||||||
import globalize from '../../scripts/globalize';
|
import globalize from '../../scripts/globalize';
|
||||||
|
|
||||||
function replaceAll(str, find, replace) {
|
|
||||||
return str.split(find).join(replace);
|
|
||||||
}
|
|
||||||
|
|
||||||
function useNativeConfirm() {
|
function useNativeConfirm() {
|
||||||
// webOS seems to block modals
|
// webOS seems to block modals
|
||||||
// Tizen 2.x seems to block modals
|
// Tizen 2.x seems to block modals
|
||||||
|
@ -24,7 +20,7 @@ async function nativeConfirm(options) {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
const text = replaceAll(options.text || '', '<br/>', '\n');
|
const text = (options.text || '').replaceAll('<br/>', '\n');
|
||||||
await appRouter.ready();
|
await appRouter.ready();
|
||||||
const result = window.confirm(text);
|
const result = window.confirm(text);
|
||||||
|
|
||||||
|
|
|
@ -12,10 +12,6 @@ import '../formdialog.scss';
|
||||||
import template from './prompt.template.html';
|
import template from './prompt.template.html';
|
||||||
|
|
||||||
export default (() => {
|
export default (() => {
|
||||||
function replaceAll(str, find, replace) {
|
|
||||||
return str.split(find).join(replace);
|
|
||||||
}
|
|
||||||
|
|
||||||
function setInputProperties(dlg, options) {
|
function setInputProperties(dlg, options) {
|
||||||
const txtInput = dlg.querySelector('#txtInput');
|
const txtInput = dlg.querySelector('#txtInput');
|
||||||
|
|
||||||
|
@ -105,7 +101,7 @@ export default (() => {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
const label = replaceAll(options.label || '', '<br/>', '\n');
|
const label = (options.label || '').replaceAll('<br/>', '\n');
|
||||||
const result = prompt(label, options.text || '');
|
const result = prompt(label, options.text || '');
|
||||||
|
|
||||||
if (result) {
|
if (result) {
|
||||||
|
|
|
@ -112,14 +112,11 @@ import Dashboard from '../utils/dashboard';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function replaceAll(str, find, replace) {
|
|
||||||
return str.split(find).join(replace);
|
|
||||||
}
|
|
||||||
|
|
||||||
function parseHtml(html, hasScript) {
|
function parseHtml(html, hasScript) {
|
||||||
if (hasScript) {
|
if (hasScript) {
|
||||||
html = replaceAll(html, '\x3c!--<script', '<script');
|
html = html
|
||||||
html = replaceAll(html, '</script>--\x3e', '</script>');
|
.replaceAll('\x3c!--<script', '<script')
|
||||||
|
.replaceAll('</script>--\x3e', '</script>');
|
||||||
}
|
}
|
||||||
|
|
||||||
const wrapper = document.createElement('div');
|
const wrapper = document.createElement('div');
|
||||||
|
|
|
@ -232,14 +232,10 @@ const Direction = {
|
||||||
return key;
|
return key;
|
||||||
}
|
}
|
||||||
|
|
||||||
function replaceAll(str, find, replace) {
|
|
||||||
return str.split(find).join(replace);
|
|
||||||
}
|
|
||||||
|
|
||||||
export function translate(key) {
|
export function translate(key) {
|
||||||
let val = translateKey(key);
|
let val = translateKey(key);
|
||||||
for (let i = 1; i < arguments.length; i++) {
|
for (let i = 1; i < arguments.length; i++) {
|
||||||
val = replaceAll(val, '{' + (i - 1) + '}', arguments[i].toLocaleString(currentCulture));
|
val = val.replaceAll('{' + (i - 1) + '}', arguments[i].toLocaleString(currentCulture));
|
||||||
}
|
}
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue