Skip to content

Commit

Permalink
Refactor & Adding view dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
gnock committed Aug 18, 2018
1 parent 81c7e52 commit 1356cc2
Show file tree
Hide file tree
Showing 11 changed files with 125 additions and 106 deletions.
7 changes: 6 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
node_modules
.idea
*iml
package-lock.json
package-lock.json

config.txt
cpu.txt
nvidia.txt
pools.txt
55 changes: 0 additions & 55 deletions index.html

This file was deleted.

2 changes: 1 addition & 1 deletion main.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ function createWindow () {
// Create the browser window.
mainWindow = new BrowserWindow({width: 800, height: 600})

mainWindow.loadFile('index.html');
mainWindow.loadFile('views/index.html');

mainWindow.on('closed', function () {
mainWindow = null
Expand Down
6 changes: 3 additions & 3 deletions setup.js → models/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,18 +52,18 @@ exports.openSetupWindow = function() {
const BrowserWindow = electron.remote.BrowserWindow;
let win = new BrowserWindow({width:400, height: 450, frame: false, backgroundColor: '#1c222e'});
win.on('close', function() { win = null });
win.loadFile('setup.html');
win.loadFile('../views/setup.html');
win.show();
};

exports.startChild = function() {
if(this.doConfigsExist()) {
var child;
if (process.platform === "win32") {
child = childProcess.spawn('msr-stak.exe');
child = childProcess.spawn('../msr-stak.exe');
}
else {
child = childProcess.spawn('./msr-stak');
child = childProcess.spawn('../msr-stak');
}
return child;
}
Expand Down
File renamed without changes.
46 changes: 0 additions & 46 deletions setup.html

This file was deleted.

26 changes: 26 additions & 0 deletions views/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Masari Miner</title>
</head>
<body>

<div id="app">
<h1>Masari One Click Miner</h1>
<div align=center style="padding-top: 10px">
<h2 id="hashRate">Hashrate: {{hashrate}}H/s</h2>
</div>

<div align=center style="padding-top: 25px">
<button type="button" onClick="startMining()">Start Mining!</button>
</div>
<div align=center style="padding-top: 10px">
<button type="button" onClick="stopMining()">Stop Mining</button>
</div>
</div>

<script src="js/vue.min.js"></script>
<script src="index.js"></script>
</body>
</html>
39 changes: 39 additions & 0 deletions views/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
const setup = require('../models/setup.js');
const stats = require('../models/stats.js');

if(!setup.doConfigsExist()) {
setup.openSetupWindow();
}

var child;
var interval;


let app = new Vue({
el: '#app',
data: {
hashrate:0
},
methods:{
startMining: function() {
child = setup.startChild();
alert(child);
if(child === false)
setup.openSetupWindow();

interval = setInterval(()=>{
this.updateHashRate()
}, 2000);
},
stopMining:function() {
setup.stopChild(child);
clearInterval(interval);
},
updateHashRate:function() {
if(!child)
this.hashRate = 0;
else
this.hashrate = stats.get10SecHashRate();
}
}
});
6 changes: 6 additions & 0 deletions views/js/vue.min.js

Large diffs are not rendered by default.

23 changes: 23 additions & 0 deletions views/setup.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Setup</title>
</head>
<body>
<div align=center>
<h3 style="color:#037235; padding-top: 25px">Enter Your Masari Address</h3>
<input type="text" id="address">
</div>

<div align=center>
<h3 style="color:#037235">Select A Pool</h3>
<button type="button" onClick="masaricoin()">masaricoin.com</button>
<button type="button" onClick="optimusblue()">msr.optimusblue.com</button>
</div>
<div align=center style="padding-top: 15px">
<button type="button" onClick="finish()">Finish</button>
</div>
<script src="setup.js"></script>
</body>
</html>
21 changes: 21 additions & 0 deletions views/setup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
const electron = require('electron');
const setup = require('../models/setup.js');

let pool;

function masaricoin() {
pool = "pool.masaricoin.com:3333";
}

function optimusblue() {
pool = "msr.optimusblue.com:3333";
}

function finish() {
var address = document.getElementById('address').value;
setup.writeConfigTxt();
setup.writePoolsTxt(address);
setup.writeCpuTxt();
var thisWindow = electron.remote.getCurrentWindow();
setTimeout( function () { thisWindow.close() } , 500);
}

0 comments on commit 1356cc2

Please sign in to comment.