@@ -123,21 +123,12 @@ function updateCard(cardSelector, dataKey, data, unit = '', barSelector = null,
123123
124124 let percentage = parseFloat ( dataValue ) ;
125125
126- if ( ! isNaN ( percentage ) ) {
127- // If a maxDataKey is provided, calculate the percentage based on the max value
128- if ( maxDataKey ) {
129- const maxDataValue = parseFloat ( data ?. [ maxDataKey ] ) ;
130- if ( ! isNaN ( maxDataValue ) && maxDataValue > 0 ) {
131- percentage = ( percentage / maxDataValue ) * 100 ;
132- }
133- }
134126
135- // Ensure the percentage doesn't exceed 100%
136- percentage = Math . min ( percentage , 100 ) ;
127+ // Ensure the percentage doesn't exceed 100%
128+ percentage = Math . min ( percentage , 100 ) ;
137129
138- // Set the bar width based on the percentage
139- barElement . style . width = `${ percentage } %` ;
140- }
130+ // Set the bar width based on the percentage
131+ barElement . style . width = `${ percentage } %` ;
141132 }
142133}
143134
@@ -165,7 +156,7 @@ async function refreshData() {
165156 updateCard ( '.bg-disk' , 'disk_percent' , data , '%' , '.disk-bar' ) ;
166157 updateCard ( '.cpu-temp-card' , 'current_temp' , data , ' °C' , '.temp-bar' ) ;
167158 updateCard ( '.bg-memory' , 'memory_percent' , data , '%' , '.memory-usage-bar' ) ;
168- updateCard ( '.cpu-frequency-card' , 'cpu_frequency' , data , ' MHz' , '.frequency-bar' , 'cpu_max_frequency' ) ;
159+ updateCard ( '.cpu-frequency-card' , 'cpu_frequency' , data , ' MHz' , '.frequency-bar' ) ;
169160 updateCard ( '.cpu-usage-card' , 'cpu_percent' , data , '%' , '.cpu-usage-bar' ) ;
170161 updateCard ( '.network-received' , 'network_received' , data , 'MB' ) ;
171162 updateCard ( '.network-sent' , 'network_sent' , data , 'MB' ) ;
@@ -181,28 +172,21 @@ function updateColorBars() {
181172 { selector : '.battery-bar' , dataAttr : 'data-battery' , limits : [ 25 , 75 ] } , // alreday in %
182173 { selector : '.disk-bar' , dataAttr : 'data-disk-usage' , limits : [ 60 , 80 ] } , // alreday in %
183174 { selector : '.cpu-usage-bar' , dataAttr : 'data-cpu-usage' , limits : [ 60 , 90 ] } , // alreday in %
184- { selector : '.memory-usage-bar' , dataAttr : 'data-memory-usage' , limits : [ 60 , 90 ] , maxAttr : 'data-memory-total' } ,
185- { selector : '.frequency-bar' , dataAttr : 'data-cpu-frequency' , limits : [ 60 , 90 ] , maxAttr : 'data-cpu-max-frequency' } ,
186- { selector : '.temp-bar' , dataAttr : 'data-cpu-temp' , limits : [ 70 , 90 ] , maxAttr : 'data-cpu-max-temp' }
175+ { selector : '.memory-usage-bar' , dataAttr : 'data-memory-usage' , limits : [ 60 , 90 ] } ,
176+ { selector : '.frequency-bar' , dataAttr : 'data-cpu-frequency' , limits : [ 60 , 90 ] } ,
177+ { selector : '.temp-bar' , dataAttr : 'data-cpu-temp' , limits : [ 70 , 90 ] }
187178 ] ;
188179
189- barConfigs . forEach ( ( { selector, dataAttr, limits, maxAttr } ) => {
180+ barConfigs . forEach ( ( { selector, dataAttr, limits } ) => {
190181 const bar = document . querySelector ( selector ) ;
191182 const card = document . querySelector ( `[${ dataAttr } ]` ) ;
192- const maxElement = maxAttr ? document . querySelector ( `[${ maxAttr } ]` ) : null ;
193183
194184 if ( ! bar || ! card ) return ;
195185 let card_value = parseFloat ( bar . style . width ) ;
196186 if ( isNaN ( card_value ) ) return ;
197187
198- if ( maxElement ) {
199- const maxValue = parseFloat ( maxElement . getAttribute ( maxAttr ) ) ;
200- if ( ! isNaN ( maxValue ) ) {
201- limits = [ maxValue * limits [ 0 ] / 100 , maxValue * limits [ 1 ] / 100 ] ;
202- }
203- }
204- // console.log("card_value", card_value, limits)
205188 bar . classList . remove ( 'low' , 'medium' , 'high' ) ;
189+ console . log ( "dataAttr" , dataAttr , card_value , limits )
206190 // Apply the appropriate class based on the limits
207191 if ( card_value <= limits [ 0 ] ) {
208192 bar . classList . add ( 'low' ) ;
0 commit comments