Skip to content

Commit

Permalink
fix automated jargon file example #100
Browse files Browse the repository at this point in the history
  • Loading branch information
jcubic committed Oct 8, 2024
1 parent 79fdd02 commit 3c425e3
Showing 1 changed file with 22 additions and 28 deletions.
50 changes: 22 additions & 28 deletions examples/automated_jargon_file.gs
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

0 comments on commit 3c425e3

Please sign in to comment.