@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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