Everywhere: Add initial cut of the blogging functionality

This commit is contained in:
Riyyi
2022-11-15 17:40:18 +01:00
parent 3b47e0ed71
commit 7beef3a1d5
8 changed files with 168 additions and 2 deletions
+5
View File
@@ -57,6 +57,11 @@ nav.shadow {
cursor: pointer;
}
a.clear {
color: inherit;
text-decoration: none;
}
/* Anchor offset */
h3 {
position: relative;
+33
View File
@@ -12,6 +12,39 @@ $(document).ready(function() {
return elementBottom > viewportTop && elementTop < viewportBottom;
}
//------------------------------------------//
// Blog search
function blogSearch(input)
{
var url = input.data("url");
var search = input.val();
window.location.href = url + '?search=' + search;
}
$("#js-blog-search").keydown(function(e) {
if (e.key == 'Enter') {
e.preventDefault();
blogSearch($(this));
}
});
$("#js-blog-search-button").click(function() {
blogSearch($("#js-blog-search"));
});
$("#js-blog-search").on("input", function() {
var url = $(this).data("url");
var search = $(this).val();
if (search.length == 0 || search.length >= 3) {
fetch(url + '/search?query=' + search)
.then(response => response.text())
.then(data => {
$("#blog-posts").empty().append(data);
});
}
});
//------------------------------------------//
// Image hover mouseenter