Skip to content
Snippets Groups Projects
Commit c2ac3fc7 authored by Jiří Setnička's avatar Jiří Setnička
Browse files

Fix informování o nových novinkách

Pokud byla vypsaná zpráva o žádných novinkách, tak se započítala jako novinka,
při dalším reloadu se vyměnil celý obsah <div> a tak se lišil počet.

Teď už se zpráva o žádných novinkách při reloadu nezmizí.
parent 70482210
No related branches found
No related tags found
No related merge requests found
......@@ -12,6 +12,3 @@
{% endif %}
</div>
{% endfor %}
{% if not messages %}
<p><em>Žádné novinky zatím nebyly vydány.</em>
{% endif %}
<div id="novinky">
{% include "parts/messages.html" %}
</div>
<div id="novinky-status">
{% if not messages %}
<p><em>Žádné novinky zatím nebyly vydány.</em>
{% endif %}
</div>
<script type="text/javascript">
r = new NewsReloader(document.getElementById("novinky"), "{{ url }}", 60000);
r = new NewsReloader(document.getElementById("novinky"), document.getElementById("novinky-status"), "{{ url }}", 60000);
</script>
......@@ -107,7 +107,7 @@
{% if contest.round.has_messages %}
<h3>Novinky k soutěži</h3>
{% with title="Novinky k soutěži", url=url_for('user_contest_news', id=contest.contest_id) %}
{% with url=url_for('user_contest_news', id=contest.contest_id) %}
{% include "parts/user_news.html" %}
{% endwith %}
{% endif %}
......
......@@ -93,7 +93,7 @@
{% if contest.round.has_messages %}
<h3>Novinky k soutěži</h3>
{% with title="Novinky k soutěži", url=url_for('user_contest_news', id=contest.contest_id) %}
{% with url=url_for('user_contest_news', id=contest.contest_id) %}
{% include "parts/user_news.html" %}
{% endwith %}
{% endif %}
......
......@@ -3,8 +3,9 @@ class NewsReloader {
notification_interval = null;
original_title = "";
constructor(element, url, check_interval=60000) {
constructor(element, status_element, url, check_interval=60000) {
this.element = element;
this.status_element = status_element;
this.url = url;
this.check_interval = check_interval;
......@@ -44,6 +45,14 @@ class NewsReloader {
var newsArr = JSON.parse(this.responseText);
var count = newsArr.length
if (t.status_element != null) {
if (count == 0) {
t.status_element.innerHTML = "<p><em>Žádné novinky zatím nebyly vydány.</em>";
} else {
t.status_element.innerHTML = "";
}
}
var markN = 0; // how many elements to mark with class "new"
if (count > t.news_count) {
markN = count - t.news_count;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment