metanohi-misc-subsites/old-projects/webcli/functions.js

137 lines
2.7 KiB
JavaScript

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);
}
}