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

Commit

Permalink
♻️ Code cleanup round 3 - arrow functions
Browse files Browse the repository at this point in the history
Harmonizing code style
  • Loading branch information
GitSquared committed Feb 3, 2019
1 parent fa0584c commit 436a30c
Show file tree
Hide file tree
Showing 10 changed files with 33 additions and 33 deletions.
6 changes: 3 additions & 3 deletions src/_boot.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,23 +87,23 @@ try {
} catch(e) {
// Folder already exists
}
fs.readdirSync(innerThemesDir).forEach((e) => {
fs.readdirSync(innerThemesDir).forEach(e => {
fs.writeFileSync(path.join(themesDir, e), fs.readFileSync(path.join(innerThemesDir, e), {encoding:"utf-8"}));
});
try {
fs.mkdirSync(kblayoutsDir);
} catch(e) {
// Folder already exists
}
fs.readdirSync(innerKblayoutsDir).forEach((e) => {
fs.readdirSync(innerKblayoutsDir).forEach(e => {
fs.writeFileSync(path.join(kblayoutsDir, e), fs.readFileSync(path.join(innerKblayoutsDir, e), {encoding:"utf-8"}));
});
try {
fs.mkdirSync(fontsDir);
} catch(e) {
// Folder already exists
}
fs.readdirSync(innerFontsDir).forEach((e) => {
fs.readdirSync(innerFontsDir).forEach(e => {
fs.writeFileSync(path.join(fontsDir, e), fs.readFileSync(path.join(innerFontsDir, e)));
});

Expand Down
2 changes: 1 addition & 1 deletion src/classes/clock.class.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class Clock {
let clockString = `${array[0]}:${array[1]}:${array[2]}`;
array = clockString.match(/.{1}/g);
clockString = "";
array.forEach((e) => {
array.forEach(e => {
if (e === ":") clockString += "<em>"+e+"</em>";
else clockString += "<span>"+e+"</span>";
});
Expand Down
10 changes: 5 additions & 5 deletions src/classes/cpuinfo.class.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class Cpuinfo {

this.series = [];
this.charts = [];
window.si.cpu().then((data) => {
window.si.cpu().then(data => {
let divide = Math.floor(data.cores/2);
this.divide = divide;

Expand Down Expand Up @@ -118,7 +118,7 @@ class Cpuinfo {
});
}
updateCPUload() {
window.si.currentLoad().then((data) => {
window.si.currentLoad().then(data => {
let average = [[], []];

if (!data.cpus) return; // Prevent memleak in rare case where systeminformation takes extra time to retrieve CPU info (see github issue #216)
Expand All @@ -144,7 +144,7 @@ class Cpuinfo {
});
}
updateCPUtemp() {
window.si.cpuTemperature().then((data) => {
window.si.cpuTemperature().then(data => {
try {
document.getElementById("mod_cpuinfo_temp").innerText = `${data.max}°C`;
} catch(e) {
Expand All @@ -153,7 +153,7 @@ class Cpuinfo {
});
}
updateCPUspeed() {
window.si.cpuCurrentspeed().then((data) => {
window.si.cpuCurrentspeed().then(data => {
try {
document.getElementById("mod_cpuinfo_speed_min").innerText = `${data.min}GHz`;
document.getElementById("mod_cpuinfo_speed_max").innerText = `${data.max}GHz`;
Expand All @@ -163,7 +163,7 @@ class Cpuinfo {
});
}
updateCPUtasks() {
window.si.processes().then((data) => {
window.si.processes().then(data => {
try {
document.getElementById("mod_cpuinfo_tasks").innerText = `${data.all}`;
} catch(e) {
Expand Down
6 changes: 3 additions & 3 deletions src/classes/filesystem.class.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class FilesystemDisplay {
this.followTab = () => {
let num = window.currentTerm;

window.term[num].oncwdchange = (cwd) => {
window.term[num].oncwdchange = cwd => {
if (cwd && window.currentTerm === num) {
if (this._fsWatcher) {
this._fsWatcher.close();
Expand All @@ -98,7 +98,7 @@ class FilesystemDisplay {
};
this.followTab();

this.watchFS = (dir) => {
this.watchFS = dir => {
if (this._fsWatcher) {
this._fsWatcher.close();
}
Expand Down Expand Up @@ -387,7 +387,7 @@ class FilesystemDisplay {
this.space_bar.bar.value = 100;
}
}

// Render animation
let id = 0;
while (this.filesContainer.childNodes[id]) {
Expand Down
12 changes: 6 additions & 6 deletions src/classes/locationGlobe.class.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,9 @@ class LocationGlobe {
// Connections
this.conns = [];
this.addConn = ip => {
require("https").get({host: "ipinfo.now.sh", port: 443, path: "/"+ip, localAddress: window.mods.netstat.internalIPv4, agent: false}, (res) => {
require("https").get({host: "ipinfo.now.sh", port: 443, path: "/"+ip, localAddress: window.mods.netstat.internalIPv4, agent: false}, res => {
let rawData = "";
res.on("data", (chunk) => {
res.on("data", chunk => {
rawData += chunk;
});
res.on("end", () => {
Expand All @@ -93,7 +93,7 @@ class LocationGlobe {
electron.ipcRenderer.send("log", "debug", `Error: ${e}`);
})
});
}).on("error", (e) => {
}).on("error", e => {
// Drop it
});
};
Expand Down Expand Up @@ -152,9 +152,9 @@ class LocationGlobe {
this.globe.addMarker(randomLat - 20, randomLong + 150, '', true);
}
addTemporaryConnectedMarker(ip) {
require("https").get({host: "ipinfo.now.sh", port: 443, path: "/"+ip, localAddress: window.mods.netstat.internalIPv4, agent: false}, (res) => {
require("https").get({host: "ipinfo.now.sh", port: 443, path: "/"+ip, localAddress: window.mods.netstat.internalIPv4, agent: false}, res => {
let rawData = "";
res.on("data", (chunk) => {
res.on("data", chunk => {
rawData += chunk;
});
res.on("end", () => {
Expand All @@ -178,7 +178,7 @@ class LocationGlobe {
}, 3000);
}
});
}).on("error", (e) => {
}).on("error", e => {
// Drop it
});
}
Expand Down
2 changes: 1 addition & 1 deletion src/classes/modal.class.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class Modal {
<h1>${this.title}</h1>
${this.type === "custom" ? options.html : "<h5>"+this.message+"</h5>"}
<div>`;
buttons.forEach((b) => {
buttons.forEach(b => {
DOMstring += `<button onclick="${b.action}">${b.label}</button>`;
});
DOMstring += `</div>
Expand Down
8 changes: 4 additions & 4 deletions src/classes/netstat.class.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class Netstat {
}, 2000);
}
updateInfo() {
window.si.networkInterfaces().then((data) => {
window.si.networkInterfaces().then(data => {
let offline = false;

let net = data[0];
Expand Down Expand Up @@ -86,9 +86,9 @@ class Netstat {
offline = true;
} else {
if (this.lastconn.finished) {
this.lastconn = require("https").get({host: "ipinfo.now.sh", port: 443, path: "/", localAddress: net.ip4, agent: this._httpsAgent}, (res) => {
this.lastconn = require("https").get({host: "ipinfo.now.sh", port: 443, path: "/", localAddress: net.ip4, agent: this._httpsAgent}, res => {
let rawData = "";
res.on("data", (chunk) => {
res.on("data", chunk => {
rawData += chunk;
});
res.on("end", () => {
Expand All @@ -109,7 +109,7 @@ class Netstat {
electron.ipcRenderer.send("log", "debug", `Error: ${e}`);
}
});
}).on("error", (e) => {
}).on("error", e => {
// Drop it
});
}
Expand Down
8 changes: 4 additions & 4 deletions src/classes/ramwatcher.class.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class RAMwatcher {
}, 1500);
}
updateInfo() {
window.si.mem().then((data) => {
window.si.mem().then(data => {
let total = data.free+data.used;
let free = data.free;
let available = data.used-data.active;
Expand All @@ -46,17 +46,17 @@ class RAMwatcher {
available = Math.round((440*available)/total);

// Update grid
this.points.slice(0, active).forEach((domPoint) => {
this.points.slice(0, active).forEach(domPoint => {
if (domPoint.attributes.class.value !== "mod_ramwatcher_point active") {
domPoint.setAttribute("class", "mod_ramwatcher_point active");
}
});
this.points.slice(active, available).forEach((domPoint) => {
this.points.slice(active, available).forEach(domPoint => {
if (domPoint.attributes.class.value !== "mod_ramwatcher_point available") {
domPoint.setAttribute("class", "mod_ramwatcher_point available");
}
});
this.points.slice(available, this.points.length).forEach((domPoint) => {
this.points.slice(available, this.points.length).forEach(domPoint => {
if (domPoint.attributes.class.value !== "mod_ramwatcher_point free") {
domPoint.setAttribute("class", "mod_ramwatcher_point free");
}
Expand Down
10 changes: 5 additions & 5 deletions src/classes/terminal.class.js
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ class Terminal {
this.ondisconnected = () => {};

this._disableCWDtracking = false;
this._getTtyCWD = (tty) => {
this._getTtyCWD = tty => {
return new Promise((resolve, reject) => {
let pid = tty._pid;
switch(require("os").type()) {
Expand Down Expand Up @@ -307,7 +307,7 @@ class Terminal {
this.wss = new this.Websocket({
port: this.port,
clientTracking: true,
verifyClient: (info) => {
verifyClient: info => {
if (this.wss.clients.length >= 1) {
return false;
} else {
Expand Down Expand Up @@ -336,15 +336,15 @@ class Terminal {
return;
}
});
this.wss.on("connection", (ws) => {
this.wss.on("connection", ws => {
this.onopened();
ws.on("close", (code, reason) => {
this.ondisconnected(code, reason);
});
ws.on("message", (msg) => {
ws.on("message", msg => {
this.tty.write(msg);
});
this.tty.on("data", (data) => {
this.tty.on("data", data => {
this._nextTickUpdateTtyCWD = true;
this._nextTickUpdateProcess = true;
try {
Expand Down
2 changes: 1 addition & 1 deletion src/classes/updateChecker.class.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class UpdateChecker {

this._failed = false;
this._willfail = false;
this._fail = (e) => {
this._fail = e => {
this._failed = true;
electron.ipcRenderer.send("log", "note", "UpdateChecker: Could not fetch latest release from GitHub's API.");
electron.ipcRenderer.send("log", "debug", `Error: ${e}`);
Expand Down

0 comments on commit 436a30c

Please # to comment.