diff --git a/soundboard.py b/soundboard.py index f3a9f9d..cc0da8a 100644 --- a/soundboard.py +++ b/soundboard.py @@ -94,4 +94,6 @@ def edit(sound): # TODO: Store changes return redirect("/edit") - return render_template("edit.html") + tags = queryDB("SELECT name FROM tag ORDER BY name COLLATE NOCASE") + + return render_template("edit.html", sound=sound, tags=tags) diff --git a/static/main.css b/static/main.css index 4f61fcb..a70b8f7 100644 --- a/static/main.css +++ b/static/main.css @@ -43,6 +43,35 @@ input { margin: 5px; } +.editform input[type="text"] { + display: block; +} + +.editform input[type="checkbox"] { + display: block; + float: left; + height: 15px; + margin: 5px; + width: 15px; +} + +.editform .tags li { + clear: left; + display: block; + line-height: 20px; + vertical-align: middle; +} + +.editform .tags li span { + display: inline-block; + line-height: 20px; + vertical-align: middle; +} + +.tags { + padding-left: 0; +} + .tags li { display: inline-block; list-style-type: none; diff --git a/static/main.js b/static/main.js index 198de5a..b0fa63e 100644 --- a/static/main.js +++ b/static/main.js @@ -30,23 +30,8 @@ ready(function() { var searchfield = document.querySelector("#search"); - if (searchfield !== null) { - searchfield.addEventListener("keyup", function() { - var buttons = document.querySelectorAll(".sound"); - - buttons.forEach(function(item) { - item.style.display = "inline-block"; - }); - - buttons.forEach(function(item) { - var name = item.firstChild.innerHTML; - - if (name.toLowerCase().indexOf(searchfield.value.toLowerCase()) === -1) { - item.style.display = "none"; - } - }); - }); - } + filter(searchfield, ".sound", "inline-block"); + filter(searchfield, ".tag", "block"); var reset = document.querySelector("#sounds .reset"); @@ -78,6 +63,27 @@ ready(function() { } }); +function filter(searchfield, itemSelector, unHideStyle) { + if (searchfield !== null) { + searchfield.addEventListener("keyup", function() { + var items = document.querySelectorAll(itemSelector); + + items.forEach(function(item) { + item.style.display = unHideStyle; + }); + + items.forEach(function(item) { + var name = item.firstChild.innerHTML; + console.log(name); + + if (name.toLowerCase().indexOf(searchfield.value.toLowerCase()) === -1) { + item.style.display = "none"; + } + }); + }); + } +} + function hideSections() { var sections = document.querySelectorAll("section"); diff --git a/templates/edit.html b/templates/edit.html index f8ac239..d9182ad 100644 --- a/templates/edit.html +++ b/templates/edit.html @@ -3,32 +3,16 @@ {% endblock %} {% block content %}
-

Filename

+

Edit {{ sound }}

-
-
- -
-
- -
-
-
-
-
-
    -
  • Testтип
  • -
-
-
-
-
-
-
- - -
-
+ + + +
{% endblock %}