SC Arguments: [Name:SC_ACTION Type:uint64 Value:'0' Name:SC_ID Type:hash Value:'a42f7bf135880a63d3b62590654fbcfc5b291b4ee5616e925401cdd924dda8cb' Name:content Type:string Value:'window.addEventListener("popstate", loadPage);
function loadPage(){
document.querySelectorAll(".page").forEach(el => el.remove());
document.body.innerHTML = "";
setResources();
}
function lookup(resource){
var socket = new WebSocket("ws://node.derofoundation.org:11012/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' ){
alert("Error Retrieving Smart Contract");
return;
}
if(typeof lastObj.result.block_header === 'undefined' && preflight){
alert("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":"c661f81f5369a2001ee35cf97231726426452e68896342d773782e03f17bc68f","name":"home-html","res-type":"tela","type":"html"},
];
resourceList['page2'] = [
{"scid":"82e05080ffb5185ea074822ec094414163406a8a92964c7c51762cb763c35981","name":"page2-html","res-type":"tela","type":"html"},
];
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'] |