ui&core: pjax load problem content

This commit is contained in:
undefined committed 2022-03-19 16:30:49 +08:00
1 parent 29fbb08b4b
commit 985fcd18f5
7 files changed
+45 -23

No files matched your search

+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@hydrooj/ui-default",
"version": "4.34.15",
"version": "4.34.16",
"author": "undefined <i@undefined.moe>",
"license": "AGPL-3.0",
"main": "hydro.js",
@@ -4,6 +4,7 @@ import { NamedPage } from 'vj/misc/Page';
import { downloadProblemSet } from 'vj/components/zipDownloader';
import loadReactRedux from 'vj/utils/loadReactRedux';
import delay from 'vj/utils/delay';
import pjax from 'vj/utils/pjax';
class ProblemPageExtender {
constructor() {
@@ -266,6 +267,14 @@ const page = new NamedPage(['problem_detail', 'contest_detail_problem', 'homewor
ev.preventDefault();
});
$(document).on('click', '[data-lang]', (ev) => {
ev.preventDefault();
const url = new URL(window.location.href);
url.searchParams.set('lang', ev.currentTarget.dataset.lang);
$('[data-lang]').removeClass('tab--active');
pjax.request({ url: url.toString() });
$(ev.currentTarget).addClass('tab--active');
});
$(document).on('click', '[name="show_tags"]', (ev) => {
$(ev.currentTarget).hide();
$('span.tags').css('display', 'inline-block');
@@ -11,6 +11,7 @@
transition-timing-function: cubic-bezier(0.215, 0.61, 0.355, 1);
margin-right: 0;
color: #182026 !important;
text-decoration: none;
&:hover
border-color: #5f9fd6;
@@ -0,0 +1,18 @@
<div class="section__body typo" data-fragment-id="problem-description">
{% if not pdoc.data.length and not pdoc.reference %}
<blockquote class="warn">
<p>{{ _('No testdata at current.') }}</p>
</blockquote>
{% endif %}
{% if typeof(pdoc.config) == 'string' %}
<blockquote class="warn">
<p>{{ pdoc.config }}</p>
</blockquote>
{% endif %}
{% if tdoc and tdoc.docType == model.document.TYPE_CONTEST and model.contest.isDone(tdoc) %}
<blockquote class="note">
<p>{{ _('You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.') }}</p>
</blockquote>
{% endif %}
{{ pdoc.content|content(handler.request.query.lang or handler.user.viewLang or handler.session.viewLang, pdoc.html)|safe }}
</div>
@@ -75,10 +75,10 @@
<div class="section__header non-scratchpad--hide">
<h1 class="section__title">{{ pdoc.title }}</h1>
</div>
{% if pdoc.content|contentLang %}
{% if pdoc.content|contentLang|length %}
<div class="section__tab-container">
<div class="section__tab-header-wrapper">
<ul class="section__tab-header">
<ul class="section__tab-header flex-row">
{% for k in pdoc.content|contentLang %}
<a class="section__tab-header-item {{'tab--active' if (handler.request.query.lang or handler.user.viewLang or handler.session.viewLang) == k }}" data-lang="{{ k }}" href="./{{pdoc.pid|default(pdoc.docId)}}?lang={{k}}">
{{ model.setting.SETTINGS_BY_KEY['viewLang'].range[k] }}
@@ -88,24 +88,7 @@
</div>
</div>
{% endif %}
<div class="section__body typo">
{% if not pdoc.data.length and not pdoc.reference %}
<blockquote class="warn">
<p>{{ _('No testdata at current.') }}</p>
</blockquote>
{% endif %}
{% if typeof(pdoc.config) == 'string' %}
<blockquote class="warn">
<p>{{ pdoc.config }}</p>
</blockquote>
{% endif %}
{% if tdoc and tdoc.docType == model.document.TYPE_CONTEST and model.contest.isDone(tdoc) %}
<blockquote class="note">
<p>{{ _('You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.') }}</p>
</blockquote>
{% endif %}
{{ pdoc.content|content(handler.request.query.lang or handler.user.viewLang or handler.session.viewLang, pdoc.html)|safe }}
</div>
{% include "partials/problem_description.html" %}
</div></div>
</div>
</div>