-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathindex.html
173 lines (172 loc) · 8.26 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
<!DOCTYPE html>
<head>
<title>Regex Generator</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/2.3.0/socket.io.js"></script>
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
<!-- CSS only -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css" integrity="sha384-9aIt2nRpC12Uk9gS9baDl411NQApFmC26EwAOH8WgZl5MYYxFfc+NcPb1dKGj7Sk" crossorigin="anonymous">
<style>
.form.input{
display: inline-block;
vertical-align: middle;
line-height: normal;
}
.undertext{
display: block;
width: 100%;
margin-top: .25rem;
font-size: 80%;
color: #28a745;
}
li{
overflow:visible;
}
</style>
</head>
<body>
<div class="d-flex flex-column flex-md-row align-items-center p-3 px-md-4 mb-3 bg-white border-bottom box-shadow" style="background-color:#ffac92 !important">
<h5 class="my-0 mr-md-auto font-weight-normal">Regex Generator</h5>
<nav class="my-2 my-md-0 mr-md-3">
<a class="p-2 text-dark" href="https://github.com/maojui/Regex-Generator" target="_blank" rel="noopener" aria-label="GitHub">
<svg class="navbar-nav-svg" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 499.36" focusable="false" width="20px">
<title>GitHub</title>
<path d="M256 0C114.64 0 0 114.61 0 256c0 113.09 73.34 209 175.08 242.9 12.8 2.35 17.47-5.56 17.47-12.34 0-6.08-.22-22.18-.35-43.54-71.2 15.49-86.2-34.34-86.2-34.34-11.64-29.57-28.42-37.45-28.42-37.45-23.27-15.84 1.73-15.55 1.73-15.55 25.69 1.81 39.21 26.38 39.21 26.38 22.84 39.12 59.92 27.82 74.5 21.27 2.33-16.54 8.94-27.82 16.25-34.22-56.84-6.43-116.6-28.43-116.6-126.49 0-27.95 10-50.8 26.35-68.69-2.63-6.48-11.42-32.5 2.51-67.75 0 0 21.49-6.88 70.4 26.24a242.65 242.65 0 0 1 128.18 0c48.87-33.13 70.33-26.24 70.33-26.24 14 35.25 5.18 61.27 2.55 67.75 16.41 17.9 26.31 40.75 26.31 68.69 0 98.35-59.85 120-116.88 126.32 9.19 7.9 17.38 23.53 17.38 47.41 0 34.22-.31 61.83-.31 70.23 0 6.85 4.61 14.81 17.6 12.31C438.72 464.97 512 369.08 512 256.02 512 114.62 397.37 0 256 0z" fill="currentColor" fill-rule="evenodd"></path>
</svg>
GitHub
</a>
<a class="p-2 text-dark" href="mailto:maojui0427@gmail.com" target="_blank" rel="noopener" aria-label="mail">
<svg version="1.1" id="Capa_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 382.117 382.117" style="enable-background:new 0 0 382.117 382.117;" xml:space="preserve" width="20px">
<path d="M336.764,45.945H45.354C20.346,45.945,0,65.484,0,89.5v203.117c0,24.016,20.346,43.555,45.354,43.555h291.41
c25.008,0,45.353-19.539,45.353-43.555V89.5C382.117,65.484,361.772,45.945,336.764,45.945z M336.764,297.72H45.354
c-3.676,0-6.9-2.384-6.9-5.103V116.359l131.797,111.27c2.702,2.282,6.138,3.538,9.676,3.538l22.259,0.001
c3.536,0,6.974-1.257,9.677-3.539l131.803-111.274v176.264C343.664,295.336,340.439,297.72,336.764,297.72z M191.059,192.987
L62.87,84.397h256.378L191.059,192.987z"/>
</svg>
Contact
</a>
</nav>
</div>
<div id="app" class="container">
<div class="row" width="100%" style="padding:1em;">
<!-- <h1 class="bd-title">Regex Generator</h1> -->
<form class="form col-sm-10 col-lg-12 col-md-12 col-12" >
<div class="form-inline row">
<label for="generations" style="width:100px;">Generation</label>
<input ref="generation" type="number" min="0" id="generations" class="form-control mx-sm-3" aria-describedby="generationHelpInline" value="10">
<small id="generationHelpInline" class="mx-sm-2 text-muted">
Must be 10-30 generation.
</small>
</div>
<br>
<div class="form-inline row" id="population-row">
<label for="populatios" style="width:100px;">Population</label>
<input ref="population" type="number" id="populatios" class="form-control mx-sm-3" aria-describedby="populatioHelpInline" value=30>
<small id="populatioHelpInline" class="mx-sm-2 text-muted">
Population size must beteen 10-100.
</small>
</div>
<br>
<div class="form-inline row">
<label for="matchs" style="width:100px;text-align:left">Match</label>
<input ref="match" type="number" id="matchs" class="form-control mx-sm-3" aria-describedby="matchHelpInline" value="30">
<small id="matchHelpInline" class="mx-sm-2 text-muted">
At least match how many string.
</small>
</div>
<br>
<br>
<div class="form-inline row" style="margin-top: -1em; margin-bottom: 0.3em;">
<label for="matchs" style="width:100px;text-align:left;">Target</label>
<!-- <input style="display: none;"> -->
<textarea ref="target" class="form-control col-12 col-sm-7 col-md-10" id="textarea" rows="10">
asdkfjasldf
asdfkjaskl
asdkfja</textarea>
</div>
<button class="btn btn-primary col-12 " ref="start" @click="start" type="button" data-toggle="modal" data-target="#myModal" style="margin-top:1em;">Submit</button>
</form>
</div>
<!-- Modal -->
<div id="myModal" class="modal fade" tabindex="-1" role="dialog">
<div class="modal-dialog modal-xl">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<h3 class="modal-title">Generate Result</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<div class="col-md-12 col-12">
<ul style="padding-left:1em;">
<li v-for="x in outputs" v-if="outputs.length">
<pre>{{ x.fit }} : {{ x.regex }}</pre>
</li>
</ul>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
</div>
</div>
<script>
new Vue({
el: '#app',
data() {
return {
outputs: [{
fit: '',
regex: '',
}],
testset: []
};
},
created() {
var tmp = this;
this.socket = io("http://localhost:8080");
this.socket.on("output", function(data) {
tmp.outputs = []
if(data['ERROR']) {
tmp.outputs.push({
fit: "ERROR",
regex: data['ERROR'],
})
} else {
for (let ind of data) {
tmp.outputs.push({
fit: ind[0],
regex: ind[1],
});
}
}
// tmp.outputs.sort((a, b) => (a.fit > b.fit));
console.log(tmp.outputs);
});
},
methods: {
start() {
this.socket.emit('start', {
generation : this.$refs.generation.value,
population : this.$refs.population.value,
match : this.$refs.match.value,
target : this.$refs.target.value,
});
},
stop() {
this.socket.emit('stop');
},
},
})
</script>
<!-- JS, Popper.js, and jQuery -->
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js" integrity="sha384-OgVRvuATP1z7JjHLkuOU7Xw704+h835Lr+6QL9UvYjZE3Ipu6Tp75j7Bh/kR0JKI" crossorigin="anonymous"></script>
</body>