saçvar painel selecionado
This commit is contained in:
parent
a0dd05b518
commit
65118f2838
4 changed files with 170 additions and 0 deletions
49
web/static/painel.js
Normal file
49
web/static/painel.js
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
(function(){
|
||||
// Bootstrap mínimo do painel.
|
||||
// Regra (.agent): a lógica fica no WASM; aqui apenas garantimos que o WASM
|
||||
// esteja carregado/executando.
|
||||
//
|
||||
// Este arquivo existe para evitar JS inline no HTML do painel.
|
||||
|
||||
async function carregarWasmPainel(){
|
||||
try{
|
||||
if(window.__eli_nps_wasm_ready) return true;
|
||||
if(window.__eli_nps_wasm_loading) return window.__eli_nps_wasm_loading;
|
||||
|
||||
window.__eli_nps_wasm_loading = (async function(){
|
||||
try{
|
||||
if(!window.Go){
|
||||
// wasm_exec.js deve ter sido carregado pelo HTML.
|
||||
return false;
|
||||
}
|
||||
const go = new Go();
|
||||
const res = await fetch('/static/e-li.nps.wasm', {cache: 'no-cache'});
|
||||
if(!res.ok) return false;
|
||||
const bytes = await res.arrayBuffer();
|
||||
const {instance} = await WebAssembly.instantiate(bytes, go.importObject);
|
||||
go.run(instance);
|
||||
return !!window.__eli_nps_wasm_ready;
|
||||
}catch(e){
|
||||
return false;
|
||||
}
|
||||
})();
|
||||
|
||||
return window.__eli_nps_wasm_loading;
|
||||
}catch(e){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
document.addEventListener('DOMContentLoaded', function(){
|
||||
carregarWasmPainel().then(function(ok){
|
||||
if(!ok) return;
|
||||
// Executa o init do painel no WASM (best-effort).
|
||||
try{
|
||||
if(typeof window.__eli_nps_wasm_painel_init === 'function'){
|
||||
window.__eli_nps_wasm_painel_init();
|
||||
}
|
||||
}catch(e){}
|
||||
});
|
||||
});
|
||||
})();
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue