SC CODE: Function InitializePrivate() Uint64
10 IF init() == 0 THEN GOTO 30
20 RETURN 1
30 STORE("var_header_name", "spa.js")
31 STORE("var_header_description", "")
32 STORE("var_header_icon", "")
33 STORE("dURL", "")
34 STORE("docType", "TELA-JS-1")
35 STORE("subDir", "/")
36 STORE("fileCheckC", "157a861023ca5b4a878cbbe735fb2d8161e04f090410f0235dbdef4e114e1477")
37 STORE("fileCheckS", "0deed2aa33c21669f76e65c5aeb6574a89ebe34ace736cc71d3c975b587b80ac")
100 RETURN 0
End Function
Function init() Uint64
10 IF EXISTS("owner") == 0 THEN GOTO 30
20 RETURN 1
30 STORE("owner", address())
50 STORE("docVersion", "1.0.0")
60 STORE("hash", HEX(TXID()))
70 STORE("likes", 0)
80 STORE("dislikes", 0)
100 RETURN 0
End Function
Function address() String
10 DIM s as String
20 LET s = SIGNER()
30 IF IS_ADDRESS_VALID(s) THEN GOTO 50
40 RETURN "anon"
50 RETURN ADDRESS_STRING(s)
End Function
Function Rate(r Uint64) Uint64
10 DIM addr as String
15 LET addr = address()
16 IF r < 100 && EXISTS(addr) == 0 && addr != "anon" THEN GOTO 30
20 RETURN 1
30 STORE(addr, ""+r+"_"+BLOCK_HEIGHT())
40 IF r < 50 THEN GOTO 70
50 STORE("likes", LOAD("likes")+1)
60 RETURN 0
70 STORE("dislikes", LOAD("dislikes")+1)
100 RETURN 0
End Function
/*
async function loadPage(url, pushState = true) {
try {
const response = await fetch(url);
if (!response.ok || !response.headers.get("content-type")?.includes("text/html")) {
throw new Error(`Page load failed: ${response.status}`);
}
const text = await response.text();
const temp = document.createElement("div");
temp.innerHTML = text;
const newMain = temp.querySelector("main");
if (newMain) {
const currentMain = document.querySelector("#app main");
if (currentMain) currentMain.innerHTML = newMain.innerHTML;
}
if (pushState) history.pushState({ url }, "", url);
window.scrollTo(0, 0);
} catch (err) {
console.error("Failed to load page:", err);
}
}
document.addEventListener("click", e => {
const link = e.target.closest("a.nav");
if (link) {
const url = link.getAttribute("href");
if (!url.startsWith("#")) {
e.preventDefault();
loadPage(url, true);
}
}
});
window.addEventListener("popstate", e => {
if (e.state?.url) loadPage(e.state.url, false);
});
*/ |
| SC Arguments: [Name:SC_ACTION Type:uint64 Value:'1' Name:SC_CODE Type:string Value:'Function InitializePrivate() Uint64
10 IF init() == 0 THEN GOTO 30
20 RETURN 1
30 STORE("var_header_name", "spa.js")
31 STORE("var_header_description", "")
32 STORE("var_header_icon", "")
33 STORE("dURL", "")
34 STORE("docType", "TELA-JS-1")
35 STORE("subDir", "/")
36 STORE("fileCheckC", "157a861023ca5b4a878cbbe735fb2d8161e04f090410f0235dbdef4e114e1477")
37 STORE("fileCheckS", "0deed2aa33c21669f76e65c5aeb6574a89ebe34ace736cc71d3c975b587b80ac")
100 RETURN 0
End Function
Function init() Uint64
10 IF EXISTS("owner") == 0 THEN GOTO 30
20 RETURN 1
30 STORE("owner", address())
50 STORE("docVersion", "1.0.0")
60 STORE("hash", HEX(TXID()))
70 STORE("likes", 0)
80 STORE("dislikes", 0)
100 RETURN 0
End Function
Function address() String
10 DIM s as String
20 LET s = SIGNER()
30 IF IS_ADDRESS_VALID(s) THEN GOTO 50
40 RETURN "anon"
50 RETURN ADDRESS_STRING(s)
End Function
Function Rate(r Uint64) Uint64
10 DIM addr as String
15 LET addr = address()
16 IF r < 100 && EXISTS(addr) == 0 && addr != "anon" THEN GOTO 30
20 RETURN 1
30 STORE(addr, ""+r+"_"+BLOCK_HEIGHT())
40 IF r < 50 THEN GOTO 70
50 STORE("likes", LOAD("likes")+1)
60 RETURN 0
70 STORE("dislikes", LOAD("dislikes")+1)
100 RETURN 0
End Function
/*
async function loadPage(url, pushState = true) {
try {
const response = await fetch(url);
if (!response.ok || !response.headers.get("content-type")?.includes("text/html")) {
throw new Error(`Page load failed: ${response.status}`);
}
const text = await response.text();
const temp = document.createElement("div");
temp.innerHTML = text;
const newMain = temp.querySelector("main");
if (newMain) {
const currentMain = document.querySelector("#app main");
if (currentMain) currentMain.innerHTML = newMain.innerHTML;
}
if (pushState) history.pushState({ url }, "", url);
window.scrollTo(0, 0);
} catch (err) {
console.error("Failed to load page:", err);
}
}
document.addEventListener("click", e => {
const link = e.target.closest("a.nav");
if (link) {
const url = link.getAttribute("href");
if (!url.startsWith("#")) {
e.preventDefault();
loadPage(url, true);
}
}
});
window.addEventListener("popstate", e => {
if (e.state?.url) loadPage(e.state.url, false);
});
*/'] |