Refactor 3-col-content
This commit is contained in:
parent
326b3d5dd3
commit
a711fb9768
37 changed files with 453 additions and 384 deletions
|
@ -66,7 +66,7 @@ class AceWidget(forms.Textarea):
|
||||||
if self.toolbar:
|
if self.toolbar:
|
||||||
toolbar = (
|
toolbar = (
|
||||||
'<div style="width: {}" class="django-ace-toolbar">'
|
'<div style="width: {}" class="django-ace-toolbar">'
|
||||||
'<a href="./" class="django-ace-max_min"></a>'
|
'<a href="#" class="django-ace-max_min"></a>'
|
||||||
"</div>"
|
"</div>"
|
||||||
).format(self.width)
|
).format(self.width)
|
||||||
html = toolbar + html
|
html = toolbar + html
|
||||||
|
|
|
@ -671,21 +671,13 @@ class OrganizationRequestBaseView(
|
||||||
LoginRequiredMixin,
|
LoginRequiredMixin,
|
||||||
SingleObjectTemplateResponseMixin,
|
SingleObjectTemplateResponseMixin,
|
||||||
SingleObjectMixin,
|
SingleObjectMixin,
|
||||||
|
AdminOrganizationMixin,
|
||||||
):
|
):
|
||||||
model = Organization
|
model = Organization
|
||||||
slug_field = "key"
|
slug_field = "key"
|
||||||
slug_url_kwarg = "key"
|
slug_url_kwarg = "key"
|
||||||
tab = None
|
tab = None
|
||||||
|
|
||||||
def get_object(self, queryset=None):
|
|
||||||
organization = super(OrganizationRequestBaseView, self).get_object(queryset)
|
|
||||||
if not (
|
|
||||||
organization.admins.filter(id=self.request.profile.id).exists()
|
|
||||||
or organization.registrant_id == self.request.profile.id
|
|
||||||
):
|
|
||||||
raise PermissionDenied()
|
|
||||||
return organization
|
|
||||||
|
|
||||||
def get_content_title(self):
|
def get_content_title(self):
|
||||||
return _("Manage join requests")
|
return _("Manage join requests")
|
||||||
|
|
||||||
|
|
|
@ -426,6 +426,192 @@ function submitFormWithParams($form, method) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function saveCurrentPageToSessionStorage() {
|
||||||
|
const storageLimit = 5;
|
||||||
|
const sessionStorageKey = 'oj-content-keys';
|
||||||
|
|
||||||
|
let key = `oj-content-${window.location.href}`;
|
||||||
|
let $contentClone = $('body').clone();
|
||||||
|
$contentClone.find('.select2').remove();
|
||||||
|
$contentClone.find('.select2-hidden-accessible').removeClass('select2-hidden-accessible');
|
||||||
|
$contentClone.find('.noUi-base').remove();
|
||||||
|
$contentClone.find('.wmd-button-row').remove();
|
||||||
|
|
||||||
|
let contentData = JSON.stringify({
|
||||||
|
"html": $contentClone.html(),
|
||||||
|
"page": window.page,
|
||||||
|
"has_next_page": window.has_next_page,
|
||||||
|
"scrollOffset": $(window).scrollTop(),
|
||||||
|
});
|
||||||
|
|
||||||
|
let keys = JSON.parse(sessionStorage.getItem(sessionStorageKey)) || [];
|
||||||
|
|
||||||
|
// Remove the existing key if it exists
|
||||||
|
if (keys.includes(key)) {
|
||||||
|
keys = keys.filter(k => k !== key);
|
||||||
|
}
|
||||||
|
|
||||||
|
keys.push(key);
|
||||||
|
|
||||||
|
if (keys.length > storageLimit) {
|
||||||
|
let oldestKey = keys.shift();
|
||||||
|
sessionStorage.removeItem(oldestKey);
|
||||||
|
}
|
||||||
|
|
||||||
|
sessionStorage.setItem(sessionStorageKey, JSON.stringify(keys));
|
||||||
|
sessionStorage.setItem(key, contentData);
|
||||||
|
}
|
||||||
|
|
||||||
|
function loadPageFromSessionStorage() {
|
||||||
|
let key = `oj-content-${window.location.href}`;
|
||||||
|
let content = sessionStorage.getItem(key);
|
||||||
|
if (content) {
|
||||||
|
content = JSON.parse(content);
|
||||||
|
$('body').html(content.html);
|
||||||
|
onWindowReady();
|
||||||
|
window.PAGE_FROM_BACK_BUTTON_CACHE = true;
|
||||||
|
setTimeout(() => {
|
||||||
|
$(window).scrollTop(content.scrollOffset - 50);
|
||||||
|
}, 1);
|
||||||
|
window.page = content.page;
|
||||||
|
window.has_next_page = content.has_next_page;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let currentRequest = null; // Variable to keep track of the current request
|
||||||
|
|
||||||
|
function navigateTo(url, reload_container, force_new_page=false) {
|
||||||
|
if (url === '#') return;
|
||||||
|
if (force_new_page) {
|
||||||
|
window.location.href = url;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!reload_container || !$(reload_container).length) {
|
||||||
|
reload_container = "#content";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (currentRequest) {
|
||||||
|
currentRequest.abort();
|
||||||
|
}
|
||||||
|
|
||||||
|
const controller = new AbortController();
|
||||||
|
const signal = controller.signal;
|
||||||
|
currentRequest = controller;
|
||||||
|
|
||||||
|
$(window).off("scroll");
|
||||||
|
|
||||||
|
saveCurrentPageToSessionStorage();
|
||||||
|
replaceLoadingPage(reload_container);
|
||||||
|
|
||||||
|
const toUpdateElements = [
|
||||||
|
"#nav-container",
|
||||||
|
"#js_media",
|
||||||
|
"#media",
|
||||||
|
".left-sidebar",
|
||||||
|
"#bodyend",
|
||||||
|
];
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
url: url,
|
||||||
|
method: 'GET',
|
||||||
|
dataType: 'html',
|
||||||
|
signal: signal,
|
||||||
|
success: function (data) {
|
||||||
|
let reload_content = $(data).find(reload_container).first();
|
||||||
|
if (!reload_content.length) {
|
||||||
|
reload_container = "#content";
|
||||||
|
reload_content = $(data).find(reload_container).first();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (reload_content.length) {
|
||||||
|
window.history.pushState("", "", url);
|
||||||
|
$(window).scrollTop(0);
|
||||||
|
$("#loading-bar").stop(true, true);
|
||||||
|
$("#loading-bar").hide().css({ width: 0});
|
||||||
|
|
||||||
|
for (let elem of toUpdateElements) {
|
||||||
|
$(elem).replaceWith($(data).find(elem).first());
|
||||||
|
}
|
||||||
|
|
||||||
|
$(reload_container).replaceWith(reload_content);
|
||||||
|
|
||||||
|
$(document).prop('title', $(data).filter('title').text());
|
||||||
|
renderKatex($(reload_container)[0]);
|
||||||
|
onWindowReady();
|
||||||
|
$('.xdsoft_datetimepicker').hide();
|
||||||
|
} else {
|
||||||
|
window.location.href = url;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
error: function (xhr, status, error) {
|
||||||
|
if (status !== 'abort') { // Ignore aborted requests
|
||||||
|
window.location.href = url;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function isEligibleLinkToRegister($e) {
|
||||||
|
if ($e.attr('target') === '_blank') {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if ($e.data('initialized_navigation')) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
const href = $e.attr('href');
|
||||||
|
if (!href) return false;
|
||||||
|
return (
|
||||||
|
href.startsWith('http')
|
||||||
|
|| href.startsWith('/')
|
||||||
|
|| href.startsWith('#')
|
||||||
|
|| href.startsWith('?')
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
function replaceLoadingPage(reload_container) {
|
||||||
|
const loadingPage = `
|
||||||
|
<div style="height: 80vh; margin: 0; display: flex; align-items: center; justify-content: center; width: 100%; font-size: xx-large;">
|
||||||
|
<i class="fa fa-spinner fa-pulse"></i>
|
||||||
|
</div>
|
||||||
|
`;
|
||||||
|
$(reload_container).fadeOut(100, function() {
|
||||||
|
$(this).html(loadingPage).fadeIn(100);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function registerNavigation() {
|
||||||
|
const containerMap = {
|
||||||
|
'.left-sidebar-item': '.middle-right-content',
|
||||||
|
'.pagination li a': '.middle-content',
|
||||||
|
'.tabs li a': '.middle-content',
|
||||||
|
'#control-panel a': '.middle-content',
|
||||||
|
};
|
||||||
|
|
||||||
|
$.each(containerMap, function(selector, target) {
|
||||||
|
$(selector).each(function() {
|
||||||
|
const href = $(this).attr('href');
|
||||||
|
const force_new_page = $(this).data('force_new_page');
|
||||||
|
|
||||||
|
if (isEligibleLinkToRegister($(this))) {
|
||||||
|
$(this).data('initialized_navigation', true);
|
||||||
|
|
||||||
|
$(this).on('click', function(e) {
|
||||||
|
e.preventDefault();
|
||||||
|
let containerSelector = null;
|
||||||
|
for (let key in containerMap) {
|
||||||
|
if ($(this).is(key)) {
|
||||||
|
containerSelector = containerMap[key];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
navigateTo(href, containerSelector, force_new_page);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function onWindowReady() {
|
function onWindowReady() {
|
||||||
// http://stackoverflow.com/a/1060034/1090657
|
// http://stackoverflow.com/a/1060034/1090657
|
||||||
var hidden = 'hidden';
|
var hidden = 'hidden';
|
||||||
|
@ -537,12 +723,13 @@ function onWindowReady() {
|
||||||
});
|
});
|
||||||
register_all_toggles();
|
register_all_toggles();
|
||||||
activateBlogBoxOnClick();
|
activateBlogBoxOnClick();
|
||||||
|
registerNavigation();
|
||||||
|
registerPopper($('#nav-lang-icon'), $('#lang-dropdown'));
|
||||||
|
registerPopper($('#user-links'), $('#userlink_dropdown'));
|
||||||
}
|
}
|
||||||
|
|
||||||
$(function() {
|
$(function() {
|
||||||
onWindowReady();
|
onWindowReady();
|
||||||
registerPopper($('#nav-lang-icon'), $('#lang-dropdown'));
|
|
||||||
registerPopper($('#user-links'), $('#userlink_dropdown'));
|
|
||||||
var $nav_list = $('#nav-list');
|
var $nav_list = $('#nav-list');
|
||||||
$('#navicon').click(function (event) {
|
$('#navicon').click(function (event) {
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
|
@ -582,33 +769,15 @@ $(function() {
|
||||||
$nav_list.hide();
|
$nav_list.hide();
|
||||||
});
|
});
|
||||||
|
|
||||||
$(window).on('beforeunload', function() {
|
$(window).on('beforeunload', saveCurrentPageToSessionStorage);
|
||||||
let key = `oj-content-${window.location.href}`;
|
|
||||||
let $contentClone = $('#content').clone();
|
|
||||||
$contentClone.find('.select2').remove();
|
|
||||||
$contentClone.find('.select2-hidden-accessible').removeClass('select2-hidden-accessible');
|
|
||||||
$contentClone.find('.noUi-base').remove();
|
|
||||||
$contentClone.find('.wmd-button-row').remove();
|
|
||||||
sessionStorage.setItem(key, JSON.stringify({
|
|
||||||
"html": $contentClone.html(),
|
|
||||||
"page": window.page,
|
|
||||||
"has_next_page": window.has_next_page,
|
|
||||||
"scrollOffset": $(window).scrollTop(),
|
|
||||||
}));
|
|
||||||
});
|
|
||||||
if (window.performance &&
|
if (window.performance &&
|
||||||
window.performance.navigation.type
|
window.performance.navigation.type
|
||||||
=== window.performance.navigation.TYPE_BACK_FORWARD) {
|
=== window.performance.navigation.TYPE_BACK_FORWARD) {
|
||||||
let key = `oj-content-${window.location.href}`;
|
loadPageFromSessionStorage();
|
||||||
let content = sessionStorage.getItem(key);
|
|
||||||
if (content) {
|
|
||||||
content = JSON.parse(content);
|
|
||||||
$('#content').html(content.html);
|
|
||||||
onWindowReady();
|
|
||||||
window.PAGE_FROM_BACK_BUTTON_CACHE = true;
|
|
||||||
$(window).scrollTop(content.scrollOffset - 100);
|
|
||||||
window.page = content.page;
|
|
||||||
window.has_next_page = content.has_next_page;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
window.addEventListener('popstate', (e) => {
|
||||||
|
window.location.href = e.currentTarget.location.href;
|
||||||
|
});
|
||||||
});
|
});
|
File diff suppressed because one or more lines are too long
|
@ -67,7 +67,7 @@
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% block media %}{% endblock %}
|
|
||||||
{% if use_darkmode %}
|
{% if use_darkmode %}
|
||||||
<link rel="stylesheet" href="{{ static('darkmode.css') }}">
|
<link rel="stylesheet" href="{{ static('darkmode.css') }}">
|
||||||
<link rel="stylesheet" href="{{ static('darkmode-svg.css') }}">
|
<link rel="stylesheet" href="{{ static('darkmode-svg.css') }}">
|
||||||
|
@ -210,7 +210,7 @@
|
||||||
<div class="dropdown-item"><i class="fa fa-gear"></i> {{ _('Settings') }}</div>
|
<div class="dropdown-item"><i class="fa fa-gear"></i> {{ _('Settings') }}</div>
|
||||||
</a>
|
</a>
|
||||||
{% if request.user.is_impersonate %}
|
{% if request.user.is_impersonate %}
|
||||||
<a href="{{ url('impersonate-stop') }}">
|
<a href="{{ url('impersonate-stop') }}" data-force_new_page="1">
|
||||||
<div class="dropdown-item"><i class="fa fa-eye"></i> {{_('Stop impersonating')}}</div>
|
<div class="dropdown-item"><i class="fa fa-eye"></i> {{_('Stop impersonating')}}</div>
|
||||||
</a>
|
</a>
|
||||||
{% else %}
|
{% else %}
|
||||||
|
@ -261,6 +261,9 @@
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<div id="page-container">
|
<div id="page-container">
|
||||||
|
<div id="media">
|
||||||
|
{% block media %}{% endblock %}
|
||||||
|
</div>
|
||||||
<noscript>
|
<noscript>
|
||||||
<div id="noscript">{{ _('This site works best with JavaScript enabled.') }}</div>
|
<div id="noscript">{{ _('This site works best with JavaScript enabled.') }}</div>
|
||||||
</noscript>
|
</noscript>
|
||||||
|
@ -303,8 +306,9 @@
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
{% endcompress %}
|
{% endcompress %}
|
||||||
|
<div id="js_media">
|
||||||
{% block js_media %}{% endblock %}
|
{% block js_media %}{% endblock %}
|
||||||
|
</div>
|
||||||
{% if request.in_contest %}
|
{% if request.in_contest %}
|
||||||
<script>$(function () {
|
<script>$(function () {
|
||||||
if ($("#contest-time-remaining").length) {
|
if ($("#contest-time-remaining").length) {
|
||||||
|
@ -379,10 +383,9 @@
|
||||||
{{ misc_config.analytics|safe }}
|
{{ misc_config.analytics|safe }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
<div id="extra_js">
|
<div id="bodyend">
|
||||||
{% block extra_js %}{% endblock %}
|
|
||||||
</div>
|
|
||||||
{% block bodyend %}{% endblock %}
|
{% block bodyend %}{% endblock %}
|
||||||
|
</div>
|
||||||
<script src="{{ static('katex_config.js') }}"></script>
|
<script src="{{ static('katex_config.js') }}"></script>
|
||||||
{% include "katex-load.html" %}
|
{% include "katex-load.html" %}
|
||||||
{% block footer %}
|
{% block footer %}
|
||||||
|
|
|
@ -46,8 +46,3 @@
|
||||||
<hr style="width: 60%; margin:4em auto;">
|
<hr style="width: 60%; margin:4em auto;">
|
||||||
{% include "comments/list.html" %}
|
{% include "comments/list.html" %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block bodyend %}
|
|
||||||
{{ super() }}
|
|
||||||
{% include "comments/math.html" %}
|
|
||||||
{% endblock %}
|
|
|
@ -19,7 +19,7 @@
|
||||||
</style>
|
</style>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block three_col_js %}
|
{% block js_media %}
|
||||||
{% include "actionbar/media-js.html" %}
|
{% include "actionbar/media-js.html" %}
|
||||||
{% include "feed/feed_js.html" %}
|
{% include "feed/feed_js.html" %}
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
|
|
@ -4,8 +4,6 @@
|
||||||
{% block title_ruler %}{% endblock %}
|
{% block title_ruler %}{% endblock %}
|
||||||
{% block title %} {{_('Chat Box')}} {% endblock %}
|
{% block title %} {{_('Chat Box')}} {% endblock %}
|
||||||
{% block js_media %}
|
{% block js_media %}
|
||||||
|
|
||||||
{% 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 %}
|
||||||
|
@ -41,11 +39,12 @@
|
||||||
|
|
||||||
return receiver;
|
return receiver;
|
||||||
}
|
}
|
||||||
let message_template = `
|
function message_template() {
|
||||||
|
return`
|
||||||
{% with message=message_template %}
|
{% with message=message_template %}
|
||||||
{% include "chat/message.html" %}
|
{% include "chat/message.html" %}
|
||||||
{% endwith %}
|
{% endwith %}
|
||||||
`;
|
`};
|
||||||
$(function() {
|
$(function() {
|
||||||
load_dynamic_update({{last_msg}});
|
load_dynamic_update({{last_msg}});
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
let isMobile = window.matchMedia("only screen and (max-width: 799px)").matches;
|
function isMobile() {
|
||||||
|
return window.matchMedia("only screen and (max-width: 799px)").matches;
|
||||||
|
}
|
||||||
|
|
||||||
function load_next_page(last_id, refresh_html=false) {
|
function load_next_page(last_id, refresh_html=false) {
|
||||||
if (refresh_html) {
|
if (refresh_html) {
|
||||||
|
@ -218,7 +220,7 @@
|
||||||
if (window.room_id) {
|
if (window.room_id) {
|
||||||
$("#last_msg-" + window.room_id).html(body);
|
$("#last_msg-" + window.room_id).html(body);
|
||||||
}
|
}
|
||||||
var html = message_template;
|
var html = message_template();
|
||||||
html = html.replaceAll('$body', body).replaceAll('$id', tmp_id);
|
html = html.replaceAll('$body', body).replaceAll('$id', tmp_id);
|
||||||
var $html = $(html);
|
var $html = $(html);
|
||||||
$html.find('.time-with-rel').attr('data-iso', (new Date()).toISOString());
|
$html.find('.time-with-rel').attr('data-iso', (new Date()).toISOString());
|
||||||
|
@ -288,7 +290,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
function show_right_panel() {
|
function show_right_panel() {
|
||||||
if (isMobile) {
|
if (isMobile()) {
|
||||||
$('.chat-left-panel').hide();
|
$('.chat-left-panel').hide();
|
||||||
$('#chat-area').css('display', 'flex');
|
$('#chat-area').css('display', 'flex');
|
||||||
$('#chat-box').scrollTop($('#chat-box')[0].scrollHeight);
|
$('#chat-box').scrollTop($('#chat-box')[0].scrollHeight);
|
||||||
|
@ -296,7 +298,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
function hide_right_panel() {
|
function hide_right_panel() {
|
||||||
if (isMobile) {
|
if (isMobile()) {
|
||||||
$('.chat-left-panel').show();
|
$('.chat-left-panel').show();
|
||||||
$('#chat-area').hide();
|
$('#chat-area').hide();
|
||||||
}
|
}
|
||||||
|
@ -479,7 +481,7 @@
|
||||||
const button = document.querySelector('#emoji-button');
|
const button = document.querySelector('#emoji-button');
|
||||||
const tooltip = document.querySelector('.tooltip');
|
const tooltip = document.querySelector('.tooltip');
|
||||||
const popper = Popper.createPopper(button, tooltip, {
|
const popper = Popper.createPopper(button, tooltip, {
|
||||||
placement: isMobile ? 'auto-end' : 'left',
|
placement: isMobile() ? 'auto-end' : 'left',
|
||||||
});
|
});
|
||||||
|
|
||||||
function toggleEmoji() {
|
function toggleEmoji() {
|
||||||
|
|
|
@ -1,3 +0,0 @@
|
||||||
{% compress js, inline %}
|
|
||||||
<script src="{{ static('pagedown_math.js') }}"></script>
|
|
||||||
{% endcompress %}
|
|
|
@ -10,7 +10,7 @@
|
||||||
{% include "contest/contest-tabs.html" %}
|
{% include "contest/contest-tabs.html" %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block two_col_js %}
|
{% block js_media %}
|
||||||
{% include "contest/media-js.html" %}
|
{% include "contest/media-js.html" %}
|
||||||
{% include "comments/media-js.html" %}
|
{% include "comments/media-js.html" %}
|
||||||
{% include "actionbar/media-js.html" %}
|
{% include "actionbar/media-js.html" %}
|
||||||
|
|
|
@ -31,13 +31,14 @@
|
||||||
{% block contest_list_media %}{% endblock %}
|
{% block contest_list_media %}{% endblock %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block three_col_js %}
|
{% block js_media %}
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
$(document).ready(function () {
|
$(document).ready(function () {
|
||||||
$('#active-url').attr('href', changeTabParameter('active'));
|
$('#active-url').attr('href', changeTabParameter('active'));
|
||||||
$('#current-url').attr('href', changeTabParameter('current'));
|
$('#current-url').attr('href', changeTabParameter('current'));
|
||||||
$('#future-url').attr('href', changeTabParameter('future'));
|
$('#future-url').attr('href', changeTabParameter('future'));
|
||||||
$('#past-url').attr('href', changeTabParameter('past'));
|
$('#past-url').attr('href', changeTabParameter('past'));
|
||||||
|
registerNavigation();
|
||||||
|
|
||||||
var $form = $('form#filter-form');
|
var $form = $('form#filter-form');
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
</style>
|
</style>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block two_col_js %}
|
{% block js_media %}
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
$(function () {
|
$(function () {
|
||||||
$('.contest-moss').click(function () {
|
$('.contest-moss').click(function () {
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
{% include "contest/contest-tabs.html" %}
|
{% include "contest/contest-tabs.html" %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block two_col_js %}
|
{% block js_media %}
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
window.stats = {{ stats }};
|
window.stats = {{ stats }};
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
</style>
|
</style>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block two_col_js %}
|
{% block js_media %}
|
||||||
{{ form.media.js }}
|
{{ form.media.js }}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
</style>
|
</style>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block two_col_js %}
|
{% block js_media %}
|
||||||
<script>
|
<script>
|
||||||
$(document).ready(function(){
|
$(document).ready(function(){
|
||||||
var $searchInput = $("#search-input");
|
var $searchInput = $("#search-input");
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
</style>
|
</style>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block three_col_js %}
|
{% block js_media %}
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
$(function () {
|
$(function () {
|
||||||
$('.vote-detail').each(function() {
|
$('.vote-detail').each(function() {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{% extends "two-column-content.html" %}
|
{% extends "two-column-content.html" %}
|
||||||
|
|
||||||
{% block two_col_js %}
|
{% block js_media %}
|
||||||
{{ form.media.js }}
|
{{ form.media.js }}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{% extends "organization/home-base.html" %}
|
{% extends "organization/home-base.html" %}
|
||||||
|
|
||||||
{% block three_col_js %}
|
{% block js_media %}
|
||||||
{{ form.media.js }}
|
{{ form.media.js }}
|
||||||
{% include "organization/home-js.html" %}
|
{% include "organization/home-js.html" %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{% extends "organization/home-base.html" %}
|
{% extends "organization/home-base.html" %}
|
||||||
|
|
||||||
{% block three_col_js %}
|
{% block js_media %}
|
||||||
{{ form.media.js }}
|
{{ form.media.js }}
|
||||||
{% include "organization/home-js.html" %}
|
{% include "organization/home-js.html" %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{% extends "organization/home-base.html" %}
|
{% extends "organization/home-base.html" %}
|
||||||
|
|
||||||
{% block three_col_js %}
|
{% block js_media %}
|
||||||
{{ form.media.js }}
|
{{ form.media.js }}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{% extends "organization/home-base.html" %}
|
{% extends "organization/home-base.html" %}
|
||||||
|
|
||||||
{% block three_col_js %}
|
{% block js_media %}
|
||||||
{{ form.media.js }}
|
{{ form.media.js }}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{% extends "three-column-content.html" %}
|
{% extends "three-column-content.html" %}
|
||||||
|
|
||||||
{% block three_col_js %}
|
{% block js_media %}
|
||||||
{% include "organization/home-js.html" %}
|
{% include "organization/home-js.html" %}
|
||||||
{% block org_js %}{% endblock %}
|
{% block org_js %}{% endblock %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
|
@ -1,8 +1,5 @@
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
$(function () {
|
function confirmLeaveOrganization() {
|
||||||
$('.time-remaining').each(function () {
|
|
||||||
count_down($(this));
|
|
||||||
});
|
|
||||||
$('.leave-organization').click(function () {
|
$('.leave-organization').click(function () {
|
||||||
if (confirm('{{ _('Are you sure you want to leave this organization?') }}\n' +
|
if (confirm('{{ _('Are you sure you want to leave this organization?') }}\n' +
|
||||||
{% if organization.is_open %}
|
{% if organization.is_open %}
|
||||||
|
@ -14,5 +11,10 @@
|
||||||
$(this).parent().submit();
|
$(this).parent().submit();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
$(function () {
|
||||||
|
$('.time-remaining').each(function () {
|
||||||
|
count_down($(this));
|
||||||
|
});
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
|
@ -1,11 +1,12 @@
|
||||||
{% extends "three-column-content.html" %}
|
{% extends "three-column-content.html" %}
|
||||||
|
|
||||||
{% block three_col_js %}
|
{% block js_media %}
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
$(document).ready(function () {
|
$(document).ready(function () {
|
||||||
$('#mine-tab').attr('href', changeTabParameter('mine'));
|
$('#mine-tab').attr('href', changeTabParameter('mine'));
|
||||||
$('#public-tab').attr('href', changeTabParameter('public'));
|
$('#public-tab').attr('href', changeTabParameter('public'));
|
||||||
$('#private-tab').attr('href', changeTabParameter('private'));
|
$('#private-tab').attr('href', changeTabParameter('private'));
|
||||||
|
registerNavigation();
|
||||||
|
|
||||||
var $form = $('form#filter-form');
|
var $form = $('form#filter-form');
|
||||||
|
|
||||||
|
|
|
@ -58,7 +58,7 @@
|
||||||
<div class="link-row" style="color: red;">
|
<div class="link-row" style="color: red;">
|
||||||
<form method="post" action="{{ url('leave_organization', organization.id, organization.slug) }}">
|
<form method="post" action="{{ url('leave_organization', organization.id, organization.slug) }}">
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
<a href="#" class="leave-organization">
|
<a href="#" class="leave-organization" onclick="confirmLeaveOrganization()">
|
||||||
<i class="fa fa-sign-out-alt"></i>{{ _('Leave group') }}</a>
|
<i class="fa fa-sign-out-alt"></i>{{ _('Leave group') }}</a>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -36,7 +36,3 @@
|
||||||
<br>
|
<br>
|
||||||
{% include "comments/list.html" %}
|
{% include "comments/list.html" %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block bodyend %}
|
|
||||||
{% include "comments/math.html" %}
|
|
||||||
{% endblock %}
|
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
</div>
|
</div>
|
||||||
{% if request.user.has_perm('judge.suggest_problem_changes') and feed_type == 'volunteer' %}
|
{% if request.user.has_perm('judge.suggest_problem_changes') and feed_type == 'volunteer' %}
|
||||||
<ul style="margin-bottom: 1em; margin-left: auto">
|
<ul style="margin-bottom: 1em; margin-left: auto">
|
||||||
<li><a href="{{url('admin:judge_volunteerproblemvote_changelist')}}">{{_('View your votes')}}</a></li>
|
<li><a href="{{url('admin:judge_volunteerproblemvote_changelist')}}" target="_blank">{{_('View your votes')}}</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% include "problem/feed/items.html" %}
|
{% include "problem/feed/items.html" %}
|
||||||
|
|
|
@ -47,7 +47,7 @@
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block three_col_js %}
|
{% block js_media %}
|
||||||
{% include "actionbar/media-js.html" %}
|
{% include "actionbar/media-js.html" %}
|
||||||
{% block problem_list_js %}{% endblock %}
|
{% block problem_list_js %}{% endblock %}
|
||||||
<script>
|
<script>
|
||||||
|
|
|
@ -467,8 +467,3 @@
|
||||||
{% include "problem/related_problems.html" %}
|
{% include "problem/related_problems.html" %}
|
||||||
<iframe name="raw_problem" id="raw_problem"></iframe>
|
<iframe name="raw_problem" id="raw_problem"></iframe>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block bodyend %}
|
|
||||||
{{ super() }}
|
|
||||||
{% include "comments/math.html" %}
|
|
||||||
{% endblock %}
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
{% set has_hidden_subtasks = request.in_contest_mode and request.participation.contest.format.has_hidden_subtasks %}
|
{% set has_hidden_subtasks = request.in_contest_mode and request.participation.contest.format.has_hidden_subtasks %}
|
||||||
|
|
||||||
{% block three_col_js %}
|
{% block js_media %}
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
{% if dynamic_update and last_msg %}
|
{% if dynamic_update and last_msg %}
|
||||||
{% if request.in_contest_mode %}
|
{% if request.in_contest_mode %}
|
||||||
|
@ -91,6 +91,7 @@
|
||||||
|
|
||||||
// Draw the statistics graph.
|
// Draw the statistics graph.
|
||||||
{% if results_json %}
|
{% if results_json %}
|
||||||
|
$(function () {
|
||||||
var chart = null;
|
var chart = null;
|
||||||
function stats_graph(raw_data) {
|
function stats_graph(raw_data) {
|
||||||
var colors = {{ results_colors_json }};
|
var colors = {{ results_colors_json }};
|
||||||
|
@ -130,12 +131,15 @@
|
||||||
|
|
||||||
$('#total-submission-count').text(raw_data.total);
|
$('#total-submission-count').text(raw_data.total);
|
||||||
}
|
}
|
||||||
|
|
||||||
$(function () {
|
|
||||||
stats_graph(window.results_json);
|
stats_graph(window.results_json);
|
||||||
});
|
});
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
</script>
|
||||||
|
{% endcompress %}
|
||||||
|
|
||||||
|
{% if dynamic_update and last_msg and not has_hidden_subtasks %}
|
||||||
|
<script type="text/javascript">
|
||||||
|
$(function () {
|
||||||
function load_dynamic_update(last_msg) {
|
function load_dynamic_update(last_msg) {
|
||||||
var _collect = function (e) {
|
var _collect = function (e) {
|
||||||
return e.value;
|
return e.value;
|
||||||
|
@ -242,19 +246,9 @@
|
||||||
console.log('Navigated away');
|
console.log('Navigated away');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
console.log('You probably should refresh?');
|
|
||||||
// $('.ws-closed').show().find('a').click(function () {
|
|
||||||
// window.location.reload();
|
|
||||||
// });
|
|
||||||
};
|
};
|
||||||
return receiver;
|
return receiver;
|
||||||
}
|
}
|
||||||
</script>
|
|
||||||
{% endcompress %}
|
|
||||||
|
|
||||||
{% if dynamic_update and last_msg and not has_hidden_subtasks %}
|
|
||||||
<script type="text/javascript">
|
|
||||||
$(function () {
|
|
||||||
load_dynamic_update({{last_msg}});
|
load_dynamic_update({{last_msg}});
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{% macro make_tab(name, fa, url, text) %}
|
{% macro make_tab(name, fa, url, text, force_new_page=False) %}
|
||||||
<li class="tab{% if tab == name %} active{% endif %}">
|
<li class="tab{% if tab == name %} active{% endif %}">
|
||||||
{%- if url %}<a href="{{ url }}">{% else %}<span>{% endif -%}
|
{%- if url %}<a href="{{ url }}" {% if force_new_page%}data-force_new_page="1"{% endif %}>{% else %}<span>{% endif -%}
|
||||||
<i class="tab-icon fa {{ fa }}"></i> {{ text }}
|
<i class="tab-icon fa {{ fa }}"></i> {{ text }}
|
||||||
{%- if url %}</a>{% else %}</span>{% endif -%}
|
{%- if url %}</a>{% else %}</span>{% endif -%}
|
||||||
</li>
|
</li>
|
||||||
|
|
|
@ -26,86 +26,6 @@
|
||||||
</style>
|
</style>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block js_media %}
|
|
||||||
<script type="text/javascript">
|
|
||||||
let loadingPage;
|
|
||||||
|
|
||||||
function navigateTo($elem, update_sidebar = false) {
|
|
||||||
var url = $elem.attr('href');
|
|
||||||
var force_new_page = $elem.data('force_new_page');
|
|
||||||
|
|
||||||
if (url === '#') return;
|
|
||||||
|
|
||||||
if (force_new_page) {
|
|
||||||
window.location.href = url;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (update_sidebar) {
|
|
||||||
$('.left-sidebar-item').removeClass('active');
|
|
||||||
$elem.addClass('active');
|
|
||||||
}
|
|
||||||
$(window).off("scroll");
|
|
||||||
$('.middle-right-content').html(loadingPage);
|
|
||||||
$.get(url, function (data) {
|
|
||||||
var reload_content = $(data).find('.middle-right-content');
|
|
||||||
var bodyend_script = $(data).find('#extra_js');
|
|
||||||
if (reload_content.length) {
|
|
||||||
window.history.pushState("", "", url);
|
|
||||||
$('html, body').animate({scrollTop: 0}, 'fast');
|
|
||||||
$('.middle-right-content').html(reload_content.first().html());
|
|
||||||
$('#extra_js').html(bodyend_script.first().html());
|
|
||||||
$("#loading-bar").stop(true, true);
|
|
||||||
$("#loading-bar").hide().css({ width: 0});
|
|
||||||
if (reload_content.hasClass("wrapper")) {
|
|
||||||
$('.middle-right-content').addClass("wrapper");
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$('.middle-right-content').removeClass("wrapper");
|
|
||||||
}
|
|
||||||
$(document).prop('title', $(data).filter('title').text());
|
|
||||||
renderKatex($('.middle-right-content')[0]);
|
|
||||||
onWindowReady();
|
|
||||||
$('.xdsoft_datetimepicker').hide();
|
|
||||||
registerNavigation();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
window.location.href = url;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function registerNavigation() {
|
|
||||||
const links = ['.pagination a', '.tabs li a', '#control-panel a'];
|
|
||||||
for (let linkSelector of links) {
|
|
||||||
$(linkSelector).each(function() {
|
|
||||||
if ($(this).attr('target') !== '_blank') {
|
|
||||||
$(this).on('click', function(e) {
|
|
||||||
e.preventDefault();
|
|
||||||
navigateTo($(this));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$(function () {
|
|
||||||
window.addEventListener('popstate', (e) => {
|
|
||||||
window.location.href = e.currentTarget.location.href;
|
|
||||||
});
|
|
||||||
|
|
||||||
$('.left-sidebar-item').on('click', function (e) {
|
|
||||||
e.preventDefault();
|
|
||||||
navigateTo($(this), true);
|
|
||||||
});
|
|
||||||
registerNavigation();
|
|
||||||
$.get("{{static('html/loading-page.html')}}", function(data) {
|
|
||||||
loadingPage = data;
|
|
||||||
});
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
{% endblock %}
|
|
||||||
|
|
||||||
{% macro make_tab_item(name, fa, url, text, force_new_page=False) %}
|
{% macro make_tab_item(name, fa, url, text, force_new_page=False) %}
|
||||||
<a class="left-sidebar-item {% if page_type == name %}active{% endif %}" href="{{ url }}" id="{{ name }}-tab" {% if force_new_page%}data-force_new_page="1"{% endif %}>
|
<a class="left-sidebar-item {% if page_type == name %}active{% endif %}" href="{{ url }}" id="{{ name }}-tab" {% if force_new_page%}data-force_new_page="1"{% endif %}>
|
||||||
<span class="sidebar-icon"><i class="{{ fa }}"></i></span>
|
<span class="sidebar-icon"><i class="{{ fa }}"></i></span>
|
||||||
|
@ -128,12 +48,3 @@
|
||||||
</div>
|
</div>
|
||||||
{% block after_posts %}{% endblock %}
|
{% block after_posts %}{% endblock %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block extra_js %}
|
|
||||||
{% block three_col_js %}{% endblock %}
|
|
||||||
{% endblock %}
|
|
||||||
|
|
||||||
{% block bodyend %}
|
|
||||||
{{ super() }}
|
|
||||||
{% include "comments/math.html" %}
|
|
||||||
{% endblock %}
|
|
|
@ -223,8 +223,3 @@
|
||||||
</aside>
|
</aside>
|
||||||
</div>
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block bodyend %}
|
|
||||||
{{ super() }}
|
|
||||||
{% include "comments/math.html" %}
|
|
||||||
{% endblock %}
|
|
||||||
|
|
|
@ -1,10 +1,6 @@
|
||||||
{% set is_two_column = true %}
|
{% set is_two_column = true %}
|
||||||
{% extends "three-column-content.html" %}
|
{% extends "three-column-content.html" %}
|
||||||
|
|
||||||
{% block three_col_js %}
|
|
||||||
{% block two_col_js %}{% endblock %}
|
|
||||||
{% endblock %}
|
|
||||||
|
|
||||||
{% block three_col_media %}
|
{% block three_col_media %}
|
||||||
<style>
|
<style>
|
||||||
@media (min-width: 800px) {
|
@media (min-width: 800px) {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{% extends "two-column-content.html" %}
|
{% extends "two-column-content.html" %}
|
||||||
|
|
||||||
{% block two_col_js %}
|
{% block js_media %}
|
||||||
{% block users_js_media %}{% endblock %}
|
{% block users_js_media %}{% endblock %}
|
||||||
{% include "user/base-users-js.html" %}
|
{% include "user/base-users-js.html" %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
|
@ -5,17 +5,17 @@
|
||||||
{{ make_tab('problems', 'fa-puzzle-piece', url('user_problems', user.user.username), _('Problems')) }}
|
{{ make_tab('problems', 'fa-puzzle-piece', url('user_problems', user.user.username), _('Problems')) }}
|
||||||
{{ make_tab('submissions', 'fa-code', url('all_user_submissions', user.username), _('Submissions')) }}
|
{{ make_tab('submissions', 'fa-code', url('all_user_submissions', user.username), _('Submissions')) }}
|
||||||
{% if request.user.is_superuser and user != request.profile and not user.user.is_superuser %}
|
{% if request.user.is_superuser and user != request.profile and not user.user.is_superuser %}
|
||||||
{{ make_tab('impersonate', 'fa-eye', url('impersonate-start', user.user.id), _('Impersonate')) }}
|
{{ make_tab('impersonate', 'fa-eye', url('impersonate-start', user.user.id), _('Impersonate'), force_new_page=True) }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if user == request.profile %}
|
{% if user == request.profile %}
|
||||||
{{ make_tab('bookmark', 'fa-bookmark', url('user_bookmark'), _('Bookmarks')) }}
|
{{ make_tab('bookmark', 'fa-bookmark', url('user_bookmark'), _('Bookmarks')) }}
|
||||||
{{ make_tab('edit', 'fa-edit', url('user_edit_profile'), _('Edit profile')) }}
|
{{ make_tab('edit', 'fa-gear', url('user_edit_profile'), _('Settings')) }}
|
||||||
{% else %}
|
{% else %}
|
||||||
{% if perms.auth.change_user %}
|
{% if perms.auth.change_user %}
|
||||||
{{ make_tab('edit', 'fa-edit', url('admin:auth_user_change', user.user.id), _('Admin User')) }}
|
{{ make_tab('edit', 'fa-edit', url('admin:auth_user_change', user.user.id), _('Admin User'), force_new_page=True) }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if perms.judge.change_profile %}
|
{% if perms.judge.change_profile %}
|
||||||
{{ make_tab('edit', 'fa-edit', url('admin:judge_profile_change', user.id), _('Admin Profile')) }}
|
{{ make_tab('edit', 'fa-edit', url('admin:judge_profile_change', user.id), _('Admin Profile'), force_new_page=True) }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
Loading…
Reference in a new issue