Mon Aug 26 14:20:28 CST 2019 Source Update...
This commit is contained in:
@@ -25,10 +25,7 @@
|
||||
var CONFIG_DATA={};
|
||||
var NumDappGet=0;
|
||||
var NumDappInfo=0;
|
||||
|
||||
// var arr = new Uint8Array(6);
|
||||
// window.crypto.getRandomValues(arr);
|
||||
// var glSession=GetHexFromArr(arr);
|
||||
var DAPPPREFIX="DAPP-";
|
||||
|
||||
|
||||
//DAPP TRANSFER
|
||||
@@ -67,12 +64,12 @@
|
||||
}
|
||||
case "setstorage":
|
||||
{
|
||||
Storage.setItem("DAPP-"+DapNumber+"-"+Data.Key,JSON.stringify(Data.Value));
|
||||
Storage.setItem(DAPPPREFIX+DapNumber+"-"+Data.Key,JSON.stringify(Data.Value));
|
||||
break;
|
||||
}
|
||||
case "getstorage":
|
||||
{
|
||||
Data.Value=Storage.getItem("DAPP-"+DapNumber+"-"+Data.Key);
|
||||
Data.Value=Storage.getItem(DAPPPREFIX+DapNumber+"-"+Data.Key);
|
||||
if(Data.Value)
|
||||
Data.Value=JSON.parse(Data.Value);
|
||||
SendMessage(Data);
|
||||
@@ -80,12 +77,12 @@
|
||||
}
|
||||
case "setcommon":
|
||||
{
|
||||
Storage.setItem("DAPP-"+Data.Key,JSON.stringify(Data.Value));
|
||||
Storage.setItem(DAPPPREFIX+Data.Key,JSON.stringify(Data.Value));
|
||||
break;
|
||||
}
|
||||
case "getcommon":
|
||||
{
|
||||
Data.Value=Storage.getItem("DAPP-"+Data.Key);
|
||||
Data.Value=Storage.getItem(DAPPPREFIX+Data.Key);
|
||||
if(Data.Value)
|
||||
Data.Value=JSON.parse(Data.Value);
|
||||
SendMessage(Data);
|
||||
@@ -322,17 +319,22 @@
|
||||
SetBlockChainConstant(SetData);
|
||||
document.title=SMART.Name;
|
||||
|
||||
if(CONFIG_DATA.NETWORK!=="TERA-MAIN")
|
||||
DAPPPREFIX="DAPP-"+CONFIG_DATA.NETWORK;
|
||||
|
||||
InitMenu();
|
||||
|
||||
|
||||
var HTMLBlock=BASE_ACCOUNT.SmartState.HTMLBlock;
|
||||
var HTMLTr=BASE_ACCOUNT.SmartState.HTMLTr;
|
||||
if(!glDebugPath && HTMLBlock)
|
||||
if(HTMLBlock && !glDebugPath)
|
||||
{
|
||||
console.log("Load HTML from: /file/"+HTMLBlock+"/"+HTMLTr);
|
||||
GetData("DappBlockFile",{BlockNum:HTMLBlock,TrNum:HTMLTr}, function (SetData)
|
||||
{
|
||||
if(SetData && SetData.result)
|
||||
{
|
||||
CreateFrame(SetData);
|
||||
CreateFrame(SetData,0);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -342,7 +344,7 @@
|
||||
{
|
||||
if(SetData && SetData.result)
|
||||
{
|
||||
CreateFrame(SetData);
|
||||
CreateFrame(SetData,0);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -364,16 +366,17 @@
|
||||
|
||||
if(isMobile())
|
||||
SetMobileMode();
|
||||
|
||||
|
||||
}
|
||||
|
||||
function CreateFrame(SetData)
|
||||
function CreateFrame(SetData,bTrust)
|
||||
{
|
||||
|
||||
var SriptLW="";
|
||||
if(MainServer)
|
||||
{
|
||||
var StrPath=GetProtocolServerPath(MainServer);
|
||||
//console.log("StrPath:"+StrPath);
|
||||
//console.log("WAS:\n"+SetData.Body);
|
||||
|
||||
//поддрежка старого кода dapp (после обновления dapp этот код возможно будет удален)
|
||||
SetData.Body=SetData.Body.replace(/.\/CSS\/[0-9a-z_-]+.css\">/g,StrPath+"$&");
|
||||
@@ -390,8 +393,10 @@
|
||||
|
||||
|
||||
var iframe = document.createElement('iframe');
|
||||
iframe.id="idFrame";
|
||||
iframe.name = 'dapp';
|
||||
iframe.sandbox="allow-scripts";
|
||||
|
||||
SetData.Body='\
|
||||
<meta charset="UTF-8">\
|
||||
<meta http-equiv="X-Frame-Options" value="sameorigin">\
|
||||
@@ -423,25 +428,41 @@
|
||||
if(!idInstallApp)
|
||||
idInstallApp=setInterval(RunCheckInstall,2000);
|
||||
}
|
||||
|
||||
function GetWalletLink()
|
||||
{
|
||||
if(MainServer)
|
||||
return "./web-wallet.html#TabAccounts";
|
||||
else
|
||||
if(Storage.getItem("BIGWALLET"))
|
||||
return "/wallet.html#TabAccounts";
|
||||
else
|
||||
return "/web-wallet.html#TabAccounts";
|
||||
}
|
||||
|
||||
function RunCheckInstall()
|
||||
{
|
||||
if(CONFIG_DATA && CONFIG_DATA.ArrWallet && CONFIG_DATA.ArrWallet.length===0)
|
||||
{
|
||||
var StrRef;
|
||||
if(MainServer)
|
||||
StrRef='<A class="btcreate" href="./web-wallet.html#TabAccounts">Accounts</A>';
|
||||
StrRef='<A class="btcreate" href="'+GetWalletLink()+'">Accounts</A>';
|
||||
else
|
||||
{
|
||||
if(Storage.getItem("BIGWALLET"))
|
||||
StrRef='<A class="btcreate" href="/wallet.html#TabAccounts">Config</A>'
|
||||
StrRef='<A class="btcreate" href="'+GetWalletLink()+'">Config</A>'
|
||||
else
|
||||
StrRef='<A class="btcreate" href="/web-wallet.html#TabAccounts">Accounts</A>';
|
||||
StrRef='<A class="btcreate" href="'+GetWalletLink()+'">Accounts</A>';
|
||||
}
|
||||
|
||||
var Str='<DIV style="background-color: #c8ecff;">For install this app press: <button class="btcreate" onclick="InstallApp()">Create account</button> or goto '+StrRef+' tab and Set smart number <B>'+SMART.Num+'</B> to your account<DIV>';
|
||||
//var Str='<DIV style="background-color: #c8ecff;">For install this app press: <button class="btcreate" onclick="InstallApp()">Create account</button> or goto '+StrRef+' tab and Set smart number <B>'+SMART.Num+'</B> to your account<DIV>';
|
||||
var Str='<DIV style="background-color: #c8ecff;">For install this app press: <button class="btcreate" onclick="InstallApp()">Create account</button><DIV>';
|
||||
SetStatus(Str);
|
||||
}
|
||||
|
||||
}
|
||||
function OpenWalletPage()
|
||||
{
|
||||
window.open(GetWalletLink());
|
||||
}
|
||||
|
||||
//LIB
|
||||
@@ -463,7 +484,10 @@
|
||||
{
|
||||
var Data={};
|
||||
Data.cmd="OnEvent";
|
||||
Data.Description="Error: "+Item.text;
|
||||
if(isMobile())
|
||||
Data.Description=Item.text;
|
||||
else
|
||||
Data.Description="Error: "+Item.text;
|
||||
Data.Error=1;
|
||||
//console.log(JSON.stringify(Item));
|
||||
SendMessage(Data);
|
||||
@@ -471,6 +495,7 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function IsPrivateMode(PrivKeyStr)
|
||||
{
|
||||
if(PrivKeyStr && PrivKeyStr.length===64)
|
||||
@@ -484,7 +509,8 @@
|
||||
{
|
||||
var id = $("idStatus");
|
||||
id.innerHTML=Str;
|
||||
console.log(id.innerText);
|
||||
if(Str)
|
||||
console.log(id.innerText);
|
||||
}
|
||||
|
||||
function SetError(Str,bNoSound)
|
||||
@@ -542,32 +568,225 @@
|
||||
|
||||
}
|
||||
|
||||
function ResetDapp()
|
||||
{
|
||||
SetStatus("");
|
||||
DoNewSession();
|
||||
if(idInstallApp)
|
||||
{
|
||||
clearInterval(idInstallApp);
|
||||
idInstallApp=0;
|
||||
}
|
||||
}
|
||||
function RunDappFromFile()
|
||||
{
|
||||
CloseMenu();
|
||||
LoadDappFromFile();
|
||||
|
||||
}
|
||||
var WasLoadFromFile=0;
|
||||
function LoadDappFromFile()
|
||||
{
|
||||
$('idFile').onchange=function ()
|
||||
{
|
||||
ResetDapp();
|
||||
CreateFromFile();
|
||||
};
|
||||
$('idFile').click();
|
||||
}
|
||||
function ReloadDapp()
|
||||
{
|
||||
ResetDapp();
|
||||
|
||||
if(WasLoadFromFile)
|
||||
CreateFromFile();
|
||||
else
|
||||
window.location.reload();
|
||||
}
|
||||
function CreateFromFile()
|
||||
{
|
||||
var file = $("idFile").files[0];
|
||||
var reader = new FileReader();
|
||||
reader.onload = function()
|
||||
{
|
||||
WasLoadFromFile=1;
|
||||
var view = new Uint8Array(reader.result);
|
||||
var Str=Utf8ArrayToStr(view);
|
||||
if($("idFrame"))
|
||||
$("idFrame").outerHTML="";
|
||||
CreateFrame({Body:Str},1);
|
||||
$("idRunItem").innerText="Runing DApp from: "+file.name;
|
||||
}
|
||||
if(file)
|
||||
reader.readAsArrayBuffer(file);
|
||||
}
|
||||
|
||||
function InitMenu()
|
||||
{
|
||||
$("idCreateItem").innerText=$("idCreateItem").innerText.replace("NNN",SMART.Num);
|
||||
}
|
||||
var OpenMenu=0;
|
||||
function OnClickMenu()
|
||||
{
|
||||
DoVisibleMenu(!OpenMenu);
|
||||
}
|
||||
function CloseMenu()
|
||||
{
|
||||
DoVisibleMenu(0);
|
||||
}
|
||||
function DoVisibleMenu(SetMenu)
|
||||
{
|
||||
setTimeout(function ()
|
||||
{
|
||||
OpenMenu=SetMenu;
|
||||
$("idMenu").className="top "+(OpenMenu?"open":"close");
|
||||
},50);
|
||||
|
||||
}
|
||||
|
||||
window.onclick=function (t)
|
||||
{
|
||||
if(OpenMenu)
|
||||
{
|
||||
CloseMenu();
|
||||
}
|
||||
}
|
||||
window.onkeydown = function (e)
|
||||
{
|
||||
//ToLog("keyCode="+e.keyCode);
|
||||
switch (e.keyCode)
|
||||
{
|
||||
case 27:
|
||||
if(OpenMenu)
|
||||
{
|
||||
CloseMenu();
|
||||
}
|
||||
break;
|
||||
case 115:
|
||||
e.preventDefault();
|
||||
ReloadDapp();
|
||||
break;
|
||||
default:
|
||||
}
|
||||
};
|
||||
|
||||
</script>
|
||||
|
||||
<style>
|
||||
iframe
|
||||
:root
|
||||
{
|
||||
left:0;
|
||||
top: 20px;
|
||||
width: 100%;
|
||||
height: 97vh;
|
||||
border: 0;
|
||||
--colorMenu0: black;
|
||||
--colorMenu1: #8daab2;
|
||||
--colorMenu2: #86b0cb;
|
||||
|
||||
--colorMenu0: white;
|
||||
--colorMenu1: black;
|
||||
--colorMenu2: #343434;
|
||||
}
|
||||
|
||||
body
|
||||
{
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
}
|
||||
.top
|
||||
{
|
||||
z-index:20;
|
||||
position:fixed;
|
||||
top: 0;
|
||||
height:25px;
|
||||
margin: 0;
|
||||
text-align: center;
|
||||
}
|
||||
#idStatus
|
||||
{
|
||||
text-align: center;
|
||||
position:fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 90%;
|
||||
min-width: 90%;
|
||||
height:25px;
|
||||
padding: 5px 0 0 0;
|
||||
}
|
||||
#idMenu
|
||||
{
|
||||
z-index:30;
|
||||
right: 2px;
|
||||
min-width: 70px;
|
||||
max-width: 150px;
|
||||
color: var(--colorMenu0);
|
||||
background-color: var(--colorMenu1);
|
||||
cursor: pointer;
|
||||
padding: 5px 0 0 0;
|
||||
}
|
||||
#idMenuList
|
||||
{
|
||||
top: 30px;
|
||||
margin-right: 2px;
|
||||
}
|
||||
|
||||
#idMenu.open
|
||||
{
|
||||
width: 100px;
|
||||
min-width: 150px;
|
||||
}
|
||||
|
||||
.open
|
||||
{
|
||||
z-index:30;
|
||||
right: 0;
|
||||
width: 100px;
|
||||
min-width: 150px;
|
||||
cursor: pointer;
|
||||
}
|
||||
.close
|
||||
{
|
||||
width: 10%;
|
||||
min-width: 50px;
|
||||
}
|
||||
|
||||
.item
|
||||
{
|
||||
width: 100px;
|
||||
color: var(--colorMenu0);
|
||||
background-color: var(--colorMenu1);
|
||||
cursor: pointer;
|
||||
padding: 4px;
|
||||
margin: 0;
|
||||
margin-left: 5px;
|
||||
min-height: 24px;
|
||||
border: 1px solid #5a6c74;
|
||||
vertical-align: middle;
|
||||
|
||||
min-width: 130px;
|
||||
max-width: 130px;
|
||||
|
||||
}
|
||||
.item:hover
|
||||
{
|
||||
color: #ecb84e;
|
||||
background-color: var(--colorMenu2);
|
||||
}
|
||||
|
||||
#idMenu.close #idMenuList
|
||||
{
|
||||
display: none;
|
||||
}
|
||||
|
||||
#idFrame
|
||||
{
|
||||
z-index:10;
|
||||
position:fixed;
|
||||
left:0;
|
||||
top: 30px;
|
||||
width: 100%;
|
||||
height:18px;
|
||||
height: 97vh;
|
||||
border: 0;
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
background-color:white;
|
||||
}
|
||||
|
||||
.btcreate
|
||||
{
|
||||
height:18px;
|
||||
height:22px;
|
||||
background-color: #347867;
|
||||
color: white;
|
||||
cursor: pointer;
|
||||
@@ -577,23 +796,41 @@
|
||||
border: 1px solid gray;
|
||||
}
|
||||
|
||||
#idMenu.close
|
||||
{
|
||||
background-image: url('./PIC/down.png');
|
||||
background-repeat: no-repeat;
|
||||
background-size: 16px;
|
||||
background-position: right;
|
||||
}
|
||||
#idMenu.open
|
||||
{
|
||||
background-image: url('./PIC/up.png');
|
||||
background-repeat: no-repeat;
|
||||
background-size: 16px;
|
||||
background-position: right;
|
||||
}
|
||||
|
||||
|
||||
</style>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<DIV id="idStatus"></DIV>
|
||||
<DIV id="idStatus" class="top"></DIV>
|
||||
<DIV id="idMenu" class="top close" onclick="OnClickMenu()">Menu
|
||||
<div id="idMenuList" class="top open">
|
||||
<div class="item" onclick="OpenWalletPage();">Open wallet page</div>
|
||||
<div class="item" onclick="RunDappFromFile();" id="idRunItem">Load from file...</div>
|
||||
<div class="item" onclick="ReloadDapp();">F4: Rerun</div>
|
||||
<div class="item" onclick="InstallApp();" id="idCreateItem">Create account with DApp NNN</div>
|
||||
</div>
|
||||
</DIV>
|
||||
<input type="file" id="idFile" style="display: none">
|
||||
</body>
|
||||
</html>
|
||||
<script>
|
||||
var glDebugPath="";
|
||||
//glDebugPath="./dapp-smart/forum.html";
|
||||
//glDebugPath="./dapp-smart/DEX.html";
|
||||
//glDebugPath="./dapp-smart/OnlineStore.html";
|
||||
//glDebugPath="./dapp-smart/BTC-coin.html";
|
||||
//glDebugPath="./dapp-smart/static/miner-list.html";
|
||||
//glDebugPath="./dapp-smart/acc-control/RescueMoney.html";
|
||||
//glDebugPath="./dapp-smart/airdrop/page.html";
|
||||
//glDebugPath="./dapp-smart/ambassador/page.html";
|
||||
//glDebugPath="./dapp-smart/mixer/mixer.html";
|
||||
//{"HTMLBlock":2303846,"HTMLTr":0}
|
||||
</script>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user