Integrate fortune-telling, make fortunes local

This commit is contained in:
Neale Pickett 2021-04-26 17:55:46 -06:00
parent fbe55ae6b6
commit 130eb73ff3
6 changed files with 540 additions and 50 deletions

1
.gitignore vendored
View File

@ -1 +1,2 @@
go.sum go.sum
vail

View File

@ -1,35 +0,0 @@
import * as Morse from "./morse.mjs"
class Fortune {
constructor() {
let button = document.querySelector("#fortune")
button.addEventListener("click", () => this.go())
this.buzzer = new Morse.Buzzer({highFreq: 440})
this.iambic = new Morse.Iambic(() => this.buzzer.Buzz(true), () => this.buzzer.Silence(true))
document.querySelector("#iambic-duration").addEventListener("input", e => this.iambic.SetIntervalDuration(e.target.value))
}
async go() {
let resp = await fetch("https://rot47.net/api/fortune/")
let fortune = await resp.json()
this.iambic.EnqueueAsciiString(fortune)
}
}
function fortuneInit() {
try {
window.fortune = new Fortune()
} catch (err) {
console.log(err)
Morse.toast(err)
}
}
if (document.readyState === "loading") {
document.addEventListener("DOMContentLoaded", fortuneInit)
} else {
fortuneInit()
}

467
static/fortunes.mjs Normal file
View File

@ -0,0 +1,467 @@
/*
These were converted, and lightly edited, from the `fortunes-min` Debian package,
which came with the following copyright:
Copyright (c) 1991 The Regents of the University of California.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. [ Deleted. see :-
ftp://ftp.cs.berkeley.edu/pub/4bsd/README.Impt.License.Change
]
4. Neither the name of the University nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
export const fortunes = [
"A day for firm decisions! Or is it?",
"A few hours grace before the madness begins again.",
"A gift of a flower will soon be made to you.",
"A long-forgotten loved one will appear soon. Buy the negatives at any price.",
"A tall, dark stranger will have more fun than you.",
"A visit to a fresh place will bring strange work.",
"A visit to a strange place will bring fresh work.",
"A vivid and creative mind characterizes you.",
"Abandon the search for Truth; settle for a good fantasy.",
"Accent on helpful side of your nature. Drain the moat.",
"Advancement in position.",
"After your lover has gone you will still have PEANUT BUTTER!",
"Afternoon very favorable for romance. Try a single person for a change.",
"Alimony and bribes will engage a large share of your wealth.",
"All the troubles you have will pass away very quickly.",
"Among the lucky, you are the chosen one.",
"An avocado-tone refrigerator would look good on your resume.",
"An exotic journey in downtown Newark is in your future.",
"Another good night not to sleep in a eucalyptus tree.",
"Are you a turtle?",
"Are you ever going to do the dishes? Or will you change your major to biology?",
"Are you making all this up as you go along?",
"Are you sure the back door is locked?",
"Artistic ventures highlighted. Rob a museum.",
"Avert misunderstanding by calm, poise, and balance.",
"Avoid gunfire in the bathroom tonight.",
"Avoid reality at all costs.",
"Bank error in your favor. Collect $200.",
"Be careful! Is it classified?",
"Be careful! UGLY strikes 9 out of 10!",
"Be cautious in your daily affairs.",
"Be cheerful while you are alive. -- Phathotep, 24th Century B.C.",
"Be different: conform.",
"Be free and open and breezy! Enjoy! Things won't get any better so get used to it.",
"Be security conscious -- National defense is at stake.",
"Beauty and harmony are as necessary to you as the very breath of life.",
"Best of all is never to have been born. Second best is to die soon.",
"Better hope the life-inspector doesn't come around while you have your life in such a mess.",
"Beware of a dark-haired man with a loud tie.",
"Beware of a tall black man with one blond shoe.",
"Beware of a tall blond man with one black shoe.",
"Beware of Bigfoot!",
"Beware of low-flying butterflies.",
"Beware the one behind you.",
"Blow it out your ear.",
"Break into jail and claim police brutality.",
"Bridge ahead. Pay troll.",
"Caution: breathing may be hazardous to your health.",
"Caution: Keep out of reach of children.",
"Celebrate Hannibal Day this year. Take an elephant to lunch.",
"Change your thoughts and you change your world.",
"Cheer Up! Things are getting worse at a slower rate.",
"Chess tonight.",
"Chicken Little only has to be right once.",
"Chicken Little was right.",
"Cold hands, no gloves.",
"Communicate! It can't make things any worse.",
"Courage is your greatest present need.",
"Day of inquiry. You will be subpoenaed.",
"Do not overtax your powers.",
"Do not sleep in a eucalyptus tree tonight.",
"Do nothing unless you must, and when you must act -- hesitate.",
"Do something unusual today. Pay a bill.",
"Do what comes naturally. Seethe and fume and throw a tantrum.",
"Domestic happiness and faithful friends.",
"Don't feed the bats tonight.",
"Don't get stuck in a closet -- wear yourself out.",
"Don't get to bragging.",
"Don't go surfing in South Dakota for a while.",
"Don't hate yourself in the morning -- sleep till noon.",
"Don't kiss an elephant on the lips today.",
"Don't let your mind wander -- it's too little to be let out alone.",
"Don't look back, the lemmings are gaining on you.",
"Don't look now, but the man in the moon is laughing at you.",
"Don't look now, but there is a multi-legged creature on your shoulder.",
"Don't plan any hasty moves. You'll be evicted soon anyway.",
"Don't read any sky-writing for the next two weeks.",
"Don't read everything you believe.",
"Don't relax! It's only your tension that's holding you together.",
"Don't tell any big lies today. Small ones can be just as effective.",
"Don't worry so loud, your roommate can't think.",
"Don't Worry, Be Happy. -- Meher Baba",
"Don't you feel more like you do now than you did when you came in?",
"Don't you wish you had more energy... or less ambition?",
"Everything that you know is wrong, but you can be straightened out.",
"Everything will be just tickety-boo today.",
"Excellent day for putting Slinkies on an escalator.",
"Excellent day to have a rotten day.",
"Excellent time to become a missing person.",
"Executive ability is prominent in your make-up.",
"Exercise caution in your daily affairs.",
"Expect a letter from a friend who will ask a favor of you.",
"Expect the worst, it's the least you can do.",
"Fine day for friends. So-so day for you.",
"Fine day to work off excess energy. Steal something heavy.",
"Future looks spotty. You will spill soup in late evening.",
"Generosity and perfection are your everlasting goals.",
"Give him an evasive answer.",
"Give thought to your reputation. Consider changing name and moving to a new town.",
"Give your very best today. Heaven knows it's little enough.",
"Go to a movie tonight. Darkness becomes you.",
"Good day for a change of scene. Repaper the bedroom wall.",
"Good day for overcoming obstacles. Try a steeplechase.",
"Good day to deal with people in high places; particularly lonely stewardesses.",
"Good day to let down old friends who need help.",
"Good news from afar can bring you a welcome visitor.",
"Good news. Ten weeks from Friday will be a pretty good day.",
"Good night to spend with family, but avoid arguments with your mate's new lover.",
"Green light in A.M. for new projects. Red light in P.M. for traffic tickets.",
"Hope that the day after you die is a nice day.",
"If you can read this, you're too close.",
"If you learn one useless thing every day, in a single year you'll learn 365 useless things.",
"If you sow your wild oats, hope for a crop failure.",
"If you stand on your head, you will get footprints in your hair.",
"If you think last Tuesday was a drag, wait till you see what happens tomorrow!",
"If your life was a horse, you'd have to shoot it.",
"In the stairway of life, you'd best take the elevator.",
"Increased knowledge will help you now. Have mate's phone bugged.",
"Is that really YOU that is reading this?",
"Is this really happening?",
"It may or may not be worthwhile, but it still has to be done.",
"It was all so different before everything changed.",
"It's all in the mind, ya know.",
"It's lucky you're going so slowly, because you're going in the wrong direction.",
"Just because the message may never be received does not mean it is not worth sending.",
"Just to have it is enough.",
"Keep emotionally active. Cater to your favorite neurosis.",
"Keep it short for pithy sake.",
"Lady Luck brings added income today. Lady friend takes it away tonight.",
"Learn to pause -- or nothing worthwhile can catch up to you.",
"Let me put it this way: today is going to be a learning experience.",
"Life is to you a dashing and bold adventure.",
"Live in a world of your own, but always welcome visitors.",
"Living your life is a task so difficult, it has never been attempted before.",
"Long life is in store for you.",
"Look afar and see the end from the beginning.",
"Love is in the offing. Be affectionate to one who adores you.",
"Make a wish, it might come true.",
"Many changes of mind and mood; do not hesitate too long.",
"Never be led astray onto the path of virtue.",
"Never commit yourself! Let someone else commit you.",
"Never give an inch!",
"Never look up when dragons fly overhead.",
"Never reveal your best argument.",
"Next Friday will not be your lucky day. As a matter of fact, you don't have a lucky day this year.",
"Of course you have a purpose -- to find a purpose.",
"People are beginning to notice you. Try dressing before you leave the house.",
"Perfect day for scrubbing the floor and other exciting things.",
"Questionable day. Ask somebody something.",
"Reply hazy, ask again later.",
"Save energy: be apathetic.",
"Ships are safe in harbor, but they were never meant to stay there.",
"Slow day. Practice crawling.",
"Snow Day -- stay home.",
"So this is it. We're going to die.",
"So you're back... about time...",
"Someone is speaking well of you.",
"Someone is speaking well of you. How unusual!",
"Someone whom you reject today, will reject you tomorrow.",
"Stay away from flying saucers today.",
"Stay away from hurricanes for a while.",
"Stay the curse.",
"That secret you've been guarding, isn't.",
"The time is right to make new friends.",
"There is a 20% chance of tomorrow.",
"There is a fly on your nose.",
"There was a phone call for you.",
"There will be big changes for you but you will be happy.",
"Things will be bright in P.M. A cop will shine a light in your face.",
"Think twice before speaking, but don't say \"think think click click\".",
"This life is yours. Some of it was given to you; the rest, you made yourself.",
"This will be a memorable month -- no matter how hard you try to forget it.",
"Time to be aggressive. Go after a tattooed Virgo.",
"Today is National Existential Ennui Awareness Day.",
"Today is the first day of the rest of the mess.",
"Today is the first day of the rest of your life.",
"Today is the last day of your life so far.",
"Today is the tomorrow you worried about yesterday.",
"Today is what happened to yesterday.",
"Tomorrow will be cancelled due to lack of interest.",
"Tomorrow, this will be part of the unchangeable past but fortunately, it can still be changed today.",
"Tomorrow, you can be anywhere.",
"Tonight you will pay the wages of sin; Don't forget to leave a tip.",
"Tonight's the night: Sleep in a eucalyptus tree.",
"Troubled day for virgins over 16 who are beautiful and wealthy and live in eucalyptus trees.",
"Truth will out this morning. (Which may really mess things up.)",
"Try the Moo Shu Pork. It is especially good today.",
"Try to get all of your posthumous medals in advance.",
"Try to have as good a life as you can under the circumstances.",
"Try to value useful qualities in one who loves you.",
"Tuesday After Lunch is the cosmic time of the week.",
"Tuesday is the Wednesday of the rest of your life.",
"What happened last night can happen again.",
"While you recently had your problems on the run, they've regrouped and are making another attack.",
"Write yourself a threatening letter and pen a defiant reply.",
"You are a bundle of energy, always on the go.",
"You are a fluke of the universe; you have no right to be here.",
"You are a very redundant person, that's what kind of person you are.",
"You are always busy.",
"You are as I am with You.",
"You are capable of planning your future.",
"You are confused; but this is your normal state.",
"You are deeply attached to your friends and acquaintances.",
"You are destined to become the commandant of the fighting men of the department of transportation.",
"You are dishonest, but never to the point of hurting a friend.",
"You are fairminded, just and loving.",
"You are farsighted, a good planner, an ardent lover, and a faithful friend.",
"You are fighting for survival in your own sweet and gentle way.",
"You are going to have a new love affair.",
"You are magnetic in your bearing.",
"You are not dead yet. But watch for further reports.",
"You are number 6! Who is number one?",
"You are only young once, but you can stay immature indefinitely.",
"You are scrupulously honest, frank, and straightforward. Therefore you have few friends.",
"You are sick, twisted and perverted. I like that in a person.",
"You are so boring that when I see you my feet go to sleep.",
"You are standing on my toes.",
"You are taking yourself far too seriously.",
"You are the only person to ever get this message.",
"You are wise, witty, and wonderful, but you spend too much time reading this sort of trash.",
"You attempt things that you do not even plan because of your extreme stupidity.",
"You can create your own opportunities this week. Blackmail a senior executive.",
"You can do very well in speculation where land or anything to do with dirt is concerned.",
"You can rent this space for only $5 a week.",
"You could live a better life, if you had a better mind and a better body.",
"You definitely intend to start living sometime soon.",
"You dialed 5483.",
"You display the wonderful traits of charm and courtesy.",
"You don't become a failure until you're satisfied with being one.",
"You enjoy the company of other people.",
"You feel a whole lot more like you do now than you did when you used to.",
"You fill a much-needed gap.",
"You get along very well with everyone except animals and people.",
"You had some happiness once, but your parents moved away, and you had to leave it behind.",
"You have a deep appreciation of the arts and music.",
"You have a deep interest in all that is artistic.",
"You have a reputation for being thoroughly reliable and trustworthy. A pity that it's totally undeserved.",
"You have a strong appeal for members of the opposite sex.",
"You have a strong appeal for members of your own sex.",
"You have a strong desire for a home and your family interests come first.",
"You have a truly strong individuality.",
"You have a will that can be influenced by all with whom you come in contact.",
"You have an ability to sense and know higher truth.",
"You have an ambitious nature and may make a name for yourself.",
"You have an unusual equipment for success. Be sure to use it properly.",
"You have an unusual magnetic personality. Don't walk too close to metal objects which are not fastened down.",
"You have an unusual understanding of the problems of human relationships.",
"You have been selected for a secret mission.",
"You have Egyptian flu: you're going to be a mummy.",
"You have had a long-term stimulation relative to business.",
"You have literary talent that you should take pains to develop.",
"You have many friends and very few living enemies.",
"You have no real enemies.",
"You have taken yourself too seriously.",
"You have the body of a 19 year old. Please return it before it gets wrinkled.",
"You have the capacity to learn from mistakes. You'll learn a lot today.",
"You have the power to influence all with whom you come in contact.",
"You like to form new friendships and make new acquaintances.",
"You look like a million dollars. All green and wrinkled.",
"You look tired.",
"You love peace.",
"You love your home and want it to be beautiful.",
"You may be gone tomorrow, but that doesn't mean that you weren't here today.",
"You may be infinitely smaller than some things, but you're infinitely larger than others.",
"You may be recognized soon. Hide.",
"You may get an opportunity for advancement today. Watch it!",
"You may worry about your hair-do today, but tomorrow much peanut butter will be sold.",
"You need more time; and you probably always will.",
"You need no longer worry about the future. This time tomorrow you'll be dead.",
"You never hesitate to tackle the most difficult problems.",
"You never know how many friends you have until you rent a house on the beach.",
"You now have Asian Flu.",
"You own a dog, but you can only feed a cat.",
"You plan things that you do not even attempt because of your extreme caution.",
"You possess a mind not merely twisted, but actually sprained.",
"You prefer the company of the opposite sex, but are well liked by your own.",
"You recoil from the crude; you tend naturally toward the exquisite.",
"You seek to shield those you love and you like the role of the provider.",
"You shall be rewarded for a dastardly deed.",
"You should emulate your heroes, but don't carry it too far. Especially if they are dead.",
"You should go home.",
"You single-handedly fought your way into this hopeless mess.",
"You teach best what you most need to learn.",
"You too can wear a nose mitten.",
"You two ought to be more careful--your love could drag on for years and years.",
"You will always get the greatest recognition for the job you least like.",
"You will always have good luck in your personal affairs.",
"You will attract cultured and artistic people to your home.",
"You will be a winner today. Pick a fight with a four-year-old.",
"You will be advanced socially, without any special effort on your part.",
"You will be aided greatly by a person whom you thought to be unimportant.",
"You will be attacked by a beast who has the body of a wolf, the tail of a lion, and the face of Donald Duck.",
"You will be audited by the Internal Revenue Service.",
"You will be awarded a medal for disregarding safety in saving someone.",
"You will be awarded some great honor.",
"You will be awarded the Nobel Peace Prize... posthumously.",
"You will be called upon to help a friend in trouble.",
"You will be divorced within a year.",
"You will be given a post of trust and responsibility.",
"You will be held hostage by a radical group.",
"You will be honored for contributing your time and skill to a worthy cause.",
"You will be imprisoned for contributing your time and skill to a bank robbery.",
"You will be married within a year, and divorced within two.",
"You will be married within a year.",
"You will be misunderstood by everyone.",
"You will be recognized and honored as a community leader.",
"You will be reincarnated as a toad; and you will be much happier.",
"You will be run over by a beer truck.",
"You will be run over by a bus.",
"You will be singled out for promotion in your work.",
"You will be successful in love.",
"You will be surprised by a loud noise.",
"You will be surrounded by luxury.",
"You will be the last person to buy a Chrysler.",
"You will be the victim of a bizarre joke.",
"You will be Told about it Tomorrow. Go Home and Prepare Thyself.",
"You will be traveling and coming into a fortune.",
"You will be winged by an anti-aircraft battery.",
"You will become rich and famous unless you don't.",
"You will contract a rare disease.",
"You will engage in a profitable business activity.",
"You will experience a strong urge to do good; but it will pass.",
"You will feel hungry again in another hour.",
"You will forget that you ever knew me.",
"You will gain money by a fattening action.",
"You will gain money by a speculation or lottery.",
"You will gain money by an illegal action.",
"You will gain money by an immoral action.",
"You will get what you deserve.",
"You will give someone a piece of your mind, which you can ill afford.",
"You will have a long and boring life.",
"You will have a long and unpleasant discussion with your supervisor.",
"You will have domestic happiness and faithful friends.",
"You will have good luck and overcome many hardships.",
"You will have long and healthy life.",
"You will hear good news from one you thought unfriendly to you.",
"You will inherit millions of dollars.",
"You will inherit some money or a small piece of land.",
"You will live a long, healthy, happy life and make bags of money.",
"You will live to see your grandchildren.",
"You will lose your present job and have to become a door to door mayonnaise salesman.",
"You will meet an important person who will help you advance professionally.",
"You will never know hunger.",
"You will not be elected to public office this year.",
"You will obey or molten silver will be poured into your ears.",
"You will outgrow your usefulness.",
"You will overcome the attacks of jealous associates.",
"You will pass away very quickly.",
"You will pay for your sins. If you have already paid, please disregard this message.",
"You will pioneer the first Martian colony.",
"You will probably marry after a very brief courtship.",
"You will reach the highest possible point in your business or profession.",
"You will receive a legacy which will place you above want.",
"You will remember something that you should not have forgotten.",
"You will soon forget this.",
"You will soon meet a person who will play an important role in your life.",
"You will step on the night soil of many countries.",
"You will stop at nothing to reach your objective, but only because your brakes are defective.",
"You will triumph over your enemy.",
"You will visit the Dung Pits of Glive soon.",
"You will win success in whatever calling you adopt.",
"You will wish you hadn't.",
"You work very hard. Don't try to think as well.",
"You worry too much about your job. Stop it. You are not paid enough to worry.",
"You would if you could but you can't so you won't.",
"You'd like to do it instantaneously, but that's too slow.",
"You'll be called to a post requiring ability in handling groups of people.",
"You'll be sorry...",
"You'll feel devilish tonight. Toss dynamite caps under a flamenco dancer's heel.",
"You'll feel much better once you've given up hope.",
"You'll never be the man your mother was!",
"You'll never see all the places, or read all the books, but fortunately, they're not all recommended.",
"You'll wish that you had done some of the hard things when they were easier to do.",
"You're a card which will have to be dealt with.",
"You're almost as happy as you think you are.",
"You're at the end of the road again.",
"You're being followed. Cut out the hanky-panky for a few days.",
"You're currently going through a difficult transition period called \"Life.\"",
"You're definitely on their list. The question to ask next is what list it is.",
"You're growing out of some of your problems, but there are others that you're growing into.",
"You're not my type. For that matter, you're not even my species!",
"You're ugly and your mother dresses you funny.",
"You're working under a slight handicap. You happen to be human.",
"You've been leading a dog's life. Stay off the furniture.",
"Your aim is high and to the right.",
"Your aims are high, and you are capable of much.",
"Your analyst has you mixed up with another patient. Don't believe a thing he tells you.",
"Your best consolation is the hope that the things you failed to get weren't really worth having.",
"Your boss climbed the corporate ladder, wrong by wrong.",
"Your boss is a few sandwiches short of a picnic.",
"Your boyfriend takes chocolate from strangers.",
"Your business will assume vast proportions.",
"Your business will go through a period of considerable expansion.",
"Your depth of comprehension may tend to make you lax in worldly ways.",
"Your domestic life may be harmonious.",
"Your fly might be open (but don't check it just now).",
"Your heart is pure, and your mind clear, and your soul devout.",
"Your ignorance cramps my conversation.",
"Your life would be very empty if you had nothing to regret.",
"Your love life will be happy and harmonious.",
"Your love life will be... interesting.",
"Your lover will never wish to leave you.",
"Your lucky color has faded.",
"Your lucky number has been disconnected.",
"Your lucky number is 3552664958674928. Watch for it everywhere.",
"Your mode of life will be changed for the better because of good news soon.",
"Your mode of life will be changed for the better because of new developments.",
"Your motives for doing whatever good deed you may have in mind will be misinterpreted by somebody.",
"Your nature demands love and your happiness depends on it.",
"Your object is to save the world, while still leading a pleasant life.",
"Your own qualities will help prevent your advancement in the world.",
"Your present plans will be successful.",
"Your reasoning is excellent -- it's only your basic assumptions that are wrong.",
"Your reasoning powers are good, and you are a fairly good planner.",
"Your sister swims out to meet troop ships.",
"Your society will be sought by people of taste and refinement.",
"Your step will soil many countries.",
"Your supervisor is thinking about you.",
"Your talents will be recognized and suitably rewarded.",
"Your temporary financial embarrassment will be relieved in a surprising manner.",
"Your true value depends entirely on what you are compared with.",
]
/**
* Return a randomly-chosen fortune.
*/
export function getFortune() {
return fortunes[Math.floor(Math.random() * fortunes.length)]
}

View File

@ -15,7 +15,6 @@
<link rel="icon" href="vail.png" sizes="256x256" type="image/png"> <link rel="icon" href="vail.png" sizes="256x256" type="image/png">
<link rel="icon" href="vail.svg" sizes="any" type="image/svg+xml"> <link rel="icon" href="vail.svg" sizes="any" type="image/svg+xml">
<script type="module" src="vail.mjs"></script> <script type="module" src="vail.mjs"></script>
<script type="module" src="fortune.mjs"></script>
<link rel="stylesheet" href="vail.css"> <link rel="stylesheet" href="vail.css">
</head> </head>
<body> <body>
@ -176,15 +175,22 @@
<tr class="mdl-card__supporting-text"> <tr class="mdl-card__supporting-text">
<td> <td>
<p> <p>
Check (CK) round-trip times and audio functionality Send <code>CK</code> (check) to the repeater, and play when it comes back.
by sending "CK" to the repeater and playing the returned signal.
</p> </p>
</td> </td>
<td> <td>
<p> <p>
Fetch a fortune and play it locally. Spacing: ×<output id="handicap-value"></output>
This can help practice copying (hearing) Morse code, <input
without having to involve another person. id="handicap"
class="mdl-slider mdl-js-slider"
type="range"
min="1"
max="8"
value="4">
</p>
<p>
Have vail tell your fortune, in English. Local only: not transmitted.
</p> </p>
</td> </td>
</tr> </tr>
@ -323,7 +329,8 @@
<span>8 ---..</span> <span>8 ---..</span>
<span>9 ----.</span> <span>9 ----.</span>
<br> <br>
<span>Over .-.</span> <span>End of transmission .-.-.</span>
<span>Over -.-</span>
<span>Correction ........</span> <span>Correction ........</span>
<span>? / Say Again ..--..</span> <span>? / Say Again ..--..</span>
</div> </div>

View File

@ -107,10 +107,11 @@ class Iambic {
* @param {TxControl} endTxFunc Function to end transmitting * @param {TxControl} endTxFunc Function to end transmitting
* @param {number} intervalDuration Dit duration (milliseconds) * @param {number} intervalDuration Dit duration (milliseconds)
*/ */
constructor(beginTxFunc, endTxFunc, intervalDuration=100) { constructor(beginTxFunc, endTxFunc, {intervalDuration=100, pauseMultiplier=1}={}) {
this.beginTxFunc = beginTxFunc this.beginTxFunc = beginTxFunc
this.endTxFunc = endTxFunc this.endTxFunc = endTxFunc
this.intervalDuration = intervalDuration this.intervalDuration = intervalDuration
this.pauseMultiplier = pauseMultiplier
this.ditDown = false this.ditDown = false
this.dahDown = false this.dahDown = false
this.last = null this.last = null
@ -133,7 +134,11 @@ class Iambic {
let next = this.queue.shift() let next = this.queue.shift()
if (next < 0) { if (next < 0) {
next = next * -1 next *= -1
if (next > 1) {
// Don't adjust spacing within a letter
next *= this.pauseMultiplier
}
this.endTxFunc() this.endTxFunc()
} else { } else {
this.last = next this.last = next
@ -166,6 +171,12 @@ class Iambic {
return this.last return this.last
} }
/**
* Return true if we are currently playing out something
*/
Busy() {
return this.pulseTimer
}
/** /**
* Set a new dit interval (transmission rate) * Set a new dit interval (transmission rate)
* *
@ -175,6 +186,18 @@ class Iambic {
this.intervalDuration = duration this.intervalDuration = duration
} }
/**
* Set a new pause multiplier.
*
* This slows down the inter-letter and inter-word pauses,
* which can aid in learning.
*
* @param {number} multiplier Pause multiplier
*/
SetPauseMultiplier(multiplier) {
this.pauseMultiplier = multiplier
}
/** /**
* Add to the output queue, and start processing the queue if it's not currently being processed. * Add to the output queue, and start processing the queue if it's not currently being processed.
* *
@ -204,12 +227,12 @@ class Iambic {
} }
} }
EnqueueAsciiString(s) { EnqueueAsciiString(s, {pauseLetter = PAUSE_LETTER, pauseWord = PAUSE_WORD} = {}) {
for (let c of s.toLowerCase()) { for (let c of s.toLowerCase()) {
let m = MorseMap[c] let m = MorseMap[c]
if (m) { if (m) {
this.EnqueueMorseString(m) this.EnqueueMorseString(m)
this.Enqueue(PAUSE_LETTER) this.Enqueue(pauseLetter)
continue continue
} }
@ -217,7 +240,7 @@ class Iambic {
case " ": case " ":
case "\n": case "\n":
case "\t": case "\t":
this.Enqueue(PAUSE_WORD) this.Enqueue(pauseWord)
break break
default: default:
console.warn("Unable to encode '" + c + "'!") console.warn("Unable to encode '" + c + "'!")

View File

@ -1,4 +1,6 @@
import * as Morse from "./morse.mjs" import * as Morse from "./morse.mjs"
import {getFortune} from "./fortunes.mjs"
import { toast } from "./morse.mjs"
class Vail { class Vail {
constructor() { constructor() {
@ -29,12 +31,22 @@ class Vail {
document.addEventListener("keyup", e => this.keyboard(e)) document.addEventListener("keyup", e => this.keyboard(e))
// Make helpers // Make helpers
this.iambic = new Morse.Iambic(() => this.beginTx(), () => this.endTx())
this.buzzer = new Morse.Buzzer() this.buzzer = new Morse.Buzzer()
this.iambic = new Morse.Iambic(() => this.beginTx(), () => this.endTx())
this.fortuneBuzzer = new Morse.Buzzer({highFreq: 440})
this.fortuneIambic = new Morse.Iambic(() => this.fortuneBuzzer.Buzz(true), () => this.fortuneBuzzer.Silence(true))
// Listen for slider values // Listen for slider values
this.inputInit("#iambic-duration", e => this.iambic.SetIntervalDuration(e.target.value)) this.inputInit("#iambic-duration", e => {
this.inputInit("#rx-delay", e => { this.rxDelay = Number(e.target.value) }) this.iambic.SetIntervalDuration(e.target.value)
this.fortuneIambic.SetIntervalDuration(e.target.value)
})
this.inputInit("#rx-delay", e => {
this.rxDelay = Number(e.target.value)
})
this.inputInit("#handicap", e => {
this.fortuneIambic.SetPauseMultiplier(e.target.value)
})
// Show what repeater we're on // Show what repeater we're on
let repeater = (new URL(location)).searchParams.get("repeater") || "General Chaos" let repeater = (new URL(location)).searchParams.get("repeater") || "General Chaos"
@ -309,6 +321,8 @@ class Vail {
this.straightKey(begin) this.straightKey(begin)
} else if ((event.target.id == "ck") && begin) { } else if ((event.target.id == "ck") && begin) {
this.Test() this.Test()
} else if ((event.target.id == "fortune") && begin) {
this.PlayFortune()
} }
} }
@ -373,6 +387,19 @@ class Vail {
this.socket.send(JSON.stringify(msg)) this.socket.send(JSON.stringify(msg))
} }
/**
* Play a randomly-chosen fortune
&& begin */
PlayFortune() {
if (this.fortuneIambic.Busy()) {
toast("I am already telling your fortune!")
} else {
let fortune = getFortune()
this.fortuneIambic.EnqueueAsciiString(`${fortune}\x04`)
}
}
maximize(e) { maximize(e) {
let element = e.target let element = e.target
while (!element.classList.contains("mdl-card")) { while (!element.classList.contains("mdl-card")) {