Frontend Features and refactor
This commit is contained in:
+32
-29
@@ -3,46 +3,49 @@
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Search</title>
|
||||
<title>Semantic Search - KJV API</title>
|
||||
<link rel="stylesheet" href="/styles/page.css?v=__V__">
|
||||
<style>
|
||||
#search-box {
|
||||
padding: 10px;
|
||||
border: 1px solid #ccc;
|
||||
border-radius: 4px;
|
||||
width: 100%;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
#results {
|
||||
list-style: none;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.search-row { display: flex; gap: var(--space-sm); }
|
||||
.search-row input[type=text] { margin: 0; flex: 1; min-width: 0; }
|
||||
#results, #last-searched { list-style: none; padding: 0; margin: var(--space-md) 0; }
|
||||
#results li {
|
||||
margin-bottom: 10px;
|
||||
border-bottom: 1px solid #eee;
|
||||
padding: 5px;
|
||||
background-color: var(--color-bg-secondary);
|
||||
border: 1px solid var(--color-border);
|
||||
border-left: 3px solid var(--color-accent-primary);
|
||||
border-radius: var(--border-radius-sm);
|
||||
padding: var(--space-md);
|
||||
margin-bottom: var(--space-sm);
|
||||
}
|
||||
#last-searched li { padding: 0.2rem 0; color: var(--color-text-secondary); }
|
||||
@media (max-width: 480px) { .search-row { flex-direction: column; } .search-row button { width: 100%; } }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Bible Semantic Search</h1>
|
||||
<p>This is NOT a keyword search. This means searching single words will not have the results you expect. For that, use the normal keyword search at <a href='/'>api.1611.social</a></p>
|
||||
<header>
|
||||
<a href="/">Home</a> <a href="/find">Quick Search</a>
|
||||
<a href="/random?view=rich">Random Verse</a> <a href="/votd?view=rich">Verse of the Day</a>
|
||||
</header>
|
||||
<h2>Bible Semantic Search</h2>
|
||||
<p>This is NOT a keyword search. This means searching single words will not have the results you expect. For that, use the normal keyword search at <a href='/'>bible.nicecrew.digital</a></p>
|
||||
<p>Use a sentence like "The Lord will kill his enemies without mercy" - you are supposed to search an idea, not individual words.</p>
|
||||
<h3>Recent searches:</h3>
|
||||
<h3>Recent searches</h3>
|
||||
<ul id="last-searched"></ul>
|
||||
<input type="text" id="search-box" placeholder="The lord god is a man of war, just in all his dealings">
|
||||
<button id="search-button">Search</button>
|
||||
<div class="search-row">
|
||||
<input type="text" id="search-box" aria-label="Search an idea" enterkeyhint="search" placeholder="The lord god is a man of war, just in all his dealings">
|
||||
<button id="search-button">Search</button>
|
||||
</div>
|
||||
<ul id="results"></ul>
|
||||
|
||||
<script>
|
||||
const searchButton = document.getElementById('search-button');
|
||||
const searchBox = document.getElementById('search-box');
|
||||
const esc = s => String(s).replace(/[&<>"']/g, c => ({'&':'&','<':'<','>':'>','"':'"',"'":'''}[c]));
|
||||
const resultsList = document.getElementById('results');
|
||||
const lastSearched = document.getElementById('last-searched');
|
||||
|
||||
window.addEventListener('DOMContentLoaded', async () => {
|
||||
const lastSearchedURL = `https://api.1611.social/natural`;
|
||||
const lastSearchedURL = `https://bible.nicecrew.digital/natural`;
|
||||
const data = {
|
||||
token: 'testing',
|
||||
query: '__last_searched__'
|
||||
@@ -61,7 +64,7 @@
|
||||
results.forEach(result => {
|
||||
const listItem = document.createElement('li');
|
||||
listItem.innerHTML = `
|
||||
${result.query}<br>
|
||||
${esc(result.query)}<br>
|
||||
`;
|
||||
lastSearched.appendChild(listItem);
|
||||
});
|
||||
@@ -75,7 +78,7 @@
|
||||
if (query.length >= 100){
|
||||
alert("Query too long");
|
||||
return;}
|
||||
const url = `https://api.1611.social/natural`; // Replace with your actual URL
|
||||
const url = `https://bible.nicecrew.digital/natural`; // Replace with your actual URL
|
||||
|
||||
const data = {
|
||||
token: 'testing',
|
||||
@@ -98,10 +101,10 @@
|
||||
const listItem = document.createElement('li');
|
||||
const uriRef = encodeURIComponent(result.ref);
|
||||
listItem.innerHTML = `
|
||||
<strong>Verse ID:</strong> ${result.verse_id}<br>
|
||||
<strong>Text:</strong> ${result.text}<br>
|
||||
<strong>Ref:</strong> <a href=/find?kw=${uriRef}>${result.ref}</a><br>
|
||||
<strong>Score:</strong> ${result.score}
|
||||
<strong>Verse ID:</strong> ${esc(result.verse_id)}<br>
|
||||
<strong>Text:</strong> ${esc(result.text)}<br>
|
||||
<strong>Ref:</strong> <a href="/find?kw=${uriRef}">${esc(result.ref)}</a><br>
|
||||
<strong>Score:</strong> ${esc(result.score)}
|
||||
`;
|
||||
resultsList.appendChild(listItem);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user