-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
174 lines (165 loc) · 4.51 KB
/
index.html
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
<html>
<head>
<title>nbot</title>
</head>
<body>
<button id="open">Repo</button>
<button id="close">X</button>
<div id="repository">
<div id="container">
<div id="directoryContainer">
<select multiple id="directory"></select>
<button id="crossover">Crossover</button>
<button id="compose">Compose</button>
</div>
<div id="display"></div>
</div>
</div>
<div id="panel">
<div id="selections"></div>
<div id="genomes"></div>
</div>
<div id="pit"></div>
</body>
<style>
body{
margin: 0
}
#repository{
position: fixed;
height: 0px;
width: 100%;
padding: 40px;
padding-bottom: 0;
background: rgba(0,0,0,0.05);
border-bottom: 1px solid rgba(0,0,0,0.1);
z-index: 1;
transition: all 0.4s;
}
#container{
display: none;
}
#directoryContainer{
position: absolute;
width: 20%;
height: 80%;
}
#directoryContainer *{
display: block;
}
#display{
position: absolute;
left: 20%;
padding: 20px;
width: 40%;
height: 100%;
}
#close{
position: fixed;
margin: 5px;
right: 0; top: 0;
z-index: 2;
}
#open{
position: fixed;
margin: 5px;
left: 0; top: 0;
z-index: 2;
}
#panel{
position: fixed;
height: 150px;
width: 100%;
padding: 10px;
padding-top: 50px;
background: white;
background: rgb(240,240,240);
border-bottom: 1px solid lightGray;
}
#pit{
padding: 10px;
padding-top: 210px;
}
.phenoContainer{
display: inline-block;
margin: 5px;
padding: 10px;
border: 1px dotted lightGray;
}
</style>
<script src="functions.js"></script>
<script src="stage.js"></script>
<script>
var repoSelection = []
var open = document.getElementById('open')
var close = document.getElementById('close')
var container = document.getElementById('container')
var repo = document.getElementById('repository')
var display = document.getElementById('display')
var crossoverButton = document.getElementById('crossover')
var composeButton = document.getElementById('compose')
open.onclick = function(){
repo.style.height = '100%'
repo.style.background = 'rgba(240,240,240,1)'
container.style.display = 'block'
var dir = document.getElementById('directory')
dir.innerHTML = ''
var genomes = getGenomes()
for(var i in genomes){
var genome = document.createElement('OPTION')
genome.innerHTML = genomes[i]
genome.value = genomes[i]
dir.appendChild(genome)
}
dir.onchange = function(){
display.innerHTML = ''
var selected = document.querySelectorAll('#directory option:checked')
repoSelection = []
// repoSelection.push(e.target.value)
for(var i in selected){
var select = selected[i]
if(select.value){
repoSelection.push(select.value)
var genotype = express(Store[select.value])
genotype.style.display = 'block'
display.appendChild(genotype)
}
}
}
}
close.onclick = function(){
repo.style.height = '0px'
repo.style.background = 'rgba(0,0,0,0.05)'
container.style.display = 'none'
}
crossoverButton.onclick = function(){
if(repoSelection.length > 2){
genepool = regenerate(Store,repoSelection,400)
repoSelection = []
selection = []
population = populate(genepool)
render(population,genepool)
close.click()
}
}
composeButton.onclick = function(){
if(repoSelection.length > 2){
var components = []
for(var i = 0; i < POPULATION_SIZE; i++){
var a = 0; var b = 0;
while(a == b){
a = Math.floor(Math.random() * repoSelection.length)
b = Math.floor(Math.random() * repoSelection.length)
}
components.push(compose(Store[repoSelection[a]],Store[repoSelection[b]]))
}
genepool = components
repoSelection = []
selection = []
population = populate(components)
render(population,genepool)
close.click()
}
}
</script>
</html>