mirror of
https://github.com/Xevion/trivia.git
synced 2025-12-10 16:08:56 -06:00
fixed jinja2 whitespace trim, move script tag up, re-add silent row class, table sorting function
This commit is contained in:
@@ -13,6 +13,10 @@ def create_app(env=None):
|
|||||||
env = app.config['ENV']
|
env = app.config['ENV']
|
||||||
app.config.from_object(configs[env])
|
app.config.from_object(configs[env])
|
||||||
|
|
||||||
|
# Fixes poor whitespace rendering in templates
|
||||||
|
app.jinja_env.trim_blocks = True
|
||||||
|
app.jinja_env.lstrip_blocks = True
|
||||||
|
|
||||||
with app.app_context():
|
with app.app_context():
|
||||||
# noinspection PyUnresolvedReferences
|
# noinspection PyUnresolvedReferences
|
||||||
from trivia import routes, api, utils
|
from trivia import routes, api, utils
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ let REFRESH_TIMEOUT;
|
|||||||
function ScrollOnce(autoscroll) {
|
function ScrollOnce(autoscroll) {
|
||||||
// If autoscroll has been disabled in between timer, this if statement will prevent it from executing.
|
// If autoscroll has been disabled in between timer, this if statement will prevent it from executing.
|
||||||
if (AUTOSCROLL)
|
if (AUTOSCROLL)
|
||||||
$(".ui-row:first").appendTo("tbody")
|
$(".ui-row:first").appendTo(".js-standings")
|
||||||
|
|
||||||
// Restart autoscroll as needed.
|
// Restart autoscroll as needed.
|
||||||
if (autoscroll && AUTOSCROLL) {
|
if (autoscroll && AUTOSCROLL) {
|
||||||
@@ -49,6 +49,26 @@ function ToggleAutorefresh() {
|
|||||||
} else {
|
} else {
|
||||||
$(".js-refresh-start").show();
|
$(".js-refresh-start").show();
|
||||||
$(".js-refresh-stop").hide();
|
$(".js-refresh-stop").hide();
|
||||||
|
|
||||||
|
clearTimeout(REFRESH_TIMEOUT);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function sortUsingNestedText(parent, childSelector, keySelector) {
|
||||||
|
var items = parent.children(childSelector).sort(function(a, b) {
|
||||||
|
var vA = $(keySelector, a).text();
|
||||||
|
var vB = $(keySelector, b).text();
|
||||||
|
return (vA < vB) ? 1 : (vA > vB) ? -1 : 0;
|
||||||
|
});
|
||||||
|
parent.append(items);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sorts all Teams, rearranging them by Rank
|
||||||
|
function SortTeams(topTeam = 0) {
|
||||||
|
sortUsingNestedText($(".js-standings"), '.ui-row', 'td.js-total-score')
|
||||||
|
|
||||||
|
while($('.js-standings').firstChild.data('row-index') !== topTeam) {
|
||||||
|
$(".ui-row:first").appendTo("tbody")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -60,4 +80,5 @@ $().ready(function () {
|
|||||||
|
|
||||||
ToggleAutoscroll()
|
ToggleAutoscroll()
|
||||||
ToggleAutorefresh()
|
ToggleAutorefresh()
|
||||||
|
SortTeams();
|
||||||
})
|
})
|
||||||
@@ -15,6 +15,8 @@ tr[data-row-index="0"] td { border-top: 0.25em solid #000; }
|
|||||||
.ui-header { background-color: #b51329; border-bottom: 2px solid #27233a; color: #fff; padding: 0.5em 1em; }
|
.ui-header { background-color: #b51329; border-bottom: 2px solid #27233a; color: #fff; padding: 0.5em 1em; }
|
||||||
/*.ui-content { padding: 0.5em 1em; }*/
|
/*.ui-content { padding: 0.5em 1em; }*/
|
||||||
.ui-footer { }
|
.ui-footer { }
|
||||||
|
.ui-silent-row {color: #7c7c7c
|
||||||
|
}
|
||||||
|
|
||||||
.center { text-align: center; }
|
.center { text-align: center; }
|
||||||
.pointer { cursor: pointer; }
|
.pointer { cursor: pointer; }
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
integrity="sha256-9/aliU8dGd2tb6OSsuzixeV4y/faTqgFtohetphbbj0=" crossorigin="anonymous"></script>
|
integrity="sha256-9/aliU8dGd2tb6OSsuzixeV4y/faTqgFtohetphbbj0=" crossorigin="anonymous"></script>
|
||||||
<script>window.jQuery || document.write('<script src="{{
|
<script>window.jQuery || document.write('<script src="{{
|
||||||
url_for('static', filename='jquery.js') }}">\x3C/script>')</script>
|
url_for('static', filename='jquery.js') }}">\x3C/script>')</script>
|
||||||
|
<script src="{{ url_for('static', filename='script.js') }}"></script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<header class="ui-header">
|
<header class="ui-header">
|
||||||
@@ -52,6 +53,7 @@
|
|||||||
{% else %}
|
{% else %}
|
||||||
<td class="ui-silent-row">Team {{ team.id }}</td>
|
<td class="ui-silent-row">Team {{ team.id }}</td>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
<td class="js-total-score">{{ team.scores | sum }}</td>
|
||||||
{% for score in team.scores %}
|
{% for score in team.scores %}
|
||||||
<td>{{ score }}</td>
|
<td>{{ score }}</td>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
@@ -62,5 +64,4 @@
|
|||||||
</div>
|
</div>
|
||||||
<footer class="ui-footer"></footer>
|
<footer class="ui-footer"></footer>
|
||||||
</body>
|
</body>
|
||||||
<script src="{{ url_for('static', filename='script.js') }}"></script>
|
|
||||||
</html>
|
</html>
|
||||||
Reference in New Issue
Block a user