Further codestyle improvements

This commit is contained in:
Patrick Jentsch 2021-12-09 15:39:45 +01:00
parent 40bd169101
commit 44f9d0a560
3 changed files with 60 additions and 33 deletions

View File

@ -1,44 +1,64 @@
<script src="https://cdnjs.cloudflare.com/ajax/libs/darkreader/4.9.40/darkreader.min.js" integrity="sha512-0Jbi9gWSyU5SvNS16za0aILl6l+MgM8N+TGlZxy4qPQEzqKoU9egh4h56Kz0xp2R+ZFPQMfeDn26Gh6cqu2WAg==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/fast-json-patch/3.1.0/fast-json-patch.min.js" integrity="sha512-KrvLlmKBiDoTa0Fke92aFoEv4xS0+cuYGP27nt39w0yLZWvVOhArmZ29uuOe3uOOBcbnkpvnLhkvYcYjahSOwg==" crossorigin="anonymous" referrerpolicy="no-referrer"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/fast-json-patch/3.1.0/fast-json-patch.min.js" integrity="sha512-KrvLlmKBiDoTa0Fke92aFoEv4xS0+cuYGP27nt39w0yLZWvVOhArmZ29uuOe3uOOBcbnkpvnLhkvYcYjahSOwg==" 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/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.4.0/socket.io.js" integrity="sha512-nYuHvSAhY5lFZ4ixSViOwsEKFvlxHMU2NHts1ILuJgOS6ptUmAGt/0i5czIgMOahKZ6JN84YFDA+mCdky7dD8A==" crossorigin="anonymous" referrerpolicy="no-referrer"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/4.4.0/socket.io.js" integrity="sha512-nYuHvSAhY5lFZ4ixSViOwsEKFvlxHMU2NHts1ILuJgOS6ptUmAGt/0i5czIgMOahKZ6JN84YFDA+mCdky7dD8A==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script src="{{ url_for('static', filename='js/App.js') }}"></script> <script src="{{ url_for('static', filename='js/App.js') }}"></script>
<script src="{{ url_for('static', filename='js/JobStatusNotifier.js') }}"></script> <script src="{{ url_for('static', filename='js/JobStatusNotifier.js') }}"></script>
{% assets filters='rjsmin', output="js/RessourceDisplays.min.bundle.js", {%- assets
"js/RessourceDisplays/RessourceDisplay.js", filters='rjsmin',
"js/RessourceDisplays/CorpusDisplay.js", output='js/RessourceDisplays.min.bundle.js',
"js/RessourceDisplays/JobDisplay.js" %} 'js/RessourceDisplays/RessourceDisplay.js',
'js/RessourceDisplays/CorpusDisplay.js',
'js/RessourceDisplays/JobDisplay.js'
%}
<script src="{{ ASSET_URL }}"></script> <script src="{{ ASSET_URL }}"></script>
{% endassets %} {%- endassets %}
{% assets filters='rjsmin', output="js/RessourceLists.min.bundle.js", {%- assets
"js/RessourceLists/RessourceList.js", filters='rjsmin',
"js/RessourceLists/CorpusList.js", output='js/RessourceLists.min.bundle.js',
"js/RessourceLists/CorpusFileList.js", 'js/RessourceLists/RessourceList.js',
"js/RessourceLists/JobList.js", 'js/RessourceLists/CorpusList.js',
"js/RessourceLists/JobInputList.js", 'js/RessourceLists/CorpusFileList.js',
"js/RessourceLists/JobResultList.js", 'js/RessourceLists/JobList.js',
"js/RessourceLists/QueryResultList.js", 'js/RessourceLists/JobInputList.js',
"js/RessourceLists/UserList.js" %} 'js/RessourceLists/JobResultList.js',
'js/RessourceLists/QueryResultList.js',
'js/RessourceLists/UserList.js'
%}
<script src="{{ ASSET_URL }}"></script> <script src="{{ ASSET_URL }}"></script>
{% endassets %} {%- endassets %}
<script src="{{ url_for('static', filename='js/UploadForm.js') }}"></script> <script src="{{ url_for('static', filename='js/UploadForm.js') }}"></script>
<script> <script>
{% if current_user.setting_dark_mode %} const app = new App();
DarkReader.enable({brightness: 150, contrast: 100, sepia: 0}); {%- if current_user.is_authenticated %}
{% endif %} const currentUserId = {{ current_user.hashid|tojson }};
const jobStatusNotifier = new JobStatusNotifier(currentUserId);
// Initialize components for current user
app.addEventListener('users.patch', patch => jobStatusNotifier.usersPatchHandler(patch));
app.getUserById(currentUserId)
.then(
user => {return;},
error => {throw JSON.stringify(error);}
);
{%- endif %}
// Disable all option elements with no value // Disable all option elements with no value
for (let optionElement of document.querySelectorAll('option[value=""]')) {optionElement.disabled = true;} for (let optionElementWithoutValue of document.querySelectorAll('option[value=""]')) {
optionElementWithoutValue.disabled = true;
}
// Initialize components
M.AutoInit(); M.AutoInit();
M.CharacterCounter.init(document.querySelectorAll('input[data-length][type="email"], input[data-length][type="password"], input[data-length][type="text"], textarea[data-length]')); M.CharacterCounter.init(document.querySelectorAll('input[data-length][type="email"], input[data-length][type="password"], input[data-length][type="text"], textarea[data-length]'));
M.Dropdown.init(document.querySelectorAll('#nav-more-dropdown-trigger'), {alignment: 'right', constrainWidth: false, coverTrigger: false}); M.Dropdown.init(
var app = new App(); document.querySelectorAll('#nav-more-dropdown-trigger'),
{% if current_user.is_authenticated %} {alignment: 'right', constrainWidth: false, coverTrigger: false}
var currentUserId = '{{ current_user.hashid }}'; );
let jobStatusNotifier = new JobStatusNotifier(currentUserId);
app.addEventListener('users.patch', patch => jobStatusNotifier.usersPatchHandler(patch));
app.getUserById(currentUserId).then(user => {}, error => {throw JSON.stringify(error)});
{% endif %}
UploadForm.autoInit();
RessourceList.autoInit(); RessourceList.autoInit();
for (let flashedMessage of {{ get_flashed_messages(with_categories=True)|tojson }}) {app.flash(flashedMessage[1], flashedMessage[0]);} UploadForm.autoInit();
// Display flashed messages
for (let flashedMessage of {{ get_flashed_messages(with_categories=True)|tojson }}) {
app.flash(flashedMessage[1], flashedMessage[0]);
}
</script> </script>

View File

@ -5,6 +5,12 @@
{% block head %} {% block head %}
{{ super() }} {{ super() }}
<link href="{{ url_for('static', filename='images/nopaque_-_favicon.png') }}" rel="icon"> <link href="{{ url_for('static', filename='images/nopaque_-_favicon.png') }}" rel="icon">
{% if current_user.setting_dark_mode %}
<script src="https://cdnjs.cloudflare.com/ajax/libs/darkreader/4.9.40/darkreader.min.js" integrity="sha512-0Jbi9gWSyU5SvNS16za0aILl6l+MgM8N+TGlZxy4qPQEzqKoU9egh4h56Kz0xp2R+ZFPQMfeDn26Gh6cqu2WAg==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script>
DarkReader.enable();
</script>
{% endif %}
{% endblock head %} {% endblock head %}
{% block metas %} {% block metas %}

View File

@ -65,9 +65,10 @@
<script src="{{ ASSET_URL }}"></script> <script src="{{ ASSET_URL }}"></script>
{% endassets %} {% endassets %}
<script> <script>
let corpusAnalysisApp = new CorpusAnalysisApp('{{ corpus.hashid }}'); const corpusAnalysisApp = new CorpusAnalysisApp({{ corpus.hashid|tojson }});
let corpusAnalysisConcordance = new CorpusAnalysisConcordance(corpusAnalysisApp); const corpusAnalysisConcordance = new CorpusAnalysisConcordance(corpusAnalysisApp);
let corpusAnalysisReader = new CorpusAnalysisReader(corpusAnalysisApp); const corpusAnalysisReader = new CorpusAnalysisReader(corpusAnalysisApp);
corpusAnalysisApp.init(); corpusAnalysisApp.init();
</script> </script>
{% endblock scripts %} {% endblock scripts %}