Update src/app.py
Browse files- src/app.py +40 -23
src/app.py
CHANGED
|
@@ -1214,17 +1214,28 @@ def render_grouped_alert_panel(prices, rate):
|
|
| 1214 |
function hideAlertBtn() {{
|
| 1215 |
pdoc.querySelectorAll('button').forEach(function(b) {{
|
| 1216 |
if (b.textContent && b.textContent.trim() === 'alert_trigger') {{
|
|
|
|
| 1217 |
var wrap = b.closest('[data-testid="stButton"]');
|
| 1218 |
-
if (wrap
|
| 1219 |
-
wrap.
|
| 1220 |
-
|
| 1221 |
-
'position:
|
|
|
|
| 1222 |
}}
|
| 1223 |
}}
|
| 1224 |
}});
|
| 1225 |
}}
|
| 1226 |
hideAlertBtn();
|
|
|
|
| 1227 |
setTimeout(hideAlertBtn, 800);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1228 |
var root = pdoc.getElementById(PID);
|
| 1229 |
if (!root) {{
|
| 1230 |
root = pdoc.createElement('div');
|
|
@@ -1232,12 +1243,13 @@ def render_grouped_alert_panel(prices, rate):
|
|
| 1232 |
root.style.cssText = 'position:fixed;bottom:65px;right:24px;z-index:2147483647;font-family:"JetBrains Mono","Noto Sans KR",monospace;';
|
| 1233 |
pdoc.body.appendChild(root);
|
| 1234 |
}}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1235 |
if (!window.parent._alState) {{
|
| 1236 |
-
|
| 1237 |
-
var keys = ['๊ธ๋ณ','๋งค์','์ต์ ','์คํฑ๋ก์ค'];
|
| 1238 |
-
for (var ki=0; ki<keys.length; ki++) {{
|
| 1239 |
-
if (DATA[keys[ki]] && DATA[keys[ki]].length > 0) {{ firstTab = keys[ki]; break; }}
|
| 1240 |
-
}}
|
| 1241 |
window.parent._alState = {{
|
| 1242 |
minimized: false,
|
| 1243 |
tab: firstTab,
|
|
@@ -1246,7 +1258,13 @@ def render_grouped_alert_panel(prices, rate):
|
|
| 1246 |
data: DATA
|
| 1247 |
}};
|
| 1248 |
}} else {{
|
|
|
|
| 1249 |
window.parent._alState.data = DATA;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1250 |
}}
|
| 1251 |
var s = window.parent._alState;
|
| 1252 |
var CAT = {{
|
|
@@ -1995,30 +2013,29 @@ elif st.session_state.main_menu == "โ ์์คํ
์ค์ ":
|
|
| 1995 |
time.sleep(0.5); st.rerun()
|
| 1996 |
|
| 1997 |
# โโ ์จ๊น ๋ฆฌํ๋ ์ ๋ฒํผ (ํ๋กํ
ํจ๋์์ URL ๋ณ๊ฒฝ ํ ํด๋ฆญ ํธ๋ฆฌ๊ฑฐ์ฉ) โโ
|
| 1998 |
-
|
|
|
|
|
|
|
| 1999 |
st.markdown("""
|
| 2000 |
<style>
|
|
|
|
|
|
|
| 2001 |
div[data-testid="stButton"]:has(button[title="alert_trigger_btn"]),
|
| 2002 |
-
div[data-testid="stButton"]:has(button[
|
|
|
|
| 2003 |
display: none !important;
|
| 2004 |
visibility: hidden !important;
|
| 2005 |
height: 0 !important;
|
| 2006 |
width: 0 !important;
|
|
|
|
| 2007 |
overflow: hidden !important;
|
| 2008 |
position: fixed !important;
|
| 2009 |
-
top: -
|
| 2010 |
-
left: -
|
| 2011 |
pointer-events: none !important;
|
| 2012 |
opacity: 0 !important;
|
| 2013 |
-
|
| 2014 |
-
|
| 2015 |
-
display: none !important;
|
| 2016 |
-
visibility: hidden !important;
|
| 2017 |
-
pointer-events: none !important;
|
| 2018 |
-
position: fixed !important;
|
| 2019 |
-
top: -9999px !important;
|
| 2020 |
-
left: -9999px !important;
|
| 2021 |
-
opacity: 0 !important;
|
| 2022 |
}
|
| 2023 |
</style>
|
| 2024 |
""", unsafe_allow_html=True)
|
|
@@ -2029,4 +2046,4 @@ nc = st.columns(4)
|
|
| 2029 |
with nc[0]: st.button("*โก*\n๋ฉ๋ด", key="nav_menu", on_click=toggle_menu, use_container_width=True)
|
| 2030 |
with nc[1]: st.button("*โ*\nํ", key="nav_home", on_click=go_home, use_container_width=True)
|
| 2031 |
with nc[2]: st.button("*โ
*\n๊ด์ฌ", key="nav_fav", on_click=lambda: select_menu("โ
๊ด์ฌ ์ข
๋ชฉ"), use_container_width=True)
|
| 2032 |
-
with nc[3]: st.button("*โน*\n๋ค๋ก", key="nav_back", on_click=go_back, use_container_width=True)
|
|
|
|
| 1214 |
function hideAlertBtn() {{
|
| 1215 |
pdoc.querySelectorAll('button').forEach(function(b) {{
|
| 1216 |
if (b.textContent && b.textContent.trim() === 'alert_trigger') {{
|
| 1217 |
+
b.style.cssText = 'display:none!important;visibility:hidden!important;opacity:0!important;pointer-events:none!important;position:fixed!important;top:-9999px!important;';
|
| 1218 |
var wrap = b.closest('[data-testid="stButton"]');
|
| 1219 |
+
if (wrap) {{
|
| 1220 |
+
wrap.style.cssText = 'display:none!important;height:0!important;overflow:hidden!important;position:fixed!important;top:-9999px!important;pointer-events:none!important;opacity:0!important;';
|
| 1221 |
+
if (wrap.parentElement) {{
|
| 1222 |
+
wrap.parentElement.style.cssText = 'display:none!important;height:0!important;overflow:hidden!important;position:fixed!important;top:-9999px!important;pointer-events:none!important;opacity:0!important;';
|
| 1223 |
+
}}
|
| 1224 |
}}
|
| 1225 |
}}
|
| 1226 |
}});
|
| 1227 |
}}
|
| 1228 |
hideAlertBtn();
|
| 1229 |
+
setTimeout(hideAlertBtn, 300);
|
| 1230 |
setTimeout(hideAlertBtn, 800);
|
| 1231 |
+
setTimeout(hideAlertBtn, 2000);
|
| 1232 |
+
// MutationObserver: Streamlit DOM ๋ณ๊ฒฝ ์์๋ ๊ณ์ ์จ๊น ์ ์ง
|
| 1233 |
+
if (!window.parent._alHideObserver) {{
|
| 1234 |
+
window.parent._alHideObserver = new MutationObserver(function() {{
|
| 1235 |
+
hideAlertBtn();
|
| 1236 |
+
}});
|
| 1237 |
+
window.parent._alHideObserver.observe(pdoc.body, {{childList:true, subtree:true}});
|
| 1238 |
+
}}
|
| 1239 |
var root = pdoc.getElementById(PID);
|
| 1240 |
if (!root) {{
|
| 1241 |
root = pdoc.createElement('div');
|
|
|
|
| 1243 |
root.style.cssText = 'position:fixed;bottom:65px;right:24px;z-index:2147483647;font-family:"JetBrains Mono","Noto Sans KR",monospace;';
|
| 1244 |
pdoc.body.appendChild(root);
|
| 1245 |
}}
|
| 1246 |
+
var firstTab = '๊ธ๋ณ';
|
| 1247 |
+
var keys = ['๊ธ๋ณ','๋งค์','์ต์ ','์คํฑ๋ก์ค'];
|
| 1248 |
+
for (var ki=0; ki<keys.length; ki++) {{
|
| 1249 |
+
if (DATA[keys[ki]] && DATA[keys[ki]].length > 0) {{ firstTab = keys[ki]; break; }}
|
| 1250 |
+
}}
|
| 1251 |
if (!window.parent._alState) {{
|
| 1252 |
+
// ์ต์ด ์์ฑ
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1253 |
window.parent._alState = {{
|
| 1254 |
minimized: false,
|
| 1255 |
tab: firstTab,
|
|
|
|
| 1258 |
data: DATA
|
| 1259 |
}};
|
| 1260 |
}} else {{
|
| 1261 |
+
// Streamlit ๋ฆฌ๋ ๋ ์: ๋ฐ์ดํฐ๋ง ๊ฐฑ์ , minimized ์ํ ์ ์ง
|
| 1262 |
window.parent._alState.data = DATA;
|
| 1263 |
+
// ํ์ฌ ํญ์ด ๋น์์ผ๋ฉด ์ฒซ ๋ฒ์งธ ์ ํจ ํญ์ผ๋ก ์ด๋
|
| 1264 |
+
var curTab = window.parent._alState.tab;
|
| 1265 |
+
if (!DATA[curTab] || DATA[curTab].length === 0) {{
|
| 1266 |
+
window.parent._alState.tab = firstTab;
|
| 1267 |
+
}}
|
| 1268 |
}}
|
| 1269 |
var s = window.parent._alState;
|
| 1270 |
var CAT = {{
|
|
|
|
| 2013 |
time.sleep(0.5); st.rerun()
|
| 2014 |
|
| 2015 |
# โโ ์จ๊น ๋ฆฌํ๋ ์ ๋ฒํผ (ํ๋กํ
ํจ๋์์ URL ๋ณ๊ฒฝ ํ ํด๋ฆญ ํธ๋ฆฌ๊ฑฐ์ฉ) โโ
|
| 2016 |
+
# key๋ฅผ ๋งค ๋ ๋๋ง๋ค ๊ณ ์ ํ๊ฒ ๋ง๋ค์ด Streamlit ์ค๋ณต key ์ค๋ฅ ๋ฐฉ์ง
|
| 2017 |
+
_trigger_key = f"hidden_alert_btn_{st.session_state.get('main_menu','home')}"
|
| 2018 |
+
st.button("alert_trigger", key=_trigger_key, help="alert_trigger_btn", on_click=lambda: None)
|
| 2019 |
st.markdown("""
|
| 2020 |
<style>
|
| 2021 |
+
/* alert_trigger ๋ฒํผ ์์ ์จ๊น โ ๋ค์ค ์ ํ์ */
|
| 2022 |
+
button[title="alert_trigger_btn"],
|
| 2023 |
div[data-testid="stButton"]:has(button[title="alert_trigger_btn"]),
|
| 2024 |
+
div[data-testid="stButton"]:has(button[title="alert_trigger_btn"]) ~ div,
|
| 2025 |
+
.element-container:has(button[title="alert_trigger_btn"]) {
|
| 2026 |
display: none !important;
|
| 2027 |
visibility: hidden !important;
|
| 2028 |
height: 0 !important;
|
| 2029 |
width: 0 !important;
|
| 2030 |
+
max-height: 0 !important;
|
| 2031 |
overflow: hidden !important;
|
| 2032 |
position: fixed !important;
|
| 2033 |
+
top: -99999px !important;
|
| 2034 |
+
left: -99999px !important;
|
| 2035 |
pointer-events: none !important;
|
| 2036 |
opacity: 0 !important;
|
| 2037 |
+
margin: 0 !important;
|
| 2038 |
+
padding: 0 !important;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2039 |
}
|
| 2040 |
</style>
|
| 2041 |
""", unsafe_allow_html=True)
|
|
|
|
| 2046 |
with nc[0]: st.button("*โก*\n๋ฉ๋ด", key="nav_menu", on_click=toggle_menu, use_container_width=True)
|
| 2047 |
with nc[1]: st.button("*โ*\nํ", key="nav_home", on_click=go_home, use_container_width=True)
|
| 2048 |
with nc[2]: st.button("*โ
*\n๊ด์ฌ", key="nav_fav", on_click=lambda: select_menu("โ
๊ด์ฌ ์ข
๋ชฉ"), use_container_width=True)
|
| 2049 |
+
with nc[3]: st.button("*โน*\n๋ค๋ก", key="nav_back", on_click=go_back, use_container_width=True)
|