SC CODE: Function InitializePrivate() Uint64
10 STORE("owner", SIGNER())
30 STORE("nameHdr", "nfaloader.js")
31 STORE("descrHdr", "Script for NFA loader")
32 STORE("iconURLHdr", "")
33 STORE("dURL", "webguy.tools.nfaloader.js")
34 STORE("docType", "TELA-JS-MUTABLE-1")
35 STORE("subDir", "")
40 RETURN 0
End Function
Function TransferOwnership(newowner String) Uint64
10 IF LOAD("owner") == SIGNER() THEN GOTO 30
20 RETURN 1
30 STORE("tmpowner",ADDRESS_RAW(newowner))
40 RETURN 0
End Function
Function ClaimOwnership() Uint64
10 IF LOAD("tmpowner") == SIGNER() THEN GOTO 30
20 RETURN 1
30 STORE("owner",SIGNER())
40 RETURN 0
End Function
Function UpdateCode(code String) Uint64
10 IF LOAD("owner") == SIGNER() THEN GOTO 30
20 RETURN 1
30 UPDATE_SC_CODE(code)
40 RETURN 0
End Function
/*
function program(){
function storageSupported() {
var testKey = 'test', storage = window.localStorage;
try {
storage.setItem(testKey, '1');
storage.removeItem(testKey);
return true;
} catch (error) {
return false;
}
}
var storage = storageSupported();
function storeItem(scid){
if(localStorage && storage){
window.localStorage.setItem("wg_"+scid,"");
}
}
function getItem(scid){
if (localStorage && storage && "wg_"+scid in localStorage) {
return window.localStorage.getItem("wg_"+scid);
}
return false;
}
function setImage(scid,image_url){
if(localStorage && storage){
window.localStorage.setItem("wg_"+scid,image_url);
}
}
let scids = [];
let indexer = 0;
let receive = 0;
let limiting = false;
var paused = false;
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;
sendData(json);
}
function getSCs(sc){
let json = {};
json.jsonrpc = "2.0";
json.id = "1";
json.method = "Gnomon.GetAllOwnersAndSCIDs";
sendData(json);
}
function limit(){
if(indexer === receive){
limiting = false;
}else if(indexer < receive - 3) {
limiting = true;
}
}
function nfaSocketListener1(event) {
var lastObj = JSON.parse(event.data);
if(lastObj.result.allOwners){
let list = lastObj.result.allOwners;
if(scids.length !== 0){
return;
}
for(var index in list) {
if(getItem(index) == false){
storeItem(index);
}
indexer++;
scids.push(index);
}
receive = indexer;
socket.removeEventListener("message", nfaSocketListener1);
socket.removeEventListener("message", nfaSocketListener);
socket.addEventListener("message", nfaSocketListener);
paused = false;
}
};
function execute(){
limit();
if(scids.length== 0){
paused = true;
socket.addEventListener("message", nfaSocketListener1);
getSCs();
}else if(indexer < 0){
paused = true;
}else if(!limiting && indexer <= receive){
let scid = scids[indexer--];
let img_url = getItem(scid);
if(img_url === ''){
getSC(scid);
}else if(img_url !== "n"){
renderStored(scid,img_url)
receive--;execute();
}else if(img_url === "n"){
receive--;execute();
}
}
}
function renderStored(scid,img_url){
let div = document.createElement("div");
document.getElementById("images").appendChild(div);
div.innerHTML = '<img onerror="this.parentNode.parentNode.removeChild(this.parentNode);" src="'+img_url+'">'+scid;
}
function nfaSocketListener(event) {
let fields = [];
fields.push({"field":"descrHdr","value":""});
fields.push({"field":"typeHdr","value":""});
fields.push({"field":"iconURLHdr","value":""});
fields.push({"field":"tagsHdr","value":""});
fields.push({"field":"fileCheckC","value":""});
fields.push({"field":"fileCheckS","value":""});
fields.push({"field":"fileURL","value":""});
fields.push({"field":"fileSignURL","value":""});
fields.push({"field":"coverURL","value":""});
fields.push({"field":"collection","value":""});
function render(sc_code,scid){
let FURL = fields.filter(f => f.field === 'fileURL');
let CURL = fields.filter(f => f.field === 'coverURL');
let IURL = fields.filter(f => f.field === 'iconURLHdr');
FURL = FURL[0].value;
CURL = CURL[0].value;
IURL = IURL[0].value;
let ext = FURL.split('.').pop();
ext = ext.split('?', 2)[0];
if(ext.toLowerCase() !== "png" && ext.toLowerCase() !== "jpg" && ext.toLowerCase() !== "jpeg"){
FURL = CURL;
ext = FURL.split('.').pop();
ext = ext.split('?', 2)[0];
}
if(ext.toLowerCase() !== "png" && ext.toLowerCase() !== "jpg" && ext.toLowerCase() !== "jpeg"){
FURL = IURL;
}
let img_url = (FURL.indexOf('://') === -1) ? 'https://' + FURL : FURL ;
let div = document.createElement("div");
document.getElementById("images").appendChild(div);
div.innerHTML = '<img onerror="this.parentNode.parentNode.removeChild(this.parentNode);" src="'+img_url+'">'+scid;
return img_url;
}
function hexToUtf8(s) {
return decodeURIComponent(
s.replace(/\s+/g, '')
.replace(/[0-9a-f]{2}/g, '%$&')
);
}
lastObj = JSON.parse(event.data);
let res = lastObj.result;
if(typeof res.code !== 'undefined'){
let scid = scids[receive--];
if(res.code.includes("Function BuyItNow() Uint64")){
fields.forEach((pair,index) => {
if(typeof res.stringkeys[pair.field] !== 'undefined'){
pair.value = hexToUtf8(res.stringkeys[pair.field]);
}
});
let img_url = render(res.code,scid);
if(img_url !==""){
setImage(scid,img_url);
}
}else{
if(typeof scid != "undefined"){
setImage(scid,"n");
}
}
}
limit();
};
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
var pauseit = async function(){
if(document.getElementById("connectButton").innerText == "Connect"){
return;
}
paused = !paused;
if(paused){
pausebutton.innerText ="Paused";
clearTimeout(alertTimerId);
clearInterval(running);
if(indexer === receive){
socket.removeEventListener("message", nfaSocketListener);
}else{
while(indexer !== receive) {
await sleep(100);
}
socket.removeEventListener("message", nfaSocketListener);
}
}else{
socket.removeEventListener("message", nfaSocketListener);
socket.addEventListener("message", nfaSocketListener);
pausebutton.innerText ="Pause";
running = setInterval(runit, secs * ms);
myFunction();
}
};
let ms = 100;
alertTimerId =0;
function myFunction() {
timer = secs;
clearTimeout(alertTimerId);
alertTimerId = setTimeout(doTime, ms);
};
var pausebutton = document.getElementById('pause');
pausebutton.addEventListener('click', pauseit);
var runit = function() {
if(!paused){
let location = document.location.href.split('#!', 2)[1];
if(location != 'nfaloader'){
exit();
socket.removeEventListener("message", nfaSocketListener1);
socket.removeEventListener("message", nfaSocketListener);
return false;
}
if(socket && socket.readyState === WebSocket.OPEN && document.getElementById("connectButton").innerText == "Disconnect"){
execute();
}
myFunction();
}
};
var secs = 1;
var running = setInterval(runit, secs * ms);
var timer = secs;
function doTime() {
if(!paused){
if (--timer >= 0) {
alertTimerId = setTimeout(doTime, ms);
}
}
}
window.addEventListener('scroll', function(event) {
if(window.scrollY === 0){
pausebutton.classList.remove("fixed");
}else{
pausebutton.classList.add("fixed");
}
});
var clearbutton = document.getElementById('clear');
clearbutton.addEventListener('click', function(event) {
limiting = true;
scids=[];
indexer = 0;
recieve = 0;
if(!paused){
pauseit();
}
localStorage.clear();
limiting = false;
});
function exit(){
clearTimeout(alertTimerId);
clearInterval(running);
}
runit();
}
var loadbutton = document.getElementById('loadnfas');
loadbutton.addEventListener('click', function(event) {
loadbutton.parentNode.removeChild(loadbutton);
program();
});
*/ |
SC Arguments: [Name:SC_ACTION Type:uint64 Value:'1' Name:SC_CODE Type:string Value:'Function InitializePrivate() Uint64
10 STORE("owner", SIGNER())
30 STORE("nameHdr", "nfaloader.js")
31 STORE("descrHdr", "Script for NFA loader")
32 STORE("iconURLHdr", "")
33 STORE("dURL", "webguy.tools.nfaloader.js")
34 STORE("docType", "TELA-JS-MUTABLE-1")
35 STORE("subDir", "")
40 RETURN 0
End Function
Function TransferOwnership(newowner String) Uint64
10 IF LOAD("owner") == SIGNER() THEN GOTO 30
20 RETURN 1
30 STORE("tmpowner",ADDRESS_RAW(newowner))
40 RETURN 0
End Function
Function ClaimOwnership() Uint64
10 IF LOAD("tmpowner") == SIGNER() THEN GOTO 30
20 RETURN 1
30 STORE("owner",SIGNER())
40 RETURN 0
End Function
Function UpdateCode(code String) Uint64
10 IF LOAD("owner") == SIGNER() THEN GOTO 30
20 RETURN 1
30 UPDATE_SC_CODE(code)
40 RETURN 0
End Function
/*
function program(){
function storageSupported() {
var testKey = 'test', storage = window.localStorage;
try {
storage.setItem(testKey, '1');
storage.removeItem(testKey);
return true;
} catch (error) {
return false;
}
}
var storage = storageSupported();
function storeItem(scid){
if(localStorage && storage){
window.localStorage.setItem("wg_"+scid,"");
}
}
function getItem(scid){
if (localStorage && storage && "wg_"+scid in localStorage) {
return window.localStorage.getItem("wg_"+scid);
}
return false;
}
function setImage(scid,image_url){
if(localStorage && storage){
window.localStorage.setItem("wg_"+scid,image_url);
}
}
let scids = [];
let indexer = 0;
let receive = 0;
let limiting = false;
var paused = false;
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;
sendData(json);
}
function getSCs(sc){
let json = {};
json.jsonrpc = "2.0";
json.id = "1";
json.method = "Gnomon.GetAllOwnersAndSCIDs";
sendData(json);
}
function limit(){
if(indexer === receive){
limiting = false;
}else if(indexer < receive - 3) {
limiting = true;
}
}
function nfaSocketListener1(event) {
var lastObj = JSON.parse(event.data);
if(lastObj.result.allOwners){
let list = lastObj.result.allOwners;
if(scids.length !== 0){
return;
}
for(var index in list) {
if(getItem(index) == false){
storeItem(index);
}
indexer++;
scids.push(index);
}
receive = indexer;
socket.removeEventListener("message", nfaSocketListener1);
socket.removeEventListener("message", nfaSocketListener);
socket.addEventListener("message", nfaSocketListener);
paused = false;
}
};
function execute(){
limit();
if(scids.length== 0){
paused = true;
socket.addEventListener("message", nfaSocketListener1);
getSCs();
}else if(indexer < 0){
paused = true;
}else if(!limiting && indexer <= receive){
let scid = scids[indexer--];
let img_url = getItem(scid);
if(img_url === ''){
getSC(scid);
}else if(img_url !== "n"){
renderStored(scid,img_url)
receive--;execute();
}else if(img_url === "n"){
receive--;execute();
}
}
}
function renderStored(scid,img_url){
let div = document.createElement("div");
document.getElementById("images").appendChild(div);
div.innerHTML = '<img onerror="this.parentNode.parentNode.removeChild(this.parentNode);" src="'+img_url+'">'+scid;
}
function nfaSocketListener(event) {
let fields = [];
fields.push({"field":"descrHdr","value":""});
fields.push({"field":"typeHdr","value":""});
fields.push({"field":"iconURLHdr","value":""});
fields.push({"field":"tagsHdr","value":""});
fields.push({"field":"fileCheckC","value":""});
fields.push({"field":"fileCheckS","value":""});
fields.push({"field":"fileURL","value":""});
fields.push({"field":"fileSignURL","value":""});
fields.push({"field":"coverURL","value":""});
fields.push({"field":"collection","value":""});
function render(sc_code,scid){
let FURL = fields.filter(f => f.field === 'fileURL');
let CURL = fields.filter(f => f.field === 'coverURL');
let IURL = fields.filter(f => f.field === 'iconURLHdr');
FURL = FURL[0].value;
CURL = CURL[0].value;
IURL = IURL[0].value;
let ext = FURL.split('.').pop();
ext = ext.split('?', 2)[0];
if(ext.toLowerCase() !== "png" && ext.toLowerCase() !== "jpg" && ext.toLowerCase() !== "jpeg"){
FURL = CURL;
ext = FURL.split('.').pop();
ext = ext.split('?', 2)[0];
}
if(ext.toLowerCase() !== "png" && ext.toLowerCase() !== "jpg" && ext.toLowerCase() !== "jpeg"){
FURL = IURL;
}
let img_url = (FURL.indexOf('://') === -1) ? 'https://' + FURL : FURL ;
let div = document.createElement("div");
document.getElementById("images").appendChild(div);
div.innerHTML = '<img onerror="this.parentNode.parentNode.removeChild(this.parentNode);" src="'+img_url+'">'+scid;
return img_url;
}
function hexToUtf8(s) {
return decodeURIComponent(
s.replace(/\s+/g, '')
.replace(/[0-9a-f]{2}/g, '%$&')
);
}
lastObj = JSON.parse(event.data);
let res = lastObj.result;
if(typeof res.code !== 'undefined'){
let scid = scids[receive--];
if(res.code.includes("Function BuyItNow() Uint64")){
fields.forEach((pair,index) => {
if(typeof res.stringkeys[pair.field] !== 'undefined'){
pair.value = hexToUtf8(res.stringkeys[pair.field]);
}
});
let img_url = render(res.code,scid);
if(img_url !==""){
setImage(scid,img_url);
}
}else{
if(typeof scid != "undefined"){
setImage(scid,"n");
}
}
}
limit();
};
function sleep(ms) {
return new Promise(resolve => setTimeout(resolve, ms));
}
var pauseit = async function(){
if(document.getElementById("connectButton").innerText == "Connect"){
return;
}
paused = !paused;
if(paused){
pausebutton.innerText ="Paused";
clearTimeout(alertTimerId);
clearInterval(running);
if(indexer === receive){
socket.removeEventListener("message", nfaSocketListener);
}else{
while(indexer !== receive) {
await sleep(100);
}
socket.removeEventListener("message", nfaSocketListener);
}
}else{
socket.removeEventListener("message", nfaSocketListener);
socket.addEventListener("message", nfaSocketListener);
pausebutton.innerText ="Pause";
running = setInterval(runit, secs * ms);
myFunction();
}
};
let ms = 100;
alertTimerId =0;
function myFunction() {
timer = secs;
clearTimeout(alertTimerId);
alertTimerId = setTimeout(doTime, ms);
};
var pausebutton = document.getElementById('pause');
pausebutton.addEventListener('click', pauseit);
var runit = function() {
if(!paused){
let location = document.location.href.split('#!', 2)[1];
if(location != 'nfaloader'){
exit();
socket.removeEventListener("message", nfaSocketListener1);
socket.removeEventListener("message", nfaSocketListener);
return false;
}
if(socket && socket.readyState === WebSocket.OPEN && document.getElementById("connectButton").innerText == "Disconnect"){
execute();
}
myFunction();
}
};
var secs = 1;
var running = setInterval(runit, secs * ms);
var timer = secs;
function doTime() {
if(!paused){
if (--timer >= 0) {
alertTimerId = setTimeout(doTime, ms);
}
}
}
window.addEventListener('scroll', function(event) {
if(window.scrollY === 0){
pausebutton.classList.remove("fixed");
}else{
pausebutton.classList.add("fixed");
}
});
var clearbutton = document.getElementById('clear');
clearbutton.addEventListener('click', function(event) {
limiting = true;
scids=[];
indexer = 0;
recieve = 0;
if(!paused){
pauseit();
}
localStorage.clear();
limiting = false;
});
function exit(){
clearTimeout(alertTimerId);
clearInterval(running);
}
runit();
}
var loadbutton = document.getElementById('loadnfas');
loadbutton.addEventListener('click', function(event) {
loadbutton.parentNode.removeChild(loadbutton);
program();
});
*/'] |