SeaWolf-AI commited on
Commit
7632f46
ยท
verified ยท
1 Parent(s): 1df941e

gate sandbox: re-localize the verdict/audit line when the language toggles

Browse files
Files changed (1) hide show
  1. index.html +10 -2
index.html CHANGED
@@ -151,8 +151,16 @@ function pickVideo(l){var v=document.getElementById('vid');var src=(l==='ko')?'d
151
  };
152
  function ko(){return document.documentElement.lang==="ko";}
153
  var V=document.getElementById("tbverdict"), A=document.getElementById("tbaudit");
 
154
  function setV(cls,txt,aud){V.className="stamp "+cls;V.textContent=txt;A.textContent=aud||"";}
 
 
 
 
 
 
155
  async function run(){
 
156
  var fn=(document.getElementById("tbfn").value||"").trim();
157
  var raw=document.getElementById("tbargs").value, args;
158
  try{args=JSON.parse(raw||"{}");}catch(e){setV("s-leak",ko()?"args JSON ํ˜•์‹ ์˜ค๋ฅ˜":"args is not valid JSON","");return;}
@@ -161,8 +169,7 @@ function pickVideo(l){var v=document.getElementById('vid');var src=(l==='ko')?'d
161
  var r=await fetch(API,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({fn:fn,args:args})});
162
  var d=await r.json();
163
  if(d.error){setV("",d.error,"");return;}
164
- var cls=d.decision==="ALLOW"?"s-safe":(d.decision==="DENY"?"s-leak":"s-deny");
165
- setV(cls, d.decision+": "+(d.reason||""), d.decision==="DENY"?(ko()?"ํ•œ ๋ฐ”์ดํŠธ๊ฐ€ ๋‚˜๊ฐ€๊ธฐ ์ „์— ์ฐจ๋‹จ":"blocked before any bytes left"):"");
166
  }catch(e){setV("",ko()?"๊ฒŒ์ดํŠธ์— ์—ฐ๊ฒฐํ•  ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค":"could not reach the gate","");}
167
  }
168
  document.getElementById("tbrun").addEventListener("click",run);
@@ -170,6 +177,7 @@ function pickVideo(l){var v=document.getElementById('vid');var src=(l==='ko')?'d
170
  var d=PRE[b.getAttribute("data-k")]; if(!d)return;
171
  document.getElementById("tbfn").value=d.fn; document.getElementById("tbargs").value=d.args; run();
172
  });});
 
173
  })();
174
  </script>
175
  </body>
 
151
  };
152
  function ko(){return document.documentElement.lang==="ko";}
153
  var V=document.getElementById("tbverdict"), A=document.getElementById("tbaudit");
154
+ var last=null; // last gate result, re-rendered when the language changes
155
  function setV(cls,txt,aud){V.className="stamp "+cls;V.textContent=txt;A.textContent=aud||"";}
156
+ function render(){
157
+ if(!last) return;
158
+ var d=last;
159
+ var cls=d.decision==="ALLOW"?"s-safe":(d.decision==="DENY"?"s-leak":"s-deny");
160
+ setV(cls, d.decision+": "+(d.reason||""), d.decision==="DENY"?(ko()?"ํ•œ ๋ฐ”์ดํŠธ๊ฐ€ ๋‚˜๊ฐ€๊ธฐ ์ „์— ์ฐจ๋‹จ":"blocked before any bytes left"):"");
161
+ }
162
  async function run(){
163
+ last=null;
164
  var fn=(document.getElementById("tbfn").value||"").trim();
165
  var raw=document.getElementById("tbargs").value, args;
166
  try{args=JSON.parse(raw||"{}");}catch(e){setV("s-leak",ko()?"args JSON ํ˜•์‹ ์˜ค๋ฅ˜":"args is not valid JSON","");return;}
 
169
  var r=await fetch(API,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({fn:fn,args:args})});
170
  var d=await r.json();
171
  if(d.error){setV("",d.error,"");return;}
172
+ last=d; render();
 
173
  }catch(e){setV("",ko()?"๊ฒŒ์ดํŠธ์— ์—ฐ๊ฒฐํ•  ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค":"could not reach the gate","");}
174
  }
175
  document.getElementById("tbrun").addEventListener("click",run);
 
177
  var d=PRE[b.getAttribute("data-k")]; if(!d)return;
178
  document.getElementById("tbfn").value=d.fn; document.getElementById("tbargs").value=d.args; run();
179
  });});
180
+ document.querySelectorAll(".lang button").forEach(function(b){b.addEventListener("click",function(){setTimeout(render,0);});});
181
  })();
182
  </script>
183
  </body>