Spaces:
Runtime error

ditgun commited on
Commit
b28d9f9
ยท
verified ยท
1 Parent(s): 8d48eba

Update src/app.py

Browse files
Files changed (1) hide show
  1. 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 && wrap.parentElement) {{
1219
- wrap.parentElement.style.cssText =
1220
- 'display:none!important;height:0!important;overflow:hidden!important;' +
1221
- 'position:absolute!important;pointer-events:none!important;';
 
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
- var firstTab = '๊ธ‰๋ณ€';
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
- st.button("alert_trigger", key="hidden_alert_btn", help="alert_trigger_btn", on_click=lambda: None)
 
 
1999
  st.markdown("""
2000
  <style>
 
 
2001
  div[data-testid="stButton"]:has(button[title="alert_trigger_btn"]),
2002
- div[data-testid="stButton"]:has(button[data-testid="baseButton-secondary"][title="alert_trigger_btn"]) {
 
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: -9999px !important;
2010
- left: -9999px !important;
2011
  pointer-events: none !important;
2012
  opacity: 0 !important;
2013
- }
2014
- button[title="alert_trigger_btn"] {
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)