A bit of UI work

This commit is contained in:
Neale Pickett 2020-04-20 22:12:30 -06:00
parent 0677d7171c
commit 7ba5ee836e
3 changed files with 245 additions and 155 deletions

View File

@ -2,138 +2,178 @@
<html> <html>
<head> <head>
<title>Vail</title> <title>Vail</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- Material Design Lite -->
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
<link rel="stylesheet" href="https://code.getmdl.io/1.3.0/material.teal-purple.min.css">
<script defer src="https://code.getmdl.io/1.3.0/material.min.js"></script>
<!-- Vail stuff -->
<script src="vail.js"></script> <script src="vail.js"></script>
<link rel="stylesheet" href="vail.css"> <link rel="stylesheet" href="vail.css">
</head> </head>
<body> <body>
<div> <div class="mdl-layout mdl-js-layout">
<img src="code-tree.png"> <header class="mdl-layout__header mdl-layout__header--scroll">
</div> <div class="mdl-layout__header-row">
<!-- Title -->
<span class="mdl-layout-title">Vail</span>
<!-- Add spacer, to align navigation to the right -->
<div class="mdl-layout-spacer"></div>
<!-- Navigation -->
<nav class="mdl-navigation">
<a class="mdl-navigation__link" href="">Link</a>
<a class="mdl-navigation__link" href="">Link</a>
<a class="mdl-navigation__link" href="">Link</a>
<a class="mdl-navigation__link" href="">Link</a>
</nav>
</div>
</header>
<div class="mdl-layout__drawer">
<span class="mdl-layout-title">Title</span>
<nav class="mdl-navigation">
<a class="mdl-navigation__link" href="">Link</a>
<a class="mdl-navigation__link" href="">Link</a>
<a class="mdl-navigation__link" href="">Link</a>
<a class="mdl-navigation__link" href="">Link</a>
</nav>
</div>
<main class="mdl-layout__content">
<div class="flex">
<div class="mdl-card mdl-shadow--4dp">
<div class="mdl-card__title">
<h2 class="mdl-card__title-text">
Code Tree
</h2>
</div>
<div class="mdl-card__supporting-text">
<img src="code-tree.png">
</div>
</div>
<div> <div class="mdl-card mdl-shadow--4dp">
<table> <div class="mdl-card__title">
<tr> <h2 class="mdl-card__title-text">
<th>Dot</th> Input
<td><code>,</code>, <code>w</code>, left mouse button</td> </h2>
</tr> </div>
<tr> <div class="mdl-tabs mdl-js-tabs mdl-js-ripple-effect">
<th>Dash</th> <div class="mdl-tabs__tab-bar">
<td><code>.</code>, <code>v</code>, right mouse button</td> <a href="#iambic" class="mdl-tabs__tab is-active">Iambic</a>
</tr> <a href="#straight" class="mdl-tabs__tab">Straight Key</a>
</table> </div>
</div> <div class="mdl-tabs__panel is-active" id="iambic">
<table style="width: 100%; text-align: center;">
<tr>
<td>
<button class="key mdl-button mdl-js-button mdl-button--raised mdl-button--colored">
dit
</button>
</td>
<td>
<button class="key mdl-button mdl-js-button mdl-button--raised mdl-button--colored">
dah
</button>
</td>
</tr>
<tr>
<td>
<code>.</code> or <code></code>
</td>
<td>
<code>/</code> or <code>z</code>
</td>
</tr>
</table>
</div>
<div class="mdl-tabs__panel" id="straight">
<button class="key mdl-button mdl-js-button mdl-button--raised mdl-button--colored">
Key
</button>
</div>
</div>
</div>
<div> <div class="mdl-card mdl-shadow--4dp">
<pre> <div class="mdl-card__title">
a : .- <h2 class="mdl-card__title-text">
b : -... Vail
c : -.-. </h2>
d : -.. </div>
e : . <div class="mdl-card__supporting-text">
f : ..-. <p>
g : --. This is a CW repeater,
h : .... named after Alfred Vail,
i : .. who may or may not have invented what's called "Morse code",
j : .--- but clearly had some role in it.
k : -.- </p>
l : .-..
m : --
n : -.
o : ---
p : .--.
q : --.-
r : .-.
s : ...
t : -
u : ..-
v : ...-
w : .--
x : -..-
y : -.--
z : --..
0 : -----
1 : .----
2 : ..---
3 : ...--
4 : ....-
5 : .....
6 : -....
7 : --...
8 : ---..
9 : ----.
. : .-.-.-
, : --..--
: : ---...
? : ..--..
' : .----.
- : -....-
/ : -..-.
" : .-..-.
@ : .--.-.
= : -...-
! : -.-.--
</pre>
</div>
<div> <p>
<h1>Vail</h1> Just like a radio repeater,
anybody can connect and start transmitting stuff,
and this will broadcast it to everyone connected.
If there's enough interest,
I'll add something like channels.
</p>
<p> <p>
This is a CW repeater, If you need this to work on a cell phone,
named after Alfred Vail, let me know and I'll come up with something for you.
who may or may not have invented what's called "Morse code", </p>
but clearly had some role in it. </div>
</p> </div>
<p> <div class="mdl-card mdl-shadow--4dp">
Just like a radio repeater, <div class="mdl-card__title">
anybody can connect and start transmitting stuff, <h2 class="mdl-card__title-text">
and this will broadcast it to everyone connected. Why Does This Exist?
If there's enough interest, </h2>
I'll add something like channels. </div>
</p> <div class="mdl-card__supporting-text">
<p>
I need a place to practice CW with actual human beings,
and I want it to be as close as possible to what I'd experience on a radio.
Also, I don't want to make people buy a bunch of radio hardware.
Nothing else like this exists on the Internet, as far as I can tell.
</p>
<p> <h3>Who made it?</h3>
If you need this to work on a cell phone,
let me know and I'll come up with something for you.
</p>
</div>
<div> <p>
<h2>Why does this exist?</h2> <a href="mailto:neale@woozle.org">Neale Pickett</a> kd7oqi
</p>
<p> </div>
I need a place to practice CW with actual human beings, </div>
and I want it to be as close as possible to what I'd experience on a radio.
Also, I don't want to make people buy a bunch of radio hardware.
Nothing else like this exists on the Internet, as far as I can tell.
</p>
<h2>Who made it?</h2> <div class="mdl-card mdl-shadow--4dp">
<div class="mdl-card__title">
<p> <h3 class="mdl-card__title-text">Future plans</h3>
<a href="mailto:neale@woozle.org">Neale Pickett</a> kd7oqi </div>
</p> <div class="mdl-card__supporting_text">
<ul>
<h2>Future plans</h2> <li>Move to a more permanent URL</li>
<li>Make this page less ugly</li>
<ul> <li>Arduino program to let you hook up an iambic paddle over USB</li>
<li>Move to a more permanent URL</li> <li>Document the protocol</li>
<li>Make this page less ugly</li> <li>Support multiple channels/frequencies</li>
<li>Arduino program to let you hook up an iambic paddle over USB</li> <li>Sensible way to make this work on a cell phone</li>
<li>Document the protocol</li> <li>Make this page less ugly (I really hate it right now)</li>
<li>Support multiple channels/frequencies</li> </ul>
<li>Sensible way to make this work on a cell phone</li>
<li>Make this page less ugly (I really hate it right now)</li>
</ul>
<h2>How can I help?</h2> <h3>How can I help?</h3>
<ul> <ul>
<li>Improve the <a href="https://github.com/nealey/vail/">source code</a></li> <li>Improve the <a href="https://github.com/nealey/vail/">source code</a></li>
<li><a href="mailto:neale@woozle.org">Email me</a> and let me know you're using it</li> <li><a href="mailto:neale@woozle.org">Email me</a> and let me know you're using it</li>
</ul> </ul>
</div>
</div>
</div>
</main>
</div> </div>
</body> </body>
</html> </html>

View File

@ -1,8 +1,13 @@
body { .flex {
background-color: #ccc;
font-family: sans-serif;
display: flex; display: flex;
flex-wrap: wrap; flex-wrap: wrap;
align-items: flex-start;
justify-content: space-around;
}
.key {
width: 100%;
height: 6em;
} }
code { code {

View File

@ -1,46 +1,89 @@
var ac = new AudioContext() // jshint asi:true
var gain = ac.createGain()
gain.connect(ac.destination)
gain.gain.value = 0.1
var short = 80 var short = 80
var long = 200 var long = 200
var audioFreq = 660 var audioFreq = 660
var audioFreqMe = audioFreq * 6 / 5 // I think this works out to a minor third var audioFreqMe = audioFreq * 6 / 5 // I think this works out to a minor third
var myosc
var ac = new AudioContext()
var mygain = ac.createGain()
mygain.connect(ac.destination)
mygain.gain.value = 0
var myosc = ac.createOscillator()
myosc.connect(mygain)
myosc.frequency.value = audioFreqMe
myosc.start()
var theirgain = ac.createGain()
theirgain.connect(ac.destination)
theirgain.gain.value = 0
var theirosc = ac.createOscillator()
theirosc.connect(theirgain)
theirosc.frequency.value = audioFreq
theirosc.start()
var repeatInterval
function message(event) { function message(event) {
let now = ac.currentTime
let duration = Number(event.data) || 0 let duration = Number(event.data) || 0
duration = Math.min(duration, long) duration = Math.min(duration, long)
let osc = ac.createOscillator() if (now === 0) {
osc.connect(gain) // Audio Context hasn't started, we can't make sound yet
osc.frequency.value = audioFreq return
osc.start(ac.currentTime) }
osc.stop(ac.currentTime + (duration * 0.001))
theirgain.gain.linearRampToValueAtTime(0.1, now + 0.01)
mygain.gain.setValueAtTime(0.1, now + duration/1000)
theirgain.gain.linearRampToValueAtTime(0.0, now + 0.01 + duration/1000)
}
function send(duration) {
let now = ac.currentTime
window.socket.send(duration)
if (now === 0) {
return
}
mygain.gain.linearRampToValueAtTime(0.1, now + 0.01)
mygain.gain.setValueAtTime(0.1, now + duration/1000)
mygain.gain.linearRampToValueAtTime(0.0, now + 0.01 + duration/1000)
} }
function key(event) { function key(event) {
let duration = 0 let duration = 0
if ((event.button === 0) || (event.key == ",") || (event.key == "w")) { ac.resume()
duration = short
} if (event.repeat) {
if ((event.button === 2) || (event.key == ".") || (event.key == "v")) { // Ignore key repeats generated by the OS, we do this ourselves
duration = long
}
// You don't get to hold the key down yet, sorry
if ((event.repeat) || (duration === 0)) {
return return
} }
window.socket.send(duration) if ((event.button === 0) || (event.code == "Period") || (event.key == "Shift")) {
duration = short
}
if ((event.button === 2) || (event.code == "Slash") || (event.code == "KeyZ")) {
duration = long
}
if (duration === 0) {
return
}
myosc = ac.createOscillator() if (repeatInterval) {
myosc.connect(gain) clearInterval(repeatInterval)
myosc.frequency.value = audioFreqMe }
myosc.start(ac.currentTime)
myosc.stop(ac.currentTime + duration * 0.001) if (event.type.endsWith("down")) {
send(duration)
repeatInterval = setInterval(() => {send(duration)}, duration + short)
}
} }
function canWeJustNot(event) { function canWeJustNot(event) {
@ -58,7 +101,9 @@ function init() {
// disable RMB context menu // disable RMB context menu
document.addEventListener("contextmenu", e => canWeJustNot(e)) document.addEventListener("contextmenu", e => canWeJustNot(e))
document.addEventListener("mousedown", e => key(e)) document.addEventListener("mousedown", e => key(e))
document.addEventListener("mouseup", e => key(e))
document.addEventListener("keydown", e => key(e)) document.addEventListener("keydown", e => key(e))
document.addEventListener("keyup", e => key(e))
} }