1
1
import { exec , toast } from './kernelsu.js' ;
2
- import { get_active_iface , get_active_algorithm , getInitcwndInitrwndValue , get_wifi_calling_state } from './common.js' ;
2
+ import { get_active_iface , get_active_algorithm , getInitcwndInitrwndValue , get_wifi_calling_state , getModuleActiveState } from './common.js' ;
3
3
import router_state from './router.js' ;
4
4
5
5
export async function updateModuleStatus ( ) {
6
+ var module_status = "Loading Module Status...⌛" ;
6
7
var active_iface = "None" ;
7
- var active_iface_type = "Unknown ⁉️"
8
+ var active_iface_type = "Unknown ⁉️" ;
8
9
var active_algorithm = "Unknown ⁉️" ;
9
10
var wifi_calling_state = "Unknown ⁉️" ;
10
11
var active_InitcwndInitrwndValue = [ ] ;
11
12
try
12
13
{
14
+ module_status = ( await getModuleActiveState ( ) ) == true ? "Enabled ✅" : "Disabled ❌" ;
13
15
active_iface = await get_active_iface ( ) ;
14
16
active_iface = active_iface ? active_iface : "None" ;
15
17
active_iface_type = active_iface . startsWith ( "rmnet" ) || active_iface . startsWith ( "ccmni" ) ? "Cellular 📶" : active_iface . startsWith ( "wlan" ) ? "Wi-Fi 🛜" : "Unknown ⁉️" ;
@@ -24,6 +26,7 @@ export async function updateModuleStatus () {
24
26
addLog ( 'Error updating status.' ) ;
25
27
toast ( "Error updating status." ) ;
26
28
} finally {
29
+ router_state . homePageParams . module_status = module_status ;
27
30
router_state . homePageParams . active_iface_type = active_iface_type ;
28
31
router_state . homePageParams . active_iface = active_iface ;
29
32
router_state . homePageParams . active_algorithm = active_algorithm ;
@@ -34,54 +37,71 @@ export async function updateModuleStatus () {
34
37
35
38
export function updateHomeUI ( ) {
36
39
if ( router_state . isInitializing == false ) {
37
- document . getElementById ( 'active_iface_type_value' ) . textContent = router_state . homePageParams . active_iface_type ;
38
- document . getElementById ( 'active_iface_value' ) . textContent = router_state . homePageParams . active_iface ;
39
- document . getElementById ( 'tcp_cong_value' ) . textContent = router_state . homePageParams . active_algorithm ;
40
-
41
- const wifiCallingDiv = document . getElementById ( 'wifi_calling_value_div' ) ;
42
- const wifiCallingSpan = document . getElementById ( 'wifi_calling_value' ) ;
43
-
44
- if ( router_state . homePageParams . active_iface_type == "Wi-Fi 🛜" )
40
+ document . getElementById ( 'module_status_value' ) . textContent = router_state . homePageParams . module_status ;
41
+ if ( router_state . homePageParams . module_status == "Enabled ✅" )
45
42
{
46
- if ( wifiCallingDiv ?. classList . contains ( 'hidden' ) )
47
- wifiCallingDiv . classList . remove ( 'hidden' ) ;
43
+ const ifaceTypeDiv = document . getElementById ( 'active_iface_type_div' ) ;
44
+ const ifaceValDiv = document . getElementById ( 'active_iface_div' ) ;
45
+ const tcpCongValDiv = document . getElementById ( 'tcp_cong_div' ) ;
48
46
49
- wifiCallingSpan . textContent = router_state . homePageParams . wifi_calling_state ;
50
- }
51
- else
52
- {
53
- if ( wifiCallingDiv . classList . contains ( 'hidden' ) )
54
- wifiCallingDiv . classList . add ( 'hidden' ) ;
55
- wifiCallingSpan . textContent = "Unknown ⁉️" ;
56
- }
57
-
58
- const initcwndDiv = document . getElementById ( 'initcwnd_value_div' ) ;
59
- const initrwndDiv = document . getElementById ( 'initrwnd_value_div' ) ;
60
- const initcwndSpan = document . getElementById ( 'initcwnd_value' ) ;
61
- const initrwndSpan = document . getElementById ( 'initrwnd_value' ) ;
62
-
63
- const values = router_state . homePageParams . active_InitcwndInitrwndValue ;
64
- const isLoading = values . length < 2 && router_state . settingsPageParams . initcwndInitrwnd ;
65
-
66
- if ( values . length == 2 || isLoading )
67
- {
68
- if ( initcwndDiv ?. classList . contains ( 'hidden' ) )
69
- initcwndDiv . classList . remove ( 'hidden' ) ;
47
+ document . getElementById ( 'active_iface_type_value' ) . textContent = router_state . homePageParams . active_iface_type ;
48
+ document . getElementById ( 'active_iface_value' ) . textContent = router_state . homePageParams . active_iface ;
49
+ document . getElementById ( 'tcp_cong_value' ) . textContent = router_state . homePageParams . active_algorithm ;
70
50
71
- if ( initrwndDiv ?. classList . contains ( 'hidden' ) )
72
- initrwndDiv . classList . remove ( 'hidden' ) ;
51
+ if ( ifaceTypeDiv ?. classList . contains ( 'hidden' ) )
52
+ ifaceTypeDiv . classList . remove ( 'hidden' ) ;
73
53
74
- initcwndSpan . textContent = values . length == 2 ? values [ 0 ] : "Loading initcwnd value..." ;
75
- initrwndSpan . textContent = values . length == 2 ? values [ 1 ] : "Loading initrwnd value..." ;
76
- }
77
- else
78
- {
79
- // No data and not loading → hide the section
80
- if ( initcwndDiv && ! initcwndDiv . classList . contains ( 'hidden' ) )
81
- initcwndDiv . classList . add ( 'hidden' ) ;
54
+ if ( ifaceValDiv ?. classList . contains ( 'hidden' ) )
55
+ ifaceValDiv . classList . remove ( 'hidden' ) ;
56
+
57
+ if ( tcpCongValDiv ?. classList . contains ( 'hidden' ) )
58
+ tcpCongValDiv . classList . remove ( 'hidden' ) ;
59
+
60
+ const wifiCallingDiv = document . getElementById ( 'wifi_calling_value_div' ) ;
61
+ const wifiCallingSpan = document . getElementById ( 'wifi_calling_value' ) ;
62
+
63
+ if ( router_state . homePageParams . active_iface_type == "Wi-Fi 🛜" )
64
+ {
65
+ if ( wifiCallingDiv ?. classList . contains ( 'hidden' ) )
66
+ wifiCallingDiv . classList . remove ( 'hidden' ) ;
67
+
68
+ wifiCallingSpan . textContent = router_state . homePageParams . wifi_calling_state ;
69
+ }
70
+ else
71
+ {
72
+ if ( wifiCallingDiv . classList . contains ( 'hidden' ) )
73
+ wifiCallingDiv . classList . add ( 'hidden' ) ;
74
+ wifiCallingSpan . textContent = "Unknown ⁉️" ;
75
+ }
76
+
77
+ const initcwndDiv = document . getElementById ( 'initcwnd_value_div' ) ;
78
+ const initrwndDiv = document . getElementById ( 'initrwnd_value_div' ) ;
79
+ const initcwndSpan = document . getElementById ( 'initcwnd_value' ) ;
80
+ const initrwndSpan = document . getElementById ( 'initrwnd_value' ) ;
81
+
82
+ const values = router_state . homePageParams . active_InitcwndInitrwndValue ;
83
+ const isLoading = values . length < 2 && router_state . settingsPageParams . initcwndInitrwnd ;
82
84
83
- if ( initrwndDiv && ! initrwndDiv . classList . contains ( 'hidden' ) )
84
- initrwndDiv . classList . add ( 'hidden' ) ;
85
+ if ( values . length == 2 || isLoading )
86
+ {
87
+ if ( initcwndDiv ?. classList . contains ( 'hidden' ) )
88
+ initcwndDiv . classList . remove ( 'hidden' ) ;
89
+
90
+ if ( initrwndDiv ?. classList . contains ( 'hidden' ) )
91
+ initrwndDiv . classList . remove ( 'hidden' ) ;
92
+
93
+ initcwndSpan . textContent = values . length == 2 ? values [ 0 ] : "Loading initcwnd value..." ;
94
+ initrwndSpan . textContent = values . length == 2 ? values [ 1 ] : "Loading initrwnd value..." ;
95
+ }
96
+ else
97
+ {
98
+ // No data and not loading → hide the section
99
+ if ( initcwndDiv && ! initcwndDiv . classList . contains ( 'hidden' ) )
100
+ initcwndDiv . classList . add ( 'hidden' ) ;
101
+
102
+ if ( initrwndDiv && ! initrwndDiv . classList . contains ( 'hidden' ) )
103
+ initrwndDiv . classList . add ( 'hidden' ) ;
104
+ }
85
105
}
86
106
}
87
107
}
0 commit comments