Get rid of a redundant directory level.
This commit is contained in:
1
projects/webcli/.gitignore
vendored
Normal file
1
projects/webcli/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
bak/
|
||||
344
projects/webcli/commands.js
Normal file
344
projects/webcli/commands.js
Normal file
@@ -0,0 +1,344 @@
|
||||
<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 <command>] 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 <command>]">
|
||||
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 <command>]. 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 <values/action>] or [font <property> <value>]\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<values> can be any values matching the css property ''font''.\n<property> can be ''family'', ''size'', ''style'', ''variant'' and ''weight''. <value> can be any css value matching the property (e.g. font-size = [font size <value>]).\nYou can type [font -reset] to reset everything about the font, or you can type [font <property> -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 <action>] or [text <property> <value>]\nIf 1 there's 1 parameter, the first alternative is used. If there's 2 parameters, alternative no. 2 is used.\n<action> can be ''-reset''.\n<property> can be ''color'', ''line-height'', ''letter-spacing'', ''decoration'', ''transform'' or ''word-spacing''. <value> 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 <property> -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 <values/action>] or [background <property> <value>]\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<values> can be any values matching the css property ''background''.\n<property> can be ''attachment'', ''color'', ''image'', ''position'' and ''repeat''. <value> can be any css value matching the property (e.g. background-image = [background image <value>]).\nYou can type [background -reset] to reset everything about the background, or you can type [background <property> -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 <url>]\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 <input> <site>]\nif <site> 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 <input>]\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 <number>]\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>
|
||||
137
projects/webcli/functions.js
Normal file
137
projects/webcli/functions.js
Normal file
@@ -0,0 +1,137 @@
|
||||
function whatis() {
|
||||
<?php echo $determinewhat."\n"; ?>
|
||||
}
|
||||
|
||||
function commandexists() {
|
||||
if (<?php echo $commandexists; ?>) return true
|
||||
else return false
|
||||
}
|
||||
|
||||
function getwh() {
|
||||
if (self.innerHeight) {
|
||||
h=self.innerHeight
|
||||
w=self.innerWidth
|
||||
}
|
||||
else if (document.documentElement && document.documentElement.clientHeight) {
|
||||
h=document.documentElement.clientHeight
|
||||
w=document.documentElement.clientHeight
|
||||
}
|
||||
else if (document.body) {
|
||||
h=document.body.clientHeight
|
||||
w=document.body.clientWidth
|
||||
}
|
||||
}
|
||||
|
||||
anin=1
|
||||
aniw=274
|
||||
anih=538
|
||||
function animation() {
|
||||
if (anin==1 || anin==3) aninn=0
|
||||
else if (anin==2) aninn=1
|
||||
else if (anin==4) aninn=2
|
||||
|
||||
aniw=aniw*0.99
|
||||
anih=anih*0.99
|
||||
animt=animt+4
|
||||
|
||||
getwh()
|
||||
|
||||
fanip=h/2-animt+anih
|
||||
|
||||
for (i=0;i<3;i++) {
|
||||
ani[i].style.display="none"
|
||||
ani[i].style.width=aniw+"px"
|
||||
ani[i].style.height=anih+"px"
|
||||
ani[i].style.marginTop="-"+animt+"px"
|
||||
ani[i].style.marginLeft="-"+aniw/2+"px"
|
||||
}
|
||||
ani[aninn].style.display="block"
|
||||
|
||||
if (anin<4) anin+=1
|
||||
else anin=1
|
||||
|
||||
if (fanip>10) setTimeout("animation()",100)
|
||||
else {
|
||||
bdy.removeChild(road)
|
||||
for (i=0;i<3;i++) {
|
||||
bdy.removeChild(ani[i])
|
||||
}
|
||||
anirunning=false
|
||||
aniw=274
|
||||
anih=538
|
||||
}
|
||||
}
|
||||
|
||||
function exit() {
|
||||
var opl=pl
|
||||
pl=""
|
||||
add(opl.substr(0,1).toUpperCase()+opl.substr(1).toLowerCase()+" session ended.")
|
||||
}
|
||||
|
||||
function isnumeric(ttext) {
|
||||
var validchars="0123456789"
|
||||
var isnumber=true
|
||||
var charac
|
||||
|
||||
for (i=0; i<ttext.length && isnumber; i++)
|
||||
{
|
||||
charac=ttext.substr(i,1)
|
||||
if (validchars.indexOf(charac)==-1)
|
||||
{
|
||||
isnumber=false
|
||||
}
|
||||
}
|
||||
return isnumber
|
||||
}
|
||||
|
||||
function getCookie(c_name)
|
||||
{
|
||||
if (document.cookie.length>0)
|
||||
{
|
||||
c_start=document.cookie.indexOf(c_name + "=");
|
||||
if (c_start!=-1)
|
||||
{
|
||||
c_start=c_start + c_name.length+1;
|
||||
c_end=document.cookie.indexOf(";",c_start);
|
||||
if (c_end==-1) c_end=document.cookie.length;
|
||||
return unescape(document.cookie.substring(c_start,c_end));
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
function setCookie(c_name,value,expiredays)
|
||||
{
|
||||
var exdate=new Date();
|
||||
exdate.setDate(exdate.getDate()+expiredays);
|
||||
document.cookie=c_name+ "=" +escape(value)+
|
||||
((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
|
||||
}
|
||||
|
||||
function ie() {
|
||||
if (navigator.appName=="Microsoft Internet Explorer") return true
|
||||
else return false
|
||||
}
|
||||
|
||||
function ie6() {
|
||||
if (navigator.appVersion.indexOf("MSIE 6")!=-1) return true
|
||||
else return false
|
||||
}
|
||||
|
||||
function opera() {
|
||||
if (navigator.appName=="Opera") return true
|
||||
else return false
|
||||
}
|
||||
|
||||
function setCaretToEnd (control) {
|
||||
if (control.createTextRange) {
|
||||
var range = control.createTextRange();
|
||||
range.collapse(false);
|
||||
range.select();
|
||||
}
|
||||
else if (control.setSelectionRange) {
|
||||
control.focus();
|
||||
var length = control.value.length;
|
||||
control.setSelectionRange(length, length);
|
||||
}
|
||||
}
|
||||
BIN
projects/webcli/img/m1.png
Normal file
BIN
projects/webcli/img/m1.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 15 KiB |
BIN
projects/webcli/img/m2.png
Normal file
BIN
projects/webcli/img/m2.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 39 KiB |
BIN
projects/webcli/img/m3.png
Normal file
BIN
projects/webcli/img/m3.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 38 KiB |
BIN
projects/webcli/img/road.png
Normal file
BIN
projects/webcli/img/road.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 34 KiB |
BIN
projects/webcli/img/road.xcf
Normal file
BIN
projects/webcli/img/road.xcf
Normal file
Binary file not shown.
2
projects/webcli/index.htm
Normal file
2
projects/webcli/index.htm
Normal file
@@ -0,0 +1,2 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><script type="text/javascript" src="script.php"></script></head><body></body></html>
|
||||
<!-- This is odd.. Where's the HTML code and the css styles? I'll tell you the secret: JavaScript... -->
|
||||
275
projects/webcli/script.php
Normal file
275
projects/webcli/script.php
Normal file
@@ -0,0 +1,275 @@
|
||||
<?php
|
||||
/*
|
||||
This program is free software. It comes without any warranty, to
|
||||
the extent permitted by applicable law. You can redistribute it
|
||||
and/or modify it under the terms of the Do What The Fuck You Want
|
||||
To Public License, Version 2, as published by Sam Hocevar. See
|
||||
http://sam.zoy.org/wtfpl/COPYING for more details.
|
||||
*/
|
||||
|
||||
/*
|
||||
The above is true for both the PHP code and the JavaScript code in this
|
||||
file, but also the mix of XML and JavaScript code found in commands.js.
|
||||
*/
|
||||
header("Content-type: text/javascript");
|
||||
|
||||
$o=fopen("commands.js","r");
|
||||
$a=fread($o,filesize("commands.js"));
|
||||
fclose($o);
|
||||
$a=str_replace("''","\"",str_replace(">".chr(13).chr(10),">\n",str_replace(">",">",str_replace("\n<","\n<",str_replace("<","<",str_replace("\&","&",str_replace("&&","&&",$a)))))));
|
||||
$a="<".substr($a,4,strlen($a)-8).">";
|
||||
|
||||
$xml=new SimpleXMLElement($a);
|
||||
//$xml=simplexml_load_file("commands.js");
|
||||
$i=0;
|
||||
foreach($xml->children() as $child) {
|
||||
$newfunction=true;
|
||||
$childname=$child->getName();
|
||||
|
||||
$ifpl="";
|
||||
$what="None";
|
||||
$param="None";
|
||||
foreach($child->attributes() as $a=>$b) {
|
||||
if ($a=="rel" && $b!="") {
|
||||
$newfunction=false;
|
||||
$childname=$b;
|
||||
}
|
||||
else if ($a=="what" && $b!="") {
|
||||
$what=$b;
|
||||
}
|
||||
else if ($a=="param" && $b!="") {
|
||||
$param=$b;
|
||||
}
|
||||
else if ($a=="pl" && $b!="") {
|
||||
$pl=$b;
|
||||
$apl.="\nelse if (pl==\"".$pl."\") pl_".strtolower($pl)."()";
|
||||
$ifpl="\npl=\"".$pl."\"";
|
||||
|
||||
foreach($child->children() as $nchild) {
|
||||
$plfunctions.="\n\nfunction pl_".strtolower($pl)."() {".$nchild."}";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!$newfunction) {
|
||||
foreach($xml->children() as $childb) {
|
||||
if ($childb->getName()==$childname) {
|
||||
foreach($childb->attributes() as $ab=>$bb) {
|
||||
if ($ab=="what" && $bb!="") {
|
||||
if ($what!="None") {
|
||||
$bb=$what;
|
||||
}
|
||||
$what=$bb." (does the same as [".$childb->getName()."])";
|
||||
}
|
||||
else if ($ab=="param" && $bb!="") {
|
||||
if ($param!="None") {
|
||||
$bb=$param;
|
||||
}
|
||||
$param=$bb." (the same as [".$childb->getName()."])";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
$allfunctions.="\n\nfunction command_".$child->getName()."() {".$ifpl.$child."}";
|
||||
}
|
||||
$determinefunction.="\nelse if (ca==\"".$child->getName()."\") command_".$childname."()";
|
||||
$determinewhat.="\nelse if (cb==\"".$child->getName()."\") return \"Description: ".$what."\\nParameters: ".$param."\"";
|
||||
|
||||
$allcommands[$i]="\\n".$child->getName().": ".$what;
|
||||
$allcommandsdetailed[$i]="\\nThe \\\"".$child->getName()."\\\" command\\nDescription: ".$what."\\nParameters: ".$param."\\n";
|
||||
//$allcommands.="\\n".$child->getName().": ".$what;
|
||||
//$allcommandsdetailed.="\\nThe \\\"".$child->getName()."\\\" command\\nDescription: ".$what."\\nParameters: ".$param."\\n";
|
||||
$commandexists.=" || cb==\"".$child->getName()."\"";
|
||||
|
||||
$i++;
|
||||
}
|
||||
|
||||
$allfunctions=substr($allfunctions,2);
|
||||
$determinewhat=substr($determinewhat,6);
|
||||
|
||||
sort($allcommands);
|
||||
while (list($key, $val) = each($allcommands)) {
|
||||
$nallcommands.=$val;
|
||||
}
|
||||
|
||||
sort($allcommandsdetailed);
|
||||
while (list($key, $val) = each($allcommandsdetailed)) {
|
||||
$nallcommandsdetailed.=$val;
|
||||
}
|
||||
|
||||
$allcommands="";
|
||||
$allcommandsdetailed="";
|
||||
|
||||
$allcommands=substr($nallcommands,2);
|
||||
$allcommandsdetailed=substr($nallcommandsdetailed,2);
|
||||
$commandexists=substr($commandexists,4);
|
||||
|
||||
include("functions.js");
|
||||
echo "\n\n".$allfunctions.$plfunctions;
|
||||
?>
|
||||
|
||||
|
||||
function add(sometext,l,ll) {
|
||||
nn="\n\n"
|
||||
if (l) nn="\n"
|
||||
if (ll) nn=""
|
||||
t.value+=sometext+nn+pl+">"
|
||||
t.focus()
|
||||
}
|
||||
|
||||
function resize() {
|
||||
if (self.innerHeight) h=self.innerHeight
|
||||
else if (document.documentElement && document.documentElement.clientHeight) h=document.documentElement.clientHeight
|
||||
else if (document.body) h=document.body.clientHeight
|
||||
t.style.height=h-2+"px"
|
||||
scrolldown()
|
||||
}
|
||||
|
||||
function focusafterawhile() {
|
||||
if (focuswait) {
|
||||
focuswait=false
|
||||
setTimeout("focusafterawhile()",250)
|
||||
}
|
||||
else
|
||||
t.focus()
|
||||
}
|
||||
|
||||
function scrolldown() {
|
||||
th=t.scrollHeight
|
||||
if (th>h) t.scrollTop=th
|
||||
}
|
||||
|
||||
function onenter(e) {
|
||||
if (!enterdown) {
|
||||
if (window.event) keycode=window.event.keyCode
|
||||
else if (e) keycode=e.which
|
||||
enterdown=true
|
||||
setTimeout("onenter()",50)
|
||||
}
|
||||
else {
|
||||
enterdown=false
|
||||
if (keycode!=13) return
|
||||
msga=t.value.split("\n")
|
||||
msgl=msga.length
|
||||
msg=msga[msgl-2].substr(1+pl.length)
|
||||
//msg=msg.toLowerCase()
|
||||
msgl=msg.length
|
||||
if (ie() || opera()) {
|
||||
msgl-=1
|
||||
msg=msg.substr(0,msgl)
|
||||
}
|
||||
|
||||
|
||||
msgps=new Array()
|
||||
c=0
|
||||
cc=0
|
||||
qtd=false
|
||||
for (i=0; i<msgl; i+=1) {
|
||||
msgt=msg.substr(i,1)
|
||||
if (msgt=="\"") {
|
||||
if (qtd) qtd=false
|
||||
else qtd=true
|
||||
}
|
||||
else if (msgt==" " && !qtd) {
|
||||
msgps[c]=msg.substr(cc,i-cc).replace("\"","").replace("\"","")
|
||||
c+=1
|
||||
cc=i+1
|
||||
}
|
||||
}
|
||||
msgps[c]=msg.substr(cc,i-cc).replace("\"","").replace("\"","")
|
||||
|
||||
cac=msgps[0]
|
||||
cbc=msgps[1]
|
||||
ccc=msgps[2]
|
||||
|
||||
ca=false
|
||||
cb=false
|
||||
cc=false
|
||||
|
||||
if (!cbc)
|
||||
ca=cac.toLowerCase()
|
||||
else if (!ccc) {
|
||||
ca=cac.toLowerCase()
|
||||
cb=cbc.toLowerCase()
|
||||
}
|
||||
else {
|
||||
ca=cac.toLowerCase()
|
||||
cb=cbc.toLowerCase()
|
||||
cc=ccc.toLowerCase()
|
||||
}
|
||||
|
||||
if (pl=="") {
|
||||
if (ca=="") add("",true,true)<?php echo $determinefunction."\n"; ?>
|
||||
else add("Error! The command \""+ca+"\" doesn't exist! Type help for help.")
|
||||
}
|
||||
else {
|
||||
if (ca=="") add("",true,true)
|
||||
else if (ca=="/exit") exit()<?php echo $apl; ?>
|
||||
|
||||
}
|
||||
if (opera()) setCaretToEnd(t)
|
||||
scrolldown()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function start() {
|
||||
|
||||
document.title="webCLI"
|
||||
stylelink=document.createElement("link")
|
||||
stylelink.href="style.css"
|
||||
stylelink.type="text/css"
|
||||
stylelink.rel="stylesheet"
|
||||
head=document.getElementsByTagName("head")[0]
|
||||
head.appendChild(stylelink)
|
||||
|
||||
enterdown=false
|
||||
allcommands="<?php echo $allcommands; ?>"
|
||||
allcommandsdetailed="<?php echo $allcommandsdetailed; ?>"
|
||||
anirunning=false
|
||||
svsn=0
|
||||
svs=new Array()
|
||||
startmessage="webCLI [version 0.01]\nwebCLI is free software. No warranty blah blah."
|
||||
if (opera()) beware="\nYou are using Opera, and webCLI is, for some reason, not working perfectly in Opera. Most of it works, though. You might want to consider using Firefox, where webCLI works perfectly."
|
||||
else if (ie()) beware="\nYou are using Internet Explorer, and webCLI works okay in this browser. However, you might want to consider using Firefox, where webCLI works perfectly."
|
||||
else beware=""
|
||||
pl=""
|
||||
cookie=navigator.cookieEnabled
|
||||
if (cookie) {
|
||||
var coie=getCookie("mem")
|
||||
if (coie) {
|
||||
coie=coie.split("\n")
|
||||
csvn=coie.length
|
||||
}
|
||||
else csvn=0
|
||||
}
|
||||
|
||||
img1=new Image()
|
||||
img1.src="img/m1.png"
|
||||
img2=new Image()
|
||||
img2.src="img/m2.png"
|
||||
img3=new Image()
|
||||
img3.src="img/m3.png"
|
||||
img4=new Image()
|
||||
img4.src="img/road.png"
|
||||
|
||||
bdy=document.body
|
||||
|
||||
t=document.createElement("textarea")
|
||||
bdy.appendChild(t)
|
||||
|
||||
resize()
|
||||
t.innerHTML=""
|
||||
add(startmessage+beware,true)
|
||||
focuswait=true
|
||||
if (ie() || opera()) setCaretToEnd(t)
|
||||
focusafterawhile()
|
||||
}
|
||||
|
||||
window.onload=start
|
||||
window.onresize=resize
|
||||
document.onkeydown=onenter
|
||||
21
projects/webcli/style.css
Normal file
21
projects/webcli/style.css
Normal file
@@ -0,0 +1,21 @@
|
||||
* {
|
||||
margin:0;
|
||||
padding:0;
|
||||
}
|
||||
|
||||
body {
|
||||
background:#000;
|
||||
height:100%;
|
||||
overflow:hidden;
|
||||
}
|
||||
|
||||
textarea {
|
||||
font:normal normal bold 12px 'lucida console';
|
||||
color:#fff;
|
||||
width:100%;
|
||||
height:50px;
|
||||
background:transparent;
|
||||
border:0;
|
||||
cursor:default;
|
||||
overflow-x:hidden;
|
||||
}
|
||||
Reference in New Issue
Block a user