Skip to content

Commit

Permalink
UI: replace backticks as string delimiters
Browse files Browse the repository at this point in the history
  • Loading branch information
klees committed Oct 23, 2023
1 parent ecb1071 commit d192500
Show file tree
Hide file tree
Showing 20 changed files with 114 additions and 114 deletions.
14 changes: 7 additions & 7 deletions src/UI/templates/js/Core/dist/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -478,20 +478,20 @@
if (Array.isArray(value)) {
value.forEach(
(v) => {
url += `${encodeURIComponent(`${key}`)}[]=${encodeURIComponent(v)}&`;
url += '${encodeURIComponent('${key}')}[]=${encodeURIComponent(v)}&';
},
);
} else {
url += `${encodeURIComponent(key)}=${encodeURIComponent(value)}&`;
url += '${encodeURIComponent(key)}=${encodeURIComponent(value)}&';
}
},
);
url = url.slice(0, url.length - 1);
}
if (this.#fragment !== '') { url += `#${this.#fragment}`; }
if (this.#fragment !== '') { url += '#${this.#fragment}'; }

if (!URLBuilder.checkLength(url)) {
throw new Error(`The final URL is longer than ${URLBuilderUrlMaxLength} and will not be valid.`);
throw new Error('The final URL is longer than ${URLBuilderUrlMaxLength} and will not be valid.');
}
return new URL(url);
}
Expand Down Expand Up @@ -540,7 +540,7 @@

const parameter = namespace.join(URLBuilderSeparator) + URLBuilderSeparator + name;
if (this.#parameterExists(parameter)) {
throw new Error(`Parameter '${parameter}' has already been acquired`);
throw new Error('Parameter '${parameter}' has already been acquired');
}

const newToken = new URLBuilderToken(namespace, name);
Expand Down Expand Up @@ -599,10 +599,10 @@
}
if (!this.#tokens.has(token.getName())
|| this.#tokens.get(token.getName()).getToken() !== token.getToken()) {
throw new Error(`Token for '${token.getName()}' is not valid`);
throw new Error('Token for '${token.getName()}' is not valid');
}
if (!this.#parameters.has(token.getName())) {
throw new Error(`Parameter '${token.getName()}' does not exist in URL`);
throw new Error('Parameter '${token.getName()}' does not exist in URL');
}
}
}
Expand Down
14 changes: 7 additions & 7 deletions src/UI/templates/js/Core/src/core.URLBuilder.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,20 +121,20 @@ export default class URLBuilder {
if (Array.isArray(value)) {
value.forEach(
(v) => {
url += `${encodeURIComponent(`${key}`)}%5B%5D=${encodeURIComponent(v)}&`;
url += '${encodeURIComponent('${key}')}%5B%5D=${encodeURIComponent(v)}&';
},
);
} else {
url += `${encodeURIComponent(key)}=${encodeURIComponent(value)}&`;
url += '${encodeURIComponent(key)}=${encodeURIComponent(value)}&';
}
},
);
url = url.slice(0, url.length - 1);
}
if (this.#fragment !== '') { url += `#${this.#fragment}`; }
if (this.#fragment !== '') { url += '#${this.#fragment}'; }

if (!URLBuilder.checkLength(url)) {
throw new Error(`The final URL is longer than ${URLBuilderUrlMaxLength} and will not be valid.`);
throw new Error('The final URL is longer than ${URLBuilderUrlMaxLength} and will not be valid.');
}
return new URL(url);
}
Expand Down Expand Up @@ -183,7 +183,7 @@ export default class URLBuilder {

const parameter = namespace.join(URLBuilderSeparator) + URLBuilderSeparator + name;
if (this.#parameterExists(parameter)) {
throw new Error(`Parameter '${parameter}' has already been acquired`);
throw new Error('Parameter '${parameter}' has already been acquired');
}

const newToken = new URLBuilderToken(namespace, name);
Expand Down Expand Up @@ -242,10 +242,10 @@ export default class URLBuilder {
}
if (!this.#tokens.has(token.getName())
|| this.#tokens.get(token.getName()).getToken() !== token.getToken()) {
throw new Error(`Token for '${token.getName()}' is not valid`);
throw new Error('Token for '${token.getName()}' is not valid');
}
if (!this.#parameters.has(token.getName())) {
throw new Error(`Parameter '${token.getName()}' does not exist in URL`);
throw new Error('Parameter '${token.getName()}' does not exist in URL');
}
}
}
6 changes: 3 additions & 3 deletions src/UI/templates/js/Dropzone/File/dropzone.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,11 @@ il.UI = il.UI || {};
*/
let init = function (dropzone_id) {
if (typeof dropzones[dropzone_id] !== 'undefined') {
console.error(`Error: tried initializing dropzone '${dropzone_id}' twice.`);
console.error('Error: tried initializing dropzone '${dropzone_id}' twice.');
return;
}

let dropzone = $(`#${dropzone_id}`);
let dropzone = $('#${dropzone_id}');
dropzones[dropzone_id] = {
file_input_id: dropzone.find(SELECTOR.file_input).attr('id'),
};
Expand Down Expand Up @@ -113,7 +113,7 @@ il.UI = il.UI || {};

let removeAllFilesFromQueue = function (dropzone_id) {
if (typeof dropzones[dropzone_id] === 'undefined') {
console.error(`Error: tried accessing unknown dropzone '${dropzone_id}'.`);
console.error('Error: tried accessing unknown dropzone '${dropzone_id}'.');
return;
}
il.UI.Input.File.removeAllFilesFromQueue(dropzones[dropzone_id].file_input_id);
Expand Down
24 changes: 12 additions & 12 deletions src/UI/templates/js/Input/Field/dist/input.factory.min.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class Textarea {
this.textarea = document.getElementById(input_id);

if (null === this.textarea) {
throw new Error(`Could not find textarea for input-id '${input_id}'.`);
throw new Error('Could not find textarea for input-id '${input_id}'.');
}

if (this.shouldShowRemainder()) {
Expand All @@ -29,7 +29,7 @@ class Textarea {
?.querySelector('[data-action="remainder"]');

if (!this.remainder instanceof HTMLSpanElement) {
throw new Error(`Could not find remainder-element for input-id '${input_id}'.`);
throw new Error('Could not find remainder-element for input-id '${input_id}'.');
}

this.textarea.addEventListener('input', () => {
Expand Down Expand Up @@ -243,7 +243,7 @@ class TextareaFactory {
*/
init(input_id) {
if (undefined !== this.instances[input_id]) {
throw new Error(`Textarea with input-id '${input_id}' has already been initialized.`);
throw new Error('Textarea with input-id '${input_id}' has already been initialized.');
}

this.instances[input_id] = new Textarea(input_id);
Expand Down Expand Up @@ -354,7 +354,7 @@ class Markdown extends Textarea {
let input_wrapper = this.textarea.closest('.c-input-markdown');

if (null === input_wrapper) {
throw new Error(`Could not find input-wrapper for input-id '${input_id}'.`);
throw new Error('Could not find input-wrapper for input-id '${input_id}'.');
}

this.preview_renderer = preview_renderer;
Expand Down Expand Up @@ -487,7 +487,7 @@ class Markdown extends Textarea {
this.insertSingleEnumeration();
break;
default:
throw new Error(`Could not perform markdown-action '${markdown_action}'.`);
throw new Error('Could not perform markdown-action '${markdown_action}'.');
}
}

Expand Down Expand Up @@ -573,13 +573,13 @@ class Markdown extends Textarea {
*/
applyTransformationToSelection(transformation) {
if (!transformation instanceof Function) {
throw new Error(`Transformation must be an instance of Function, ${typeof transformation} given.`);
throw new Error('Transformation must be an instance of Function, ${typeof transformation} given.');
}

let transformed_selection = transformation(this.getLinesOfSelection());

if (!transformed_selection instanceof Array) {
throw new Error(`Transformation must return an instance of Array, ${typeof transformed_selection} returned.`);
throw new Error('Transformation must return an instance of Array, ${typeof transformed_selection} returned.');
}

let is_multiline = (1 < transformed_selection.length);
Expand Down Expand Up @@ -687,7 +687,7 @@ function getContentWrappersOrAbort(input_wrapper) {

content_wrappers.forEach(function (wrapper) {
if (null === wrapper) {
throw new Error(`Could not find all content-wrappers for markdown-input.`);
throw new Error('Could not find all content-wrappers for markdown-input.');
}
});

Expand All @@ -705,7 +705,7 @@ function getViewControlsOrAbort(input_wrapper) {
?.getElementsByTagName('button');

if (!controls instanceof HTMLCollection || 2 !== controls.length) {
throw new Error(`Could not find exactly two view-controls.`);
throw new Error('Could not find exactly two view-controls.');
}

return [...controls];
Expand Down Expand Up @@ -783,7 +783,7 @@ function toggleBulletPoints(lines_of_selection) {
let to_list = !isBulletPointed(lines_of_selection[0] ?? '');
for (let line of lines_of_selection) {
transformed_lines.push(
(to_list) ? `- ${line}` : removeBulletPointOrEnummeration(line)
(to_list) ? '- ${line}' : removeBulletPointOrEnummeration(line)
);
}

Expand All @@ -800,7 +800,7 @@ function toggleEnumeration(lines_of_selection, next_number = 1) {
let to_list = !isEnumerated(lines_of_selection[0] ?? '');
for (let line of lines_of_selection) {
transformed_lines.push(
(to_list) ? `${next_number++}. ${line}` : removeBulletPointOrEnummeration(line)
(to_list) ? '${next_number++}. ${line}' : removeBulletPointOrEnummeration(line)
);
}

Expand Down Expand Up @@ -895,7 +895,7 @@ class MarkdownFactory {
*/
init(input_id, preview_url, parameter_name) {
if (undefined !== this.instances[input_id]) {
throw new Error(`Markdown with input-id '${input_id}' has already been initialized.`);
throw new Error('Markdown with input-id '${input_id}' has already been initialized.');
}

this.instances[input_id] = new Markdown(
Expand Down
10 changes: 5 additions & 5 deletions src/UI/templates/js/Input/Field/dynamic_inputs_renderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ il.UI.Input = il.UI.Input || {};
let render = function (input_id) {
// abort if the DynamicInputsAware input was not yet registered.
if (typeof dynamic_inputs[input_id] === 'undefined') {
console.error(`Error: tried rendering dynamic sub input for '${input_id}' which is unregistered.`);
console.error('Error: tried rendering dynamic sub input for '${input_id}' which is unregistered.');
return null;
}

Expand All @@ -38,7 +38,7 @@ il.UI.Input = il.UI.Input || {};
template = addInputTemplateIds(template, dynamic_inputs[input_id].sub_input_count);

template = $(template);
template.appendTo($(`#${input_id} ${SELECTORS.dynamic_inputs_list}`));
template.appendTo($('#${input_id} ${SELECTORS.dynamic_inputs_list}'));

return template;
}
Expand All @@ -51,7 +51,7 @@ il.UI.Input = il.UI.Input || {};
let init = function (input_id, template_html, input_count) {
// abort if the DynamicInputsAware input was already registered.
if (typeof dynamic_inputs[input_id] !== 'undefined') {
console.error(`Error: tried to register input '${input_id}' as dynamic input twice.`);
console.error('Error: tried to register input '${input_id}' as dynamic input twice.');
return;
}

Expand All @@ -70,7 +70,7 @@ il.UI.Input = il.UI.Input || {};
*/
let registerEventListeners = function (input_id) {
// register the removal event listener for dynamic inputs.
$(document).on('click', `#${input_id} ${SELECTORS.dynamic_input_close}`, removeDynamicInputHook);
$(document).on('click', '#${input_id} ${SELECTORS.dynamic_input_close}', removeDynamicInputHook);
}

let removeDynamicInputHook = function () {
Expand All @@ -91,7 +91,7 @@ il.UI.Input = il.UI.Input || {};
for (let i = 0; i < sub_input_count; i++) {
template_html = replaceAll(
template_html,
`${INPUT_ID_PLACEHOLDER}_${i}`,
'${INPUT_ID_PLACEHOLDER}_${i}',
generateId()
);
}
Expand Down
Loading

0 comments on commit d192500

Please sign in to comment.