specifičen vnos
This commit is contained in:
@@ -1,3 +1,7 @@
|
||||
function getSpecific(kljuc) {
|
||||
window.location.href = `/vnos.html?kljuc=${kljuc}`;
|
||||
}
|
||||
|
||||
function getLast() {
|
||||
const url = `http://localhost:3000/vnosi`;
|
||||
fetch(url, {
|
||||
@@ -19,7 +23,7 @@ function getLast() {
|
||||
|
||||
for (let entry of data.data) {
|
||||
let build = `
|
||||
<div class="entry-card">
|
||||
<div class="entry-card" onclick="getSpecific('${entry.PK}')">
|
||||
<h3 class="entry-title">${entry.kljuc}</h3>
|
||||
<p class="entry-definition">${entry.tip}</p>
|
||||
${entry.vsebina}
|
||||
@@ -48,7 +52,8 @@ function search() {
|
||||
},
|
||||
body: JSON.stringify({
|
||||
query: `*${val}*`, // Potencialno mora biti tukaj en "*" wildcard
|
||||
limit: -1
|
||||
limit: -1,
|
||||
sort: true
|
||||
})
|
||||
})
|
||||
.then(response => response.json())
|
||||
@@ -62,7 +67,7 @@ function search() {
|
||||
let len = data.data.length;
|
||||
document.getElementById("page-title").innerText = `Rezultati iskanja (${len}):`;
|
||||
document.getElementById("entry-container").innerHTML = "";
|
||||
|
||||
|
||||
if (len <= 0) {
|
||||
document.getElementById("entry-container").innerHTML = `
|
||||
<p class="page-paragraph">Ni bilo najednih zadetkov za poizvedbo "${val}".</p>
|
||||
@@ -72,7 +77,7 @@ function search() {
|
||||
|
||||
for (let entry of data.data) {
|
||||
let build = `
|
||||
<div class="entry-card">
|
||||
<div class="entry-card" onclick="getSpecific('${entry.PK}')">
|
||||
<h3 class="entry-title">${entry.kljuc}</h3>
|
||||
<p class="entry-definition">${entry.tip}</p>
|
||||
${entry.vsebina}
|
||||
|
||||
37
scripts/vnos.js
Normal file
37
scripts/vnos.js
Normal file
@@ -0,0 +1,37 @@
|
||||
const kljuc = new URLSearchParams(window.location.search).get("kljuc");
|
||||
|
||||
function getKey() {
|
||||
const url = `http://localhost:3000/vnos`;
|
||||
fetch(url, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
},
|
||||
body: JSON.stringify({
|
||||
pk: kljuc
|
||||
})
|
||||
})
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
if (!data.success) {
|
||||
console.error('API Error:', data.message);
|
||||
return;
|
||||
}
|
||||
|
||||
let build = `
|
||||
<h3 class="entry-title">${data.data.kljuc}</h3>
|
||||
<p class="entry-definition">${data.data.tip}</p>
|
||||
${data.data.vsebina}
|
||||
<p class="entry-example">${data.data.primer}</p>
|
||||
<p class="entry-example">Vnos dodal: ${data.data.avtor}</p>
|
||||
`;
|
||||
|
||||
document.getElementById("page-title").innerText = `Vnos '${data.data.kljuc}'`;
|
||||
document.getElementById("entry-container-single").innerHTML += build;
|
||||
})
|
||||
.catch((error) => {
|
||||
console.error('Error:', error);
|
||||
});
|
||||
}
|
||||
|
||||
getKey();
|
||||
Reference in New Issue
Block a user