SC CODE: Function InitializePrivate() Uint64
10 IF init() == 0 THEN GOTO 30
20 RETURN 1
30 STORE("nameHdr", "nfaloader.js")
31 STORE("descrHdr", "Scripts for NFA loader")
32 STORE("iconURLHdr", "")
33 STORE("dURL", "webguy.tools.nfaloader.js")
34 STORE("docType", "TELA-JS-1")
35 STORE("subDir", "")
36 STORE("fileCheckC", "9bc93b729dd2747deb080153747e921db0e2b924fcab336005ac810d5ac1e22")
37 STORE("fileCheckS", "1df96a6f2ba924fc766c20e4aef5c1bc9bb60ec1c0948b33f1cb2263acda8f75")
100 RETURN 0
End Function
Function init() Uint64
10 IF EXISTS("owner") == 0 THEN GOTO 30
20 RETURN 1
30 STORE("owner", address())
50 STORE("docVersion", "1.0.0")
60 STORE("hash", HEX(TXID()))
70 STORE("likes", 0)
80 STORE("dislikes", 0)
100 RETURN 0
End Function
Function address() String
10 DIM s as String
20 LET s = SIGNER()
30 IF IS_ADDRESS_VALID(s) THEN GOTO 50
40 RETURN "anon"
50 RETURN ADDRESS_STRING(s)
End Function
Function Rate(r Uint64) Uint64
10 DIM addr as String
15 LET addr = address()
16 IF r < 100 && EXISTS(addr) == 0 && addr != "anon" THEN GOTO 30
20 RETURN 1
30 STORE(addr, ""+r+"_"+BLOCK_HEIGHT())
40 IF r < 50 THEN GOTO 70
50 STORE("likes", LOAD("likes")+1)
60 RETURN 0
70 STORE("dislikes", LOAD("dislikes")+1)
100 RETURN 0
End Function
/*
function program(){
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;
for(var index in list) {
if (list.hasOwnProperty(index)) {
indexer++;
scids.push(index);
}
}
receive = indexer;
}
socket.removeEventListener("message", nfaSocketListener1);
socket.removeEventListener("message", nfaSocketListener);
socket.addEventListener("message", nfaSocketListener);
};
function execute(){
limit();
if(scids.length== 0){
socket.addEventListener("message", nfaSocketListener1);
getSCs();
}else if(!limiting){
getSC(scids[indexer--]);
}
}
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){
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+'">'+scids[indexer + 1];
}
function hexToUtf8(s) {
return decodeURIComponent(
s.replace(/\s+/g, '') // remove spaces
.replace(/[0-9a-f]{2}/g, '%$&') // add '%' before each 2 characters
);
}
lastObj = JSON.parse(event.data);
let res = lastObj.result;
if(typeof res.code !== 'undefined'){
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]);
}
});
if(fields[0].value !=""){
render(res.code);
}
}
}
limit();
};
let ms = 100;
alertTimerId =0;
function myFunction() {
timer = secs;
clearTimeout(alertTimerId);
alertTimerId = setTimeout(doTime, ms);
};
var pausebutton = document.getElementById('pause');
pausebutton.addEventListener('click', function(event) {
paused = !paused;
if(paused){
if(indexer === receive){socket.removeEventListener("message", nfaSocketListener);}
pausebutton.innerText ="Paused";
clearTimeout(alertTimerId);
clearInterval(running);
}else{
socket.removeEventListener("message", nfaSocketListener);
socket.addEventListener("message", nfaSocketListener);
pausebutton.innerText ="Pause";
running = setInterval(runit, secs * ms);
myFunction();
}
});
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");
}
});
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 IF init() == 0 THEN GOTO 30
20 RETURN 1
30 STORE("nameHdr", "nfaloader.js")
31 STORE("descrHdr", "Scripts for NFA loader")
32 STORE("iconURLHdr", "")
33 STORE("dURL", "webguy.tools.nfaloader.js")
34 STORE("docType", "TELA-JS-1")
35 STORE("subDir", "")
36 STORE("fileCheckC", "9bc93b729dd2747deb080153747e921db0e2b924fcab336005ac810d5ac1e22")
37 STORE("fileCheckS", "1df96a6f2ba924fc766c20e4aef5c1bc9bb60ec1c0948b33f1cb2263acda8f75")
100 RETURN 0
End Function
Function init() Uint64
10 IF EXISTS("owner") == 0 THEN GOTO 30
20 RETURN 1
30 STORE("owner", address())
50 STORE("docVersion", "1.0.0")
60 STORE("hash", HEX(TXID()))
70 STORE("likes", 0)
80 STORE("dislikes", 0)
100 RETURN 0
End Function
Function address() String
10 DIM s as String
20 LET s = SIGNER()
30 IF IS_ADDRESS_VALID(s) THEN GOTO 50
40 RETURN "anon"
50 RETURN ADDRESS_STRING(s)
End Function
Function Rate(r Uint64) Uint64
10 DIM addr as String
15 LET addr = address()
16 IF r < 100 && EXISTS(addr) == 0 && addr != "anon" THEN GOTO 30
20 RETURN 1
30 STORE(addr, ""+r+"_"+BLOCK_HEIGHT())
40 IF r < 50 THEN GOTO 70
50 STORE("likes", LOAD("likes")+1)
60 RETURN 0
70 STORE("dislikes", LOAD("dislikes")+1)
100 RETURN 0
End Function
/*
function program(){
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;
for(var index in list) {
if (list.hasOwnProperty(index)) {
indexer++;
scids.push(index);
}
}
receive = indexer;
}
socket.removeEventListener("message", nfaSocketListener1);
socket.removeEventListener("message", nfaSocketListener);
socket.addEventListener("message", nfaSocketListener);
};
function execute(){
limit();
if(scids.length== 0){
socket.addEventListener("message", nfaSocketListener1);
getSCs();
}else if(!limiting){
getSC(scids[indexer--]);
}
}
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){
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+'">'+scids[indexer + 1];
}
function hexToUtf8(s) {
return decodeURIComponent(
s.replace(/\s+/g, '') // remove spaces
.replace(/[0-9a-f]{2}/g, '%$&') // add '%' before each 2 characters
);
}
lastObj = JSON.parse(event.data);
let res = lastObj.result;
if(typeof res.code !== 'undefined'){
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]);
}
});
if(fields[0].value !=""){
render(res.code);
}
}
}
limit();
};
let ms = 100;
alertTimerId =0;
function myFunction() {
timer = secs;
clearTimeout(alertTimerId);
alertTimerId = setTimeout(doTime, ms);
};
var pausebutton = document.getElementById('pause');
pausebutton.addEventListener('click', function(event) {
paused = !paused;
if(paused){
if(indexer === receive){socket.removeEventListener("message", nfaSocketListener);}
pausebutton.innerText ="Paused";
clearTimeout(alertTimerId);
clearInterval(running);
}else{
socket.removeEventListener("message", nfaSocketListener);
socket.addEventListener("message", nfaSocketListener);
pausebutton.innerText ="Pause";
running = setInterval(runit, secs * ms);
myFunction();
}
});
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");
}
});
function exit(){
clearTimeout(alertTimerId);
clearInterval(running);
}
runit();
}
var loadbutton = document.getElementById('loadnfas');
loadbutton.addEventListener('click', function(event) {
loadbutton.parentNode.removeChild(loadbutton);
program();
});
*/'] |