metanohi-misc-subsites/projects/webcli/commands.js

344 lines
12 KiB
JavaScript
Raw Normal View History

2011-08-02 19:57:57 +02:00
<commands>
<help what="Helps you (but only regarding webCLI - it can't help you with e.g. finding the meaning of life).">
add("If you don't know what this is, you'll know in less than one minute. If you already know what this is, you'll already know what it is (simple).\nThis is webCLI, a playground for people who find it fascinating to use a computer with commands. You can't use your mouse. You need to type words - commands. Type [whatis] to see a list of all commands. Type [whatis -detail] to see a list of all commands in detail. Type [whatis &lt;command&gt;] to see a more detailed description of just one command.")
</help>
<man rel="help" />
<whatis what="Shows you all of the available commands or just one." param="[whatis &lt;command&gt;]">
if (!cb)
add("Here's a list of available commands and a description of them:\n\n"+allcommands+"\n\nIf you want to see a more detailed description of a command, type [whatis &lt;command&gt;]. Type [whatis -detail] to see a list of all commands in detail.")
else if (cb=="-detail")
add("Here's a list of available commands, a description of them and possible parameters:\n\n"+allcommandsdetailed+"\n\nIf you only want to see a list of commands with a description, type [whatis] with no parameters. \n")
else if (commandexists())
add("The \""+cb+"\" command:\n"+whatis())
else
add("The command \""+cb+"\" doesn't exist. Type [whatis] for a list of all commands and a description. Type [whatis -detail] for a complete reference of all commands.")
</whatis>
<reload what="Simply reloads the page.">
add(ca.substr(0,1).toUpperCase()+ca.substr(1)+"ing...")
window.location.reload()
</reload>
<refresh rel="reload" what="Simply refreshes the page." />
<clear what="Clears all text">
t.value=""
add(startmessage,true)
</clear>
<font what="Adjusts font properties." param="[font &lt;values/action&gt;] or [font &lt;property&gt; &lt;value&gt;]\nAs long as only one parameter is specified, the first alternative will be used. If two parameters are specified, the second alternative is used.\n&lt;values&gt; can be any values matching the css property ''font''.\n&lt;property&gt; can be ''family'', ''size'', ''style'', ''variant'' and ''weight''. &lt;value&gt; can be any css value matching the property (e.g. font-size = [font size &lt;value&gt;]).\nYou can type [font -reset] to reset everything about the font, or you can type [font &lt;property&gt; -reset] to reset only a certain property's value.">
if (!cb) {
add("You have to specify parameters!")
return
}
if (!cc) {
if (cb=="-reset") t.style.font=""
else t.style.font=cb
}
else {
if (cb=="family") {
if (cc=="-reset") t.style.fontFamily="lucida console"
else t.style.fontFamily=cc
}
else if (cb=="size") {
if (cc=="-reset") t.style.fontSize="12px"
else t.style.fontSize=cc
}
else if (cb=="style") {
if (cc=="-reset") t.style.fontStyle="normal"
else t.style.fontStyle=cc
}
else if (cb=="variant") {
if (cc=="-reset") t.style.fontVariant="normal"
else t.style.fontVariant=cc
}
else if (cb=="weight") {
if (cc=="-reset") t.style.fontWeight="bold"
else t.style.fontWeight=cc
}
else {
add("That property doesn't exist.")
return
}
}
add("",true,true)
</font>
<text what="Changes text properties." param="[text &lt;action&gt;] or [text &lt;property&gt; &lt;value&gt;]\nIf 1 there's 1 parameter, the first alternative is used. If there's 2 parameters, alternative no. 2 is used.\n&lt;action&gt; can be ''-reset''.\n&lt;property&gt; can be ''color'', ''line-height'', ''letter-spacing'', ''decoration'', ''transform'' or ''word-spacing''. &lt;value&gt; can be any css value matching the property (the property might not look exactly like the equivalent css property).\nYou can type [text -reset] to reset everything about the text, or you can type [text &lt;property&gt; -reset] to reset only a certain property's value.">
if (!cb) {
add("You have to specify parameters!")
return
}
if (!cc) {
if (cb=="-reset") {
t.style.color="#fff"
t.style.lineHeight="normal"
t.style.letterSpacing="normal"
t.style.textDecoration="none"
t.style.textTransform="none"
t.style.wordSpacing="normal"
}
else {
add("You have to specify a value!")
return
}
}
else {
if (cb=="color") {
if (cc=="-reset") t.style.color="#fff"
else t.style.color=cc
}
else if (cb=="line-height") {
if (cc=="-reset") t.style.lineHeight="normal"
else t.style.lineHeight=cc
}
else if (cb=="letter-spacing") {
if (cc=="-reset") t.style.letterSpacing="normal"
else t.style.letterSpacing=cc
}
else if (cb=="decoration") {
if (cc=="-reset") t.style.textDecoration="none"
else t.style.textDecoration=cc
}
else if (cb=="transform") {
if (cc=="-reset") t.style.textTransform="none"
else t.style.textTransform=cc
}
else if (cb=="word-spacing") {
if (cc=="-reset") t.style.wordSpacing="normal"
else t.style.wordSpacing=cc
}
else {
add("That property doesn't exist.")
return
}
}
add("",true,true)
</text>
<background what="Adjusts background properties." param="[background &lt;values/action&gt;] or [background &lt;property&gt; &lt;value&gt;]\nAs long as only one parameter is specified, the first alternative will be used. If two parameters are specified, the second alternative is used.\n&lt;values&gt; can be any values matching the css property ''background''.\n&lt;property&gt; can be ''attachment'', ''color'', ''image'', ''position'' and ''repeat''. &lt;value&gt; can be any css value matching the property (e.g. background-image = [background image &lt;value&gt;]).\nYou can type [background -reset] to reset everything about the background, or you can type [background &lt;property&gt; -reset] to reset only a certain property's value.">
if (!cb) {
add("You have to specify parameters!")
return
}
if (!cc) {
if (cb=="-reset") t.style.background=""
else t.style.background=cb
}
else {
if (cb=="attachment") {
if (cc=="-reset") t.style.backgroundAttachment="scroll"
else t.style.backgroundAttachment=cc
}
else if (cb=="color") {
if (cc=="-reset") t.style.backgroundColor="#000"
else t.style.backgroundColor=cc
}
else if (cb=="image") {
if (cc=="-reset") t.style.backgroundImage="none"
else t.style.backgroundImage=cc
}
else if (cb=="position") {
if (cc=="-reset") t.style.backgroundPosition="0% 0%"
else t.style.backgroundPosition=cc
}
else if (cb=="repeat") {
if (cc=="-reset") t.style.backgroundRepeat="repeat"
else t.style.backgroundRepeat=cc
}
else {
add("That property doesn't exist.")
return
}
}
add("",true,true)
</background>
<bg rel="background" />
<reset what="Resets everything (does not clear text - use [clear] to do that).">
t.style.font="normal normal bold 12px 'lucida console'"
t.style.color="#fff"
t.style.lineHeight="normal"
t.style.letterSpacing="normal"
t.style.textDecoration="none"
t.style.textTransform="none"
t.style.wordSpacing="normal"
t.style.background="#000"
add("",true,true)
</reset>
<joke what="Shows a joke.">
add("Fetching joke from database...\nOoops, there are no jokes! What a disaster!\nIn fact the joke system hasn't been implemented yet..")
</joke>
<chat what="Begins a chat session with the JavaScript code." pl="CHAT">
add("New chat session started.\nTry writing something like \"My name's Croxy and I'm from the planet Dyyzasf\".\nYou can't use the normal commands while in chat mode. Type [/exit] at any time to quit the chat.")
<pl>
add(msg)
</pl>
</chat>
<animation what="Shows some breathtaking animation directly on your screen.">
if (anirunning) {
add("An animation is already running. Wait until it's done.")
return
}
anirunning=true
road=document.createElement("div")
road.style.width="500px"
road.style.height="1060px"
road.style.background="url('img/road.png') no-repeat"
road.style.position="absolute"
road.style.left="50%"
road.style.top="50%"
road.style.marginTop="-530px"
road.style.marginLeft="-250px"
road.style.zIndex="2"
bdy.appendChild(road)
ani=new Array()
for (i=0;i<3;i++) {
ani[i]=document.createElement("img")
ani[i].src="img/m"+(i+1)+".png"
ani[i].style.display="hidden"
ani[i].alt=""
ani[i].style.position="absolute"
ani[i].style.top="50%"
ani[i].style.left="50%"
animt=50
ani[i].style.marginTop="-50px"
ani[i].style.marginLeft="-137px"
ani[i].style.zIndex="3"
bdy.appendChild(ani[i])
}
animation()
add("Animation is now running. You can't watch another animation while this is still running. You'll have to wait until the animation ends.")
</animation>
<ani rel="animation" />
<goto what="Opens an url and exits webCLI at the same time." param="[goto &lt;url&gt;]\nInstead of entering an url, you can also type ''back'' or ''forward''.">
if (!cb) add("You have to specify an internet address.")
else if (cb=="back") window.history.go(-1)
else if (cb=="forward") window.history.go(1)
else {
var cbn=cb
if (!(cbn.indexOf(".")>0 && cbn.indexOf(".")!=cbn.length-2)) {
add("Invalid address")
return
}
if (cbn.substr(0,7)!="http://")
cbn="http://"+cbn
window.location.href=cbn
}
add("Redirecting...",true)
</goto>
<search what="Searches on the internet. Will close webCLI." param="[search &lt;input&gt; &lt;site&gt;]\nif &lt;site&gt; isn't specified, Google will be used. Usable sites are: Google, Yahoo, Lycos, AltaVista, Live, AOL, Wikipedia and IMDb.">
if (!cb) {
add("You have to specify an input!")
return
}
var addr
if (!cc || cc=="google") addr="http://www.google.com/search?q="+cbc
else if (cc=="yahoo") addr="http://search.yahoo.com/search?p="+cbc
else if (cc=="lycos") addr="http://search.lycos.com/?query="+cbc
else if (cc=="altavista") addr="http://www.altavista.com/web/results?q="+cbc
else if (cc=="live") addr="http://search.live.com/results.aspx?q="+cbc
else if (cc=="aol") addr="http://search.aol.com/aol/search?query="+cbc
else if (cc=="wikipedia") addr="http://en.wikipedia.org/wiki/Special:Search?search="+cbc+"\&go=Go"
else if (cc=="imdb") addr="http://www.imdb.com/find?q="+cbc
else {
add("That site doesn't exist.")
return
}
add("Redirecting...",true)
window.location.href=addr
</search>
<mem what="Either remembers what you earlier wrote or memorizes what you write." param="[mem &lt;input&gt;]\nIf no input is specified, it shows what you entered earlier (If you didn't enter anything earlier, read on). However, if you have specified parameters, those will be saved. If cookies are enabled, those will be used (not eaten).">
if (!cb) {
if (svsn==0 && (getCookie("mem")=="" || getCookie("mem")==null)) {
add("You have to use [mem] with parameters before you can see what you earlier wrote!")
return
}
if (!cookie) {
var remmsg=""
for (var ii=0; ii<svsn; ii+=1) {
remmsg+=ii+1+": "+svs[svsn-ii-1]+"\n"
}
}
else {
var remmsg=""
var cmem=getCookie("mem")
cmem=cmem.split("\n")
for (var ii=0; ii<cmem.length; ii+=1) {
remmsg+=ii+1+": "+cmem[cmem.length-ii-1]+"\n"
}
}
add(remmsg,true)
}
else {
if (!cookie) {
svs[svsn]=cb
svsn+=1
}
else {
if (getCookie("mem")=="") nl=""
else nl="\n"
setCookie("mem",getCookie("mem")+nl+cbc)
csvn+=1
}
add("Memorized",true)
}
</mem>
<del what="Deletes the text you saved." param="[del &lt;number&gt;]\nUse [mem] to save text and show text. If no number is specified, everything will be deleted.">
if (!cb) {
if (!cookie) {
svsn=0
svs=new Array()
}
else {
setCookie("mem","")
csvn=0
}
add("Everything deleted.",true)
}
else if (!isnumeric(cb)) {
add("Dont write \""+cb+"\"! Write a number!",true)
}
else if ((cb*1>svsn && !cookie) || cb*1==0 || (cb*1>csvn && cookie))
add("A sentence with that number doesn't exist.",true)
else {
if (!cookie) {
for (i=svsn-cb*1; i<svsn-1; i++) {
svs[i]=svs[i+1]
}
svs.pop()
svsn-=1
}
else {
var cbmg=""
var cmem=getCookie("mem")
cmem=cmem.split("\n")
for (var ii=0; ii<cmem.length; ii+=1) {
if (cmem.length-ii!=cb*1) cbmg+=cmem[ii]+"\n"
}
cbmg=cbmg.substr(0,cbmg.length-1)
//add(getCookie("mem")+"\n\n"+cbmg)
setCookie("mem",cbmg)
csvn-=1
}
add("Number "+cb+" deleted.",true)
}
</del>
</commands>