diff --git a/app/static/css/partials/_film.scss b/app/static/css/partials/_film.scss index 8b90eaf..b258d04 100755 --- a/app/static/css/partials/_film.scss +++ b/app/static/css/partials/_film.scss @@ -6,8 +6,15 @@ color: #ee0; text-decoration: none; } + + select { + font-size: 18px; + font-family: "noto_sans", sans-serif; + padding: calc(var(--spacing) /4) var(--spacing); + } + .film { - margin-bottom: var(--spacing-2); + margin-top: var(--spacing-2); h1 { font-weight: bold; font-size: 20px; diff --git a/app/static/js/films.js b/app/static/js/films.js new file mode 100644 index 0000000..8eec4cd --- /dev/null +++ b/app/static/js/films.js @@ -0,0 +1,22 @@ +function selectChanged() { + const sortValue = document.getElementById('sort-select').value + const $films = [...document.querySelectorAll('.film')] + location.hash = sortValue + $films.sort((a, b) => { + const aVal = a.dataset[sortValue] + const bVal = b.dataset[sortValue] + return aVal < bVal ? -1 : 1 + }) + document.getElementById('films-list').innerHTML = '' + $films.forEach($film => { + document.getElementById('films-list').appendChild($film) + }) +} + +document.getElementById('sort-select').addEventListener('change', selectChanged) + +const locationHash = location.hash.replace('#', '') +if (locationHash !== '') { + document.getElementById('sort-select').value = locationHash + selectChanged() +} \ No newline at end of file diff --git a/app/templates/films.html b/app/templates/films.html old mode 100644 new mode 100755 index 3b1b15a..c059a1c --- a/app/templates/films.html +++ b/app/templates/films.html @@ -1,19 +1,44 @@ {% extends "base.html" %} {% block body_class%}animated animated-text{% endblock %} {% block main %} +
-{% for film in films %} -
-

- {{ film.data.title | safe }} - {{ film.data.title_zh | safe }} -

-

- {% for director in film.data.director %} - {{ director|safe }} - {% endfor %} -

+
+ Sort: + +
+
+ {% for film in films %} +
+

+ {{ film.data.title | safe }} + {{ film.data.title_zh | safe }} +

+

+ {% for director in film.data.director %} + {{ director|safe }} + {% endfor %} +

+
+ {% endfor %}
-{% endfor %}
{% endblock %} + +{% block end %} + +{% endblock %} \ No newline at end of file