-
Notifications
You must be signed in to change notification settings - Fork 0
/
selecting_rules.js
39 lines (28 loc) · 914 Bytes
/
selecting_rules.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
34
35
36
37
38
39
$(function() {
$('#born span').click(function() {
$(this).toggleClass('lightgreen');
updateRules();
});
$('#survive span').click(function() {
$(this).toggleClass('lightgreen');
updateRules();
});
$("#known_automata").change(function() {
var survive = $(this).val().split('/')[0].split('').map(Number);
var born = $(this).val().split('/')[1].split('').map(Number);
updateRules(born, survive);
});
$("#cell_rule span").hover(function() {
paused = true;
})
$("#cell_rule select").hover(function() {
paused = true;
})
});
function setDOMRules() {
$('#cell_rules span').removeClass('lightgreen');
for (var i=0;i<ruleset.rules['born'].length;i++)
$('#born span:nth-child('+(ruleset.rules['born'][i]+1)+')').addClass('lightgreen');
for (var i=0;i<ruleset.rules['survive'].length;i++)
$('#survive span:nth-child('+(ruleset.rules['survive'][i]+1)+')').addClass('lightgreen');
}