Skip to content
This repository was archived by the owner on Oct 22, 2021. It is now read-only.

Commit 4e5b262

Browse files
committed
🏁 mod_cpuinfo - Fix #274
1 parent d723b5f commit 4e5b262

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

src/classes/cpuinfo.class.js

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,13 @@ class Cpuinfo {
2020
let divide = Math.floor(data.cores/2);
2121
this.divide = divide;
2222

23+
let cpuName = data.manufacturer+data.brand;
24+
cpuName = cpuName.substr(0, 30);
25+
cpuName.substr(0, Math.min(cpuName.length, cpuName.lastIndexOf(" ")));
26+
2327
let innercontainer = document.createElement("div");
2428
innercontainer.setAttribute("id", "mod_cpuinfo_innercontainer");
25-
innercontainer.innerHTML = `<h1>CPU USAGE<i>${data.manufacturer} ${data.brand}</i></h1>
29+
innercontainer.innerHTML = `<h1>CPU USAGE<i>${cpuName}</i></h1>
2630
<div>
2731
<h1># <em>1</em> - <em>${divide}</em><br>
2832
<i id="mod_cpuinfo_usagecounter0">Avg. --%</i></h1>
@@ -35,8 +39,8 @@ class Cpuinfo {
3539
</div>
3640
<div>
3741
<div>
38-
<h1>TEMP<br>
39-
<i id="mod_cpuinfo_temp">--°C</i></h1>
42+
<h1>${(process.platform === "win32") ? "CORES" : "TEMP"}<br>
43+
<i id="mod_cpuinfo_temp">${(process.platform === "win32") ? "XX" : "--°C"}</i></h1>
4044
</div>
4145
<div>
4246
<h1>MIN<br>
@@ -96,15 +100,17 @@ class Cpuinfo {
96100

97101
// Init updater
98102
this.updateCPUload();
99-
this.updateCPUtemp();
103+
if (process.platform !== "win32") {this.updateCPUtemp();}
100104
this.updateCPUspeed();
101105
this.updateCPUtasks();
102106
this.loadUpdater = setInterval(() => {
103107
this.updateCPUload();
104108
}, 500);
105-
this.tempUpdater = setInterval(() => {
106-
this.updateCPUtemp();
107-
}, 2000);
109+
if (process.platform !== "win32") {
110+
this.tempUpdater = setInterval(() => {
111+
this.updateCPUtemp();
112+
}, 2000);
113+
}
108114
this.speedUpdater = setInterval(() => {
109115
this.updateCPUspeed();
110116
}, 1000);
@@ -118,7 +124,7 @@ class Cpuinfo {
118124
let average = [[], []];
119125

120126
if (!data.cpus) return; // Prevent memleak in rare case where systeminformation takes extra time to retrieve CPU info (see github issue #216)
121-
127+
122128
data.cpus.forEach((e, i) => {
123129
this.series[i].append(new Date().getTime(), e.load);
124130

0 commit comments

Comments
 (0)