mirror of
https://github.com/Xevion/trivia.git
synced 2025-12-09 22:08:51 -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']
|
||||
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():
|
||||
# noinspection PyUnresolvedReferences
|
||||
from trivia import routes, api, utils
|
||||
|
||||
@@ -14,7 +14,7 @@ let REFRESH_TIMEOUT;
|
||||
function ScrollOnce(autoscroll) {
|
||||
// If autoscroll has been disabled in between timer, this if statement will prevent it from executing.
|
||||
if (AUTOSCROLL)
|
||||
$(".ui-row:first").appendTo("tbody")
|
||||
$(".ui-row:first").appendTo(".js-standings")
|
||||
|
||||
// Restart autoscroll as needed.
|
||||
if (autoscroll && AUTOSCROLL) {
|
||||
@@ -49,6 +49,26 @@ function ToggleAutorefresh() {
|
||||
} else {
|
||||
$(".js-refresh-start").show();
|
||||
$(".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()
|
||||
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-content { padding: 0.5em 1em; }*/
|
||||
.ui-footer { }
|
||||
.ui-silent-row {color: #7c7c7c
|
||||
}
|
||||
|
||||
.center { text-align: center; }
|
||||
.pointer { cursor: pointer; }
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
integrity="sha256-9/aliU8dGd2tb6OSsuzixeV4y/faTqgFtohetphbbj0=" crossorigin="anonymous"></script>
|
||||
<script>window.jQuery || document.write('<script src="{{
|
||||
url_for('static', filename='jquery.js') }}">\x3C/script>')</script>
|
||||
<script src="{{ url_for('static', filename='script.js') }}"></script>
|
||||
</head>
|
||||
<body>
|
||||
<header class="ui-header">
|
||||
@@ -52,6 +53,7 @@
|
||||
{% else %}
|
||||
<td class="ui-silent-row">Team {{ team.id }}</td>
|
||||
{% endif %}
|
||||
<td class="js-total-score">{{ team.scores | sum }}</td>
|
||||
{% for score in team.scores %}
|
||||
<td>{{ score }}</td>
|
||||
{% endfor %}
|
||||
@@ -62,5 +64,4 @@
|
||||
</div>
|
||||
<footer class="ui-footer"></footer>
|
||||
</body>
|
||||
<script src="{{ url_for('static', filename='script.js') }}"></script>
|
||||
</html>
|
||||
Reference in New Issue
Block a user