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