1+ window . lastLogLineCount = window . lastLogLineCount || { } ;
2+
13function closeMenu ( ) {
24 $ ( "#menu" ) . animate (
35 {
@@ -502,17 +504,18 @@ $(document).ready(function () {
502504 var server = obj . servers [ index ] ;
503505 let serverName = server . name ;
504506 addDropdownNoDupe ( serverName , ! server . active ) ;
505- if ( justStarted ) {
506- // Do not update config here, wait for ConfigInfo
507- var lines = server . output . split ( "\r\n" ) ;
508- for ( linePos in lines ) {
509- var line = lines [ linePos ] ;
510- var p = $ ( '<p class="STDOutMessage"></p>' ) . appendTo (
511- "." + serverName + "Out" ,
512- ) [ 0 ] ;
507+ var outDiv = $ ( "." + serverName + "Out" ) ;
508+ var lines = server . output . split ( "\r\n" ) ;
509+ var lastCount = window . lastLogLineCount [ serverName ] || 0 ;
510+ // Only append new lines
511+ for ( let i = lastCount ; i < lines . length ; i ++ ) {
512+ var line = lines [ i ] ;
513+ if ( line . trim ( ) !== "" ) {
514+ var p = $ ( '<p class="STDOutMessage"></p>' ) . appendTo ( outDiv ) [ 0 ] ;
513515 p . innerHTML = line ;
514516 }
515517 }
518+ window . lastLogLineCount [ serverName ] = lines . length ;
516519 }
517520 window . serverInfoObj = obj ;
518521 break ;
@@ -521,6 +524,10 @@ $(document).ready(function () {
521524 // Split on <br> (or <br/>), so each log line is its own <p>
522525 var lines = str . split ( / < b r \s * \/ ? > / i) ;
523526 var outDiv = $ ( "." + obj . server_name + "Out" ) [ 0 ] ;
527+ if ( ! outDiv ) {
528+ console . warn ( "Output div not found for server:" , obj . server_name ) ;
529+ break ;
530+ }
524531 var shouldScroll = outDiv . scrollTop == outDiv . scrollHeight ;
525532 lines . forEach ( function ( line ) {
526533 if ( line . trim ( ) !== "" ) {
0 commit comments