Update search field
This commit is contained in:
1 parent
4bc5fcef7a
commit
f61034dff5
3 files changed
+50
-2
No files matched your search
@@ -167,3 +167,27 @@ $(document).on('click', '.correct-answer-btn', function () {
|
|||||||
console.error('centrifuge init error', e);
|
console.error('centrifuge init error', e);
|
||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
|
// Handle ASK IT button - transfer search text to ask page
|
||||||
|
function redirectToAsk(event) {
|
||||||
|
event.preventDefault();
|
||||||
|
const searchInput = document.getElementById('search-input');
|
||||||
|
const query = searchInput ? searchInput.value.trim() : '';
|
||||||
|
const url = query ? `/ask?q=${encodeURIComponent(query)}` : '/ask';
|
||||||
|
window.location.href = url;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Populate title field from URL parameter on ask page
|
||||||
|
function initializeTitleFromQuery() {
|
||||||
|
const params = new URLSearchParams(window.location.search);
|
||||||
|
const query = params.get('q');
|
||||||
|
if (query) {
|
||||||
|
const titleField = document.querySelector('[name="title"]');
|
||||||
|
if (titleField) {
|
||||||
|
titleField.value = query;
|
||||||
|
titleField.focus();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Run on ask page load
|
||||||
|
document.addEventListener('DOMContentLoaded', initializeTitleFromQuery);
|
||||||
@@ -12,10 +12,10 @@
|
|||||||
<body>
|
<body>
|
||||||
<header class="site-header">
|
<header class="site-header">
|
||||||
<a href="/" class="logo not-underlined">VkDesk</a>
|
<a href="/" class="logo not-underlined">VkDesk</a>
|
||||||
<form class="search">
|
<form class="search" onsubmit="return false;">
|
||||||
<input id="search-input" type="text" placeholder="Search">
|
<input id="search-input" type="text" placeholder="Search">
|
||||||
<div id="search-suggestions" class="search-suggestions"></div>
|
<div id="search-suggestions" class="search-suggestions"></div>
|
||||||
<a class="button button--ask" href="ask">ASK IT</a>
|
<a class="button button--ask" href="#" onclick="redirectToAsk(event)">ASK IT</a>
|
||||||
</form>
|
</form>
|
||||||
<div class="user-block">
|
<div class="user-block">
|
||||||
<div class="avatar-box small">
|
<div class="avatar-box small">
|
||||||
|
|||||||
@@ -167,3 +167,27 @@ $(document).on('click', '.correct-answer-btn', function () {
|
|||||||
console.error('centrifuge init error', e);
|
console.error('centrifuge init error', e);
|
||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
|
// Handle ASK IT button - transfer search text to ask page
|
||||||
|
function redirectToAsk(event) {
|
||||||
|
event.preventDefault();
|
||||||
|
const searchInput = document.getElementById('search-input');
|
||||||
|
const query = searchInput ? searchInput.value.trim() : '';
|
||||||
|
const url = query ? `/ask?q=${encodeURIComponent(query)}` : '/ask';
|
||||||
|
window.location.href = url;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Populate title field from URL parameter on ask page
|
||||||
|
function initializeTitleFromQuery() {
|
||||||
|
const params = new URLSearchParams(window.location.search);
|
||||||
|
const query = params.get('q');
|
||||||
|
if (query) {
|
||||||
|
const titleField = document.querySelector('[name="title"]');
|
||||||
|
if (titleField) {
|
||||||
|
titleField.value = query;
|
||||||
|
titleField.focus();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Run on ask page load
|
||||||
|
document.addEventListener('DOMContentLoaded', initializeTitleFromQuery);
|
||||||
Reference in new issue
Block a user