1
0
forked from circlecloud/tera

sync: sync upstream code

Signed-off-by: MiaoWoo <admin@yumc.pw>
This commit is contained in:
MiaoWoo 2019-07-19 10:45:11 +08:00
parent 8dafeb2cf0
commit fd1b23a4c3
9 changed files with 141 additions and 64 deletions

View File

@ -2753,3 +2753,12 @@ iframe
cursor: pointer;
}
.btn--float
{
float: left;
width: 230px;
margin: 10px;
}

View File

@ -13,6 +13,17 @@ function $(id)
{
return document.getElementById(id);
};
window.Storage = {};
window.Storage.setItem = function (Key,Value)
{
if(window.localStorage)
localStorage.setItem(Key, Value);
};
window.Storage.getItem = function (Key)
{
if(window.localStorage)
return localStorage.getItem(Key);
};
var WALLET_KEY_NAME = "WALLET_KEY";
var WALLET_PUB_KEY_NAME = "WALLET_PUB_KEY";
if(!Math.log2)
@ -49,17 +60,6 @@ if(!String.prototype.padStart)
}
};
}
window.Storage = {};
window.Storage.setItem = function (Key,Value)
{
if(window.localStorage)
localStorage.setItem(Key, Value);
};
window.Storage.getItem = function (Key)
{
if(window.localStorage)
return localStorage.getItem(Key);
};
window.IsLocalClient = function ()
{
return (window.location.protocol.substr(0, 4) !== "http");
@ -937,7 +937,7 @@ function RetIconPath(Item,bCurrency)
return StrPath + '/file/' + Item.IconBlockNum + '/' + Item.IconTrNum;
}
else
return StrPath + "./PIC/blank.svg";
return StrPath + "/PIC/blank.svg";
};
function RetIconDapp(Item)
@ -1437,9 +1437,9 @@ function AddToInvoiceList(Item)
Storage.setItem("InvoiceList", JSON.stringify(arr));
};
function OpenDapps(Num,AccountNum)
function OpenDapps(Num,AccountNum,HTMLLength)
{
if(!Num)
if(!Num || !HTMLLength)
return ;
var StrPath = '/dapp/' + Num;
if(IsLocalClient())
@ -1801,8 +1801,8 @@ function ToLog(Str)
function InitMainServer()
{
var Str = localStorage["MainServer"];
if(Str && !localStorage["BIGWALLET"] && Str.substr(0, 1) === "{")
var Str = Storage.getItem("MainServer");
if(Str && !Storage.getItem("BIGWALLET") && Str.substr(0, 1) === "{")
{
MainServer = JSON.parse(Str);
}
@ -1823,13 +1823,13 @@ var KeyPasswordMap = {};
function InitWalletKeyName()
{
if(!localStorage["WALLET_KEY"])
if(!Storage.getItem("WALLET_KEY"))
{
localStorage["WALLET_KEY"] = localStorage["idPrivKey"];
Storage.setItem("WALLET_KEY", Storage.getItem("idPrivKey"));
}
if(!localStorage["WALLET_PUB_KEY"])
if(!Storage.getItem("WALLET_PUB_KEY"))
{
localStorage["WALLET_PUB_KEY"] = localStorage["idPubKey"];
Storage.setItem("WALLET_PUB_KEY", Storage.getItem("idPubKey"));
}
};
@ -1862,8 +1862,11 @@ function OpenWalletKey()
{
PubKeyStr = "";
}
sessionStorage[WALLET_KEY_NAME] = RetKey;
sessionStorage[WALLET_PUB_KEY_NAME] = PubKeyStr;
if(window.sessionStorage)
{
sessionStorage[WALLET_KEY_NAME] = RetKey;
sessionStorage[WALLET_PUB_KEY_NAME] = PubKeyStr;
}
if(!WALLET_PASSWORD)
Storage.setItem(WALLET_PUB_KEY_NAME, PubKeyStr);
return RetKey;
@ -1880,26 +1883,28 @@ function IsLockedWallet()
function GetPrivKey()
{
var Key = sessionStorage[WALLET_KEY_NAME];
var Key;
if(window.sessionStorage)
Key = sessionStorage[WALLET_KEY_NAME];
if(!Key)
Key = Storage.getItem(WALLET_KEY_NAME);
if(Key && typeof Key === "string" && Key.length >= 64)
return Key;
else
return "";
};
function GetPubKey()
{
var Key = sessionStorage[WALLET_PUB_KEY_NAME];
var Key;
if(window.sessionStorage)
Key = sessionStorage[WALLET_PUB_KEY_NAME];
if(!Key)
Key = Storage.getItem(WALLET_PUB_KEY_NAME);
if(Key && typeof Key === "string" && Key.length >= 64)
if(Key && typeof Key === "string" && Key.length >= 66)
return Key;
else
return "";
};
function SetPrivKey(StrPrivKey)
@ -1920,15 +1925,18 @@ function SetPrivKey(StrPrivKey)
Storage.setItem(WALLET_KEY_NAME, Key);
Storage.setItem(WALLET_PUB_KEY_NAME, StrPubKey);
Storage.setItem("WALLET_PUB_KEY_MAIN", StrPubKey);
sessionStorage[WALLET_KEY_NAME] = StrPrivKey;
sessionStorage[WALLET_PUB_KEY_NAME] = StrPubKey;
if(window.sessionStorage)
{
sessionStorage[WALLET_KEY_NAME] = StrPrivKey;
sessionStorage[WALLET_PUB_KEY_NAME] = StrPubKey;
}
};
function SetWalletPassword(Str)
{
WALLET_PASSWORD = Str;
if(localStorage["idPrivKey"])
delete localStorage["idPrivKey"];
if(Storage.getItem("idPrivKey"))
Storage.setItem("idPrivKey", "");
};
function HashProtect(Str)

View File

@ -93,8 +93,6 @@ function OnLoad()
LoadValues();
InitDappsCard();
StartWebWallet();
UpdatesExplorerData();
UpdatesAccountsData();
setInterval(UpdatesExplorerData, 1000);
setInterval(UpdatesAccountsData, 1000);
DoStableScroll();
@ -117,9 +115,14 @@ function ChangeNetwork()
CONNECT_STATUS = 0;
NETWORK = $("idCurNetwork").value;
Storage.setItem("NETWORK", NETWORK);
StartWebWallet();
ConnectWebWallet();
};
function UpdateTabs()
{
UpdatesExplorerData();
UpdatesAccountsData();
ViewDapps();
};
function OnFindServer()
@ -134,11 +137,12 @@ function OnFindServer()
CONNECT_STATUS = 2;
Storage.setItem("MainServer", JSON.stringify({ip:MainServer.ip, port:MainServer.port}));
FillCurrencyAsync("idAccountCur");
UpdateTabs();
};
function LoadValues()
{
var StrDelList = localStorage["DelList"];
var StrDelList = Storage.getItem("DelList");
if(StrDelList)
DelList = JSON.parse(StrDelList);
if(typeof DelList !== "object")
@ -153,7 +157,7 @@ function LoadValues()
function SaveValues()
{
SaveValuesByArr(SaveIdArr);
localStorage["DelList"] = JSON.stringify(DelList);
Storage.setItem("DelList", JSON.stringify(DelList));
};
var TabArr = [{name:"TabWelcome"}, {name:"TabWalletSet"}, {name:"TabKeySet"}, {name:"TabAccounts"}, {name:"TabSend"}, {name:"TabDapps"},
{name:"TabExplorer"}, {name:"TabLogo"}];
@ -442,11 +446,12 @@ function SetAccountsCard(Data,AccountsDataStr)
Str = Str.replace("{Item.Name}", escapeHtml(Item.Name));
var SmartObj = Item.SmartObj;
if(!SmartObj)
SmartObj = {Name:"", Num:0};
SmartObj = {Name:"", Num:0, HTMLLength:0};
SmartObj.IconPath = RetIconPath(SmartObj, 0);
Str = Str.replace("{SmartObj.IconPath}", SmartObj.IconPath);
Str = Str.replace("{SmartObj.Name}", escapeHtml(SmartObj.Name));
Str = Str.replace(/{SmartObj.Num}/g, SmartObj.Num);
Str = Str.replace(/{SmartObj.HTMLLength}/g, SmartObj.HTMLLength);
if(SmartObj.Num)
{
Str = Str.replace("prod-card__link--connect", "myhidden");
@ -482,15 +487,40 @@ function SetAccountsCard(Data,AccountsDataStr)
delete LoadMapAfter["idAccount"];
}
};
var glWasSmart;
var glWasNumAccount;
function ChangeSmartLocal(NumAccount,WasSmart)
{
if(!IsPrivateMode())
{
SetError("Pls, open wallet");
return 0;
}
openModal('idSmartEnter');
if(WasSmart)
$("idSmartNum").value = WasSmart;
else
$("idSmartNum").value = "";
$("idSmartNum").focus();
glWasNumAccount = NumAccount;
glWasSmart = WasSmart;
};
function DoSetSmartLocal()
{
DoChangeSmart(glWasNumAccount, glWasSmart, $("idSmartNum").value);
closeModal();
};
function ConnectSmart(NumAccount)
{
ChangeSmart(NumAccount, 0);
ChangeSmartLocal(NumAccount, 0);
};
function SetSmart(NumAccount,WasSmart)
{
ChangeSmart(NumAccount, WasSmart);
ChangeSmartLocal(NumAccount, WasSmart);
};
function DelSmart(NumAccount,WasSmart)
@ -934,6 +964,7 @@ function FillDappCard(Str,Item)
Str = Str.replace("{Item.Owner}", Item.Owner);
if(!Item.TokenGenerate)
Str = Str.replace("dapp-modal__ok-token", "myhidden");
Str = Str.replace(/{Item.HTMLLength}/g, Item.HTMLLength);
Str = Str.replace("{Item.IconPath}", RetIconPath(Item, 0));
return Str;
};
@ -960,10 +991,13 @@ function OpenDappCard(Num)
openModal('DappCardTemplate');
};
function OpenDapp(Num)
function OpenOnlyDapp(Num,HTMLLength)
{
OpenDapps(Num);
closeModal();
if(HTMLLength)
{
OpenDapps(Num, 0, HTMLLength);
closeModal();
}
};
function FillDappCategory(Str,Item,Num)

View File

@ -658,17 +658,11 @@ function SendTrCreateAcc(Currency,PubKey,Description,Adviser,Smart,bFindAcc,bAdd
CancelCreateAccount();
};
function ChangeSmart(NumAccount,WasSmart)
function DoChangeSmart(NumAccount,WasSmart,SmartNum)
{
if(!IsPrivateMode())
if(SmartNum !== null && SmartNum != WasSmart)
{
SetError("Pls, open wallet");
return 0;
}
var Result = prompt("Enter smart number:", WasSmart);
if(Result !== null && Result != WasSmart)
{
var Smart = parseInt(Result);
var Smart = parseInt(SmartNum);
if(Smart)
{
GetData("GetDappList", {StartNum:Smart, CountNum:1}, function (Data)
@ -690,6 +684,17 @@ function ChangeSmart(NumAccount,WasSmart)
}
};
function ChangeSmart(NumAccount,WasSmart)
{
if(!IsPrivateMode())
{
SetError("Pls, open wallet");
return 0;
}
var SmartNum = prompt("Enter smart number:", WasSmart);
DoChangeSmart(NumAccount, WasSmart, SmartNum);
};
function SetSmartToAccount(NumAccount,Smart)
{
var OperationID = 0;

View File

@ -30,7 +30,7 @@
{
InitMainServer();
document.body.className="univers "+localStorage["idSelStyle"];
document.body.className="univers "+Storage.getItem("idSelStyle");
var i=document.URL.indexOf("#");
if(i>0)
{

View File

@ -69,12 +69,14 @@
$("idConsoleSend").value=Data.Type;
$("idProcessTX").checked=Data.ProcessTX;
$("idProcessWEB").checked=Data.ProcessWEB;
$("idProcessST").checked=Data.ProcessST;
}
else
{
$("idConsoleText").value=Data;
$("idProcessTX").checked=0;
$("idProcessWEB").checked=0;
$("idProcessST").checked=0;
$("idConsoleSend").value="ServerCode";
}
if(bRun)
@ -101,7 +103,7 @@
if(Name)
{
var Data={Code:$("idConsoleText").value,Type:$("idConsoleSend").value,ProcessTX:$("idProcessTX").checked,ProcessWEB:$("idProcessWEB").checked};
var Data={Code:$("idConsoleText").value,Type:$("idConsoleSend").value,ProcessTX:$("idProcessTX").checked,ProcessWEB:$("idProcessWEB").checked,ProcessST:$("idProcessST").checked};
CodeList[Name]=Data;
}
@ -209,9 +211,11 @@
{
var bProcessTX = $("idProcessTX").checked;
var bProcessWEB = $("idProcessWEB").checked;
var bProcessST = $("idProcessST").checked;
SetStatus("");
GetData("SendDirectCode",{Code:Value,TX:bProcessTX,WEB:bProcessWEB }, function (Data)
GetData("SendDirectCode",{Code:Value,TX:bProcessTX,WEB:bProcessWEB,ST:bProcessST }, function (Data)
{
if(Data)
{
@ -403,7 +407,7 @@
LoadValues();
SaveArrToSelect();
document.body.className="univers "+localStorage["idSelStyle"];
document.body.className="univers "+Storage.getItem("idSelStyle");
SetStatus("");
@ -427,6 +431,7 @@
$("idProcessTX").checked=(localStorage["idConsoleProcessTX"]==="true");
$("idProcessWEB").checked=(localStorage["idConsoleProcessWEB"]==="true");
$("idProcessST").checked=(localStorage["idConsoleProcessST"]==="true");
if(localStorage["idConsolePeriodRun"])
$("idPeriodRun").value=localStorage["idConsolePeriodRun"];
}
@ -443,6 +448,8 @@
localStorage["idConsoleProcessTX"]=$("idProcessTX").checked;
localStorage["idConsoleProcessWEB"]=$("idProcessWEB").checked;
localStorage["idConsoleProcessST"]=$("idProcessST").checked;
localStorage["idConsolePeriodRun"]=$("idPeriodRun").value;
}
@ -506,6 +513,7 @@
<INPUT type="number" id="idPeriodRun" style="width: 50px;" onchange="SaveValues();" value="1">sec
TX process:<INPUT type="checkbox" id="idProcessTX">
WEB process:<INPUT type="checkbox" id="idProcessWEB">
Static process:<INPUT type="checkbox" id="idProcessST">
<BR>

View File

@ -48,7 +48,7 @@
{
InitMainServer();
document.body.className="univers "+localStorage["idSelStyle"];
document.body.className="univers "+Storage.getItem("idSelStyle");
var i=document.URL.indexOf("#");
if(i>0)
{
@ -305,4 +305,4 @@
</main>
</body>
</html>
</html>

View File

@ -143,7 +143,7 @@
<div class="wallet-wrapper" style="padding-top: 10px;">
<button class="btn btn--full-width wallet-settings__generate" id="idKeyEdit" onclick="SelectTab('TabWalletSet')">Edit</button>
<div class="wallet-settings__btns-wrapper">
<div class="wallet-settings__btns-wrapper nomobile">
<button class="btn btn--white" onclick="downloadKey('idPrivKeyEdit')" id="idSave2">Save key</button>
<label for="load-key2" class="btn btn--white" onchange="UploadKey('load-key2')" id="idLoad2">
<input class="hidden" id="load-key2" type="file">
@ -227,7 +227,7 @@
<div class="prod-card__footer">
<div class="prod-card__footer-wrap" >
<a onclick="OpenDapps({SmartObj.Num},{Item.Num})" class="prod-card__link prod-card__link--dapp">
<a onclick="OpenDapps({SmartObj.Num},{Item.Num},{SmartObj.HTMLLength})" class="prod-card__link prod-card__link--dapp">
<img src="{SmartObj.IconPath}" alt="." width="32" height="32">
<span class="prod-card__dapp-name mob-hidden">{SmartObj.Name}</span>
</a>
@ -414,7 +414,7 @@
<div class="prod-card__second-line">
<div class="prod-card__second-line-left">
<div class="prod-card__heading">
<a class="prod-card__link" onclick="OpenDapp({Item.Num})">{Item.Name}</a>
<a class="prod-card__link" onclick="OpenOnlyDapp({Item.Num},{Item.HTMLLength})">{Item.Name}</a>
<!--<span class="lighter-grey-text">Without token generate</span>-->
<!--<span class="dapp-modal__ok-token">Token generate</span>-->
</div>
@ -426,7 +426,7 @@
<!--</ol> -->
</div>
<div class="prod-card__second-line-img">
<a class="prod-card__link" onclick="OpenDapp({Item.Num})"><img src="{Item.IconPath}" width="32"></a>
<a class="prod-card__link" onclick="OpenOnlyDapp({Item.Num},{Item.HTMLLength})"><img src="{Item.IconPath}" width="32"></a>
</div>
</div>
</li>
@ -551,7 +551,7 @@
</dl>
<div class="modal__btns-wrap">
<button class="btn" onclick="OpenDapp({Item.Num})">Open DApp</button>
<button class="btn" onclick="OpenOnlyDapp({Item.Num},{Item.HTMLLength})">Open DApp</button>
<button class="btn btn--white" onclick="closeModal()">Back</button>
</div>
@ -633,6 +633,17 @@
</section>
<section class="modal password-modal" id="idSmartEnter">
<h2 class="password-modal__title">Enter number of dapp</h2>
<p class="password-modal__subtitle">Enter the dapps number that will be added to your account. Attention make sure that you trust this dapp, otherwise you may lose all funds in this account.</p>
<input type="number" class="password-modal__input" placeholder="Dapp number" id="idSmartNum">
<a class="btn btn--270 btn--float" onclick="DoSetSmartLocal()">OK</a>
<a class="btn btn--270 btn--float btn--white" onclick="closeModal()">Cancel</a>
</section>
<div class="fixed-status">
<div class="fixed-status__wrap">
<div id="idStatus" class="fixed-status__status">&nbsp;</div>
@ -640,7 +651,7 @@
<option value="TERA-MAIN">TERA MAIN</option>
<option value="TERA-TEST3">TERA TEST3</option>
</select>
<button class="grey-btn reconnect" onclick="ConnectWebWallet()" title="Reconnect"><span>RECONNECT</span></button>
<button class="grey-btn reconnect" onclick="ChangeNetwork()" title="Reconnect"><span>RECONNECT</span></button>
<!--рудименты-->
<span id="idNetwork" style="display: none"></span>
<span id="idSignJSON"></span>

View File

@ -625,12 +625,14 @@ global.HTTPCaller.SendTransactionHex = function(Params) {
};
global.HTTPCaller.SendDirectCode = function(Params, response) {
var Result;
if (Params.TX || Params.WEB) {
if (Params.TX || Params.WEB || Params.ST) {
var RunProcess;
if (Params.TX)
RunProcess = global.TX_PROCESS;
if (Params.WEB)
RunProcess = global.WEB_PROCESS;
if (Params.ST)
RunProcess = global.STATIC_PROCESS;
if (RunProcess && RunProcess.RunRPC) {
RunProcess.RunRPC("EvalCode", Params.Code, function(Err, Ret) {
Result = { result: !Err, sessionid: sessionid, text: Ret, };