2019-07-10 04:01:15 +00:00
/ *
* @ project : TERA
* @ version : Development ( beta )
* @ license : MIT ( not for evil )
* @ copyright : Yuriy Ivanov ( Vtools ) 2017 - 2019 [ progr76 @ gmail . com ]
* Web : https : //terafoundation.org
* Twitter : https : //twitter.com/terafoundation
* Telegram : https : //t.me/terafoundation
* /
var SaveIdArr = [ "idAccount" , "idTo" , "idSumSend" , "idDescription" , "idCurTabName" , "idViewBlockNum" , "idViewAccountNum" , "idViewDappNum" ,
2019-07-10 09:53:52 +00:00
"idLang" ] ;
var CONFIG _DATA = { PRICE _DAO : { NewAccount : 10 } , MaxNumBlockDB : 0 , MaxAccID : 0 , MaxDappsID : 0 } ;
2019-07-10 04:01:15 +00:00
var CountViewRows = 20 ;
2019-07-10 09:53:52 +00:00
var DefAccounts = { BlockName : "idPaginationAccount" , NumName : "idViewAccountNum" , TabName : "explorer_accounts" , APIName : "GetAccountList" } ;
var DefBlock = { BlockName : "idPaginationBlock" , NumName : "idViewBlockNum" , TabName : "explorer_blocks" , APIName : "GetBlockList" } ;
var DefDapps = {
BlockName : "idPaginationDapps" , NumName : "idViewDappNum" , TabName : "dapps_list" , APIName : "GetDappList" , CountViewRows : 10 ,
FilterName : "idCategory"
} ;
2019-07-10 04:01:15 +00:00
2019-07-10 09:53:52 +00:00
function SetImg ( ) {
2019-07-10 04:01:15 +00:00
} ;
var CONNECT _STATUS = 0 ;
var NotModalClose = 0 ;
2019-07-10 09:53:52 +00:00
window . onload = function ( ) {
2019-07-10 04:01:15 +00:00
InitAccountsCard ( ) ;
DoLangScript ( ) ;
InitWalletKeyName ( ) ;
2019-07-10 09:53:52 +00:00
if ( Storage . getItem ( "NETWORK" ) || IsLocalClient ( ) ) {
2019-07-10 04:01:15 +00:00
OnLoad ( ) ;
}
2019-07-10 09:53:52 +00:00
else {
GetData ( "/GetCurrentInfo" , { } , function ( Data ) {
if ( Data && Data . result ) {
2019-07-10 04:01:15 +00:00
Storage . setItem ( "NETWORK" , Data . NETWORK ) ;
console . log ( "Default network: " + Data . NETWORK ) ;
OnLoad ( ) ;
}
} ) ;
}
var HasPassword = IsLockedWallet ( ) ;
2019-07-10 09:53:52 +00:00
if ( HasPassword ) {
2019-07-10 04:01:15 +00:00
NotModalClose = 1 ;
openModal ( 'password-modal-enter' ) ;
}
2019-07-10 09:53:52 +00:00
else {
2019-07-10 04:01:15 +00:00
OpenWalletKey ( ) ;
}
SetUsePassword ( HasPassword ) ;
2019-07-10 09:53:52 +00:00
window . onkeydown = function ( e ) {
if ( e . keyCode === 27 ) {
if ( IsVisibleBlock ( "overlay" ) )
2019-07-10 04:01:15 +00:00
closeModal ( ) ;
}
} ;
$ ( "idAccountsList" ) . addEventListener ( "click" , MyToggleList ) ;
} ;
2019-07-10 09:53:52 +00:00
function OnLoad ( ) {
if ( Storage . getItem ( "NETWORK" ) ) {
2019-07-10 04:01:15 +00:00
NETWORK = Storage . getItem ( "NETWORK" ) ;
}
$ ( "idCurNetwork" ) . value = NETWORK ;
LoadValues ( ) ;
InitDappsCard ( ) ;
StartWebWallet ( ) ;
UpdatesExplorerData ( ) ;
UpdatesAccountsData ( ) ;
setInterval ( UpdatesExplorerData , 1000 ) ;
setInterval ( UpdatesAccountsData , 1000 ) ;
DoStableScroll ( ) ;
2019-07-10 09:53:52 +00:00
window . onmousemove = function ( event ) {
2019-07-10 04:01:15 +00:00
SetDiagramMouseX ( event ) ;
} ;
2019-07-10 09:53:52 +00:00
if ( window . location . hash ) {
2019-07-10 04:01:15 +00:00
var LocationPath = window . location . hash . substr ( 1 ) ;
2019-07-10 09:53:52 +00:00
if ( LocationPath ) {
2019-07-10 04:01:15 +00:00
SelectTab ( LocationPath ) ;
}
}
} ;
2019-07-10 09:53:52 +00:00
function ChangeNetwork ( ) {
2019-07-10 04:01:15 +00:00
CONNECT _STATUS = 0 ;
NETWORK = $ ( "idCurNetwork" ) . value ;
Storage . setItem ( "NETWORK" , NETWORK ) ;
StartWebWallet ( ) ;
UpdatesExplorerData ( ) ;
UpdatesAccountsData ( ) ;
} ;
2019-07-10 09:53:52 +00:00
function OnFindServer ( ) {
if ( ! MainServer ) {
CONNECT _STATUS = - 1 ;
2019-07-10 04:01:15 +00:00
SetStatus ( "Server not found" ) ;
Storage . setItem ( "MainServer" , undefined ) ;
2019-07-10 09:53:52 +00:00
return ;
2019-07-10 04:01:15 +00:00
}
CONNECT _STATUS = 2 ;
2019-07-10 09:53:52 +00:00
Storage . setItem ( "MainServer" , JSON . stringify ( { ip : MainServer . ip , port : MainServer . port } ) ) ;
2019-07-10 04:01:15 +00:00
FillCurrencyAsync ( "idAccountCur" ) ;
} ;
2019-07-10 09:53:52 +00:00
function LoadValues ( ) {
2019-07-10 04:01:15 +00:00
var StrDelList = localStorage [ "DelList" ] ;
2019-07-10 09:53:52 +00:00
if ( StrDelList )
2019-07-10 04:01:15 +00:00
DelList = JSON . parse ( StrDelList ) ;
2019-07-10 09:53:52 +00:00
if ( LoadValuesByArr ( SaveIdArr ) ) {
2019-07-10 04:01:15 +00:00
ChangeLang ( ) ;
}
InitPrivKey ( ) ;
} ;
2019-07-10 09:53:52 +00:00
function SaveValues ( ) {
2019-07-10 04:01:15 +00:00
SaveValuesByArr ( SaveIdArr ) ;
localStorage [ "DelList" ] = JSON . stringify ( DelList ) ;
} ;
2019-07-10 09:53:52 +00:00
var TabArr = [ { name : "TabWelcome" } , { name : "TabWalletSet" } , { name : "TabKeySet" } , { name : "TabAccounts" } , { name : "TabSend" } , { name : "TabDapps" } ,
{ name : "TabExplorer" } , { name : "TabLogo" } ] ;
2019-07-10 04:01:15 +00:00
2019-07-10 09:53:52 +00:00
function SelectTab ( name ) {
2019-07-10 04:01:15 +00:00
SetStatus ( "" ) ;
$ ( "idCurTabName" ) . value = name ;
SetVisibleTab ( ) ;
SaveValues ( ) ;
OnSelectTab ( name ) ;
2019-07-10 09:53:52 +00:00
if ( name && history . pushState )
2019-07-10 04:01:15 +00:00
history . pushState ( null , null , "#" + name ) ;
} ;
2019-07-10 09:53:52 +00:00
function OnSelectTab ( name ) {
if ( ! GetPrivKey ( ) ) {
2019-07-10 04:01:15 +00:00
GenerateKeyNew ( ) ;
SetPrivKey ( $ ( "idPrivKeyEdit" ) . value . trim ( ) ) ;
InitPrivKey ( ) ;
}
2019-07-10 09:53:52 +00:00
if ( name === "TabDapps" ) {
2019-07-10 04:01:15 +00:00
ViewDapps ( ) ;
}
} ;
2019-07-10 09:53:52 +00:00
function SetVisibleTab ( ) {
2019-07-10 04:01:15 +00:00
var CurTabName = $ ( "idCurTabName" ) . value ;
2019-07-10 09:53:52 +00:00
if ( ! CurTabName || CurTabName === "undefined" )
2019-07-10 04:01:15 +00:00
CurTabName = TabArr [ 0 ] . name ;
var str ;
2019-07-10 09:53:52 +00:00
for ( var i = 0 ; i < TabArr . length ; i ++ ) {
2019-07-10 04:01:15 +00:00
var name = TabArr [ i ] . name ;
var Item = $ ( name ) ;
2019-07-10 09:53:52 +00:00
if ( ! Item )
2019-07-10 04:01:15 +00:00
continue ;
2019-07-10 09:53:52 +00:00
if ( CurTabName === name ) {
2019-07-10 04:01:15 +00:00
Item . style . display = 'block' ;
str = "active" ;
}
2019-07-10 09:53:52 +00:00
else {
2019-07-10 04:01:15 +00:00
Item . style . display = 'none' ;
str = "" ;
}
var ItemM = $ ( "M" + name ) ;
2019-07-10 09:53:52 +00:00
if ( ItemM ) {
if ( str ) {
2019-07-10 04:01:15 +00:00
ItemM . classList . add ( str ) ;
}
2019-07-10 09:53:52 +00:00
else {
2019-07-10 04:01:15 +00:00
ItemM . classList . remove ( "active" ) ;
}
}
}
} ;
2019-07-10 09:53:52 +00:00
function IsPrivateMode ( ) {
2019-07-10 04:01:15 +00:00
var PrivKeyStr = GetPrivKey ( ) ;
2019-07-10 09:53:52 +00:00
if ( PrivKeyStr && PrivKeyStr . length === 64 )
2019-07-10 04:01:15 +00:00
return 1 ;
else
return 0 ;
} ;
2019-07-10 09:53:52 +00:00
function SetVisiblePrivKey ( ) {
if ( bShowPrivKey )
2019-07-10 04:01:15 +00:00
$ ( "idPrivKeyStatic" ) . innerText = GetPrivKey ( ) ;
else
$ ( "idPrivKeyStatic" ) . innerText = "••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••" ;
} ;
var bShowPrivKey = 0 ;
2019-07-10 09:53:52 +00:00
function OnVisiblePrivKey ( ) {
2019-07-10 04:01:15 +00:00
bShowPrivKey = ! bShowPrivKey ;
SetVisiblePrivKey ( ) ;
} ;
2019-07-10 09:53:52 +00:00
function SetPubKeyHTML ( ) {
2019-07-10 04:01:15 +00:00
$ ( "idPubKeyStatic" ) . innerText = GetPubKey ( ) ;
} ;
2019-07-10 09:53:52 +00:00
function GenerateKeyNew ( ) {
2019-07-10 04:01:15 +00:00
var arr = new Uint8Array ( 32 ) ;
window . crypto . getRandomValues ( arr ) ;
var Str = GetHexFromArr ( sha3 ( arr ) ) ;
$ ( "idPrivKeyEdit" ) . value = Str ;
} ;
2019-07-10 09:53:52 +00:00
function OnGenerateKeyNew ( ) {
2019-07-10 04:01:15 +00:00
GenerateKeyNew ( ) ;
} ;
2019-07-10 09:53:52 +00:00
function OnEditPrivKey ( ) {
2019-07-10 04:01:15 +00:00
} ;
2019-07-10 09:53:52 +00:00
function OnPrivKeyOK ( ) {
2019-07-10 04:01:15 +00:00
SetPrivKey ( $ ( "idPrivKeyEdit" ) . value . trim ( ) ) ;
InitPrivKey ( ) ;
SelectTab ( 'TabKeySet' ) ;
ClearSend ( ) ;
} ;
2019-07-10 09:53:52 +00:00
function OnPrivKeyCancel ( ) {
2019-07-10 04:01:15 +00:00
InitPrivKey ( ) ;
SelectTab ( 'TabKeySet' ) ;
} ;
var FirstAccountsData = 1 ;
2019-07-10 09:53:52 +00:00
var AccountsCount = - 1 ;
function UpdatesAccountsData ( ) {
if ( IsVisibleClass ( ".accounts-info__add" ) )
return ;
if ( ! CONNECT _STATUS )
return ;
2019-07-10 04:01:15 +00:00
var Str = GetPubKey ( ) ;
2019-07-10 09:53:52 +00:00
if ( ! Str ) {
return ;
}
GetData ( "/GetAccountListByKey" , { Key : Str , AllData : FirstAccountsData } , function ( Data , responseText ) {
if ( ! Data || ! Data . result || ! Data . arr )
return ;
if ( AccountsCount === Data . arr . length ) {
if ( IsVisibleClass ( ".accounts-info__add2" ) )
return ;
2019-07-10 04:01:15 +00:00
}
AccountsCount = Data . arr . length ;
SetVisibleClass ( ".accounts-info__acc-list" , AccountsCount ) ;
SetVisibleClass ( ".accounts-info__empty" , ! AccountsCount ) ;
SetVisibleClass ( ".accounts-info__add2" , 0 ) ;
2019-07-10 09:53:52 +00:00
if ( AccountsCount ) {
2019-07-10 04:01:15 +00:00
SetAccountsCard ( Data , responseText ) ;
}
2019-07-10 09:53:52 +00:00
else {
if ( FirstAccountsData && ! Data . arr . length ) {
2019-07-10 04:01:15 +00:00
SelectTab ( 'TabAccounts' ) ;
}
}
FirstAccountsData = 0 ;
} ) ;
} ;
2019-07-10 09:53:52 +00:00
function ViewAddAccount ( Visible ) {
2019-07-10 04:01:15 +00:00
SetVisibleClass ( ".accounts-info__add" , Visible ) ;
SetVisibleClass ( ".accounts-info__acc-list" , ! Visible ) ;
SetVisibleClass ( ".accounts-info__empty" , 0 ) ;
} ;
2019-07-10 09:53:52 +00:00
function OnViewAddAccount ( ) {
2019-07-10 04:01:15 +00:00
OnChangeAccName ( ) ;
ViewAddAccount ( 1 ) ;
$ ( "idAccountName" ) . focus ( ) ;
} ;
2019-07-10 09:53:52 +00:00
function CancelAddAccount ( ) {
2019-07-10 04:01:15 +00:00
ViewAddAccount ( 0 ) ;
} ;
2019-07-10 09:53:52 +00:00
function OnChangeAccName ( ) {
2019-07-10 04:01:15 +00:00
$ ( "idBtAddAccount" ) . disabled = ! ( $ ( "idAccountName" ) . value . length ) ;
} ;
2019-07-10 09:53:52 +00:00
function CancelCreateAccount ( ) {
2019-07-10 04:01:15 +00:00
} ;
2019-07-10 09:53:52 +00:00
function OnAddAccount ( ) {
2019-07-10 04:01:15 +00:00
var Name = $ ( "idAccountName" ) . value ;
2019-07-10 09:53:52 +00:00
if ( ! Name ) {
2019-07-10 04:01:15 +00:00
SetError ( "Enter the account name" ) ;
2019-07-10 09:53:52 +00:00
return ;
2019-07-10 04:01:15 +00:00
}
var Smart = 0 ;
var Currency = ParseNum ( $ ( "idAccountCur" ) . value ) ;
SetStatus ( "Calculate Tx, wait pls ..." ) ;
SendTrCreateAccWait ( Currency , GetPubKey ( ) , Name , Smart ) ;
SetVisibleClass ( ".accounts-info__add" , 0 ) ;
SetVisibleClass ( ".accounts-info__add2" , 1 ) ;
} ;
var WasAccountsDataStr ;
var StrAccCardTemplate ;
2019-07-10 09:53:52 +00:00
function InitAccountsCard ( ) {
if ( $ ( "AccCardTemplate" ) ) {
2019-07-10 04:01:15 +00:00
StrAccCardTemplate = $ ( "AccCardTemplate" ) . outerHTML ;
$ ( "AccCardTemplate" ) . outerHTML = "" ;
}
} ;
2019-07-10 09:53:52 +00:00
function SetAccountsCard ( Data , AccountsDataStr ) {
if ( ! Data || ! Data . result ) {
return ;
2019-07-10 04:01:15 +00:00
}
2019-07-10 09:53:52 +00:00
if ( AccountsDataStr === WasAccountsDataStr )
return ;
2019-07-10 04:01:15 +00:00
WasAccountsDataStr = AccountsDataStr ;
var arr = [ ] ;
2019-07-10 09:53:52 +00:00
for ( var i = 0 ; Data . arr && i < Data . arr . length ; i ++ ) {
2019-07-10 04:01:15 +00:00
var Item = Data . arr [ i ] ;
2019-07-10 09:53:52 +00:00
if ( ! DelList [ Item . Num ] ) {
2019-07-10 04:01:15 +00:00
arr . push ( Item ) ;
}
}
var Select = $ ( "idAccount" ) ;
2019-07-10 09:53:52 +00:00
if ( arr . length !== Select . options . length ) {
2019-07-10 04:01:15 +00:00
var options = Select . options ;
options . length = arr . length ;
}
MaxBlockNum = GetCurrentBlockNumByTime ( ) ;
$ ( "idListCount" ) . innerText = arr . length ;
var StrList = "" ;
var ListTotal = { } ;
2019-07-10 09:53:52 +00:00
for ( var i = 0 ; arr && i < arr . length ; i ++ ) {
2019-07-10 04:01:15 +00:00
var Item = arr [ i ] ;
Item . MyAccount = true ;
var Num = ParseNum ( Item . Num ) ;
2019-07-10 09:53:52 +00:00
if ( ! MapAccounts [ Num ] )
2019-07-10 04:01:15 +00:00
MapAccounts [ Num ] = { } ;
CopyObjKeys ( MapAccounts [ Num ] , Item ) ;
var option = Select . options [ i ] ;
var StrText = GetAccountText ( Item , Num , 1 ) ;
2019-07-10 09:53:52 +00:00
if ( option . text !== StrText )
2019-07-10 04:01:15 +00:00
CheckNameAccTo ( ) ;
option . value = Num ;
option . text = StrText ;
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 CurrencyObj = Item . CurrencyObj ;
2019-07-10 09:53:52 +00:00
if ( ! CurrencyObj )
CurrencyObj = { IconBlockNum : 0 , Num : 0 } ;
2019-07-10 04:01:15 +00:00
Str = Str . replace ( "{Value.CurrencyIconPath}" , RetIconPath ( CurrencyObj , 1 ) ) ;
var CurrencyPath = RetIconPath ( CurrencyObj ) ;
2019-07-10 09:53:52 +00:00
if ( CurrencyPath . substr ( 0 , 6 ) !== "/file/" )
2019-07-10 04:01:15 +00:00
Str = Str . replace ( "prod-card__currency--with-dot" , "" ) ;
Str = Str . replace ( "{Item.Name}" , escapeHtml ( Item . Name ) ) ;
var SmartObj = Item . SmartObj ;
2019-07-10 09:53:52 +00:00
if ( ! SmartObj )
SmartObj = { Name : "" , Num : 0 } ;
2019-07-10 04:01:15 +00:00
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 ) ;
2019-07-10 09:53:52 +00:00
if ( SmartObj . Num ) {
2019-07-10 04:01:15 +00:00
Str = Str . replace ( "prod-card__link--connect" , "myhidden" ) ;
}
2019-07-10 09:53:52 +00:00
else {
2019-07-10 04:01:15 +00:00
Str = Str . replace ( "prod-card__link--dapp" , "myhidden" ) ;
Str = Str . replace ( "prod-card__dropdown" , "prod-card__dropdown nodapp" ) ;
}
StrList += Str ;
Str = "" ;
var Total = ListTotal [ Item . Currency ] ;
2019-07-10 09:53:52 +00:00
if ( ! Total ) {
Total = { SumCOIN : 0 , SumCENT : 0 , Name : CurrencyName ( Item . Currency ) } ;
2019-07-10 04:01:15 +00:00
ListTotal [ Item . Currency ] = Total ;
}
ADD ( Total , Item . Value ) ;
}
$ ( "idAccountsList" ) . innerHTML = StrList ;
StrList = "" ;
var StrTotal = "" ;
2019-07-10 09:53:52 +00:00
for ( var key in ListTotal ) {
2019-07-10 04:01:15 +00:00
var Total = ListTotal [ key ] ;
StrTotal += '<div class="total-info__item"><dt>' + Total . Name + '</dt><dd>' + STRING _FROM _COIN ( Total ) + '</dd></div>' ;
}
$ ( "idTotalList" ) . innerHTML = StrTotal ;
var CurentValue = LoadMapAfter [ "idAccount" ] ;
2019-07-10 09:53:52 +00:00
if ( CurentValue ) {
2019-07-10 04:01:15 +00:00
Select . value = CurentValue ;
delete LoadMapAfter [ "idAccount" ] ;
}
} ;
2019-07-10 09:53:52 +00:00
function ConnectSmart ( NumAccount ) {
2019-07-10 04:01:15 +00:00
ChangeSmart ( NumAccount , 0 ) ;
} ;
2019-07-10 09:53:52 +00:00
function SetSmart ( NumAccount , WasSmart ) {
2019-07-10 04:01:15 +00:00
ChangeSmart ( NumAccount , WasSmart ) ;
} ;
2019-07-10 09:53:52 +00:00
function DelSmart ( NumAccount , WasSmart ) {
2019-07-10 04:01:15 +00:00
SetSmartToAccount ( NumAccount , 0 ) ;
} ;
2019-07-10 09:53:52 +00:00
function DelAccount ( NumAccount ) {
2019-07-10 04:01:15 +00:00
DelList [ NumAccount ] = 1 ;
AccountsCount = 0 ;
WasAccountsDataStr = "" ;
SaveValues ( ) ;
} ;
2019-07-10 09:53:52 +00:00
function RestoreAllAccounts ( ) {
2019-07-10 04:01:15 +00:00
DelList = { } ;
DelAccount ( 0 ) ;
} ;
2019-07-10 09:53:52 +00:00
function UpdatesExplorerData ( ) {
2019-07-10 04:01:15 +00:00
var WasSendTr = 0 ;
2019-07-10 09:53:52 +00:00
for ( var key in MapSendTransaction ) {
2019-07-10 04:01:15 +00:00
var Item = MapSendTransaction [ key ] ;
2019-07-10 09:53:52 +00:00
if ( ! Item . WasProcess && ! Item . final ) {
2019-07-10 04:01:15 +00:00
WasSendTr = 1 ;
break ;
}
}
2019-07-10 09:53:52 +00:00
GetData ( "GetCurrentInfo" , { Diagram : IsVisibleBlock ( "idStatBlock" ) ? 1 : 0 , ArrLog : WasSendTr } , function ( Data ) {
if ( ! Data || ! Data . result )
return ;
2019-07-10 04:01:15 +00:00
SetExplorerData ( Data ) ;
SetBlockChainConstant ( Data ) ;
var arr = Data . arr ;
2019-07-10 09:53:52 +00:00
for ( var i = 0 ; arr && i < arr . length ; i ++ ) {
2019-07-10 04:01:15 +00:00
var ItemServer = arr [ i ] ;
var ItemClient = DiagramMap [ ItemServer . name ] ;
2019-07-10 09:53:52 +00:00
if ( ! ItemClient || ItemClient . Extern )
2019-07-10 04:01:15 +00:00
continue ;
ItemClient . arr = ItemServer . arr ;
ItemClient . AvgValue = ItemServer . AvgValue ;
ItemClient . steptime = ItemServer . steptime ;
ItemClient . fillStyle = "white" ;
DrawDiagram ( ItemClient ) ;
}
} ) ;
} ;
var FirstCallDiagram = 1 ;
2019-07-10 09:53:52 +00:00
function SetExplorerData ( Data ) {
if ( ! Data || ! Data . result )
return ;
2019-07-10 04:01:15 +00:00
CONFIG _DATA = Data ;
window . FIRST _TIME _BLOCK = Data . FIRST _TIME _BLOCK ;
2019-07-10 09:53:52 +00:00
if ( FirstCallDiagram ) {
2019-07-10 04:01:15 +00:00
ViewEnd ( DefAccounts , CONFIG _DATA . MaxAccID , 1 ) ;
ViewEnd ( DefBlock , CONFIG _DATA . MaxNumBlockDB , 1 ) ;
InitDiagram ( ) ;
}
FirstCallDiagram = 0 ;
var StrVersion = " 0." + Data . VersionNum ;
$ ( "idBHeight" ) . innerText = Data . MaxNumBlockDB ;
$ ( "idBCurrent" ) . innerText = Data . CurBlockNum ;
$ ( "idBVersion" ) . innerText = StrVersion ;
SetArrLog ( Data . ArrLog ) ;
} ;
2019-07-10 09:53:52 +00:00
function SetArrLog ( arr ) {
if ( ! arr )
return ;
for ( var i = 0 ; i < arr . length ; i ++ ) {
2019-07-10 04:01:15 +00:00
var Item = arr [ i ] ;
2019-07-10 09:53:52 +00:00
if ( ! Item . final )
2019-07-10 04:01:15 +00:00
continue ;
var TR = MapSendTransaction [ Item . key ] ;
2019-07-10 09:53:52 +00:00
if ( TR && ! TR . WasProcess && Item . final ) {
2019-07-10 04:01:15 +00:00
TR . WasProcess = 1 ;
SetStatus ( Item . text ) ;
2019-07-10 09:53:52 +00:00
if ( Item . text . indexOf ( "Add to blockchain" ) >= 0 ) {
if ( TR . Run ) {
2019-07-10 04:01:15 +00:00
TR . Run ( TR ) ;
TR . Run = undefined ;
}
}
var Account = MapCheckTransaction [ Item . key ] ;
2019-07-10 09:53:52 +00:00
if ( Account ) {
2019-07-10 04:01:15 +00:00
delete MapCheckTransaction [ Item . key ] ;
Account . NextSendTime = 0 ;
}
}
}
CheckSending ( ) ;
} ;
2019-07-10 09:53:52 +00:00
var DiagramArr = [ { name : "MAX:ALL_NODES" , text : "All nodes count" , value : 0 , red : "#1d506b" , MouseText : " nodes" } , {
name : "MAX:HASH_RATE_B" ,
text : "HashRate, Tera hash/s" , value : 0 , red : "#286b16" , MathPow : 2 , MathDiv : 1024 * 1024 * 1024 * 1024 , KPrecision : 10 , NoTextMax : 1 ,
MouseText : " T h/s"
} , ] ;
2019-07-10 04:01:15 +00:00
2019-07-10 09:53:52 +00:00
function InitDiagram ( ) {
2019-07-10 04:01:15 +00:00
InitDiagramByArr ( DiagramArr , 1120 ) ;
} ;
2019-07-10 09:53:52 +00:00
function ViewCounters ( This ) {
2019-07-10 04:01:15 +00:00
var BlockName = "idStatBlock" ;
var element = $ ( BlockName ) ;
var bVisible = IsVisibleBlock ( BlockName ) ;
2019-07-10 09:53:52 +00:00
if ( ! bVisible )
2019-07-10 04:01:15 +00:00
MoveUp ( element ) ;
SetVisibleBlock ( BlockName , ! bVisible ) ;
var ResVisible = IsVisibleBlock ( BlockName ) ;
2019-07-10 09:53:52 +00:00
if ( This && This . className ) {
2019-07-10 04:01:15 +00:00
This . className = This . className . replace ( "btpress" , "" ) ;
2019-07-10 09:53:52 +00:00
if ( ResVisible )
2019-07-10 04:01:15 +00:00
This . className += " btpress" ;
}
} ;
setInterval ( CheckSending , 1000 ) ;
2019-07-10 09:53:52 +00:00
function OpenAddressBook ( ) {
return ;
2019-07-10 04:01:15 +00:00
var bVisible = IsVisibleBlock ( "idAddressBook" ) ;
SetVisibleBlock ( "idAddressBook" , ! bVisible ) ;
} ;
2019-07-10 09:53:52 +00:00
function CloaseAddressBook ( ) {
2019-07-10 04:01:15 +00:00
OpenAddressBook ( ) ;
} ;
2019-07-10 09:53:52 +00:00
function ClearSend ( ) {
2019-07-10 04:01:15 +00:00
$ ( "idAccount" ) . value = "" ;
$ ( "idTo" ) . value = "" ;
$ ( "idSumSend" ) . value = "" ;
$ ( "idDescription" ) . value = "" ;
$ ( "idNameTo2" ) . innerText = "" ;
} ;
2019-07-10 09:53:52 +00:00
function downloadKey ( fieldID ) {
2019-07-10 04:01:15 +00:00
var text = document . getElementById ( fieldID ) . value ;
2019-07-10 09:53:52 +00:00
var blob = new Blob ( [ text ] , { type : "text/plain" } ) ;
2019-07-10 04:01:15 +00:00
var anchor = document . createElement ( "a" ) ;
anchor . download = "tera-key.txt" ;
anchor . href = window . URL . createObjectURL ( blob ) ;
anchor . target = "_blank" ;
anchor . style . display = "none" ;
document . body . appendChild ( anchor ) ;
anchor . click ( ) ;
document . body . removeChild ( anchor ) ;
} ;
2019-07-10 09:53:52 +00:00
function openModal ( id ) {
2019-07-10 04:01:15 +00:00
var modal = document . querySelector ( "#" + id ) ;
var overlay = document . querySelector ( "#overlay" ) ;
modal . style . display = "block" ;
overlay . style . display = "block" ;
} ;
2019-07-10 09:53:52 +00:00
function closeModal ( ) {
if ( NotModalClose )
return ;
2019-07-10 04:01:15 +00:00
var modals = document . querySelectorAll ( ".modal" ) ;
var overlay = document . querySelector ( "#overlay" ) ;
2019-07-10 09:53:52 +00:00
modals . forEach ( function ( item ) {
2019-07-10 04:01:15 +00:00
item . style . display = "none" ;
} ) ;
overlay . style . display = "none" ;
} ;
2019-07-10 09:53:52 +00:00
function showMenu ( Num ) {
2019-07-10 04:01:15 +00:00
var menu = document . querySelector ( "#idBt" + Num ) ;
2019-07-10 09:53:52 +00:00
if ( menu . style . display === "none" ) {
2019-07-10 04:01:15 +00:00
menu . style . display = "block" ;
}
2019-07-10 09:53:52 +00:00
else {
2019-07-10 04:01:15 +00:00
menu . style . display = "none" ;
}
} ;
2019-07-10 09:53:52 +00:00
function closeMenu ( Num ) {
2019-07-10 04:01:15 +00:00
var menu = document . querySelector ( "#idBt" + Num ) ;
2019-07-10 09:53:52 +00:00
setTimeout ( function ( ) {
2019-07-10 04:01:15 +00:00
menu . style . display = "none" ;
} , 115 ) ;
} ;
2019-07-10 09:53:52 +00:00
function UploadKey ( id ) {
2019-07-10 04:01:15 +00:00
var file = $ ( id ) . files [ 0 ] ;
var reader = new FileReader ( ) ;
2019-07-10 09:53:52 +00:00
reader . onload = function ( ) {
if ( reader . result . byteLength !== 64 )
2019-07-10 04:01:15 +00:00
SetError ( "Error file length (" + reader . result . byteLength + ")" ) ;
2019-07-10 09:53:52 +00:00
else {
2019-07-10 04:01:15 +00:00
var view = new Uint8Array ( reader . result ) ;
var Key = Utf8ArrayToStr ( view ) ;
SetStatus ( "OK" ) ;
ToLog ( "Result: " + Key ) ;
SetPrivKey ( Key ) ;
InitPrivKey ( ) ;
$ ( id ) . value = "" ;
}
} ;
reader . readAsArrayBuffer ( file ) ;
} ;
2019-07-10 09:53:52 +00:00
function InitPrivKey ( ) {
2019-07-10 04:01:15 +00:00
$ ( "idPrivKeyEdit" ) . value = GetPrivKey ( ) ;
SetPubKeyHTML ( ) ;
SetVisiblePrivKey ( ) ;
$ ( "idSave2" ) . disabled = ! IsPrivateMode ( ) ;
} ;
2019-07-10 09:53:52 +00:00
function SendMobileBefore ( ) {
if ( $ ( "idSendButton" ) . disabled )
return ;
2019-07-10 04:01:15 +00:00
var FromID = ParseNum ( $ ( "idAccount" ) . value ) ;
var Item = MapAccounts [ FromID ] ;
2019-07-10 09:53:52 +00:00
if ( ! Item ) {
2019-07-10 04:01:15 +00:00
SetError ( "Error FROM ID" ) ;
2019-07-10 09:53:52 +00:00
return ;
2019-07-10 04:01:15 +00:00
}
$ ( "idConfirmFromID" ) . innerText = Item . Num ;
$ ( "idConfirmFromName" ) . innerText = Item . Name + " (" + STRING _FROM _COIN ( Item . Value ) + " " + CurrencyNameItem ( Item ) + ")" ;
var ToID = ParseNum ( $ ( "idTo" ) . value ) ;
var Item2 = MapAccounts [ ToID ] ;
2019-07-10 09:53:52 +00:00
if ( ! Item2 ) {
2019-07-10 04:01:15 +00:00
SetError ( "Error TO ID" ) ;
2019-07-10 09:53:52 +00:00
return ;
2019-07-10 04:01:15 +00:00
}
$ ( "idConfirmToID" ) . innerText = Item2 . Num ;
$ ( "idConfirmToName" ) . innerText = Item2 . Name + " (" + STRING _FROM _COIN ( Item2 . Value ) + " " + CurrencyNameItem ( Item2 ) + ")" ;
var CoinAmount = COIN _FROM _FLOAT ( $ ( "idSumSend" ) . value ) ;
$ ( "idConfirmAmount" ) . innerText = STRING _FROM _COIN ( CoinAmount ) ;
$ ( "idConfirmCurrency" ) . innerText = CurrencyNameItem ( Item ) ;
$ ( "idConfirmDescription" ) . innerText = $ ( "idDescription" ) . value ;
SetVisibleClass ( ".send-page__setting" , 0 ) ;
SetVisibleClass ( ".send-page__confirm" , 1 ) ;
SetStatus ( "" ) ;
} ;
2019-07-10 09:53:52 +00:00
function OKSend ( ) {
2019-07-10 04:01:15 +00:00
SendMoney ( ) ;
$ ( "idSumSend" ) . value = 0 ;
CancelSend ( ) ;
} ;
2019-07-10 09:53:52 +00:00
function CancelSend ( ) {
2019-07-10 04:01:15 +00:00
SetVisibleClass ( ".send-page__setting" , 1 ) ;
SetVisibleClass ( ".send-page__confirm" , 0 ) ;
} ;
2019-07-10 09:53:52 +00:00
function SetNewPassword ( ) {
2019-07-10 04:01:15 +00:00
var Str1 = $ ( "Password1" ) . value . trim ( ) ;
var Str2 = $ ( "Password2" ) . value . trim ( ) ;
2019-07-10 09:53:52 +00:00
if ( Str1 !== Str2 ) {
2019-07-10 04:01:15 +00:00
SetError ( "Wrong passwords" ) ;
2019-07-10 09:53:52 +00:00
return ;
2019-07-10 04:01:15 +00:00
}
var Key = GetPrivKey ( ) ;
SetWalletPassword ( Str1 ) ;
SetPrivKey ( Key ) ;
SetPubKeyHTML ( ) ;
closeModal ( ) ;
$ ( "Password1" ) . value = "" ;
$ ( "Password2" ) . value = "" ;
2019-07-10 09:53:52 +00:00
if ( Str1 )
2019-07-10 04:01:15 +00:00
SetStatus ( "Password changed successfully" ) ;
else
SetStatus ( "Password has been reset successfully" ) ;
SetUsePassword ( Str1 ) ;
} ;
var MultipleMode = 0 ;
2019-07-10 09:53:52 +00:00
function MyOpenWallet ( bCheck ) {
2019-07-10 04:01:15 +00:00
var Str = $ ( "Password" ) . value . trim ( ) ;
2019-07-10 09:53:52 +00:00
if ( ! Str ) {
2019-07-10 04:01:15 +00:00
SetError ( "Type password, pls" ) ;
2019-07-10 09:53:52 +00:00
return ;
2019-07-10 04:01:15 +00:00
}
$ ( "Password" ) . value = "" ;
2019-07-10 09:53:52 +00:00
if ( Str . substr ( 0 , 11 ) === "--subwallet" ) {
2019-07-10 04:01:15 +00:00
Str = Str . substr ( 11 ) ;
2019-07-10 09:53:52 +00:00
if ( Str === " off" ) {
2019-07-10 04:01:15 +00:00
Storage . setItem ( "USESUBWALLET" , 0 ) ;
SetStatus ( "Set off subwallet mode" ) ;
}
2019-07-10 09:53:52 +00:00
else {
2019-07-10 04:01:15 +00:00
Storage . setItem ( "USESUBWALLET" , 1 ) ;
SetStatus ( "Set subwallet mode" ) ;
}
SetUsePassword ( 1 ) ;
2019-07-10 09:53:52 +00:00
return ;
2019-07-10 04:01:15 +00:00
}
2019-07-10 09:53:52 +00:00
if ( Str === "--reset" ) {
2019-07-10 04:01:15 +00:00
SetWalletPassword ( "" ) ;
OpenWalletKey ( ) ;
SetUsePassword ( 0 ) ;
NotModalClose = 0 ;
closeModal ( ) ;
2019-07-10 09:53:52 +00:00
return ;
2019-07-10 04:01:15 +00:00
}
SetWalletPassword ( Str ) ;
OpenWalletKey ( ) ;
SetStatus ( "" ) ;
2019-07-10 09:53:52 +00:00
if ( bCheck ) {
2019-07-10 04:01:15 +00:00
var WasPubKey = Storage . getItem ( "WALLET_PUB_KEY_MAIN" ) ;
var PrivKey = GetArrFromHex ( GetPrivKey ( ) ) ;
var TestPubKey = GetHexFromArr ( SignLib . publicKeyCreate ( PrivKey , 1 ) ) ;
2019-07-10 09:53:52 +00:00
if ( WasPubKey !== TestPubKey ) {
2019-07-10 04:01:15 +00:00
SetWalletPassword ( "" ) ;
SetError ( "Wrong password" ) ;
2019-07-10 09:53:52 +00:00
return ;
2019-07-10 04:01:15 +00:00
}
SetStatus ( "Password ok" ) ;
MultipleMode = 0 ;
SetVisibleBlock ( "idKeyEdit" , 1 ) ;
SetVisibleBlock ( "idLoad2" , 1 ) ;
SetVisibleBlock ( "idPasswordEdit" , 1 ) ;
}
2019-07-10 09:53:52 +00:00
else {
2019-07-10 04:01:15 +00:00
MultipleMode = 1 ;
SetVisibleBlock ( "idKeyEdit" , 0 ) ;
SetVisibleBlock ( "idLoad2" , 0 ) ;
SetVisibleBlock ( "idPasswordEdit" , 0 ) ;
}
NotModalClose = 0 ;
closeModal ( ) ;
InitPrivKey ( ) ;
SetPubKeyHTML ( ) ;
SetUsePassword ( 1 ) ;
} ;
2019-07-10 09:53:52 +00:00
function SetUsePassword ( bUse ) {
2019-07-10 04:01:15 +00:00
document . documentElement . style . setProperty ( '--fill--password' , bUse ? 'blue' : 'black' ) ;
SetVisibleBlock ( "idWalletExit" , ! ! bUse ) ;
SetVisibleBlock ( "idEntrance" , Storage . getItem ( "USESUBWALLET" ) === "1" ) ;
} ;
2019-07-10 09:53:52 +00:00
function DoExitWallet ( ) {
2019-07-10 04:01:15 +00:00
ClearSend ( ) ;
NotModalClose = 1 ;
$ ( "Password" ) . value = "" ;
SetWalletPassword ( "" ) ;
OpenWalletKey ( ) ;
openModal ( 'password-modal-enter' ) ;
} ;
var StrDappCardTemplate ;
var StrDappRowCardTemplate ;
var CardMapList = { } ;
2019-07-10 09:53:52 +00:00
function InitDappsCard ( ) {
if ( $ ( "DappRowCardTemplate" ) ) {
2019-07-10 04:01:15 +00:00
StrDappRowCardTemplate = $ ( "DappRowCardTemplate" ) . outerHTML ;
$ ( "DappRowCardTemplate" ) . outerHTML = "" ;
}
2019-07-10 09:53:52 +00:00
if ( $ ( "DappCardTemplate" ) ) {
2019-07-10 04:01:15 +00:00
StrDappCardTemplate = $ ( "DappCardTemplate" ) . outerHTML ;
}
} ;
2019-07-10 09:53:52 +00:00
function ViewDapps ( ) {
2019-07-10 04:01:15 +00:00
ViewCurrent ( DefDapps ) ;
2019-07-10 09:53:52 +00:00
GetData ( "/GetDappCategory" , { } , function ( Data ) {
if ( Data && Data . result && Data . arr ) {
2019-07-10 04:01:15 +00:00
var arr = Data . arr ;
2019-07-10 09:53:52 +00:00
for ( var i = 0 ; i < arr . length ; i ++ ) {
2019-07-10 04:01:15 +00:00
var key = arr [ i ] ;
2019-07-10 09:53:52 +00:00
arr [ i ] = { sort : MapCategory [ key ] . toUpperCase ( ) , text : MapCategory [ key ] , value : key } ;
2019-07-10 04:01:15 +00:00
}
2019-07-10 09:53:52 +00:00
arr . push ( { sort : "-" , text : "Choose the category" , value : 0 } ) ;
2019-07-10 04:01:15 +00:00
FillCategoryAndSort ( "idCategory" , arr ) ;
}
} ) ;
} ;
2019-07-10 09:53:52 +00:00
function FillDappCard ( Str , Item ) {
2019-07-10 04:01:15 +00:00
CardMapList [ Item . Num ] = Item ;
Str = Str . replace ( /{Item.Num}/g , Item . Num ) ;
Str = Str . replace ( "{Item.Name}" , escapeHtml ( Item . Name ) ) ;
Str = Str . replace ( "{Item.Description}" , escapeHtml ( Item . Description ) ) ;
Str = Str . replace ( "{Item.Owner}" , Item . Owner ) ;
2019-07-10 09:53:52 +00:00
if ( ! Item . TokenGenerate )
2019-07-10 04:01:15 +00:00
Str = Str . replace ( "dapp-modal__ok-token" , "myhidden" ) ;
Str = Str . replace ( "{Item.IconPath}" , RetIconPath ( Item , 0 ) ) ;
return Str ;
} ;
2019-07-10 09:53:52 +00:00
function RetDappCard ( Item ) {
2019-07-10 04:01:15 +00:00
var Str = FillDappCard ( StrDappRowCardTemplate , Item ) ;
Str = Str . replace ( "DappRowCardTemplate" , "idCard" + Item . Num ) ;
return Str ;
} ;
2019-07-10 09:53:52 +00:00
function OpenDappCard ( Num ) {
2019-07-10 04:01:15 +00:00
var Item = CardMapList [ Num ] ;
2019-07-10 09:53:52 +00:00
if ( ! Item )
return ;
2019-07-10 04:01:15 +00:00
var Str = FillDappCard ( StrDappCardTemplate , Item ) ;
Str = Str . replace ( "{Item.Account}" , RetBaseAccount ( Item ) ) ;
Str = Str . replace ( "{Item.BlockNum}" , RetOpenBlock ( Item . BlockNum , 2 ) ) ;
Str = FillDappCategory ( Str , Item , 1 ) ;
Str = FillDappCategory ( Str , Item , 2 ) ;
Str = FillDappCategory ( Str , Item , 3 ) ;
$ ( "DappCardTemplate" ) . outerHTML = Str ;
openModal ( 'DappCardTemplate' ) ;
} ;
2019-07-10 09:53:52 +00:00
function OpenDapp ( Num ) {
2019-07-10 04:01:15 +00:00
OpenDapps ( Num ) ;
closeModal ( ) ;
} ;
2019-07-10 09:53:52 +00:00
function FillDappCategory ( Str , Item , Num ) {
2019-07-10 04:01:15 +00:00
var Value = Item [ "Category" + Num ] ;
2019-07-10 09:53:52 +00:00
if ( Value && MapCategory [ Value ] ) {
2019-07-10 04:01:15 +00:00
Str = Str . replace ( "{Item.Category" + Num + "}" , MapCategory [ Value ] ) ;
}
2019-07-10 09:53:52 +00:00
else {
2019-07-10 04:01:15 +00:00
Str = Str . replace ( "dappcategory" + Num , "myhidden" ) ;
}
return Str ;
} ;
2019-07-10 09:53:52 +00:00
function MyToggleList ( e ) {
2019-07-10 04:01:15 +00:00
var item = e . target ;
2019-07-10 09:53:52 +00:00
while ( true ) {
if ( ! item )
2019-07-10 04:01:15 +00:00
break ;
2019-07-10 09:53:52 +00:00
if ( ! item . classList )
2019-07-10 04:01:15 +00:00
break ;
2019-07-10 09:53:52 +00:00
if ( item . onclick && item . onclick !== MyToggleList )
2019-07-10 04:01:15 +00:00
break ;
2019-07-10 09:53:52 +00:00
if ( item . classList . contains ( "find--switch" ) ) {
if ( item . classList . contains ( "prod-card--switch" ) ) {
2019-07-10 04:01:15 +00:00
item . classList . add ( "prod-card--active" ) ;
item . classList . add ( "prod-card--toggle" ) ;
item . classList . remove ( "prod-card--switch" ) ;
}
2019-07-10 09:53:52 +00:00
else {
2019-07-10 04:01:15 +00:00
item . classList . remove ( "prod-card--active" ) ;
item . classList . remove ( "prod-card--toggle" ) ;
item . classList . add ( "prod-card--switch" ) ;
}
break ;
}
item = item . parentNode ;
}
} ;
var LangItems = [ ] ;
2019-07-10 09:53:52 +00:00
function InitLangItems ( ) {
2019-07-10 04:01:15 +00:00
var tags = [ "TITLE" , "BUTTON" , "DIV" , "INPUT" , "TH" , "TD" , "SPAN" , "A" , "H1" , "H2" , "H3" , "H4" , "H5" , "P" , "DT" ] ;
var Map2 = { } ;
2019-07-10 09:53:52 +00:00
for ( var n = 0 ; n < tags . length ; n ++ ) {
2019-07-10 04:01:15 +00:00
var tagname = tags [ n ] ;
var elems = document . getElementsByTagName ( tagname ) ;
2019-07-10 09:53:52 +00:00
for ( var elem , i = 0 ; elem = elems [ i ++ ] ; ) {
2019-07-10 04:01:15 +00:00
var Text = elem . innerText ;
2019-07-10 09:53:52 +00:00
if ( elem . innerHTML !== Text )
2019-07-10 04:01:15 +00:00
continue ;
2019-07-10 09:53:52 +00:00
if ( ! Text )
2019-07-10 04:01:15 +00:00
continue ;
2019-07-10 09:53:52 +00:00
if ( Text . substr ( 0 , 1 ) === "{" )
2019-07-10 04:01:15 +00:00
continue ;
2019-07-10 09:53:52 +00:00
if ( Text . toUpperCase ( ) == Text . toLowerCase ( ) )
2019-07-10 04:01:15 +00:00
continue ;
2019-07-10 09:53:52 +00:00
LangItems . push ( { key : Text , elem : elem } ) ;
2019-07-10 04:01:15 +00:00
}
}
} ;
2019-07-10 09:53:52 +00:00
function DoLangItems ( Map ) {
2019-07-10 04:01:15 +00:00
var Map2 = { } ;
2019-07-10 09:53:52 +00:00
for ( var n = 0 ; n < LangItems . length ; n ++ ) {
2019-07-10 04:01:15 +00:00
var key = LangItems [ n ] . key ;
var elem = LangItems [ n ] . elem ;
2019-07-10 09:53:52 +00:00
if ( Map ) {
2019-07-10 04:01:15 +00:00
var TextNew = Map [ key ] ;
2019-07-10 09:53:52 +00:00
if ( TextNew === undefined ) {
2019-07-10 04:01:15 +00:00
ToLog ( "Not found translate for key: " + key ) ;
Map [ key ] = key ;
TextNew = key ;
}
2019-07-10 09:53:52 +00:00
if ( elem . innerText !== TextNew ) {
2019-07-10 04:01:15 +00:00
elem . innerText = TextNew ;
}
}
2019-07-10 09:53:52 +00:00
else {
2019-07-10 04:01:15 +00:00
Map2 [ key ] = key ;
}
}
return Map2 ;
} ;
2019-07-10 09:53:52 +00:00
function DoLangScript ( ) {
2019-07-10 04:01:15 +00:00
InitLangItems ( ) ;
LangMap [ "ENG" ] = DoLangItems ( ) ;
FillSelect ( "idLang" , LangMap , "KEY" ) ;
} ;
2019-07-10 09:53:52 +00:00
function ChangeLang ( ) {
2019-07-10 04:01:15 +00:00
var key = $ ( "idLang" ) . value ;
2019-07-10 09:53:52 +00:00
if ( ! key ) {
2019-07-10 04:01:15 +00:00
key = "ENG" ;
$ ( "idLang" ) . value = key ;
}
DoLangItems ( LangMap [ key ] ) ;
SaveValues ( ) ;
} ;
2019-07-10 09:53:52 +00:00
function GetNewLangItem ( ) {
2019-07-10 04:01:15 +00:00
ToLog ( JSON . stringify ( LangMap [ "ENG" ] ) ) ;
} ;
var LangMap = { } ;
LangMap [ "ENG" ] = { } ;
2019-07-10 09:53:52 +00:00
LangMap [ "RUS" ] = {
"TERA WALLET" : "TERA КОШЕЛЕК" , "Generate key" : "Сгенерировать ключ" , "OK" : "OK" , "Cancel" : "Отмена" , "Edit" : "Редактирование" ,
"Save key" : "Сохран." , "+ CREATE A NEW ACCOUNT" : "+ СОЗДАТЬ НОВЫЙ СЧЕТ" , "Create account" : "Создать счет" , "Send" : "Отправить" ,
"CONFIRM" : "Подтверждение" , "Accounts" : "Счета" , "Account(s)" : "Счет(а ,ов)" , "Blocks and Tx" : "Блоки и Транзакции" , "Counters" : "Показатели" ,
"Open DApp" : "Открыть Дапп" , "Back" : "Назад" , "Delete" : "Удалить" , "Save to book" : "Сохранить в книгу" , "Choose" : "Выбрать" , "RECONNECT" : "К О Н Н Е К Т " ,
"DApps" : "ДАппс" , "ID" : "ИД" , "Amount" : "Величина" , "Cur" : "Вал" , "Name" : "Имя" , "PubKey" : "Пуб.ключ" , "Operation" : "Операция" , "Smart" : "Смарт" ,
"Block Num" : "Ном блока" , "Num" : "Ном" , "Date" : "Дата" , "Data Hash" : "Хеш данных" , "PowHash" : "Хеш сложности" , "Block Hash" : "Хеш блока" ,
"Bytes" : "Байт" , "Pow" : "Сложн" , "Miner" : "Майнер" , "(secret)" : "(секрет)" , "Show" : "Показать" , "TERA" : "TERA" , "Blockchain height:" : "Высота блокчейна:" ,
"Current create:" : "Текущий блок:" , "Protocol ver:" : "Версия протокола:" , "ID: {Item.Num}" : "ИД: {Item.Num}" , "Token generate" : "Генерация токенов" ,
"ACCOUNTS" : "СЧЕТА" , "SEND" : "ПОСЛАТЬ" , "DAPPS" : "ДАППС" , "EXPLORER" : "ПРОСМ" , "ATTENTION: Before using the wallet, save the private key." : "ВНИМАНИЕ: Перед использованием кошелька сохраните приватный ключ" ,
"Web-site" : "В е б -сайт" , "Bitcointalk" : "Bitcointalk" , "Twitter" : "Твиттер" , "Telegram" : "Телеграм" , "Discord" : "Дискорд" , "QQchat" : "QQchat" ,
"Buy/sell/mine TERA" : "Купить/Продать" , "+ CREATE NEW" : "+ СОЗДАТЬ НОВЫЙ" , "Confirm Transaction" : "Подтверждение транзакции" ,
"CREATE DAPPS" : "СОЗДАТЬ" , "Set pass" : "Установить пароль" , "Unlock" : "Разблокировать" , "Entrance to sub-wallet" : "Войти в под-кошелек" ,
"Public name" : "Публичное имя" , "Currency" : "Валюта" , "Pay to:" : "Получатель:" , "Amount:" : "Сумма:" , "Description:" : "Описание:" ,
"Welcome to TERA Wallet" : "Добропожаловать в кошелек TERA" , "Edit your wallet" : "Редактирование вашего кошелька" , "Key settings" : "Задание ключей" ,
"KEY SETTINGS" : "ЗАДАНИЕ КЛЮЧЕЙ" , "Create an account" : "Создание счета" , "Sending coins" : "Отправка монет" , "Decentralized applications (dApps)" : "Децентрализованные приложения (Даппс)" ,
"Secure your wallet" : "Безопасность вашего кошелька" , "Wallet is secured" : "Установлен пароль" , "Total" : "В с е г о " , "Item.Name" : "Item.Name" ,
"You have no accounts yet" : "У вас нет ни одного счета" , "Wait 10-15 sec" : "Ждите 10-15 сек" , "Creating your account" : "Идет создание вашего счета" ,
"From:" : "Отправитель:" , "Set a password for protect entry" : "Установите пароль для безопасности" , "Enter password to unlock wallet" : "Введите пароль для разблокировки кошелька" ,
"From ID:" : "Отправитель:" , "Pay to 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" : "Публичный ключ"
} ;
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" : "选择" ,
"RECONNECT" : "重连" , "DApps" : "DApps" , "ID" : "ID" , "Amount" : "余额" , "Cur" : "币种" , "Name" : "名称" , "PubKey" : "公钥" , "Operation" : "操作次数" , "Smart" : "DApp" ,
"Block Num" : "区块编号" , "Num" : "编号" , "Date" : "日期" , "Data Hash" : "数据哈希" , "PowHash" : "Pow哈希" , "Block Hash" : "区块哈希" , "Bytes" : "字节" , "Pow" : "Pow" ,
"Miner" : "矿工" , "(secret)" : "(机密)" , "Show" : "显示" , "TERA" : "TERA" , "Blockchain height:" : "区块高度:" , "Current create:" : "最近区块:" , "Protocol ver:" : "协议版本:" ,
"ID: {Item.Num}" : "ID: {Item.Num}" , "Token generate" : "生成代币" , "ACCOUNTS" : "账号" , "DAPPS" : "DAPPS" , "EXPLORER" : "浏览器" , "ATTENTION: Before using the wallet, save the private key." : "注意: 使用钱包前,务必保存好私钥。" ,
"Web-site" : "官网" , "Bitcointalk" : "创世贴" , "Twitter" : "推特" , "Telegram" : "电报" , "Discord" : "Discord" , "QQchat" : "QQ群" , "Buy/sell/mine TERA" : "TERA 交易/挖矿" ,
"+ CREATE NEW" : "+ 新建" , "Confirm Transaction" : "确认交易" , "CREATE DAPPS" : "创建DAPPS" , "Set pass" : "设置密码" , "Unlock" : "解锁" , "Entrance to sub-wallet" : "进入子钱包" ,
"Public name" : "名称" , "Currency" : "币种" , "Pay to:" : "收款:" , "Amount:" : "金额:" , "Description:" : "描述:" , "Welcome to TERA Wallet" : "欢迎使用TERA钱包" ,
"Edit your wallet" : "编辑钱包" , "Key settings" : "设置私钥" , "KEY SETTINGS" : "设置私钥" , "Create an account" : "创建账号" , "Sending coins" : "转账" ,
"Decentralized applications (dApps)" : "去中心化应用 (DApps)" , "Secure your wallet" : "设置钱包密码" , "Wallet is secured" : "钱包密码已设置" , "Total" : "总计" ,
"Item.Name" : "Item.Name" , "You have no accounts yet" : "你还没有账号" , "Wait 10-15 sec" : "等待10-15秒" , "Creating your account" : "创建你的账号" ,
"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" : "公钥"
} ;