Speed up top nav with turbo routing and external base CSS.
Remove view-transition lag, swap main content without full reload, prefetch pages, and tear down SSE timers on leave. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+25
-19
@@ -336,28 +336,34 @@
|
||||
<script src="{{ url_for('static', filename='js/trades.js') }}"></script>
|
||||
{% if prefill %}
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
var form = document.getElementById('review-form');
|
||||
var panel = document.getElementById('review-panel');
|
||||
if (!form) return;
|
||||
var map = {{ prefill | tojson }};
|
||||
Object.keys(map).forEach(function (k) {
|
||||
var el = form.querySelector('[name="' + k + '"]');
|
||||
if (el && map[k] != null && map[k] !== '') el.value = map[k];
|
||||
});
|
||||
var symInput = form.querySelector('.symbol-input');
|
||||
if (symInput && map.symbol_name) symInput.value = map.symbol_name;
|
||||
if (typeof recalc === 'function') recalc();
|
||||
if (panel) panel.scrollIntoView({ behavior: 'smooth', block: 'start' });
|
||||
});
|
||||
function bootReviewPrefill() {
|
||||
var form = document.getElementById('review-form');
|
||||
var panel = document.getElementById('review-panel');
|
||||
if (!form) return;
|
||||
var map = {{ prefill | tojson }};
|
||||
Object.keys(map).forEach(function (k) {
|
||||
var el = form.querySelector('[name="' + k + '"]');
|
||||
if (el && map[k] != null && map[k] !== '') el.value = map[k];
|
||||
});
|
||||
var symInput = form.querySelector('.symbol-input');
|
||||
if (symInput && map.symbol_name) symInput.value = map.symbol_name;
|
||||
if (typeof recalc === 'function') recalc();
|
||||
if (panel) panel.scrollIntoView({ behavior: 'smooth', block: 'start' });
|
||||
}
|
||||
if (window.qihuoOnPageLoad) window.qihuoOnPageLoad(bootReviewPrefill);
|
||||
else document.addEventListener('DOMContentLoaded', bootReviewPrefill);
|
||||
</script>
|
||||
{% endif %}
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
if (window.location.hash === '#review-panel') {
|
||||
var panel = document.getElementById('review-panel');
|
||||
if (panel) panel.scrollIntoView({ behavior: 'smooth', block: 'start' });
|
||||
(function () {
|
||||
function scrollReviewPanel() {
|
||||
if (window.location.hash === '#review-panel') {
|
||||
var panel = document.getElementById('review-panel');
|
||||
if (panel) panel.scrollIntoView({ behavior: 'smooth', block: 'start' });
|
||||
}
|
||||
}
|
||||
});
|
||||
if (window.qihuoOnPageLoad) window.qihuoOnPageLoad(scrollReviewPanel);
|
||||
else document.addEventListener('DOMContentLoaded', scrollReviewPanel);
|
||||
})();
|
||||
</script>
|
||||
{% endblock %}
|
||||
|
||||
Reference in New Issue
Block a user