Skip to content

Commit

Permalink
feat: new custom loading animation
Browse files Browse the repository at this point in the history
  • Loading branch information
jstucke committed Dec 10, 2024
1 parent 2aa83a0 commit 1c76ee9
Show file tree
Hide file tree
Showing 5 changed files with 92 additions and 9 deletions.
65 changes: 65 additions & 0 deletions src/web_interface/static/fact_loading.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 13 additions & 2 deletions src/web_interface/static/js/loading.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,20 @@
function showImg() {
$('#form').hide();
$('#loading_img').css({'display': 'block'});
$('#loading-img').css({'display': 'block'});
}

function hideImg() {
$('#form').show();
$('#loading_img').css({'display': 'none'});
$('#loading-img').css({'display': 'none'});
}

function loadLoadingAnimation(elementId) {
fetch("/static/fact_loading.svg")
.then(response => response.text())
.then(data => {
document.getElementById(elementId).innerHTML = data;
})
.catch(error => {
console.error('Error loading loading animation:', error);
});
}
4 changes: 1 addition & 3 deletions src/web_interface/templates/database/database_search.html
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,11 @@ <h3 class="mb-3">Search Firmware Database</h3>
</div>


<button type="submit" value=submit class="btn btn-primary" id="input_submit" onclick="showImg()">
<button type="submit" value=submit class="btn btn-primary" id="input_submit">
<i class="fas fa-search"></i> Search
</button>

</form>

<img id="loading_img" src="{{ url_for('.static', filename='Pacman.gif') }}" style="display: none; margin: auto;"/>
</div>
</div>

Expand Down
9 changes: 7 additions & 2 deletions src/web_interface/templates/show_analysis.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
const selected_analysis = "{{ selected_analysis }}";
</script>
<script src="{{ url_for('static', filename='js/file_tree.js') }}"></script>
<script type="text/javascript" src="{{ url_for('static', filename='js/loading.js') }}"></script>
{% endblock %}


Expand Down Expand Up @@ -312,9 +313,11 @@ <h5 class="modal-title">Add analysis to file</h5>

<div id="summary-div">
<div class="mb-3 border" id="loading-summary-gif" style="display: none; padding: 5px; text-align: center">
<img src="{{ url_for("static", filename = "Pacman.gif") }}" alt="loading gif">
<p>Loading summary for included files ..</p>
</div>
<script>
loadLoadingAnimation('loading-summary-gif');
</script>
</div>
<script type="text/javascript" src="{{ url_for('static', filename='js/show_analysis_summary.js') }}"></script>

Expand Down Expand Up @@ -355,8 +358,10 @@ <h5 class="modal-title">Add analysis to file</h5>
</div>
</div>
<div id="preview-loading-gif" class="border" style="display: block; padding: 5px; text-align: center">
<img src="{{ url_for('static', filename = 'Pacman.gif') }}" alt="loading...">
</div>
<script>
loadLoadingAnimation('preview-loading-gif');
</script>
<div id="preview-content" class="m-0 mt-2 p-0"></div>
</div>

Expand Down
8 changes: 6 additions & 2 deletions src/web_interface/templates/upload/upload.html
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,12 @@ <h3 class="mb-3">Upload Firmware</h3>
</form>
</div>

<img id="loading_img" src="{{ url_for('.static', filename='Pacman.gif') }}"
alt="loading..." style="display: none; margin: auto;"/>
<div class="mb-3" id="loading-img" style="display: none; padding: 5px; text-align: center">
<p>Upload in progress...</p>
</div>
<script>
loadLoadingAnimation('loading-gif');
</script>
</div>
</div>

Expand Down

0 comments on commit 1c76ee9

Please sign in to comment.