diff --git a/maloja/website/css/style.css b/maloja/website/css/style.css
index 576b7a1..54eca3e 100644
--- a/maloja/website/css/style.css
+++ b/maloja/website/css/style.css
@@ -668,4 +668,7 @@ a.hidelink:hover {
}
a:hover {
text-decoration: underline;
-}
\ No newline at end of file
+}
+.hide {
+ display:none;
+}
diff --git a/maloja/website/javascript/search.js b/maloja/website/javascript/search.js
index e068313..9dd14e2 100644
--- a/maloja/website/javascript/search.js
+++ b/maloja/website/javascript/search.js
@@ -10,66 +10,86 @@ function search(searchfield) {
xhttp.send();
}
}
+
+
+function html_to_fragment(html) {
+ var template = document.createElement("template");
+ template.innerHTML = resulthtml;
+ return template.content;
+}
+
+
+const results_artists = document.getElementById("searchresults_artists");
+const results_tracks = document.getElementById("searchresults_tracks");
+const searchresultwrap = document.getElementById("resultwrap");
+
+var resulthtml = `
+
+ |
+
+
+
+ |
+
+`
+const oneresult = html_to_fragment(resulthtml).firstElementChild;
+
+
+
+
function searchresult() {
if (this.readyState == 4 && this.status == 200 && document.getElementById("searchinput").value != "") {
// checking if field is empty in case we get an old result coming in that would overwrite our cleared result window
- result = JSON.parse(this.responseText);
- artists = result["artists"].slice(0,5)
- tracks = result["tracks"].slice(0,5)
- html = `
-
Artists
-
`
+ var result = JSON.parse(this.responseText);
+ var artists = result["artists"].slice(0,5)
+ var tracks = result["tracks"].slice(0,5)
- for (var i=0;i
- |
-
- ` + name + `
- |
- `
- }
+ for (var i=0;i
-
- Tracks
- `
+ var node = oneresult.cloneNode(true);
+ node.setAttribute("onclick","goto(" + link + ")");
+ node.children[0].style.backgroundImage = "url('" + image + "')";
+ node.children[1].children[0].innerHTML = name;
- for (var i=0;i
- |
-
- ` + artists + `
- ` + title + `
- |
- `
+ var node = oneresult.cloneNode(true);
+ node.setAttribute("onclick","goto(" + link + ")");
+ node.children[0].style.backgroundImage = "url('" + image + "')";
+ node.children[1].children[0].innerHTML = artists;
+ node.children[1].children[2].innerHTML = title;
- }
+ results_tracks.appendChild(node);
+ }
+ searchresultwrap.classList.remove("hide")
- html += `
- `
-
-
- document.getElementById("resultwrap").innerHTML = html;
}
}
- function clearresults() {
- window.setTimeout(reallyclear,500)
- }
- function reallyclear() {
- document.getElementById("resultwrap").innerHTML = "";
- }
-
- function goto(link) {
- window.location = link
+function clearresults() {
+ window.setTimeout(reallyclear,500)
+}
+function reallyclear() {
+ searchresultwrap.classList.add("hide")
+}
+
+function goto(link) {
+ window.location = link
}
diff --git a/maloja/website/less/grisons.less b/maloja/website/less/grisons.less
index fd2efc9..fd8e39a 100644
--- a/maloja/website/less/grisons.less
+++ b/maloja/website/less/grisons.less
@@ -132,3 +132,10 @@ div.grisons_bar:hover>div {
a:hover {
text-decoration:underline;
}
+
+
+
+
+.hide {
+ display:none;
+}
diff --git a/setup.py b/setup.py
index 2dcde39..2272aa3 100644
--- a/setup.py
+++ b/setup.py
@@ -28,7 +28,8 @@ setuptools.setup(
include_package_data=True,
entry_points = {
"console_scripts":[
- "maloja = maloja.controller:main"
+ cmd + " = " + module.name + "." + module.commands[cmd]
+ for cmd in module.commands
]
}
)