@@ -12,10 +12,15 @@ export class ConfigModal {
1212 private colorPicker : HTMLInputElement | null ;
1313 private selectedColor : number ; // Stores the actual selected color as a number
1414 private tempColor : number ; // Temporary color for selection
15+
1516 private enableTooltipsSwitch : HTMLInputElement | null ;
1617 private enableTooltips : boolean ;
1718 private tempEnableTooltips : boolean ;
1819
20+ private useTcpRenoSwitch : HTMLInputElement | null ;
21+ private useTcpReno : boolean ;
22+ private tempUseTcpReno : boolean ;
23+
1924 constructor ( ctx : GlobalContext ) {
2025 this . ctx = ctx ;
2126 this . modalOverlay = null ;
@@ -27,6 +32,8 @@ export class ConfigModal {
2732 this . tempColor = this . selectedColor ; // Temporary color for selection
2833 this . enableTooltips = true ; // Default saved value
2934 this . tempEnableTooltips = this . enableTooltips ; // Temporary value for selection
35+ this . useTcpReno = true ; // Default saved value
36+ this . tempUseTcpReno = this . useTcpReno ; // Temporary value for selection
3037
3138 this . createModal ( ) ;
3239 this . setupEventListeners ( ) ;
@@ -83,6 +90,13 @@ export class ConfigModal {
8390 <span class="switch-slider"></span>
8491 </label>
8592 </li>
93+ <li class="setting-item">
94+ <label for="useTcpReno">Use TCP Reno</label>
95+ <label class="switch">
96+ <input type="checkbox" id="useTcpReno" class="switch-input" checked>
97+ <span class="switch-slider"></span>
98+ </label>
99+ </li>
86100 </ul>
87101 </div>
88102 </div>
@@ -111,6 +125,9 @@ export class ConfigModal {
111125 this . enableTooltipsSwitch = document . getElementById (
112126 "enableTooltips" ,
113127 ) as HTMLInputElement ;
128+ this . useTcpRenoSwitch = document . getElementById (
129+ "useTcpReno" ,
130+ ) as HTMLInputElement ;
114131 }
115132
116133 private setupEventListeners ( ) {
@@ -120,7 +137,8 @@ export class ConfigModal {
120137 ! this . closeBtn ||
121138 ! this . saveSettingsButton ||
122139 ! this . colorPicker ||
123- ! this . enableTooltipsSwitch
140+ ! this . enableTooltipsSwitch ||
141+ ! this . useTcpRenoSwitch
124142 ) {
125143 console . error ( "Some modal elements were not found." ) ;
126144 return ;
@@ -152,6 +170,12 @@ export class ConfigModal {
152170 this . tempEnableTooltips = isEnabled ; // Update the local variable only
153171 console . log ( "Tooltips setting changed (not saved yet):" , isEnabled ) ;
154172 } ;
173+
174+ this . useTcpRenoSwitch . onchange = ( ) => {
175+ const isEnabled = this . useTcpRenoSwitch ?. checked || false ;
176+ this . tempUseTcpReno = isEnabled ; // Update the local variable only
177+ console . log ( "TCP Reno setting changed (not saved yet):" , isEnabled ) ;
178+ } ;
155179 }
156180
157181 private setUpShortCuts ( ) {
@@ -192,6 +216,11 @@ export class ConfigModal {
192216 this . enableTooltipsSwitch . checked = this . tempEnableTooltips ; // Reflect the saved value in the UI
193217 }
194218
219+ if ( this . useTcpRenoSwitch ) {
220+ this . tempUseTcpReno = this . useTcpReno ;
221+ this . useTcpRenoSwitch . checked = this . tempUseTcpReno ; // Reflect the saved value in the UI
222+ }
223+
195224 this . modalOverlay . style . display = "flex" ; // Make it visible first
196225 setTimeout ( ( ) => {
197226 this . modalOverlay ?. classList . add ( "show" ) ;
@@ -223,27 +252,45 @@ export class ConfigModal {
223252 this . tempEnableTooltips = this . enableTooltips ; // Reset temp value
224253 this . enableTooltipsSwitch . checked = this . enableTooltips ; // Reflect saved value in UI
225254 }
255+
256+ if ( this . useTcpRenoSwitch ) {
257+ this . tempUseTcpReno = this . useTcpReno ; // Reset temp value
258+ this . useTcpRenoSwitch . checked = this . useTcpReno ; // Reflect saved value in UI
259+ }
226260 }
227261
228262 private saveSettings ( ) {
229263 // Save the temp color as the actual selected color
230264 if ( this . tempColor != this . selectedColor ) {
231265 this . selectedColor = this . tempColor ;
232- this . ctx . change_select_color ( this . selectedColor ) ;
266+ this . ctx . setSelectColor ( this . selectedColor ) ;
233267 }
234268
269+ let updateTooltips = false ;
270+
235271 // Save the tooltips setting
236272 if ( this . enableTooltipsSwitch ) {
237273 this . enableTooltips = this . tempEnableTooltips ; // Save the temporary value
238- this . ctx . change_enable_tooltips ( this . enableTooltips ) ; // Update the GlobalContext
239- updateTooltipsState ( ) ; // Update tooltips state in the app
274+ this . ctx . setEnableTooltips ( this . enableTooltips ) ; // Update the GlobalContext
275+ updateTooltips = true ;
276+ }
277+
278+ if ( this . useTcpRenoSwitch ) {
279+ this . useTcpReno = this . tempUseTcpReno ; // Save the temporary value
280+ this . ctx . setUseTcpReno ( this . useTcpReno ) ; // Update the GlobalContext
281+ updateTooltips = true ;
240282 }
241283
284+ if ( updateTooltips ) {
285+ updateTooltipsState ( ) ; // Update tooltips state in the app
286+ }
242287 console . log (
243288 "Settings saved. Applied color:" ,
244289 this . selectedColor ,
245290 "Tooltips enabled:" ,
246291 this . enableTooltips ,
292+ "TCP Reno enabled:" ,
293+ this . useTcpReno ,
247294 ) ;
248295 }
249296
0 commit comments