From fd1b23a4c37af5cf63388b1bca76853bdafb3a64 Mon Sep 17 00:00:00 2001 From: MiaoWoo Date: Fri, 19 Jul 2019 10:45:11 +0800 Subject: [PATCH] sync: sync upstream code Signed-off-by: MiaoWoo --- src/HTML/CSS/mobile-wallet.css | 9 +++++ src/HTML/JS/client.js | 70 +++++++++++++++++++--------------- src/HTML/JS/mobile-wallet.js | 56 +++++++++++++++++++++------ src/HTML/JS/wallet-lib.js | 23 ++++++----- src/HTML/blockviewer.html | 2 +- src/HTML/console.html | 14 +++++-- src/HTML/history.html | 4 +- src/HTML/web-wallet.html | 23 ++++++++--- src/core/html-server.ts | 4 +- 9 files changed, 141 insertions(+), 64 deletions(-) diff --git a/src/HTML/CSS/mobile-wallet.css b/src/HTML/CSS/mobile-wallet.css index a0a22ec..4e1f7e5 100644 --- a/src/HTML/CSS/mobile-wallet.css +++ b/src/HTML/CSS/mobile-wallet.css @@ -2753,3 +2753,12 @@ iframe cursor: pointer; } + + +.btn--float +{ + float: left; + width: 230px; + margin: 10px; +} + diff --git a/src/HTML/JS/client.js b/src/HTML/JS/client.js index 02b467e..e9848d3 100644 --- a/src/HTML/JS/client.js +++ b/src/HTML/JS/client.js @@ -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) diff --git a/src/HTML/JS/mobile-wallet.js b/src/HTML/JS/mobile-wallet.js index eba0d43..c79c3b9 100644 --- a/src/HTML/JS/mobile-wallet.js +++ b/src/HTML/JS/mobile-wallet.js @@ -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) diff --git a/src/HTML/JS/wallet-lib.js b/src/HTML/JS/wallet-lib.js index 099dc74..f8e834b 100644 --- a/src/HTML/JS/wallet-lib.js +++ b/src/HTML/JS/wallet-lib.js @@ -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; diff --git a/src/HTML/blockviewer.html b/src/HTML/blockviewer.html index 289eae2..a33fcad 100644 --- a/src/HTML/blockviewer.html +++ b/src/HTML/blockviewer.html @@ -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) { diff --git a/src/HTML/console.html b/src/HTML/console.html index ffc0fcb..72b182d 100644 --- a/src/HTML/console.html +++ b/src/HTML/console.html @@ -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 @@ sec TX process: WEB process: + Static process:
diff --git a/src/HTML/history.html b/src/HTML/history.html index 9e0485f..f70a739 100644 --- a/src/HTML/history.html +++ b/src/HTML/history.html @@ -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 @@ - \ No newline at end of file + diff --git a/src/HTML/web-wallet.html b/src/HTML/web-wallet.html index ef17321..37c6ddc 100644 --- a/src/HTML/web-wallet.html +++ b/src/HTML/web-wallet.html @@ -143,7 +143,7 @@
-
+