nopaque/app/templates/_scripts.html.j2
2023-07-13 12:40:37 +02:00

168 lines
6.4 KiB
Django/Jinja

<script src="https://cdnjs.cloudflare.com/ajax/libs/fast-json-patch/3.1.1/fast-json-patch.min.js" integrity="sha512-5uDdefwnzyq4N+SkmMBmekZLZNmc6dLixvVxCdlHBfqpyz0N3bzLdrJ55OLm7QrZmgZuhLGgHLDtJwU6RZoFCA==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/list.js/2.3.1/list.min.js" integrity="sha512-93wYgwrIFL+b+P3RvYxi/WUFRXXUDSLCT2JQk9zhVGXuS2mHl2axj6d+R6pP+gcU5isMHRj1u0oYE/mWyt/RjA==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/4.7.1/socket.io.min.js" integrity="sha512-+NaO7d6gQ1YPxvc/qHIqZEchjGm207SszoNeMgppoqD/67fEqmc1edS8zrbxPD+4RQI3gDgT/83ihpFW61TG/Q==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/plotly.js/2.24.2/plotly.min.js" integrity="sha512-dAXqGCq94D0kgLSPnfvd/pZpCMoJQpGj2S2XQmFQ9Ay1+96kbjss02ISEh+TBNXMggGg/1qoMcOHcxg+Op/Jmw==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/pako/2.1.0/pako_inflate.min.js" integrity="sha512-mlnC6JeOvg9V4vBpWMxGKscsCdScB6yvGVCeFF2plnQMRmwH69s9F8SHPbC0oirqfePmRBhqx2s3Bx7WIvHfWg==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
{%- assets
filters='rjsmin',
output='gen/cqi.%(version)s.js',
'js/cqi/package.js',
'js/cqi/errors.js',
'js/cqi/status.js',
'js/cqi/api/package.js',
'js/cqi/api/client.js',
'js/cqi/models/package.js',
'js/cqi/models/resource.js',
'js/cqi/models/attributes.js',
'js/cqi/models/subcorpora.js',
'js/cqi/models/corpora.js',
'js/cqi/client.js'
%}
<script src="{{ ASSET_URL }}"></script>
{%- endassets %}
{%- assets
filters='rjsmin',
output='gen/app.%(version)s.js',
'js/App.js',
'js/Utils.js',
'js/CorpusAnalysis/CorpusAnalysisApp.js',
'js/CorpusAnalysis/CorpusAnalysisConcordance.js',
'js/CorpusAnalysis/CorpusAnalysisReader.js',
'js/CorpusAnalysis/CorpusAnalysisStaticVisualization.js',
'js/CorpusAnalysis/QueryBuilder.js',
'js/XMLtoObject.js'
%}
<script src="{{ ASSET_URL }}"></script>
{%- endassets %}
{%- assets
filters='rjsmin',
output='gen/Forms.%(version)s.js',
'js/Forms/Form.js',
'js/Forms/CreateCorpusFileForm.js',
'js/Forms/CreateJobForm.js',
'js/Forms/CreateContributionForm.js'
%}
<script src="{{ ASSET_URL }}"></script>
{%- endassets %}
{%- assets
filters='rjsmin',
output='gen/ResourceDisplays.%(version)s.js',
'js/ResourceDisplays/ResourceDisplay.js',
'js/ResourceDisplays/CorpusDisplay.js',
'js/ResourceDisplays/JobDisplay.js'
%}
<script src="{{ ASSET_URL }}"></script>
{%- endassets %}
{%- assets
filters='rjsmin',
output='gen/ResourceLists.%(version)s.js',
'js/ResourceLists/ResourceList.js',
'js/ResourceLists/CorpusFileList.js',
'js/ResourceLists/CorpusList.js',
'js/ResourceLists/PublicCorpusList.js',
'js/ResourceLists/JobList.js',
'js/ResourceLists/JobInputList.js',
'js/ResourceLists/JobResultList.js',
'js/ResourceLists/SpacyNLPPipelineModelList.js',
'js/ResourceLists/TesseractOCRPipelineModelList.js',
'js/ResourceLists/UserList.js',
'js/ResourceLists/AdminUserList.js',
'js/ResourceLists/CorpusFollowerList.js',
'js/ResourceLists/CorpusTextInfoList.js',
'js/ResourceLists/DetailledPublicCorpusList.js'
%}
<script src="{{ ASSET_URL }}"></script>
{%- endassets %}
{%- assets
filters='rjsmin',
output='gen/Requests.%(version)s.js',
'js/Requests/Requests.js',
'js/Requests/admin/admin.js',
'js/Requests/contributions/contributions.js',
'js/Requests/contributions/spacy_nlp_pipeline_models.js',
'js/Requests/contributions/tesseract_ocr_pipeline_models.js',
'js/Requests/corpora/corpora.js',
'js/Requests/corpora/files.js',
'js/Requests/corpora/followers.js',
'js/Requests/jobs/jobs.js',
'js/Requests/users/users.js',
'js/Requests/users/settings.js'
%}
<script src="{{ ASSET_URL }}"></script>
{%- endassets %}
<script>
const app = new App();
{%- if current_user.is_authenticated %}
const currentUserId = {{ current_user.hashid|tojson }};
// Initialize components for current user
app.subscribeUser(currentUserId)
.catch((error) => {throw JSON.stringify(error);});
app.getUser(currentUserId, true, true)
.catch((error) => {throw JSON.stringify(error);});
{%- endif %}
// Disable all option elements with no value
for (let optionElement of document.querySelectorAll('option[value=""]')) {
optionElement.disabled = true;
}
for (let optgroupElement of document.querySelectorAll('optgroup[label=""]')) {
for (let c of optgroupElement.children) {
optgroupElement.parentElement.insertAdjacentElement('afterbegin', c);
}
optgroupElement.remove();
}
// Set the data-length attribute on textareas/inputs with the maxlength attribute
for (let inputElement of document.querySelectorAll('textarea[maxlength], input[maxlength]')) {
inputElement.dataset.length = inputElement.getAttribute('maxlength');
}
// Initialize components
M.AutoInit();
M.CharacterCounter.init(document.querySelectorAll('input[data-length], textarea[data-length]'));
M.Dropdown.init(
document.querySelectorAll('#nav-more-dropdown-trigger'),
{alignment: 'right', constrainWidth: false, coverTrigger: false}
);
ResourceList.autoInit();
Form.autoInit();
// Display flashed messages
for (let [category, message] of {{ get_flashed_messages(with_categories=True)|tojson }}) {
app.flash(message, message);
}
// Initialize manual modal
let manualModalTableOfContentsElement = document.querySelector('#manual-modal-table-of-contents');
let manualModalTableOfContents = M.Tabs.init(manualModalTableOfContentsElement);
let manualModalElement = document.querySelector('#manual-modal');
let manualModal = M.Modal.init(
manualModalElement,
{
onOpenStart: (manualModalElement, modalTriggerElement) => {
if ('manualModalChapter' in modalTriggerElement.dataset) {
manualModalTableOfContents.select(modalTriggerElement.dataset.manualModalChapter);
}
}
}
);
// Initialize terms of use modal
const termsOfUseModal = document.getElementById('terms-of-use-modal');
M.Modal.init(
termsOfUseModal,
{
dismissible: false,
onCloseEnd: () => {
Requests.users.entity.acceptTermsOfUse();
}
}
);
{% if current_user.is_authenticated and not current_user.terms_of_use_accepted %}
termsOfUseModal.M_Modal.open();
{% endif %}
</script>