-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
170 lines (143 loc) · 5.34 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
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Arecibo message generator</title>
<meta name="description" content="Arecibo message generator build in HTML and JS">
<meta name="author" content="Adrian Meresescu">
<!-- Bootstrap css -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<!-- Font-->
<link href="https://fonts.googleapis.com/css?family=Inconsolata" rel="stylesheet">
<style>
* {
font-family: 'Inconsolata', monospace;
font-family: monospace;
}
.pixel {
cursor: pointer;
}
.pixel.active {
background: #000000;
color: #ffffff;
}
#code {
word-wrap: break-word;
}
#draw-area,
#code {
font-size: 12px;
}
</style>
</head>
<body class="bg-light">
<div class="container">
<div class="py-5 text-center">
<h2>Arecibo Signal Generator</h2>
</div>
<div class="row">
<div class="col-md-5 col-sm-12">
<h4 class="mb-3">Draw area</h4>
<div class="card">
<div class="card-body text-center" id="draw-area"></div>
</div>
</div>
<div class="col-md-2 col-sm-12 py-5">
<button id="generate" class="btn btn-primary btn-lg btn-block" type="submit">Generate →</button>
<hr class="mb-4">
<h4 class="mb-3">Customize</h4>
<div class="row">
<div class="col-md-6 mb-3">
<label for="width">Width</label>
<input type="number" class="form-control" id="width" placeholder="" value="23" required="">
</div>
<div class="col-md-6 mb-3">
<label for="height">Height</label>
<input type="number" class="form-control" id="height" placeholder="" value="73" required="">
</div>
<div class="col-md-6 mb-3">
<button type="button" class="btn btn-outline-secondary" id="update-draw-area">Update draw area</button>
</div>
</div>
</div>
<div class="col-md-5 col-sm-12">
<h4 class="mb-3">Signal</h4>
<div class="card">
<div class="card-body" id="code">
<span class="text-muted">Click Generate</span>
</div>
</div>
<div class="mb-3 py-1">
<button type="button" class="btn btn-outline-secondary d-none " id="copy-signal">Copy to clipboard</button>
</div>
</div>
</div>
</div>
<footer class="my-5 pt-5 text-muted text-center text-small">
<p class="mb-1">Learn more about</p>
<ul class="list-inline">
<li class="list-inline-item"><a href="https://en.wikipedia.org/wiki/Arecibo_message" target="_blank">Arecibo signal on wikipedia</a></li>
<li class="list-inline-item"><a href="https://getbootstrap.com/" target="_blank">Bootstrap</a></li>
</ul>
</footer>
<!-- Bootstrap JS-->
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
<script type="text/javascript">
$(document).ready(function() {
var code = [];
var width = 23;
var height = 73;
function populateDrawArea() {
$('#draw-area').empty();
var drawAreaContents = '';
for (var i = 1; i <= width * height; i++) {
code.push(0);
drawAreaContents += '<span data-id="' + i + '" class="pixel">0</span>';
if (i % width == 0) {
drawAreaContents += '<br>';
}
}
$('#draw-area').append(drawAreaContents);
}
$("#draw-area").on("click", ".pixel", function() {
if ($(this).hasClass('active')) {
$(this).removeClass('active');
$(this).html(0);
code[$(this).data('id')] = 0;
} else {
$(this).addClass('active');
$(this).html(1);
code[$(this).data('id')] = 1;
}
});
$('#generate').click(function() {
$('#code').empty();
$('#copy-signal').removeClass('d-none');
for (var i = 1; i <= width * height; i++) {
$('#code').append(code[i]);
}
});
$('#update-draw-area').click(function() {
width = $('#width').val();
height = $('#height').val();
populateDrawArea();
});
$('#copy-signal').click(function() {
var textarea = document.createElement('textarea');
textarea.id = 'temp_element';
textarea.style.height = 0;
document.body.appendChild(textarea);
textarea.value = document.getElementById('code').innerText;
var selector = document.querySelector('#temp_element');
selector.select();
document.execCommand('copy');
document.body.removeChild(textarea);
});
// initial draw area populate
populateDrawArea();
});
</script>
</body>
</html>