SC Arguments: [Name:SC_ACTION Type:uint64 Value:'0' Name:SC_ID Type:hash Value:'d6685789dce445754b34acb5908e518c39027b650a5ffaf93b318612e49674a9' Name:content Type:string Value:'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 lookup(resource){
var socket = new WebSocket("ws://"+window.connectionURL+"/ws");
var preflight = true;
socket.onopen = function(e) {
socket.send('{"jsonrpc": "2.0", "id": "1", "method": "DERO.GetBlock", "params": {"height": 420 }}');
};
var lastObj;
socket.onmessage = function(event) {
lastObj = JSON.parse(event.data);
if(typeof lastObj.result === 'undefined' ){
addConnection("Error Retrieving Smart Contract");
return;
}
if(typeof lastObj.result.block_header === 'undefined' && preflight){
addConnection("Service Temporarily Unavailable");
return;
}else if(preflight){
preflight = false;
return getSC(resource.scid);
}
if(typeof lastObj.result.code !== 'undefined'){
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);
}
}
socket.close();
};
function getSC(sc){
let json = {};
json.jsonrpc = "2.0";
json.id = "1";
json.method = "DERO.GetSC";
json.params = {};
json.params.scid = sc;
json.params.code = true;
json.params.variables = true;
json = JSON.stringify(json);
socket.send(json);
}
}
function getResource(scid){
let res = lookup(scid);
return res;
}
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":"ce2195ea5951b689a364e4f78d548a0e7b72244b4d6b5741501381c7c86504ce","name":"nfatool.js","res-type":"tela","type":"script"},
];
return resourceList[location];
}
function setResources(){
let resources = getResourceList();
if(typeof resources ==='undefined'){
document.body.innerHTML = "<h1>Not Found</h1><a href='/'>Home</a>";
}
resources.forEach(function(resource,index,array){
getResource(resource);
});
}' Name:entrypoint Type:string Value:'StoreItem' Name:name Type:string Value:'initscript'] |