-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix automated jargon file example #100
- Loading branch information
Showing
1 changed file
with
22 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,36 @@ | ||
## import JavaScript objects into Gaiman | ||
import figlet from "https://cdn.jsdelivr.net/npm/figlet/lib/figlet.js" | ||
import Array | ||
import Promise | ||
|
||
figlet.defaults({ | ||
"fontPath" => "https://unpkg.com/figlet/fonts/" | ||
}) | ||
|
||
## Array.from is needed because filget expect standard behavior of Array::reduce | ||
## and Gaiman extend arrays and use it's own implementation of reduce | ||
## and other methods to make them async (in Gaiman all output JavaScript code is async) | ||
figlet.preloadFonts(Array.from(["Standard"]), ready) | ||
|
||
## jQuery Terminal RPC service used for comments and 404 error page | ||
let service = rpc "https://terminal.jcubic.pl/service.php" | ||
|
||
def ready() | ||
let ascii = figlet.textSync("Jargon File", { | ||
"font" => "Standard" | ||
}) | ||
echo "<yellow>$ascii</yellow>" | ||
echo* "<white>This is the Jargon File, a comprehensive compendium of hacker slang illuminating many aspects of hackish tradition, folklore, and humor.</white>", 20 | ||
echo | ||
let commands = ["Hacker", "Hack value"] | ||
while true do | ||
## typing and executing the given commands | ||
if commands.length then | ||
prompt "" | ||
async animate do | ||
let command = commands.shift() | ||
delay(1000) | ||
exec* command, 10 | ||
end | ||
let ascii = figlet.text("Jargon File", { | ||
"font" => "Standard" | ||
}) | ||
echo "<yellow>$ascii</yellow>" | ||
echo* "<white>This is the Jargon File, a comprehensive compendium of hacker slang illuminating many aspects of hackish tradition, folklore, and humor.</white>", 20 | ||
echo | ||
let commands = ["Hacker", "Hack value"] | ||
while true do | ||
## typing and executing the given commands | ||
if commands.length then | ||
prompt "" | ||
async animate do | ||
let command = commands.shift() | ||
delay(1000) | ||
exec* command, 10 | ||
end | ||
end | ||
|
||
let term = ask* "jargon? ", 10 | ||
for result in service.jargon(term) do | ||
echo result["def"] | ||
echo | ||
end | ||
let term = ask* "jargon? ", 10 | ||
for result in service.jargon(term) do | ||
echo result["def"] | ||
echo | ||
end | ||
end | ||
end |