Compare commits
No commits in common. "2defe8a4bdbf3596c52c4a7725e6d21b13cfa848" and "bf51819cbc7787434eb68d756c04a6ec183b3fc8" have entirely different histories.
2defe8a4bd
...
bf51819cbc
|
|
@ -12,7 +12,8 @@
|
|||
<link rel="stylesheet" href="{% static 'dist/css/adminlte.css' %}">
|
||||
<link rel="stylesheet"
|
||||
href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,400i,700&display=fallback">
|
||||
<link rel="stylesheet" href="{% static 'plugins/select2/css/select2.min.css' %}">
|
||||
<link rel="stylesheet"
|
||||
href="{% static 'plugins/fontawesome-free/css/all.min.css' %}">
|
||||
</head>
|
||||
<body class="layout-top-nav" style="height: auto;">
|
||||
<div class="wrapper">
|
||||
|
|
@ -53,15 +54,14 @@
|
|||
|
||||
<form class="form-inline ml-0 ml-md-3 float-right">
|
||||
<div class="input-group input-group-sm">
|
||||
<input class="form-control form-control-navbar" data-toggle="dropdown"
|
||||
<input class="form-control form-control-navbar"
|
||||
type="search"
|
||||
placeholder="Search"
|
||||
aria-label="Search"
|
||||
autocomplete="off"
|
||||
id="search">
|
||||
<ul class="dropdown-menu" id="searchdropdown">
|
||||
<li><span class="dropdown-item-text">Nothing</span></li>
|
||||
</ul>
|
||||
id="searchinput">
|
||||
<!--
|
||||
<div id="searchsuggestions"></div>
|
||||
-->
|
||||
<div class="input-group-append">
|
||||
<button class="btn btn-navbar" type="submit">
|
||||
<i class="fas fa-search"></i>
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ urlpatterns = [
|
|||
path('auth/', include('django.contrib.auth.urls')),
|
||||
path('', include('core.urls')),
|
||||
path('api/', include('api.urls')),
|
||||
#path('api/', include('sage_stream.api.urls')),
|
||||
]
|
||||
|
||||
if settings.DEBUG:
|
||||
|
|
|
|||
41
static/dist/js/searchsuggestions.js
vendored
41
static/dist/js/searchsuggestions.js
vendored
|
|
@ -1,38 +1,27 @@
|
|||
const searchinput = document.querySelector("#search");
|
||||
const searchsuggestions = document.querySelector("#searchdropdown");
|
||||
/*
|
||||
const searchinput = document.querySelector("#searchinput");
|
||||
const searchsuggestions = document.querySelector("#searchsuggestions");
|
||||
searchinput.addEventListener("input", (e) => {
|
||||
q(e.target.value);
|
||||
});
|
||||
async function q(s) {
|
||||
if (s.length < 1) {clearSuggestions(searchsuggestions)}
|
||||
else {
|
||||
try {
|
||||
const response = await fetch("/api/search/?q=" + s);
|
||||
const result = await response.json();
|
||||
setSuggestions(searchsuggestions, result);
|
||||
} catch(error) {
|
||||
console.log("Error: " + error);
|
||||
}
|
||||
try {
|
||||
const response = await fetch("/api/?q=" + s);
|
||||
const result = await response.json();
|
||||
console.log("Success: " + JSON.stringify(result));
|
||||
setSuggestions(searchsuggestions, result);
|
||||
} catch(error) {
|
||||
console.log("Error: " + error);
|
||||
}
|
||||
}
|
||||
function clearSuggestions(o) {
|
||||
const span = document.createElement("span");
|
||||
span.setAttribute("class", "dropdown-item-text");
|
||||
span.insertAdjacentText("afterbegin", "Nothing");
|
||||
const li = document.createElement("li");
|
||||
li.appendChild(span);
|
||||
o.replaceChildren(li);
|
||||
}
|
||||
function setSuggestions(o, s) {
|
||||
const newSuggestions = [];
|
||||
for (const vid of s) {
|
||||
const a = document.createElement("a");
|
||||
a.setAttribute("class", "dropdown-item")
|
||||
a.setAttribute("href", "/view/" + vid.id);
|
||||
a.insertAdjacentText("afterbegin", vid.name + " " + vid.id);
|
||||
const li = document.createElement("li");
|
||||
li.appendChild(a);
|
||||
newSuggestions.push(li);
|
||||
const newSugg = document.createElement("a");
|
||||
newSugg.setAttribute("href", "/view/" + vid.id);
|
||||
newSugg.insertAdjacentText("afterbegin", vid.name + " " + vid.id);
|
||||
newSuggestions.push(newSugg);
|
||||
}
|
||||
o.replaceChildren(...newSuggestions);
|
||||
}
|
||||
*/
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user