Browse Source

browser based webworker block generator demo completed

master
Kevin Froman 2 years ago
commit
1d53c5054f
  1. 3
      .gitmodules
  2. 7
      css/bulma-dark.min.css
  3. 34
      generator.html
  4. 25
      main.js
  5. 1
      onionr-jspow
  6. 38
      package-lock.json
  7. 12
      powworker.js
  8. 21
      sha3.js

3
.gitmodules vendored

@ -0,0 +1,3 @@
[submodule "onionr-jspow"]
path = onionr-jspow
url = ../onionr-jspow

7
css/bulma-dark.min.css vendored

File diff suppressed because one or more lines are too long

34
generator.html

@ -0,0 +1,34 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Onionr Block Generator</title>
<meta name="description" content="Generate Onionr block">
<meta name="viewport" content="width=device-width, initial-scale=1.0, shrink-to-fit=no">
<link rel="stylesheet" href="css/bulma-dark.min.css">
<script src="sha3.js" defer></script>
<script src="onionr-jspow/index.js" defer></script>
<script src="main.js" defer></script>
</head>
<body>
Block Type: <input type="text" id="type">
<br>
Contents:
<br>
<textarea id="message"></textarea>
<br>
<button id="generate">Generate Block</button>
<br>
<br>
<h2>Output</h2>
<br>
<textarea id="output" cols=75 rows=50></textarea>
</body>
</html>

25
main.js

@ -0,0 +1,25 @@
var worker = new Worker("./powworker.js")
document.getElementById('generate').onclick = function(){
document.getElementById('output').value = "computing..."
var metadata = {
"meta": {
"type": document.getElementById("type")
},
"time": 0
}
// todo web workers
var data = document.getElementById('message').value
var postData = {
"data": data,
"metadata": metadata,
}
worker.postMessage(JSON.stringify(postData))
}
worker.addEventListener('message', function(e) {
document.getElementById('output').value = doHashHex(e.data) + "\n"
document.getElementById('output').value += new TextDecoder("utf-8").decode(e.data)
})

1
onionr-jspow

@ -0,0 +1 @@
Subproject commit abd1872a9174c983a75f2ffe102dab72da706b14

38
package-lock.json generated

@ -0,0 +1,38 @@
{
"requires": true,
"lockfileVersion": 1,
"dependencies": {
"base64-js": {
"version": "1.3.1",
"resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.3.1.tgz",
"integrity": "sha512-mLQ4i2QO1ytvGWFWmcngKO//JXAQueZvwEKtjgQFM4jIK0kU+ytMfplL8j+n5mspOfjHwoAg+9yhb7BwAHm36g=="
},
"buffer": {
"version": "5.6.0",
"resolved": "https://registry.npmjs.org/buffer/-/buffer-5.6.0.tgz",
"integrity": "sha512-/gDYp/UtU0eA1ys8bOs9J6a+E/KWIY+DZ+Q2WESNUA0jFRsJOc0SNUO6xJ5SGA1xueg3NL65W6s+NY5l9cunuw==",
"requires": {
"base64-js": "^1.0.2",
"ieee754": "^1.1.4"
}
},
"ieee754": {
"version": "1.1.13",
"resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.1.13.tgz",
"integrity": "sha512-4vf7I2LYV/HaWerSo3XmlMkp5eZ83i+/CDluXi/IGTs/O1sejBNhTtnxzmRZfvOUqj7lZjqHkeTvpgSFDlWZTg=="
},
"sha3": {
"version": "2.1.3",
"resolved": "https://registry.npmjs.org/sha3/-/sha3-2.1.3.tgz",
"integrity": "sha512-Io53D4o9qOmf3Ow9p/DoGLQiQHhtuR0ulbyambvRSG+OX5yXExk2yYfvjHtb7AtOyk6K6+sPeK/qaowWc/E/GA==",
"requires": {
"buffer": "5.6.0"
}
},
"webworkify": {
"version": "1.5.0",
"resolved": "https://registry.npmjs.org/webworkify/-/webworkify-1.5.0.tgz",
"integrity": "sha512-AMcUeyXAhbACL8S2hqqdqOLqvJ8ylmIbNwUIqQujRSouf4+eUFaXbG6F1Rbu+srlJMmxQWsiU7mOJi0nMBfM1g=="
}
}
}

12
powworker.js

@ -0,0 +1,12 @@
importScripts("onionr-jspow/index.js")
importScripts("sha3.js")
self.addEventListener('message', function(e) {
var data = JSON.parse(e.data)
self.postMessage(
doPow(
data.metadata,
data.data,
2
));
}, false);

21
sha3.js

File diff suppressed because one or more lines are too long
Loading…
Cancel
Save