mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2025-04-13 18:38:48 +00:00
[Core] lint
This commit is contained in:
parent
9c009d2f15
commit
60874b093a
@ -251,7 +251,7 @@ final class BridgeCard
|
|||||||
$attributes = self::getInputAttributes($entry);
|
$attributes = self::getInputAttributes($entry);
|
||||||
|
|
||||||
$fieldsDisplayString = '';
|
$fieldsDisplayString = '';
|
||||||
foreach($entry['fields_name_used_for_display'] as $index => $field) {
|
foreach ($entry['fields_name_used_for_display'] as $index => $field) {
|
||||||
if ($index === 0) {
|
if ($index === 0) {
|
||||||
$fieldsDisplayString = 'option.' . $field;
|
$fieldsDisplayString = 'option.' . $field;
|
||||||
} else {
|
} else {
|
||||||
@ -260,7 +260,7 @@ final class BridgeCard
|
|||||||
}
|
}
|
||||||
|
|
||||||
$fieldsValueString = '';
|
$fieldsValueString = '';
|
||||||
foreach($entry['fields_name_used_as_value'] as $index => $field) {
|
foreach ($entry['fields_name_used_as_value'] as $index => $field) {
|
||||||
if ($index === 0) {
|
if ($index === 0) {
|
||||||
$fieldsValueString = 'option.' . $field;
|
$fieldsValueString = 'option.' . $field;
|
||||||
} else {
|
} else {
|
||||||
@ -268,64 +268,65 @@ final class BridgeCard
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$list = sprintf('<input %s id="input-%s" name="%s" type="text" list="options-%s" onmousedown="
|
$list = sprintf(
|
||||||
const id = \'%s\';
|
'<input %s id="input-%s" name="%s" type="text" list="options-%s" onmousedown="
|
||||||
const inputElement = document.getElementById(\'input-\' + id);
|
const id = \'%s\';
|
||||||
const errorElement = document.getElementById(\'error-\' + id);
|
const inputElement = document.getElementById(\'input-\' + id);
|
||||||
const datalist = document.getElementById(\'options-\' + id);
|
const errorElement = document.getElementById(\'error-\' + id);
|
||||||
const options = document.getElementById(\'options-\' + id).options;
|
const datalist = document.getElementById(\'options-\' + id);
|
||||||
|
const options = document.getElementById(\'options-\' + id).options;
|
||||||
|
|
||||||
let hasError = errorElement.innerHTML === \'\' ? false : true;
|
let hasError = errorElement.innerHTML === \'\' ? false : true;
|
||||||
if (!hasError && (!options || options.length === 0)) {
|
if (!hasError && (!options || options.length === 0)) {
|
||||||
// set himself disabled while the request is progressing
|
// set himself disabled while the request is progressing
|
||||||
inputElement.disabled = true;
|
inputElement.disabled = true;
|
||||||
inputElement.value = \'loading...\';
|
inputElement.value = \'loading...\';
|
||||||
// used to not be blocked by cors
|
// used to not be blocked by cors
|
||||||
const proxy = \'%s\';
|
const proxy = \'%s\';
|
||||||
|
|
||||||
// Perform AJAX request
|
// Perform AJAX request
|
||||||
const xhr = new XMLHttpRequest();
|
const xhr = new XMLHttpRequest();
|
||||||
|
|
||||||
xhr.open(\'GET\', proxy + \'%s\', true);
|
xhr.open(\'GET\', proxy + \'%s\', true);
|
||||||
xhr.onerror = function () {
|
xhr.onerror = function () {
|
||||||
errorElement.innerHTML = \'failed fetching data\';
|
|
||||||
inputElement.value = \'\';
|
|
||||||
inputElement.disabled = false;
|
|
||||||
hasError = true;
|
|
||||||
}
|
|
||||||
xhr.onload = function () {
|
|
||||||
if (xhr.status === 200) {
|
|
||||||
// Parse the response and update the datalist
|
|
||||||
datalist.innerHTML = \'\'; // Clear existing options
|
|
||||||
const options = JSON.parse(xhr.responseText); // Assuming JSON response
|
|
||||||
options.forEach(option => {
|
|
||||||
const opt = document.createElement(\'option\');
|
|
||||||
|
|
||||||
opt.innerHTML = %s; // the displayed value
|
|
||||||
opt.value = %s; // the value
|
|
||||||
datalist.appendChild(opt);
|
|
||||||
});
|
|
||||||
// set himself enabled when the request is done
|
|
||||||
inputElement.value = \'\';
|
|
||||||
inputElement.disabled = false;
|
|
||||||
} else {
|
|
||||||
errorElement.innerHTML = \'failed fetching data\';
|
errorElement.innerHTML = \'failed fetching data\';
|
||||||
inputElement.value = \'\';
|
inputElement.value = \'\';
|
||||||
inputElement.disabled = false;
|
inputElement.disabled = false;
|
||||||
|
hasError = true;
|
||||||
}
|
}
|
||||||
};
|
xhr.onload = function () {
|
||||||
xhr.send();
|
if (xhr.status === 200) {
|
||||||
}
|
// Parse the response and update the datalist
|
||||||
" />' . "\n",
|
datalist.innerHTML = \'\'; // Clear existing options
|
||||||
$attributes,
|
const options = JSON.parse(xhr.responseText); // Assuming JSON response
|
||||||
$id,
|
options.forEach(option => {
|
||||||
$name,
|
const opt = document.createElement(\'option\');
|
||||||
$id,
|
|
||||||
$id,
|
opt.innerHTML = %s; // the displayed value
|
||||||
Configuration::getConfig('proxy', 'url') ?: 'https://cors-anywhere.herokuapp.com/',
|
opt.value = %s; // the value
|
||||||
$entry['ajax_route'],
|
datalist.appendChild(opt);
|
||||||
$fieldsDisplayString,
|
});
|
||||||
$fieldsValueString,
|
// set himself enabled when the request is done
|
||||||
|
inputElement.value = \'\';
|
||||||
|
inputElement.disabled = false;
|
||||||
|
} else {
|
||||||
|
errorElement.innerHTML = \'failed fetching data\';
|
||||||
|
inputElement.value = \'\';
|
||||||
|
inputElement.disabled = false;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
xhr.send();
|
||||||
|
}
|
||||||
|
" />' . "\n",
|
||||||
|
$attributes,
|
||||||
|
$id,
|
||||||
|
$name,
|
||||||
|
$id,
|
||||||
|
$id,
|
||||||
|
Configuration::getConfig('proxy', 'url') ?: 'https://cors-anywhere.herokuapp.com/',
|
||||||
|
$entry['ajax_route'],
|
||||||
|
$fieldsDisplayString,
|
||||||
|
$fieldsValueString,
|
||||||
);
|
);
|
||||||
$list .= sprintf('<datalist id="options-%s"></datalist>' . "\n", $id);
|
$list .= sprintf('<datalist id="options-%s"></datalist>' . "\n", $id);
|
||||||
$list .= sprintf('<br><div id="error-%s" style="color: red; height: 28px"></div>' . "\n", $id);
|
$list .= sprintf('<br><div id="error-%s" style="color: red; height: 28px"></div>' . "\n", $id);
|
||||||
|
Loading…
Reference in New Issue
Block a user