diff --git a/Source/HTML/CSS/mobile-wallet.css b/Source/HTML/CSS/mobile-wallet.css index 0ffa6e7..defd0a4 100644 --- a/Source/HTML/CSS/mobile-wallet.css +++ b/Source/HTML/CSS/mobile-wallet.css @@ -141,9 +141,9 @@ textarea { cursor: not-allowed; } -.btn span { - opacity: .4; -} +/*.btn span {*/ + /*opacity: .4;*/ +/*}*/ .btn--white { background: #fff; diff --git a/Source/HTML/CSS/wallet.css b/Source/HTML/CSS/wallet.css index 9247324..0c0ab61 100644 --- a/Source/HTML/CSS/wallet.css +++ b/Source/HTML/CSS/wallet.css @@ -100,8 +100,6 @@ td.date - - /*SEND SEND SEND SEND SEND SEND SEND SEND SEND SEND */ table.form_input diff --git a/Source/HTML/JS/client.js b/Source/HTML/JS/client.js index a8f6386..ad95ffe 100644 --- a/Source/HTML/JS/client.js +++ b/Source/HTML/JS/client.js @@ -1220,6 +1220,17 @@ MapCurrency[16] = "BTC"; var MapCurrencyIcon = {}; MapCurrencyIcon[0] = "./PIC/T.svg"; MapCurrencyIcon[16] = "./PIC/B.svg"; + +function InitMapCurrency() +{ + if(window.NETWORK_NAME === "TERA-TEST3") + { + MapCurrency = {}; + MapCurrency[0] = "TERA"; + MapCurrency[31] = "BTC"; + MapCurrency[59] = "USD"; + } +}; var MapCategory = {}; MapCategory[0] = "-"; MapCategory[1] = "Art & Music"; @@ -1312,8 +1323,14 @@ function CurrencyName(Num) function FillCurrencyAsync(IdName,StartNum) { + InitMapCurrency(); if(!StartNum) StartNum = 8; + FillCurrencyNext(IdName, StartNum); +}; + +function FillCurrencyNext(IdName,StartNum) +{ var MaxCountViewRows = 10; GetData("DappSmartList", {StartNum:StartNum, CountNum:MaxCountViewRows, TokenGenerate:1}, function (Data) { @@ -1331,10 +1348,11 @@ function FillCurrencyAsync(IdName,StartNum) if(Smart.Num > MaxNum) MaxNum = Smart.Num; } - FillSelect(IdName, MapCurrency, 1); + if(IdName) + FillSelect(IdName, MapCurrency, 1); if(Data.arr.length === MaxCountViewRows && MaxNum) { - FillCurrencyAsync(IdName, MaxNum + 1); + FillCurrencyNext(IdName, MaxNum + 1); } } }); diff --git a/Source/HTML/JS/dapp-inner.js b/Source/HTML/JS/dapp-inner.js index cc1eb56..3af93f0 100644 --- a/Source/HTML/JS/dapp-inner.js +++ b/Source/HTML/JS/dapp-inner.js @@ -193,15 +193,25 @@ function CurrencyName(Num) return Name; }; var SendCountUpdate = 0; +var WasInitCurrency = 0; function FindAllCurrency() +{ + WasInitCurrency = 1; + InitMapCurrency(); + FindAllCurrencyNext(8); +}; + +function FindAllCurrencyNext(StartNum) { SendCountUpdate++; - GetSmartList({StartNum:8, CountNum:100, TokenGenerate:1}, function (Err,Arr) + var MaxCountViewRows = 10; + GetSmartList({StartNum:StartNum, CountNum:MaxCountViewRows, TokenGenerate:1}, function (Err,Arr) { SendCountUpdate--; if(Err) return ; + var MaxNum = 0; for(var i = 0; i < Arr.length; i++) { var Smart = Arr[i]; @@ -210,6 +220,12 @@ function FindAllCurrency() var Name = GetTokenName(Smart.Num, Smart.ShortName); MapCurrency[Smart.Num] = Name; } + if(Smart.Num > MaxNum) + MaxNum = Smart.Num; + } + if(Arr.length === MaxCountViewRows && MaxNum) + { + FindAllCurrencyNext(MaxNum + 1); } }); }; @@ -261,6 +277,62 @@ function GetState(AccNum,F,FErr) } }); }; + +function UpdateListArr(Block,Tr,Arr,StopBlock,IgnoreTailBlock,MaxDepth,F) +{ + Arr.sort(function (a,b) + { + return a.Num - b.Num; + }); + if(Arr.length) + StopBlock = Math.max(StopBlock, Arr[Arr.length - 1].BlockNum); + UpdateListArrNext(Block, Tr, Arr, StopBlock, IgnoreTailBlock, MaxDepth, F); +}; + +function UpdateListArrNext(Block,Tr,Arr,StopMinBlock,IgnoreTailBlock,MaxDepth,F) +{ + if(Block <= StopMinBlock || !MaxDepth) + return ; + SendCountUpdate++; + DappBlockFile(Block, Tr, function (Err,Data) + { + SendCountUpdate--; + if(!Err && Data.Type === 135) + { + try + { + var Params = JSON.parse(Data.Params); + } + catch(e) + { + } + if(Params) + { + if(Block <= INFO.CurBlockNum - IgnoreTailBlock) + { + Params.BlockNum = Block; + Params.TrNum = Tr; + Params.Num = Params.BlockNum * 100000 + Params.TrNum; + Params.Time = Date.now(); + if(!Arr.length || Arr[Arr.length - 1].Num !== Params.Num) + Arr.push(Params); + } + if(Params.PrevBlock) + { + UpdateListArrNext(Params.PrevBlock, Params.PrevTr, Arr, StopMinBlock, IgnoreTailBlock, MaxDepth - 1, F); + } + } + } + if(F && SendCountUpdate === 0) + { + Arr.sort(function (a,b) + { + return a.Num - b.Num; + }); + F(Arr); + } + }); +}; var glMapF = {}; var glKeyF = 0; @@ -387,8 +459,9 @@ function LoadFromStorageByArr(Arr,F,bAll) LoadFromStorageById(Arr[i]); } } - if(bAll && F) - F(0); + else + if(bAll && F) + F(0); }); }; @@ -482,6 +555,9 @@ function UpdateDappInfo() OPEN_PATH = Data.OPEN_PATH; ACCOUNT_OPEN_NUM = ParseNum(OPEN_PATH); SetBlockChainConstant(Data); + window.NETWORK_NAME = INFO.NETWORK; + if(!WasInitCurrency) + FindAllCurrency(); USER_ACCOUNT = Data.ArrWallet; USER_ACCOUNT_MAP = {}; for(var i = 0; i < USER_ACCOUNT.length; i++) diff --git a/Source/HTML/JS/mobile-wallet.js b/Source/HTML/JS/mobile-wallet.js index ddc268d..49cead0 100644 --- a/Source/HTML/JS/mobile-wallet.js +++ b/Source/HTML/JS/mobile-wallet.js @@ -83,18 +83,18 @@ function OnLoad() { if(window.location.protocol === "https:") { - NETWORK = "TERA-MAIN"; - FillSelect("idCurNetwork", [{value:NETWORK, text:"TERA MAIN"}]); - $("idCurNetwork").value = NETWORK; - Storage.setItem("NETWORK", NETWORK); + NETWORK_NAME = "TERA-MAIN"; + FillSelect("idCurNetwork", [{value:NETWORK_NAME, text:"TERA MAIN"}]); + $("idCurNetwork").value = NETWORK_NAME; + Storage.setItem("NETWORK", NETWORK_NAME); } else { if(Storage.getItem("NETWORK")) { - NETWORK = Storage.getItem("NETWORK"); + NETWORK_NAME = Storage.getItem("NETWORK"); } - $("idCurNetwork").value = NETWORK; + $("idCurNetwork").value = NETWORK_NAME; } LoadValues(); InitDappsCard(); @@ -120,8 +120,8 @@ function ChangeNetwork(bStart) { FirstAccountsData = 1; CONNECT_STATUS = 0; - NETWORK = $("idCurNetwork").value; - Storage.setItem("NETWORK", NETWORK); + NETWORK_NAME = $("idCurNetwork").value; + Storage.setItem("NETWORK", NETWORK_NAME); if(bStart) StartWebWallet(); else @@ -1261,6 +1261,16 @@ function GetNewLangItem() { console.log(JSON.stringify(LangMap["ENG"])); }; + +function OpenHelp() +{ + var Key = $("idLang").value; + var Map = LangMap[$("idLang").value]; + var Link = Map["==HELP-LINK=="]; + if(!Link) + Link = "https://medium.com/@evkara777/tera-cryptocurrency-wallet-types-account-creation-97735abad783"; + window.open(Link); +}; var LangMap = {}; LangMap["ENG"] = {}; LangMap["RUS"] = {"TERA WALLET":"TERA КОШЕЛЕК", "Generate key":"Сгенерировать ключ", "OK":"OK", "Cancel":"Отмена", "Edit":"Редактирование", @@ -1285,7 +1295,9 @@ LangMap["RUS"] = {"TERA WALLET":"TERA КОШЕЛЕК", "Generate key":"Сген "Load key":"Загруз.", "Create your first account and start using TERA":"Создайте свой первый счет и начните использовать TERA", "0 Accounts":"0 Счетов", "OWNER: {Item.Owner}":"Владелец: {Item.Owner}", "More info":"Инфо", "Public key":"Публичный ключ", "Enter number of dapp":"Введите номер Dapp", "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.":"Введите номер Dapp, который будет добавлен в ваш аккаунт. Внимание убедитесь, что Вы доверяете ему, в противном случае вы можете потерять все средства на этом счете.", - "Sending Tx":"Отправка транзакции", "Wallet ver:":"Версия:", }; + "Sending Tx":"Отправка транзакции", "Wallet ver:":"Версия:", "HELP: Tera Wallet creation Guide...":"Руководство по созданию Tera Wallet...", + "==HELP-LINK==":"https://medium.com/@evkara777/tera-%D0%BA%D1%80%D0%B8%D0%BF%D1%82%D0%BE%D0%B2%D0%B0%D0%BB%D1%8E%D1%82%D0%BD%D1%8B%D0%B9-%D0%BA%D0%BE%D1%88%D0%B5%D0%BB%D0%B5%D0%BA-%D0%B2%D0%B8%D0%B4%D1%8B-%D1%81%D0%BE%D0%B7%D0%B4%D0%B0%D0%BD%D0%B8%D0%B5-%D1%81%D1%87%D0%B5%D1%82%D0%B0-6402531ecc11", +}; LangMap["简体中文"] = {"TERA WALLET":"TERA 钱包", "Generate key":"生成私钥", "OK":"OK", "Cancel":"取消", "Edit":"编辑", "Save key":"保存私钥", "+ CREATE A NEW ACCOUNT":"+ 新建账号", "Create account":"创建账号", "Send":"发送", "SEND":"转账", "CONFIRM":"确认", "Accounts":"账号", "Account(s)":"账号", "Blocks and Tx":"区块和交易", "Counters":"状态统计", "Open DApp":"打开DApp", "Back":"返回", "Delete":"删除", "Save to book":"保存到地址本", "Choose":"选择", @@ -1302,7 +1314,8 @@ LangMap["简体中文"] = {"TERA WALLET":"TERA 钱包", "Generate key":"生成 "From:":"付款:", "Set a password for protect entry":"设置密码保护钱包", "Enter password to unlock wallet":"输入密码解锁钱包", "From ID:":"付款ID:", "Pay to ID:":"收款ID:", "Account":"账号", "Owner":"拥有者", "Block num":"区块编号", "Private key (secret)":"私钥 (机密)", "Load key":"载入私钥", "Create your first account and start using TERA":"创建你的第一个账号,开启TERA之旅", "0 Accounts":"0 账号", "OWNER: {Item.Owner}":"拥有者: {Item.Owner}", - "More info":"详情", "Public key":"公钥"}; + "More info":"详情", "Public key":"公钥", "HELP: Tera Wallet creation Guide...":"TERA钱包创作指南", "==HELP-LINK==":"https://terafoundation.org/files/Tera-Wallet-cn.pdf", +}; LangMap["한글"] = {"TERA WALLET":"TERA 지갑", "Generate key":"개인 키 생성", "OK":"OK", "Cancel":"취소", "Edit":"편집", "Save key":"개인 키 저장", "+ CREATE A NEW ACCOUNT":"+ 새 계정 만들기", "Create account":"계정 만들기", "Send":"발송", "CONFIRM":"확인", "Accounts":"계정", "Account(s)":"계정", "Blocks & Tx":"블록 & 교역 번호", "Counters":"컨디션 통계", "Open DApp":" DApp을 열기", "Back":"되돌아가기", "Delete":"삭제", "Save to book":"저장", diff --git a/Source/HTML/JS/wallet-node.js b/Source/HTML/JS/wallet-node.js index 24fb12b..782a3a4 100644 --- a/Source/HTML/JS/wallet-node.js +++ b/Source/HTML/JS/wallet-node.js @@ -323,7 +323,7 @@ function SetArrLog(arr) { var Item = arr[i]; var tr_text = GetTransactionText(MapSendTransaction[Item.key], Item.key.substr(0, 16)); - var info = Item.text; + var info = Item.time + " " + Item.text; if(tr_text) info += " (" + tr_text + ")"; if(Item.final) diff --git a/Source/HTML/JS/wallet-web.js b/Source/HTML/JS/wallet-web.js index b940d18..e125c67 100644 --- a/Source/HTML/JS/wallet-web.js +++ b/Source/HTML/JS/wallet-web.js @@ -16,7 +16,7 @@ var MaxConnectedCount = 50; var TIME_LENGTH_CONNECT_ALL = 2 * 1000; var StartTimeConnecting = 0; var ConnectedCount = 0; -var NETWORK = "TERA-MAIN"; +var NETWORK_NAME = "TERA-MAIN"; var ServerMap = {}; var ServerMainMap = {"127.0.0.1":{"ip":"127.0.0.1", "port":80, "Name":"LOCAL"}, "terawallet.org":{"ip":"terawallet.org", "port":443, "Name":"terawallet", "System":1}, "teraexplorer.org":{"ip":"teraexplorer.org", "port":443, "Name":"teraexplorer", "System":1}, @@ -30,7 +30,7 @@ var ServerTestMap = {"127.0.0.1":{"ip":"127.0.0.1", "port":80, "Name":"LOCAL"}, function StartWebWallet() { - if(NETWORK === "TERA-TEST3") + if(NETWORK_NAME === "TERA-TEST3") { MIN_SUM_POWER = 0; ServerMap = ServerTestMap; @@ -40,14 +40,14 @@ function StartWebWallet() MIN_SUM_POWER = COUNT_BLOCK_PROOF * 35; ServerMap = ServerMainMap; } - $("idNetwork").innerText = NETWORK; + $("idNetwork").innerText = NETWORK_NAME; OnInitWebWallet(); ConnectWebWallet(); }; function OnInitWebWallet() { - var str = Storage.getItem(NETWORK + "NodesArrayList"); + var str = Storage.getItem(NETWORK_NAME + "NodesArrayList"); if(str) { var arr = JSON.parse(str); @@ -77,7 +77,7 @@ function SaveServerMap() var Item = Arr[i]; Arr2.push({ip:Item.ip, port:Item.port, Stat:Item.Stat, t:Item.DeltaTime}); } - Storage.setItem(NETWORK + "NodesArrayList", JSON.stringify(Arr2)); + Storage.setItem(NETWORK_NAME + "NodesArrayList", JSON.stringify(Arr2)); }; function SetStatus(Str) @@ -145,7 +145,7 @@ function DoNodeList(Item) Item.StartTime = Date.now(); GetData(GetProtocolServerPath(Item) + "/GetNodeList", {}, function (Data) { - if(Data && Data.result && Data.NETWORK === NETWORK && Data.VersionNum >= MIN_VERSION) + if(Data && Data.result && Data.NETWORK === NETWORK_NAME && Data.VersionNum >= MIN_VERSION) { ConnectedCount++; Item.GetHandShake = 1; @@ -226,7 +226,7 @@ function DoWalletInfo(Item) { if(!idTimeFindLider) return ; - if(Data && Data.result && Data.BlockChain && Data.NETWORK === NETWORK) + if(Data && Data.result && Data.BlockChain && Data.NETWORK === NETWORK_NAME) { Item.Name = Data.NODES_NAME; Item.GetWalletInfo = 1; diff --git a/Source/HTML/dapp-edit.html b/Source/HTML/dapp-edit.html index 2dc9f0f..dfb921f 100644 --- a/Source/HTML/dapp-edit.html +++ b/Source/HTML/dapp-edit.html @@ -896,6 +896,10 @@ background-color: #e6eefe; } + .trim + { + margin: 2px; + } @@ -921,7 +925,7 @@ Smarts, start: - diff --git a/Source/HTML/dapp-frame.html b/Source/HTML/dapp-frame.html index 974a5d9..00a180b 100644 --- a/Source/HTML/dapp-frame.html +++ b/Source/HTML/dapp-frame.html @@ -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='\ \ \ @@ -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='Accounts'; + StrRef='Accounts'; else { if(Storage.getItem("BIGWALLET")) - StrRef='Config' + StrRef='Config' else - StrRef='Accounts'; + StrRef='Accounts'; } - var Str='