-
+
+
DON'T CHANGE this unless you know what you're doing (which you DON'T). To save, start the miner at least once.
diff --git a/index.js b/index.js
index 8ef246c..1ca8e9b 100755
--- a/index.js
+++ b/index.js
@@ -122,13 +122,13 @@ if (!gotTheLock && app.isPackaged) {
const userDataPath = electron.app.getPath('userData');
const xmrigFolderPath = join(userDataPath, 'xmrig');
- if (!existsSync(xmrigFolderPath)) return currentWindow.webContents.send('resetXmrigStatus', { type, message: 'There is no existing config'});
+ if (!existsSync(xmrigFolderPath)) return currentWindow.webContents.send('resetXmrigStatus', { type, message: 'Reset the config'});
const configPath = join(userDataPath, `xmrig/${type}.json`);
- if (!existsSync(configPath)) return currentWindow.webContents.send('resetXmrigStatus', { type, message: 'There is no existing config' });
+ if (!existsSync(configPath)) return currentWindow.webContents.send('resetXmrigStatus', { type, message: 'Reset the config' });
unlinkSync(configPath);
- return currentWindow.webContents.send('resetXmrigStatus', { type, message: `Deleted the config` });
+ return currentWindow.webContents.send('resetXmrigStatus', { type, message: `Reset the config` });
});
ipcMain.on('startMiner', async (event, { username, type, reload, command }) => {
diff --git a/js/main.js b/js/main.js
index 046d68b..4593746 100755
--- a/js/main.js
+++ b/js/main.js
@@ -8,68 +8,18 @@ const currentData = new SaveData({
configName: 'current',
});
-let oldUsername = undefined;
-let oldCpuCommand = undefined;
-let oldCpuCommandChecked = undefined;
-let oldGpuCommand = undefined;
-let oldGpuCommandChecked = undefined;
let mining = { cpu: false, gpu: false };
const userNameInput = document.getElementById('username');
const cpuMinerButton = document.getElementById('start-miner-cpu');
const log = document.getElementById('log');
-const getPrevious = setInterval(() => {
- if (!oldUsername) {
- oldUsername = savedata.get('username');
- if (oldUsername) {
- userNameInput.value = oldUsername;
- }
- }
-
- if (!oldCpuCommand) {
- oldCpuCommand = savedata.get('cpu-command');
- if (oldCpuCommand) {
- command = oldCpuCommand.split(' ');
- document.getElementById('custom-command-cpu-file').value = command[0];
- document.getElementById('custom-command-cpu-flags').value = command.slice(1).join(' ');
- }
- }
-
- if (!oldCpuCommandChecked) {
- oldCpuCommandChecked = savedata.get('cpu-command-checked');
- if (oldCpuCommandChecked) {
- document.getElementById('custom-command-cpu-enabled').checked = true;
- }
- }
-
- if (!oldGpuCommand) {
- oldGpuCommand = savedata.get('gpu-command');
- if (oldGpuCommand) {
- command = oldGpuCommand.split(' ');
- document.getElementById('custom-command-gpu-file').value = command[0];
- document.getElementById('custom-command-gpu-flags').value = command.slice(1).join(' ');
- }
- }
-
- if (!oldGpuCommandChecked) {
- oldGpuCommandChecked = savedata.get('gpu-command-checked');
- if (oldGpuCommandChecked) {
- document.getElementById('custom-command-gpu-enabled').checked = true;
- }
- }
-
- if (!!oldUsername && !!oldCpuCommand && !!oldGpuCommand) {
- return clearInterval(getPrevious);
- }
-}, 500);
-
const startMiner = (type, reload) => {
cpuMinerButton.onclick = () => { startMiner('cpu', false) };
const username = getUsername();
if (!username || typeof username !== 'string') return logFunction('username', 'An invalid username is specified');
- let command = false;
+ let command = null;
const enabled = document.getElementById(`custom-command-${type}-enabled`).checked;
if (enabled) {
@@ -104,9 +54,7 @@ ipcRenderer.on('miner-status', (event, { type, status, reload }) => {
});
ipcRenderer.on('resetXmrigStatus', (event, { type, message }) => {
- const myModalEl = document.getElementById(`advanced${type}`);
- const modal = bootstrap.Modal.getInstance(myModalEl);
- modal.hide();
+ closeModal(type);
return logFunction(type, message);
});
@@ -131,12 +79,85 @@ const getUsername = () => {
return username;
}
-const resetXmrig = (type) => {
+const resetConfig = (type) => {
if (mining[type]) return alert('You can not reset the configuration while mining!');
+ showLog(type, true);
+ document.getElementById(`custom-command-${type}-enabled`).checked = false;
+ document.getElementById(`custom-command-${type}-file`).value = null;
+ document.getElementById(`custom-command-${type}-flags`).value = null;
+
+ savedata.set(`${type}-command`, null);
+ savedata.set(`${type}-command-checked`, false);
+
return ipcRenderer.send('resetXmrig', { type });
}
+const showLog = (type, show) => {
+ const logEl = document.getElementById(`${type}-log`);
+ const buttonEl = document.getElementById(`show-${type}-logs`);
+
+ savedata.set(`show-${type}-log`, show);
+ closeModal(type);
+
+
+ if (show) {
+ logEl.style = "display: block";
+ buttonEl.innerHTML = `Hide ${type.toUpperCase()} logs`;
+ return buttonEl.onclick = () => { showLog(type, !show) };
+ } else {
+ logEl.style = "display: none";
+ buttonEl.innerHTML = `Show ${type.toUpperCase()} logs`;
+ return buttonEl.onclick = () => { showLog(type, !show) };
+ }
+}
+
const logFunction = (type, message) => {
return log.innerHTML = `
${type} | ${message} |
` + log.innerHTML;
-}
\ No newline at end of file
+}
+
+const loadSaved = () => {
+ const oldUsername = savedata.get('username');
+ if (oldUsername !== null) userNameInput.value = oldUsername;
+
+ const oldCpuCommand = savedata.get('cpu-command');
+ if (oldCpuCommand !== null && oldGpuCommand !== undefined) {
+ const command = oldCpuCommand.split(' ');
+ document.getElementById('custom-command-cpu-file').value = command[0];
+ document.getElementById('custom-command-cpu-flags').value = command.slice(1).join(' ');
+ }
+
+ const oldCpuCommandChecked = savedata.get('cpu-command-checked');
+ if (oldCpuCommandChecked !== null) document.getElementById('custom-command-cpu-enabled').checked = oldCpuCommandChecked;
+
+ const oldCpuShowLog = savedata.get('show-cpu-log');
+ if (oldCpuShowLog !== null) showLog('cpu', oldCpuShowLog);
+
+ const oldGpuCommand = savedata.get('gpu-command');
+ if (oldGpuCommand !== null && oldGpuCommand !== undefined) {
+ const command = oldGpuCommand.split(' ');
+ document.getElementById('custom-command-gpu-file').value = command[0];
+ document.getElementById('custom-command-gpu-flags').value = command.slice(1).join(' ');
+ }
+
+ const oldGpuCommandChecked = savedata.get('gpu-command-checked');
+ if (oldGpuCommandChecked !== null) document.getElementById('custom-command-gpu-enabled').checked = true;
+
+ const oldGpuShowLog = savedata.get('show-gpu-log');
+ if (oldCpuShowLog !== null) showLog('gpu', oldCpuShowLog);
+
+ return logFunction('config', 'Configuration loaded');
+}
+
+const closeModal = (type) => {
+ const myModalEl = document.getElementById(`advanced-${type}`);
+ const modal = bootstrap.Modal.getInstance(myModalEl);
+
+ if (!modal) return;
+ return modal.hide();
+}
+
+
+setTimeout(() => {
+ loadSaved();
+}, 2000);
\ No newline at end of file
diff --git a/package.json b/package.json
index 5f33f28..b7fb36a 100755
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "robinsch-miner",
- "version": "1.1.4",
+ "version": "1.1.5",
"description": "My GUI crypto miner",
"main": "index.js",
"scripts": {