@@ -21,6 +21,7 @@ var UI = (function(UI, undefined) {
2121 var callNodeStarted = false ;
2222 var serverLogLines = 0 ;
2323 var webviewIsLoaded = false ;
24+ var lightWallet = false ;
2425 var webview ;
2526
2627 UI . initialize = function ( ) {
@@ -33,6 +34,7 @@ var UI = (function(UI, undefined) {
3334 var params = new URLSearchParams ( location . search . slice ( 1 ) ) ;
3435 showStatusBar = params . get ( "showStatus" ) == 1 ;
3536 isFirstRun = params . get ( "isFirstRun" ) == 1 ;
37+ lightWallet = parseInt ( params . get ( "lightWallet" ) , 10 ) == 1 ;
3638 }
3739
3840 if ( isFirstRun ) {
@@ -50,13 +52,17 @@ var UI = (function(UI, undefined) {
5052 callNodeStarted = false ;
5153 }
5254
53- document . getElementById ( "status-bar-milestone" ) . addEventListener ( "click" , function ( e ) {
54- electron . ipcRenderer . send ( "showServerLog" ) ;
55- } ) ;
55+ if ( ! lightWallet ) {
56+ document . body . className += " full-node" ;
57+ document . getElementById ( "status-bar-milestone" ) . addEventListener ( "click" , function ( e ) {
58+ electron . ipcRenderer . send ( "showServerLog" ) ;
59+ } ) ;
60+
61+ document . getElementById ( "status-bar-solid-milestone" ) . addEventListener ( "click" , function ( e ) {
62+ electron . ipcRenderer . send ( "showServerLog" ) ;
63+ } ) ;
64+ }
5665
57- document . getElementById ( "status-bar-solid-milestone" ) . addEventListener ( "click" , function ( e ) {
58- electron . ipcRenderer . send ( "showServerLog" ) ;
59- } ) ;
6066
6167 document . getElementById ( "new-user" ) . addEventListener ( "click" , function ( e ) {
6268 UI . sendToWebview ( "openHelpMenu" ) ;
@@ -115,16 +121,6 @@ var UI = (function(UI, undefined) {
115121 return false ;
116122 } , false ) ;
117123
118- webview . addEventListener ( "drop" , function ( e , b ) {
119- if ( e . dataTransfer && e . dataTransfer . files && e . dataTransfer . files [ 0 ] && e . dataTransfer . files [ 0 ] . path ) {
120- if ( String ( e . dataTransfer . files [ 0 ] . path ) . match ( / I R I .* \. j a r $ / i) ) {
121- electron . ipcRenderer . send ( "upgradeIRI" , e . dataTransfer . files [ 0 ] . path ) ;
122- }
123- }
124- e . preventDefault ( ) ;
125- return false ;
126- } , false ) ;
127-
128124 //also "dom-ready"
129125 webview . addEventListener ( "did-finish-load" , UI . webviewDidFinishLoad ( ) ) ;
130126
@@ -349,13 +345,10 @@ var UI = (function(UI, undefined) {
349345 */
350346
351347 modal . setContent ( "<h1>Preferences</h1>" +
352- "<div class='input-group input-group'><label>Java Arguments:</label>" +
353- "<input type='text' name='java_args' id='preferences_java_args' placeholder='Command Line Parameters' value='" + ( settings . javaArgs ? String ( settings . javaArgs ) . escapeHTML ( ) : "" ) + "' /></div>" +
354348 ( process . platform != "linux" ? "<div class='input-group input-group-last'><label class='label--checkbox'><input type='checkbox' name='open_at_login' id='preferences_open_at_login' class='checkbox' value='1'" + ( settings . openAtLogin ? " checked='checked'" : "" ) + " />Open at Login</label>" : "" ) ) ;
355349
356350 modal . addFooterBtn ( "Save" , "tingle-btn tingle-btn--primary" , function ( ) {
357351 var settings = { } ;
358- settings . javaArgs = String ( document . getElementById ( "preferences_java_args" ) . value ) . trim ( ) ;
359352
360353 if ( process . platform != "linux" ) {
361354 settings . openAtLogin = document . getElementById ( "preferences_open_at_login" ) . checked ;
@@ -419,7 +412,7 @@ var UI = (function(UI, undefined) {
419412 var modalContent = document . querySelector ( ".tingle-modal-box__content" ) ;
420413 modalContent . appendChild ( close ) ;
421414
422- var el = document . getElementById ( "server_config_port" ) ;
415+ var el = document . getElementById ( configuration . lightWallet ? "server_config_host" : "server_config_port" ) ;
423416
424417 var temp = el . value ;
425418 el . value = "" ;
@@ -428,22 +421,51 @@ var UI = (function(UI, undefined) {
428421 }
429422 } ) ;
430423
431- modal . setContent ( "<h1>Server Config</h1>" +
432- "<div class='input-group'><label>Server Port:</label>" +
433- "<input type='number' min='1024' name='port' id='server_config_port' placeholder='' value='" + ( configuration . port ? String ( configuration . port ) . escapeHTML ( ) : "14265" ) + "' /></div>" +
434- "<div class='input-group'><label>Depth:</label>" +
435- "<input type='number' min='1' name='depth' id='server_config_depth' placeholder='' value='" + ( configuration . depth ? String ( configuration . depth ) . escapeHTML ( ) : "3" ) + "' /></div>" +
436- "<div class='input-group'><label>Min Weight Magnitude:</label>" +
437- "<input type='number' min='" + ( configuration . testNet ? "13" : "18" ) + "' name='min_weight_magnitude' id='server_config_min_weight_magnitude' placeholder='' value='" + ( configuration . minWeightMagnitude ? String ( configuration . minWeightMagnitude ) . escapeHTML ( ) : ( configuration . testNet ? "13" : "18" ) ) + "' /></div>" +
438- "<div class='input-group input-group'><label>Neighboring Nodes:</label>" +
439- "<textarea name='neighboring_nodes' id='server_config_neighboring_nodes' style='width:100%;height:150px;' placeholder='Add nodes in the following format (one per line):\r\n\r\nudp://ip:12345'>" + String ( configuration . nodes ) . escapeHTML ( ) + "</textarea></div>" ) ;
424+ var content = "" ;
425+
426+ if ( configuration . lightWallet ) {
427+ content = "<h1>Node Config</h1>" +
428+ "<div class='input-group'><label>Host: <span class='error' id='host-error'></span></label>" +
429+ "<input type='text' id='server_config_host' placeholder='' value='" + ( configuration . lightWalletHost ? String ( configuration . lightWalletHost ) . escapeHTML ( ) + ( configuration . lightWalletPort ? ":" + String ( configuration . lightWalletPort ) . escapeHTML ( ) : "" ) : "" ) + "' /></div>" +
430+ "<div class='input-group'><label>Min Weight Magnitude:</label>" +
431+ "<input type='number' min='" + ( configuration . testNet ? "13" : "18" ) + "' name='min_weight_magnitude' id='server_config_min_weight_magnitude' placeholder='' value='" + ( configuration . minWeightMagnitude ? String ( configuration . minWeightMagnitude ) . escapeHTML ( ) : ( configuration . testNet ? "13" : "18" ) ) + "' /></div>" ;
432+ } else {
433+ content = "<h1>Node Config</h1>" +
434+ "<div class='input-group'><label>Node Port:</label>" +
435+ "<input type='number' min='1024' name='port' id='server_config_port' placeholder='' value='" + ( configuration . port ? String ( configuration . port ) . escapeHTML ( ) : "14265" ) + "' /></div>" +
436+ "<div class='input-group'><label>Depth:</label>" +
437+ "<input type='number' min='1' name='depth' id='server_config_depth' placeholder='' value='" + ( configuration . depth ? String ( configuration . depth ) . escapeHTML ( ) : "3" ) + "' /></div>" +
438+ "<div class='input-group'><label>Min Weight Magnitude:</label>" +
439+ "<input type='number' min='" + ( configuration . testNet ? "13" : "18" ) + "' name='min_weight_magnitude' id='server_config_min_weight_magnitude' placeholder='' value='" + ( configuration . minWeightMagnitude ? String ( configuration . minWeightMagnitude ) . escapeHTML ( ) : ( configuration . testNet ? "13" : "18" ) ) + "' /></div>" +
440+ "<div class='input-group input-group'><label>Neighboring Nodes:</label>" +
441+ "<textarea name='neighboring_nodes' id='server_config_neighboring_nodes' style='width:100%;height:150px;' placeholder='Add nodes in the following format (one per line):\r\n\r\nudp://ip:12345'>" + String ( configuration . nodes ) . escapeHTML ( ) + "</textarea></div>" ;
442+ }
443+
444+ modal . setContent ( content ) ;
440445
441446 modal . addFooterBtn ( "Save" , "tingle-btn tingle-btn--primary" , function ( ) {
442- var config = { } ;
443- config . port = parseInt ( document . getElementById ( "server_config_port" ) . value , 10 ) ;
444- config . depth = parseInt ( document . getElementById ( "server_config_depth" ) . value , 10 ) ;
445- config . minWeightMagnitude = parseInt ( document . getElementById ( "server_config_min_weight_magnitude" ) . value , 10 ) ;
446- config . nodes = document . getElementById ( "server_config_neighboring_nodes" ) . value ;
447+ var config = { } ;
448+
449+ config . lightWallet = configuration . lightWallet ;
450+
451+ if ( configuration . lightWallet ) {
452+ var res = String ( document . getElementById ( "server_config_host" ) . value ) . match ( / ^ ( h t t p s ? : \/ \/ .* ) : ( [ 0 - 9 ] + ) $ / i) ;
453+
454+ if ( ! res ) {
455+ document . getElementById ( "host-error" ) . style . display = "inline" ;
456+ document . getElementById ( "host-error" ) . innerHTML = "Invalid!" ;
457+ return ;
458+ }
459+
460+ config . lightWalletHost = res [ 1 ] ;
461+ config . lightWalletPort = res [ 2 ] ;
462+ config . minWeightMagnitude = parseInt ( document . getElementById ( "server_config_min_weight_magnitude" ) . value , 10 ) ;
463+ } else {
464+ config . port = parseInt ( document . getElementById ( "server_config_port" ) . value , 10 ) ;
465+ config . depth = parseInt ( document . getElementById ( "server_config_depth" ) . value , 10 ) ;
466+ config . minWeightMagnitude = parseInt ( document . getElementById ( "server_config_min_weight_magnitude" ) . value , 10 ) ;
467+ config . nodes = document . getElementById ( "server_config_neighboring_nodes" ) . value ;
468+ }
447469
448470 modal . close ( ) ;
449471
@@ -629,9 +651,9 @@ var UI = (function(UI, undefined) {
629651 }
630652 }
631653
632- UI . notify = function ( type , message ) {
654+ UI . notify = function ( type , message , options ) {
633655 if ( webviewIsLoaded && webview ) {
634- webview . send ( "notify" , type , message ) ;
656+ webview . send ( "notify" , type , message , options ) ;
635657 }
636658 }
637659
@@ -643,7 +665,9 @@ var UI = (function(UI, undefined) {
643665 if ( url == "config" || url == "configuration" || url == "setup" ) {
644666 electron . ipcRenderer . send ( "editNodeConfiguration" ) ;
645667 } else if ( url == "log" ) {
646- electron . ipcRenderer . send ( "showServerLog" ) ;
668+ if ( ! lightWallet ) {
669+ electron . ipcRenderer . send ( "showServerLog" ) ;
670+ }
647671 } else if ( url == "nodeinfo" || url == "node" ) {
648672 UI . sendToWebview ( "showNodeInfo" ) ;
649673 } else if ( url == "peers" ) {
@@ -652,12 +676,16 @@ var UI = (function(UI, undefined) {
652676 UI . sendToWebview ( "showNetworkSpammer" ) ;
653677 } else if ( url == "generateseed" || url == "seed" ) {
654678 UI . sendToWebview ( "generateSeed" ) ;
679+ } else if ( url == "claim" ) {
680+ UI . sendToWebview ( "showClaimProcess" ) ;
655681 } else if ( url == "faq" ) {
656682 UI . sendToWebview ( "faq" ) ;
657683 } else {
658684 var match = url . match ( / (?: a d d n o d e | a d d n e i g h b o u ? r ) \/ ( .* ) / i) ;
659685 if ( match && match [ 1 ] && match [ 1 ] . charAt ( 0 ) != "-" ) {
660- UI . addNeighborNode ( match [ 1 ] ) ;
686+ if ( ! lightWallet ) {
687+ UI . addNeighborNode ( match [ 1 ] ) ;
688+ }
661689 } else {
662690 UI . sendToWebview ( "handleURL" , url ) ;
663691 }
@@ -799,6 +827,10 @@ electron.ipcRenderer.on("showClaimProcess", function() {
799827 UI . sendToWebview ( "showClaimProcess" ) ;
800828} ) ;
801829
830+ electron . ipcRenderer . on ( "addAndRemoveNeighbors" , function ( event , addedNodes , removedNodes ) {
831+ UI . sendToWebview ( "addAndRemoveNeighbors" , { "add" : addedNodes , "remove" : removedNodes } ) ;
832+ } ) ;
833+
802834electron . ipcRenderer . on ( "editNodeConfiguration" , function ( event , serverConfiguration ) {
803835 UI . editNodeConfiguration ( serverConfiguration ) ;
804836} ) ;
@@ -817,8 +849,8 @@ electron.ipcRenderer.on("hoverAmountStop", function() {
817849 UI . updateStatusBar ( { "hoverAmount" : - 1 } ) ;
818850} ) ;
819851
820- electron . ipcRenderer . on ( "notify" , function ( event , type , msg ) {
821- UI . notify ( type , msg ) ;
852+ electron . ipcRenderer . on ( "notify" , function ( event , type , message , options ) {
853+ UI . notify ( type , message , options ) ;
822854} ) ;
823855
824856electron . ipcRenderer . on ( "relaunch" , UI . relaunch ) ;
0 commit comments