Try moving js to body end
This commit is contained in:
parent
df49a0e353
commit
58f3807b8d
4 changed files with 120 additions and 115 deletions
|
@ -75,112 +75,6 @@
|
||||||
<link rel="stylesheet" href="{{ static('darkmode-svg.css') }}">
|
<link rel="stylesheet" href="{{ static('darkmode-svg.css') }}">
|
||||||
{% endcompress %}
|
{% endcompress %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if not INLINE_JQUERY %}
|
|
||||||
<script src="{{ JQUERY_JS }}"></script>
|
|
||||||
{% endif %}
|
|
||||||
<script src="https://unpkg.com/@popperjs/core@2"></script>
|
|
||||||
{% compress js %}
|
|
||||||
<script>{{ inlinei18n(LANGUAGE_CODE)|safe }}</script>
|
|
||||||
{% if INLINE_JQUERY %}
|
|
||||||
<script src="{{ static('libs/jquery-3.4.1.min.js') }}"></script>
|
|
||||||
{% endif %}
|
|
||||||
<script src="{{ static('libs/jquery-cookie.js') }}"></script>
|
|
||||||
<script src="{{ static('libs/jquery-taphold.js') }}"></script>
|
|
||||||
<script src="{{ static('libs/jquery.unveil.js') }}"></script>
|
|
||||||
<script src="{{ static('libs/moment.js') }}"></script>
|
|
||||||
<script src="{{ static('libs/select2/select2.js') }}"></script>
|
|
||||||
<script src="{{ static('libs/clipboard/clipboard.js') }}"></script>
|
|
||||||
{% include "extra_js.html" %}
|
|
||||||
<script src="{{ static('common.js') }}"></script>
|
|
||||||
<script src="{{ static('libs/clipboard/tooltip.js') }}"></script>
|
|
||||||
<script>
|
|
||||||
moment.locale('{{ LANGUAGE_CODE }}');
|
|
||||||
$(function () {
|
|
||||||
$('img.unveil').unveil(200);
|
|
||||||
});
|
|
||||||
const loading_page = `{% include "loading-page.html" %}`;
|
|
||||||
</script>
|
|
||||||
{% endcompress %}
|
|
||||||
|
|
||||||
{% block js_media %}{% endblock %}
|
|
||||||
{% if request.in_contest %}
|
|
||||||
<script>$(function () {
|
|
||||||
if ($("#contest-time-remaining").length) {
|
|
||||||
count_down($("#contest-time-remaining"));
|
|
||||||
}
|
|
||||||
|
|
||||||
var selected = null,
|
|
||||||
x_pos = 0, y_pos = 0,
|
|
||||||
x_elem = 0, y_elem = 0;
|
|
||||||
|
|
||||||
$('#contest-info').mousedown(function () {
|
|
||||||
selected = $(this);
|
|
||||||
x_elem = x_pos - selected.offset().left;
|
|
||||||
y_elem = y_pos - (selected.offset().top - $(window).scrollTop());
|
|
||||||
return false;
|
|
||||||
});
|
|
||||||
|
|
||||||
if (localStorage.getItem("contest_timer_position")) {
|
|
||||||
data = localStorage.getItem("contest_timer_position").split(":");
|
|
||||||
$("#contest-info").css({
|
|
||||||
left: data[0],
|
|
||||||
top: data[1]
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
$("#contest-info").show();
|
|
||||||
|
|
||||||
$("#contest-info-toggle").on('click', function() {
|
|
||||||
$.post("{{url('contest_mode_ajax')}}", function() {
|
|
||||||
window.location.reload();
|
|
||||||
})
|
|
||||||
});
|
|
||||||
|
|
||||||
$(document).mousemove(function (e) {
|
|
||||||
x_pos = e.screenX;
|
|
||||||
y_pos = e.screenY;
|
|
||||||
|
|
||||||
if (selected !== null) {
|
|
||||||
left_px = (x_pos - x_elem);
|
|
||||||
top_px = (y_pos - y_elem);
|
|
||||||
left_px = Math.max(Math.min(left_px, window.innerWidth), 0) / window.innerWidth * 100 + '%';
|
|
||||||
top_px = Math.max(Math.min(top_px, window.innerHeight), 0) / window.innerHeight * 100 + '%';
|
|
||||||
localStorage.setItem("contest_timer_position", left_px + ":" + top_px);
|
|
||||||
|
|
||||||
selected.css({
|
|
||||||
left: left_px,
|
|
||||||
top: top_px
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
$(document).mouseup(function () {
|
|
||||||
selected = null;
|
|
||||||
})
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
{% if request.user.is_authenticated %}
|
|
||||||
<script>
|
|
||||||
window.user = {
|
|
||||||
email: '{{ request.user.email|escapejs }}',
|
|
||||||
id: '{{ request.user.id|escapejs }}',
|
|
||||||
name: '{{ request.user.username|escapejs }}'
|
|
||||||
};
|
|
||||||
</script>
|
|
||||||
{% else %}
|
|
||||||
<script>window.user = {};</script>
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
{% if misc_config.analytics %}
|
|
||||||
{{ misc_config.analytics|safe }}
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
{# Don't run userscript since it may be malicious #}
|
|
||||||
{% if request.user.is_authenticated and request.profile.user_script and not request.user.is_impersonate %}
|
|
||||||
<script type="text/javascript">{{ request.profile.user_script|safe }}</script>
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
<noscript>
|
<noscript>
|
||||||
<style>
|
<style>
|
||||||
|
@ -378,7 +272,117 @@
|
||||||
<div id="announcement">{{ i18n_config.announcement|safe }}</div>
|
<div id="announcement">{{ i18n_config.announcement|safe }}</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% block bodyend %}{% endblock %}
|
{% if not INLINE_JQUERY %}
|
||||||
|
<script src="{{ JQUERY_JS }}"></script>
|
||||||
|
{% endif %}
|
||||||
|
<script src="https://unpkg.com/@popperjs/core@2"></script>
|
||||||
|
{% compress js %}
|
||||||
|
<script>{{ inlinei18n(LANGUAGE_CODE)|safe }}</script>
|
||||||
|
{% if INLINE_JQUERY %}
|
||||||
|
<script src="{{ static('libs/jquery-3.4.1.min.js') }}"></script>
|
||||||
|
{% endif %}
|
||||||
|
<script src="{{ static('libs/jquery-cookie.js') }}"></script>
|
||||||
|
<script src="{{ static('libs/jquery-taphold.js') }}"></script>
|
||||||
|
<script src="{{ static('libs/jquery.unveil.js') }}"></script>
|
||||||
|
<script src="{{ static('libs/moment.js') }}"></script>
|
||||||
|
<script src="{{ static('libs/select2/select2.js') }}"></script>
|
||||||
|
<script src="{{ static('libs/clipboard/clipboard.js') }}"></script>
|
||||||
|
{% include "extra_js.html" %}
|
||||||
|
<script src="{{ static('common.js') }}"></script>
|
||||||
|
<script src="{{ static('libs/clipboard/tooltip.js') }}"></script>
|
||||||
|
<script>
|
||||||
|
moment.locale('{{ LANGUAGE_CODE }}');
|
||||||
|
$(function () {
|
||||||
|
$('img.unveil').unveil(200);
|
||||||
|
});
|
||||||
|
const loading_page = `{% include "loading-page.html" %}`;
|
||||||
|
</script>
|
||||||
|
{% endcompress %}
|
||||||
|
|
||||||
|
{% block js_media %}{% endblock %}
|
||||||
|
{% if request.in_contest %}
|
||||||
|
<script>$(function () {
|
||||||
|
if ($("#contest-time-remaining").length) {
|
||||||
|
count_down($("#contest-time-remaining"));
|
||||||
|
}
|
||||||
|
|
||||||
|
var selected = null,
|
||||||
|
x_pos = 0, y_pos = 0,
|
||||||
|
x_elem = 0, y_elem = 0;
|
||||||
|
|
||||||
|
$('#contest-info').mousedown(function () {
|
||||||
|
selected = $(this);
|
||||||
|
x_elem = x_pos - selected.offset().left;
|
||||||
|
y_elem = y_pos - (selected.offset().top - $(window).scrollTop());
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
|
if (localStorage.getItem("contest_timer_position")) {
|
||||||
|
data = localStorage.getItem("contest_timer_position").split(":");
|
||||||
|
$("#contest-info").css({
|
||||||
|
left: data[0],
|
||||||
|
top: data[1]
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
$("#contest-info").show();
|
||||||
|
|
||||||
|
$("#contest-info-toggle").on('click', function() {
|
||||||
|
$.post("{{url('contest_mode_ajax')}}", function() {
|
||||||
|
window.location.reload();
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|
||||||
|
$(document).mousemove(function (e) {
|
||||||
|
x_pos = e.screenX;
|
||||||
|
y_pos = e.screenY;
|
||||||
|
|
||||||
|
if (selected !== null) {
|
||||||
|
left_px = (x_pos - x_elem);
|
||||||
|
top_px = (y_pos - y_elem);
|
||||||
|
left_px = Math.max(Math.min(left_px, window.innerWidth), 0) / window.innerWidth * 100 + '%';
|
||||||
|
top_px = Math.max(Math.min(top_px, window.innerHeight), 0) / window.innerHeight * 100 + '%';
|
||||||
|
localStorage.setItem("contest_timer_position", left_px + ":" + top_px);
|
||||||
|
|
||||||
|
selected.css({
|
||||||
|
left: left_px,
|
||||||
|
top: top_px
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
$(document).mouseup(function () {
|
||||||
|
selected = null;
|
||||||
|
})
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% if request.user.is_authenticated %}
|
||||||
|
<script>
|
||||||
|
window.user = {
|
||||||
|
email: '{{ request.user.email|escapejs }}',
|
||||||
|
id: '{{ request.user.id|escapejs }}',
|
||||||
|
name: '{{ request.user.username|escapejs }}'
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
{% else %}
|
||||||
|
<script>window.user = {};</script>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% if misc_config.analytics %}
|
||||||
|
{{ misc_config.analytics|safe }}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{# Don't run userscript since it may be malicious #}
|
||||||
|
{% if request.user.is_authenticated and request.profile.user_script and not request.user.is_impersonate %}
|
||||||
|
<script type="text/javascript">{{ request.profile.user_script|safe }}</script>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
<div id="bodyend">
|
||||||
|
{% block bodyend %}{% endblock %}
|
||||||
|
</div>
|
||||||
|
|
||||||
{% block footer %}
|
{% block footer %}
|
||||||
<footer>
|
<footer>
|
||||||
<span id="footer-content">
|
<span id="footer-content">
|
||||||
|
|
|
@ -5,7 +5,10 @@
|
||||||
{% block title %} {{_('Chat Box')}} {% endblock %}
|
{% block title %} {{_('Chat Box')}} {% endblock %}
|
||||||
{% block js_media %}
|
{% block js_media %}
|
||||||
|
|
||||||
<script type="text/javascript" src="{{ static('mathjax3_config.js') }}"></script>
|
{% if REQUIRE_JAX %}
|
||||||
|
{% include "mathjax-load.html" %}
|
||||||
|
{% endif %}
|
||||||
|
{% include "comments/math.html" %}
|
||||||
<script type="text/javascript" src="{{ static('event.js') }}"></script>
|
<script type="text/javascript" src="{{ static('event.js') }}"></script>
|
||||||
<script type="module" src="https://unpkg.com/emoji-picker-element@1"></script>
|
<script type="module" src="https://unpkg.com/emoji-picker-element@1"></script>
|
||||||
{% compress js %}
|
{% compress js %}
|
||||||
|
|
|
@ -7,7 +7,3 @@
|
||||||
{% else %}
|
{% else %}
|
||||||
<center id="empty_msg">{{_('You are connect now. Say something to start the conversation.')}}</center>
|
<center id="empty_msg">{{_('You are connect now. Say something to start the conversation.')}}</center>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if REQUIRE_JAX %}
|
|
||||||
{% include "mathjax-load.html" %}
|
|
||||||
{% endif %}
|
|
||||||
{% include "comments/math.html" %}
|
|
|
@ -67,10 +67,13 @@
|
||||||
$('.middle-right-content').html(loading_page);
|
$('.middle-right-content').html(loading_page);
|
||||||
$.get(url, function (data) {
|
$.get(url, function (data) {
|
||||||
var reload_content = $(data).find('.middle-right-content');
|
var reload_content = $(data).find('.middle-right-content');
|
||||||
|
var bodyend_script = $(data).find('#bodyend');
|
||||||
if (reload_content.length) {
|
if (reload_content.length) {
|
||||||
window.history.pushState("", "", url);
|
window.history.pushState("", "", url);
|
||||||
$('html, body').animate({scrollTop: 0}, 'fast');
|
$('html, body').animate({scrollTop: 0}, 'fast');
|
||||||
$('.middle-right-content').html(reload_content.first().html());
|
$('.middle-right-content').html(reload_content.first().html());
|
||||||
|
$('#bodyend').html(bodyend_script.first().html());
|
||||||
|
$("#loading-bar").hide().css({ width: 0});
|
||||||
if (reload_content.hasClass("wrapper")) {
|
if (reload_content.hasClass("wrapper")) {
|
||||||
$('.middle-right-content').addClass("wrapper");
|
$('.middle-right-content').addClass("wrapper");
|
||||||
}
|
}
|
||||||
|
@ -83,7 +86,6 @@
|
||||||
activateBlogBoxOnClick();
|
activateBlogBoxOnClick();
|
||||||
$('.xdsoft_datetimepicker').hide();
|
$('.xdsoft_datetimepicker').hide();
|
||||||
registerNavigation();
|
registerNavigation();
|
||||||
$("#loading-bar").hide().css({ width: 0});
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
window.location.href = url;
|
window.location.href = url;
|
||||||
|
@ -129,7 +131,6 @@
|
||||||
{% block left_sidebar %}{% endblock %}
|
{% block left_sidebar %}{% endblock %}
|
||||||
<div class="middle-right-content {{'wrapper' if is_two_column}}">
|
<div class="middle-right-content {{'wrapper' if is_two_column}}">
|
||||||
{% block three_col_media %}{% endblock %}
|
{% block three_col_media %}{% endblock %}
|
||||||
{% block three_col_js %}{% endblock %}
|
|
||||||
<div class="middle-content">
|
<div class="middle-content">
|
||||||
{% block middle_title %}{% endblock %}
|
{% block middle_title %}{% endblock %}
|
||||||
{% block middle_content %}{% endblock %}
|
{% block middle_content %}{% endblock %}
|
||||||
|
@ -146,4 +147,5 @@
|
||||||
{% include "mathjax-load.html" %}
|
{% include "mathjax-load.html" %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% include "comments/math.html" %}
|
{% include "comments/math.html" %}
|
||||||
|
{% block three_col_js %}{% endblock %}
|
||||||
{% endblock %}
|
{% endblock %}
|
Loading…
Reference in a new issue