SC Arguments: [Name:SC_ACTION Type:uint64 Value:'0' Name:SC_ID Type:hash Value:'d6685789dce445754b34acb5908e518c39027b650a5ffaf93b318612e49674a9' Name:content 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":"e2d090f06a19dfd009fdf09a32dff9e09e38a7eed19ffccf971cf066f01c729c","name":"general.css","res-type":"tela","type":"style"},
{"scid":"b197290616faaaeb8c2d4697ae4f396fd88fa3fa366a1e45362f3ed4b0943bc9","name":"menu1.html","res-type":"tela","type":"html"},
{"scid":"d7195ecd8dca020e801cdc350eb7d05ee6f6d68facae9e5fb2b4f23355b1c6d5","name":"home.html","res-type":"tela","type":"html"},
];
resourceList['nfatool'] = [
{"scid":"e2d090f06a19dfd009fdf09a32dff9e09e38a7eed19ffccf971cf066f01c729c","name":"general.css","res-type":"tela","type":"style"},
{"scid":"b197290616faaaeb8c2d4697ae4f396fd88fa3fa366a1e45362f3ed4b0943bc9","name":"menu1.html","res-type":"tela","type":"html"},
{"scid":"ca90bfa59a5c9bfdce6c55eb9582842970bc9200c03b5c19dadf31214913ee87","name":"nfatool.html","res-type":"tela","type":"html"},
{"scid":"fb2f4d825d31fea29577e1c3ac4e0770a7cbf6259b050d4775ecfb6b70ff68b8","name":"nfatool.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>";
}
var csocket = new WebSocket("ws://"+window.connectionURL+"/ws");
csocket.onopen = function(e) {
getSC(resources[0]);
};
csocket.onmessage = function(event) {
var lastObj = JSON.parse(event.data);
if(typeof lastObj.result === 'undefined' ){
addConnection("Error Retrieving Smart Contract");
return;
}
if(typeof lastObj.result.code !== 'undefined'){
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;
csocket.close();
}
}
};
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;
json = JSON.stringify(json);
csocket.send(json);
}
}' Name:entrypoint Type:string Value:'StoreItem' Name:name Type:string Value:'initscript'] |