SC Arguments: [Name:SC_ACTION Type:uint64 Value:'1' Name:SC_CODE Type:string Value:'//This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License
window.addEventListener("popstate", loadPage);
function loadPage(){
document.querySelectorAll(".page").forEach(el => el.remove());
document.body.innerHTML = "";
setResources();
}
document.body.addEventListener("click", function(e) {
if(e.target && e.target.nodeName == "A") {
var url = e.target.getAttribute('href');
if (url) {
e.preventDefault();
window.history.pushState({},"", url);
loadPage();
}
}
});
function getResourceList(){
let location = document.location.href.split('#!', 2)[1];
location = typeof location === 'undefined' ? 'home' : location;
var resourceList = [];
resourceList['home'] = [
{"scid":"97dbc4ff028762e426e4ad411eea9a5e7914d58b7f8cac8e76fd5e574a80b08e","name":"general.css","res-type":"tela","type":"style"},
{"scid":"997c81642c2ae43784d17ce2f061e492532ac5cf9e003f572fbedee5e8e206ac","name":"menu1.html","res-type":"tela","type":"html"},
{"scid":"a71b83a73ed27964f2bb8dd99a370e605ae81016238202fb82f4cf0f61151a9c","name":"home.html","res-type":"tela","type":"html"},
];
resourceList['nfatool'] = [
{"scid":"97dbc4ff028762e426e4ad411eea9a5e7914d58b7f8cac8e76fd5e574a80b08e","name":"general.css","res-type":"tela","type":"style"},
{"scid":"997c81642c2ae43784d17ce2f061e492532ac5cf9e003f572fbedee5e8e206ac","name":"menu1.html","res-type":"tela","type":"html"},
{"scid":"92ca1376279c4bdb1b40a54003b989d1c4a1b06fa74a7d16db6a81ebe9a4e7ac","name":"nfatool.html","res-type":"tela","type":"html"},
{"scid":"92bbb2a39422e6a93e319d60e0a28c5259a0cc349f689285bd8b712d1f61eee9","name":"nfatool.js","res-type":"tela","type":"script"},
];
resourceList['nfaloader'] = [
{"scid":"97dbc4ff028762e426e4ad411eea9a5e7914d58b7f8cac8e76fd5e574a80b08e","name":"general.css","res-type":"tela","type":"style"},
{"scid":"997c81642c2ae43784d17ce2f061e492532ac5cf9e003f572fbedee5e8e206ac","name":"menu1.html","res-type":"tela","type":"html"},
{"scid":"b292010b2830f467a3314c635c85c075ad2adb06e10cc43cea825d564cb0d391","name":"nfaloader.html","res-type":"tela","type":"html"},
{"scid":"c37de17fbf3b2f048ce53596f36ba725d1935edfa93973cb7248828e480367eb","name":"nfaloader.js","res-type":"tela","type":"script"},
];
return resourceList[location];
}
var resources;
var socket_response = 0;
function setResources(){
resources = getResourceList();
if(typeof resources ==='undefined'){
document.body.innerHTML = "<h1>Not Found</h1><a href='/'>Home</a>";
}
function socketListener(event) {
console.log("Content message Recieved");
var lastObj = JSON.parse(event.data);
if(typeof lastObj.result === 'undefined' ){
alert("Error Retrieving Smart Contract");
return;
}
if(typeof lastObj.result.code !== 'undefined' && socket_response < resources.length && lastObj.result.code.includes('STORE("docType", "TELA') ){
let resource = resources[socket_response++];
let html = lastObj.result.code.split('/*', 2)[1];
resource_content = html.split('*/', 2)[0];
if(resource.type == 'html'){
document.body.innerHTML = document.body.innerHTML + resource_content;
}else if(resource.type == 'style' || resource.type == 'script'){
let ele = document.createElement(resource.type);
ele.textContent = resource_content;
ele.classList.add("page");
document.head.appendChild(ele);
}
if(socket_response < resources.length ){
getSC(resources[socket_response]);
}else{
socket_response = 0;
socket.removeEventListener("message", socketListener);
}
}
}
socket.addEventListener("message", socketListener);
//Start loading
getSC(resources[0]);
function getSC(resource){
let json = {};
json.jsonrpc = "2.0";
json.id = "1";
json.method = "DERO.GetSC";
json.params = {};
json.params.scid = resource.scid;
json.params.code = true;
json.params.variables = true;
sendData(json);
}
}'] |