Spaces:
Sleeping
Sleeping
alex buz commited on
Commit ·
f10d421
1
Parent(s): 7936cc5
fix
Browse files
app.py
CHANGED
|
@@ -33,7 +33,7 @@ def create_anchor_link(text):
|
|
| 33 |
return ""
|
| 34 |
anchor = text.strip().lower().replace(' ', '-').replace(',', '').replace('.', '').replace(chr(39), '-')
|
| 35 |
anchor = urllib.parse.quote(anchor)
|
| 36 |
-
return f"<a href='#' onclick='navigateToSection(\"{anchor}\");'>{text}</a>"
|
| 37 |
|
| 38 |
def on_stop():
|
| 39 |
st.session_state.stopped = True
|
|
@@ -148,24 +148,30 @@ st.markdown(
|
|
| 148 |
"""
|
| 149 |
<script>
|
| 150 |
function navigateToSection(anchor) {
|
| 151 |
-
const element = document.
|
| 152 |
if (element) {
|
| 153 |
element.scrollIntoView({behavior: 'smooth'});
|
| 154 |
} else {
|
| 155 |
console.error('Section not found:', anchor);
|
| 156 |
}
|
| 157 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
| 158 |
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
|
| 163 |
-
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
|
|
|
|
|
|
|
| 169 |
});
|
| 170 |
</script>
|
| 171 |
""",
|
|
|
|
| 33 |
return ""
|
| 34 |
anchor = text.strip().lower().replace(' ', '-').replace(',', '').replace('.', '').replace(chr(39), '-')
|
| 35 |
anchor = urllib.parse.quote(anchor)
|
| 36 |
+
return f"<a href='#{anchor}' onclick='navigateToSection(\"{anchor}\");'>{text}</a>"
|
| 37 |
|
| 38 |
def on_stop():
|
| 39 |
st.session_state.stopped = True
|
|
|
|
| 148 |
"""
|
| 149 |
<script>
|
| 150 |
function navigateToSection(anchor) {
|
| 151 |
+
const element = document.getElementById(anchor);
|
| 152 |
if (element) {
|
| 153 |
element.scrollIntoView({behavior: 'smooth'});
|
| 154 |
} else {
|
| 155 |
console.error('Section not found:', anchor);
|
| 156 |
}
|
| 157 |
}
|
| 158 |
+
</script>
|
| 159 |
+
""",
|
| 160 |
+
unsafe_allow_html=True
|
| 161 |
+
)
|
| 162 |
|
| 163 |
+
# JavaScript for intercepting clicks
|
| 164 |
+
st.markdown(
|
| 165 |
+
"""
|
| 166 |
+
<script>
|
| 167 |
+
document.addEventListener('DOMContentLoaded', function() {
|
| 168 |
+
document.querySelectorAll('a').forEach(anchor => {
|
| 169 |
+
anchor.addEventListener('click', function(e) {
|
| 170 |
+
e.preventDefault();
|
| 171 |
+
const href = this.getAttribute('href').substring(1);
|
| 172 |
+
navigateToSection(href);
|
| 173 |
+
});
|
| 174 |
+
});
|
| 175 |
});
|
| 176 |
</script>
|
| 177 |
""",
|