web: fix not url

This commit is contained in:
King Kévin 2023-01-28 05:00:13 +01:00
parent c6f773c777
commit 8ff136ad82
2 changed files with 10 additions and 8 deletions

View File

@ -29,8 +29,8 @@
<div class="name">manufacturer:</div><div class="justify"><input class="full" type="text" id="part_manufacturer"></div>
<div class="name">mpn:</div><div class="justify"><input class="full" type="text" id="part_mpn"></div>
<div class="name">family:</div><div class="justify"><input class="full" type="text" id="part_family"></div>
<div class="name"><a id="url_datasheet">datasheet</a>:</div><div class="justify"><input class="full" type="text" id="part_datasheet"></div>
<div class="name"><a id="url_page">page</a>:</div><div class="justify"><input class="full" type="text" id="part_page"></div>
<div class="name"><span id="url_datasheet">datasheet</span>:</div><div class="justify"><input class="full" type="text" id="part_datasheet"></div>
<div class="name"><span id="url_page">page</span>:</div><div class="justify"><input class="full" type="text" id="part_page"></div>
<div class="name">location:</div><div class="justify"><input class="full" type="text" id="part_location"></div>
<div class="name">stock:</div><div class="justify"><input class="full" type="number" min="0" step="1" id="part_stock"></div>
<table>

View File

@ -109,14 +109,16 @@ function select_part()
}
// set URLs
for (const field of urls) {
const a = document.getElementById('url_' + field);
if (null == a) {
continue;
}
if (undefined === part[field]) {
a.href = null;
const span = document.getElementById('url_' + field);
const text = span.innerText;
span.innerHTML = null;
if (undefined === part[field] || null == part[field]) {
span.innerHTML = text;
} else {
const a = document.createElement('a');
a.href = part[field];
a.innerText = text;
span.appendChild(a);
}
}
// set distributors