Fri Jul 19 12:26:00 CST 2019 Source Update...
This commit is contained in:
@@ -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,18 +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);
|
||||
return Key;
|
||||
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);
|
||||
return Key;
|
||||
if(Key && typeof Key === "string" && Key.length >= 66)
|
||||
return Key;
|
||||
else
|
||||
return "";
|
||||
};
|
||||
|
||||
function SetPrivKey(StrPrivKey)
|
||||
@@ -1912,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)
|
||||
@@ -1942,3 +1958,11 @@ function XORHash(arr1,arr2,length)
|
||||
}
|
||||
return arr3;
|
||||
};
|
||||
|
||||
function Right(Str,count)
|
||||
{
|
||||
if(Str.length > count)
|
||||
return Str.substr(Str.length - count, count);
|
||||
else
|
||||
return Str.substr(0, Str.length);
|
||||
};
|
||||
|
||||
@@ -11,6 +11,14 @@
|
||||
var MAX_SUM_TER = 1e9;
|
||||
var MAX_SUM_CENT = 1e9;
|
||||
|
||||
function CHECKSUM(Coin)
|
||||
{
|
||||
if(typeof Coin.SumCOIN !== "number")
|
||||
Coin.SumCOIN = 0;
|
||||
if(typeof Coin.SumCENT !== "number")
|
||||
Coin.SumCENT = 0;
|
||||
};
|
||||
|
||||
function ADD(Coin,Value2)
|
||||
{
|
||||
Coin.SumCOIN += Value2.SumCOIN;
|
||||
@@ -102,6 +110,7 @@ function COIN_FROM_STRING(Str)
|
||||
};
|
||||
if(typeof global === "object")
|
||||
{
|
||||
global.CHECKSUM = CHECKSUM;
|
||||
global.ADD = ADD;
|
||||
global.SUB = SUB;
|
||||
global.DIV = DIV;
|
||||
|
||||
@@ -135,6 +135,15 @@ window.GetCurrentBlockNumByTime = function ()
|
||||
return 0;
|
||||
};
|
||||
|
||||
function SetMinPow()
|
||||
{
|
||||
var item = $("idDeltaPow");
|
||||
if(item)
|
||||
{
|
||||
window.DELTA_POWER_POW_TR = ParseNum(item.value);
|
||||
}
|
||||
};
|
||||
|
||||
function GetBlockNumTr(arr)
|
||||
{
|
||||
var BlockNum = window.DELTA_FOR_TIME_TX + GetCurrentBlockNumByTime();
|
||||
@@ -153,6 +162,7 @@ var LastCreatePOWHash = [255, 255, 255, 255];
|
||||
|
||||
function CreateHashBodyPOWInnerMinPower(arr,MinPow,startnonce)
|
||||
{
|
||||
SetMinPow();
|
||||
var TrType = arr[0];
|
||||
var BlockNum = GetBlockNumTr(arr);
|
||||
if(MinPow === undefined)
|
||||
|
||||
@@ -75,16 +75,24 @@ window.onload = function ()
|
||||
|
||||
function OnLoad()
|
||||
{
|
||||
if(Storage.getItem("NETWORK"))
|
||||
if(window.location.protocol === "https:")
|
||||
{
|
||||
NETWORK = Storage.getItem("NETWORK");
|
||||
NETWORK = "TERA-MAIN";
|
||||
FillSelect("idCurNetwork", [{value:NETWORK, text:"TERA MAIN"}]);
|
||||
$("idCurNetwork").value = NETWORK;
|
||||
Storage.setItem("NETWORK", NETWORK);
|
||||
}
|
||||
else
|
||||
{
|
||||
if(Storage.getItem("NETWORK"))
|
||||
{
|
||||
NETWORK = Storage.getItem("NETWORK");
|
||||
}
|
||||
$("idCurNetwork").value = NETWORK;
|
||||
}
|
||||
$("idCurNetwork").value = NETWORK;
|
||||
LoadValues();
|
||||
InitDappsCard();
|
||||
StartWebWallet();
|
||||
UpdatesExplorerData();
|
||||
UpdatesAccountsData();
|
||||
setInterval(UpdatesExplorerData, 1000);
|
||||
setInterval(UpdatesAccountsData, 1000);
|
||||
DoStableScroll();
|
||||
@@ -107,9 +115,14 @@ function ChangeNetwork()
|
||||
CONNECT_STATUS = 0;
|
||||
NETWORK = $("idCurNetwork").value;
|
||||
Storage.setItem("NETWORK", NETWORK);
|
||||
StartWebWallet();
|
||||
ConnectWebWallet();
|
||||
};
|
||||
|
||||
function UpdateTabs()
|
||||
{
|
||||
UpdatesExplorerData();
|
||||
UpdatesAccountsData();
|
||||
ViewDapps();
|
||||
};
|
||||
|
||||
function OnFindServer()
|
||||
@@ -124,13 +137,16 @@ 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")
|
||||
DelList = {};
|
||||
if(LoadValuesByArr(SaveIdArr))
|
||||
{
|
||||
ChangeLang();
|
||||
@@ -141,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"}];
|
||||
@@ -300,10 +316,6 @@ function UpdatesAccountsData()
|
||||
}
|
||||
else
|
||||
{
|
||||
if(FirstAccountsData && !Data.arr.length)
|
||||
{
|
||||
SelectTab('TabAccounts');
|
||||
}
|
||||
}
|
||||
FirstAccountsData = 0;
|
||||
});
|
||||
@@ -409,9 +421,21 @@ function SetAccountsCard(Data,AccountsDataStr)
|
||||
var Str = StrAccCardTemplate;
|
||||
Str = Str.replace("AccCardTemplate", "idCard" + Item.Num);
|
||||
Str = Str.replace(/{Item.Num}/g, Item.Num);
|
||||
Str = Str.replace("{Value.SumCOIN}", Item.Value.SumCOIN);
|
||||
Str = Str.replace("{Value.SumCENT}", Item.Value.SumCENT);
|
||||
Str = Str.replace("{Value.CurrencyName}", CurrencyName(Item.Currency));
|
||||
var Str1, Str2;
|
||||
if(Item.Value.SumCOIN || Item.Value.SumCENT)
|
||||
{
|
||||
Str1 = Item.Value.SumCOIN;
|
||||
Str2 = "," + Right("000000000" + Item.Value.SumCENT, 9);
|
||||
}
|
||||
else
|
||||
{
|
||||
Str1 = "";
|
||||
Str2 = "";
|
||||
}
|
||||
var StrCurrencyName = CurrencyName(Item.Currency);
|
||||
Str = Str.replace("{Value.SumCOIN}", Str1);
|
||||
Str = Str.replace("{Value.SumCENT}", Str2);
|
||||
Str = Str.replace("{Value.CurrencyName}", StrCurrencyName);
|
||||
var CurrencyObj = Item.CurrencyObj;
|
||||
if(!CurrencyObj)
|
||||
CurrencyObj = {IconBlockNum:0, Num:0};
|
||||
@@ -422,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");
|
||||
@@ -462,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)
|
||||
@@ -914,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;
|
||||
};
|
||||
@@ -940,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)
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user