-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.js
33 lines (23 loc) · 851 Bytes
/
app.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
var valueInput = function(inputName) {
return document.querySelector('[name=' + inputName + ']').value;
};
var process = function() {
var rule = parseInt(valueInput('rule'));
var options = {
cellSize: valueInput('cell-size'),
size: [valueInput('size-x'), valueInput('size-y')]
};
window.location.hash = '#' + document.querySelector('[name=rule]').value;
var t0 = performance.now();
var rule = new Rule(rule, options);
rule.process();
var t1 = performance.now();
document.querySelector('#infos .time').innerHTML = Math.round(t1 - t0);
return false;
};
window.addEventListener('hashchange', function() {
document.querySelector('[name=rule]').value = window.location.hash.replace(/[^0-9]+/g, '');
process();
});
process();
document.getElementById('panel').onsubmit = process;