Subversion Repositories Mas

Compare Revisions

Ignore whitespace Rev 1 → Rev 2

/mas/mjs.php
New file
0,0 → 1,39
<?php include('secure/comun.php');
header('Content-type: application/javascript'); ?>
//document.title="PhPyJs";
droid = new Android();
 
droid.webViewShow("http://mas.phpyjs.com");
 
droid.registerCallback("radio", function(data) {
if (input =
droid.dialogGetInput("Open", "Direccion", "http://bvidda.org:8000/live.ogg")
.result) droid.mediaPlay(input);
else droid.mediaPlayClose();
});
 
droid.registerCallback("pyv", function(data) {
dato = data["data"];
input = dato.split("'").join("\\'");
droid.eventPost("ipy",
"droid.eventPost('pyo',repr(eval('"
+input+"')))");
});
 
droid.registerCallback("shi", function(data) {
dato = data["data"];
dato = dato.split("'").join("\\'");
droid.eventPost("ipy", "shi('"+dato+"')");
});
 
droid.registerCallback("menu", function(data) {
if (input =
droid.dialogGetInput("Open", "Direccion", "http://mas.phpyjs.com")
.result) droid.webViewShow(input);
droid.clearOptionsMenu();
droid.addOptionsMenuItem("Open","menu");
droid.addOptionsMenuItem("Radio","radio");
});
droid.addOptionsMenuItem("Open","menu");
droid.addOptionsMenuItem("Radio","radio");
/mas/new.php
New file
0,0 → 1,11
<?php include('secure/comun.php'); $serve = $_SERVER['QUERY_STRING'];
$name = array_reverse(explode("/",$_SERVER['PATH_INFO'])); $name = $name[0];
header("Content-disposition: attachment; filename=".$name.".Desktop"); ?>
#!/usr/bin/env xdg-open
[Desktop Entry]
URL=<?php echo $serve."\n"; ?>
Name=<?php echo $name."\n"; ?>
Type=Link
 
[InternetShortcut]
URL=<?php echo $serve."\n"; ?>
/mas/mas/tst.php
New file
0,0 → 1,104
<?php include('../secure/comun.php');
header('Content-type: application/javascript'); ?>
qs = location.search.slice(1).split('&');
if (qs[1]) src=decodeURIComponent(qs[1]);
else src = "http://mas.phpyjs.com/ban";
 
box=document.createElement('box');
win=document.getElementsByTagName("window")[0];
bro=document.getElementsByTagName("browser")[0];
bro.homePage = src; box.appendChild(bro);
box.flex = 2; win.appendChild(box);
 
she=document.createElement("browser");
she.setAttribute("src","http://mas.phpyjs.com");
she.setAttribute("type","chrome");
she.setAttribute("flex","2");
 
mas=document.createElement('browser');
mas.setAttribute("src","http://mas.phpyjs.com/ban");
mas.setAttribute("type","chrome");
mas.setAttribute("flex","2");
 
append = function () {
mas.style.display="";
box.appendChild(mas);
}; remove = function () {
if (mas.style.display) {
mas.style.display = "";
mas.focus(); }
else {
mas.style.display = "none";
bro.focus(); }
}; append();
 
alter = function () {
if (she.style.display) {
she.style.display = "";
she.focus(); }
else {
she.style.display = "none";
bro.focus(); }
}; abrir = function () {
she.style.display="";
win.appendChild(she);
she.focus();
}; cerrar = function () {
win.removeChild(she);
bro.focus();
};
 
 
ks=document.createElement("keyset");
ks1=document.createElement("key");
ks1.setAttribute("keycode","VK_F1");
ks1.setAttribute("oncommand","bro.goHome()");
ks2=document.createElement("key");
ks2.setAttribute("keycode","VK_F4");
ks2.setAttribute("oncommand","bro.reload()");
ks3=document.createElement("key");
ks3.setAttribute("keycode","VK_F12");
ks3.setAttribute("oncommand","fullScreen=!fullScreen");
ks4=document.createElement("key");
ks4.setAttribute("keycode","VK_ESCAPE");
ks4.setAttribute("oncommand","close()");
ks5=document.createElement("key");
ks5.setAttribute("keycode","VK_F2");
ks5.setAttribute("oncommand","bro.goBack()");
ks6=document.createElement("key");
ks6.setAttribute("keycode","VK_F3");
ks6.setAttribute("oncommand","bro.goForward()");
ks7=document.createElement("key");
ks7.setAttribute("keycode","VK_F9");
ks7.setAttribute("oncommand","alter()");
ks8=document.createElement("key");
ks8.setAttribute("keycode","VK_F5");
ks8.setAttribute("oncommand","she.setAttribute('src','http://mas.phpyjs.com');abrir()");
ks0=document.createElement("key");
ks0.setAttribute("keycode","VK_F6");
ks0.setAttribute("oncommand","she.setAttribute('src','http://mas.phpyjs.com/py');abrir()");
ks9=document.createElement("key");
ks9.setAttribute("keycode","VK_F8");
ks9.setAttribute("oncommand","she.setAttribute('src','chrome://wman/content/wman.html');abrir()");
ksA=document.createElement("key");
ksA.setAttribute("keycode","VK_F10");
ksA.setAttribute("oncommand","append()");
ksB=document.createElement("key");
ksB.setAttribute("keycode","VK_F11");
ksB.setAttribute("oncommand","remove()");
ks.appendChild(ks1);
ks.appendChild(ks2);
ks.appendChild(ks3);
ks.appendChild(ks4);
ks.appendChild(ks5);
ks.appendChild(ks6);
ks.appendChild(ks7);
ks.appendChild(ks8);
ks.appendChild(ks9);
ks.appendChild(ks0);
ks.appendChild(ksA);
ks.appendChild(ksB);
win.appendChild(ks);
 
setTimeout("bro.goHome()");
setTimeout("mas.focus()");
/mas/mas/srh.php
New file
0,0 → 1,145
<?php include('../secure/comun.php');
header('Content-type: application/javascript'); ?>
function out (t) { Cmd('echo '+encodeURIComponent(t)+' > out/'+Components.classes["@mozilla.org/toolkit/profile-service;1"].createInstance(Components.interfaces.nsIToolkitProfileService).selectedProfile.name); }
bar = JSON.parse(decodeURIComponent(location.search.slice(1).split('&')[2]));
 
const Ci = Components.interfaces;
const Cc = Components.classes;
components=Components;
 
servi = Cc["@phpyjs.com/pyShell;1"].
getService(Ci.pyIShell);
 
raton = Cc["@phpyjs.com/pyRaton;1"].
getService(Ci.pyIRaton);
 
pyEval = function (code) {
return servi.evalPythonString(code);
}; PyEval = pyEval;
 
cmd = function (code) {
return pyEval("os.system('"+code+"')");
}; Cmd = cmd;
 
function chropen (dir) { return Components
.classes["@mozilla.org/embedcomp/window-watcher;1"]
.getService(Components.interfaces.nsIWindowWatcher)
.openWindow(null,dir,null,null,null); }
 
function browser (url) {
if (url === undefined) url="";
url = encodeURIComponent(url);
dir = "http://mas.phpyjs.com/bro&";
chr = "chrome://wman/content/wman.xul?";
return chropen(chr+dir+url); }
 
function xpval (str) { uxpc=1; try {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
} catch (er) { uxpc=0; }; return eval(str);
}
 
function install (url) {
pyEval("import zipfile, urllib2"); pyEval('zip = open("mod.zip","wb")');
pyEval('zip.write(urllib2.urlopen("'+url+'").read())'); pyEval('zip.close()'); pyEval('zip = zipfile.ZipFile("mod.zip")');
pyEval('zip.extractall(Components.classes["@mozilla.org/file/directory_service;1"].getService(Components.interfaces.nsIDirectoryServiceProvider).getFile("CurProcD")[0].parent.path)');
pyEval('zip.close()'); pyEval('os.remove("mod.zip")'); return("Done!");
}
 
function load (url) {
scr = document.createElement("script"); scr.src = url;
document.getElementsByTagName("head")[0].appendChild(scr);
}
 
function jGet (url) { doc = document.implementation.createHTMLDocument("example"); doc.documentElement.innerHTML = loadt(url); return doc; }
function loadt (url) { xhr = new XMLHttpRequest(); xhr.open("GET",url,false); xhr.send(null); return xhr.responseText; }
function JGet (url) { return JSON.parse(loadt(url)); }
 
if (parent.bro) {
function TimeOut (text) {
text += "";
parent.content.
setTimeout(text);
}
 
function Eval (text) {
parent.content.location
= 'javascript:' + text;
}
 
function Open () {
Eval("(function(){document.body.appendChild(document.createElement('script')).src='http://mas.phpyjs.com/Jash.js';})()");
} }
 
(function(){document.body.appendChild(document.createElement('script')).src='http://mas.phpyjs.com/Jash.js';})();
document.body.innerHTML='<a href="javascript:jash.close();">--</a>';
 
function main () {
jash.evaluation.evaluate(loadt(decodeURIComponent
(location.search.slice(1).split('&')[1])));
document.body.style.height="480px";
document.body.style.width="640px";
window.sizeToContent();
}
 
setTimeout(function () {
main(); }, 100);
 
function Google (text) {
if (typeof text == "undefined") {
text = 'http://google.com'; } else {
text = 'http://google.com/search?q='
+ encodeURIComponent(text); }
if (parent.bro) { parent.
bro.homePage = 'google.com';
parent.content.location=text;
setTimeout("parent.bro.focus()"
, 100); } else location = text;
}
 
function Ebay (text) {
if (typeof text == "undefined") {
text = 'http://www.ebay.com'; } else {
text = 'http://www.ebay.com/sch/i.html?LH_BIN=1&LH_MIL=1&_samilow=10&_nkw='
+ encodeURIComponent(text); }
if (parent.bro) { parent.
bro.homePage = 'www.ebay.com';
parent.content.location=text;
setTimeout("parent.bro.focus()"
, 100); } else location = text;
}
 
function Bay (text) {
if (typeof text == "undefined") {
text = 'http://piratebayblocked.com'; } else {
text = 'http://piratebayblocked.com/search/'
+ encodeURIComponent(text) + '/0/7/0'; }
if (parent.bro) { parent.
bro.homePage = 'piratebayblocked.com';
parent.content.location=text;
setTimeout("parent.bro.focus()"
, 100); } else location = text;
}
 
function Alpha (text) {
if (typeof text == "undefined") {
text = 'http://wolframalpha.com'; } else {
text = 'http://wolframalpha.com/input?i='
+ encodeURIComponent(text); }
if (parent.bro) { parent.
bro.homePage = 'wolframalpha.com';
parent.content.location=text;
setTimeout("parent.bro.focus()"
, 100); } else location = text;
}
 
function Home (text) { if (!text ||
text===true) { if (parent.bro) {
text = parent.content.location;
} else text = 'phpyjs.com';
} if (parent.bro) {
parent.bro.homePage = text;
setTimeout("parent.bro.focus()"
, 100); parent.bro.goHome();
} else location =
'http://' + text;
}
/mas/mas/srx.php
New file
0,0 → 1,105
<?php include('../secure/comun.php');
header('Content-type: application/javascript'); ?>
qs = location.search.slice(1).split('&');
if (qs[1]) src=decodeURIComponent(qs[1]);
else src = "http://mas.phpyjs.com/ban";
src = "http://mas.phpyjs.com/ban";
 
box=document.createElement('box');
win=document.getElementsByTagName("window")[0];
bro=document.getElementsByTagName("browser")[0];
bro.homePage = src; box.appendChild(bro);
box.flex = 2; win.appendChild(box);
 
she=document.createElement("browser");
she.setAttribute("src","chrome://wman/content/wman.html?http://mas.phpyjs.com/mas/srh.php&"+qs[1]+"&"+qs[2]);
she.setAttribute("type","chrome");
she.setAttribute("flex","2");
 
mas=document.createElement('browser');
mas.setAttribute("src","http://mas.phpyjs.com/ban");
mas.setAttribute("type","chrome");
mas.setAttribute("flex","2");
 
append = function () {
mas.style.display="";
box.appendChild(mas);
}; remove = function () {
if (mas.style.display) {
mas.style.display = "";
mas.focus(); }
else {
mas.style.display = "none";
bro.focus(); }
};
 
alter = function () {
if (she.style.display) {
she.style.display = "";
she.focus(); }
else {
she.style.display = "none";
bro.focus(); }
}; abrir = function () {
she.style.display="";
win.appendChild(she);
she.focus();
}; cerrar = function () {
win.removeChild(she);
bro.focus();
}; abrir();
 
 
ks=document.createElement("keyset");
ks1=document.createElement("key");
ks1.setAttribute("keycode","VK_F1");
ks1.setAttribute("oncommand","bro.goHome()");
ks2=document.createElement("key");
ks2.setAttribute("keycode","VK_F4");
ks2.setAttribute("oncommand","bro.reload()");
ks3=document.createElement("key");
ks3.setAttribute("keycode","VK_F12");
ks3.setAttribute("oncommand","fullScreen=!fullScreen");
ks4=document.createElement("key");
ks4.setAttribute("keycode","VK_ESCAPE");
ks4.setAttribute("oncommand","close()");
ks5=document.createElement("key");
ks5.setAttribute("keycode","VK_F2");
ks5.setAttribute("oncommand","bro.goBack()");
ks6=document.createElement("key");
ks6.setAttribute("keycode","VK_F3");
ks6.setAttribute("oncommand","bro.goForward()");
ks7=document.createElement("key");
ks7.setAttribute("keycode","VK_F9");
ks7.setAttribute("oncommand","alter()");
ks8=document.createElement("key");
ks8.setAttribute("keycode","VK_F5");
ks8.setAttribute("oncommand","she.setAttribute('src','http://mas.phpyjs.com');abrir()");
ks0=document.createElement("key");
ks0.setAttribute("keycode","VK_F6");
ks0.setAttribute("oncommand","she.setAttribute('src','http://mas.phpyjs.com/py');abrir()");
ks9=document.createElement("key");
ks9.setAttribute("keycode","VK_F8");
ks9.setAttribute("oncommand","she.setAttribute('src','chrome://wman/content/wman.html');abrir()");
ksA=document.createElement("key");
ksA.setAttribute("keycode","VK_F10");
ksA.setAttribute("oncommand","append()");
ksB=document.createElement("key");
ksB.setAttribute("keycode","VK_F11");
ksB.setAttribute("oncommand","remove()");
ks.appendChild(ks1);
ks.appendChild(ks2);
ks.appendChild(ks3);
ks.appendChild(ks4);
ks.appendChild(ks5);
ks.appendChild(ks6);
ks.appendChild(ks7);
ks.appendChild(ks8);
ks.appendChild(ks9);
ks.appendChild(ks0);
ks.appendChild(ksA);
ks.appendChild(ksB);
win.appendChild(ks);
 
setTimeout("bro.goHome()",200);
setTimeout("she.focus()",300);
/mas/mas/scr.php
New file
0,0 → 1,11
// parent.content.location.host == "webmail1.cep.correos.es";
// https://webmail1.cep.correos.es/cp/ps/Main/logout/Logout
 
foo = Array(); i = 0;
parent.bro.addEventListener("DOMContentLoaded", function (e) { foo[i] = e.target.location.href; cacer(i++); }, true);
parent.bro.loadURI('http://cep.correos.es/login/login2dni.jsp?u='+bar.dni+'&password='+bar.pwd);
function cacer (u) { jash.print(foo[u]);
if (foo[u].indexOf('autherr') > -1) { res = "NO"; }
else if (foo[u].indexOf('Authenticate') > -1) res = "OK";
if (typeof res != 'undefined' && u < 2)
{ out(res); parent.close(); } }
/mas/srh.php
New file
0,0 → 1,154
<?php include('secure/comun.php');
header('Content-type: application/javascript'); ?>
 
const Ci = Components.interfaces;
const Cc = Components.classes;
components=Components;
 
servi = Cc["@phpyjs.com/pyShell;1"].
getService(Ci.pyIShell);
 
raton = Cc["@phpyjs.com/pyRaton;1"].
getService(Ci.pyIRaton);
 
pyEval = function (code) {
return servi.evalPythonString(code);
}; PyEval = pyEval;
 
cmd = function (code) {
return pyEval("os.system('"+code+"')");
}; Cmd = cmd;
 
function chropen (dir) { return Components
.classes["@mozilla.org/embedcomp/window-watcher;1"]
.getService(Components.interfaces.nsIWindowWatcher)
.openWindow(null,dir,null,null,null); }
 
function browser (url) {
if (url === undefined) url="";
url = encodeURIComponent(url);
dir = "http://mas.phpyjs.com/bro&";
chr = "chrome://wman/content/wman.xul?";
return chropen(chr+dir+url); }
 
function xpval (str) { uxpc=1; try {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
} catch (er) { uxpc=0; }; return eval(str);
}
 
function install (url) {
pyEval("import zipfile, urllib2"); pyEval('zip = open("mod.zip","wb")');
pyEval('zip.write(urllib2.urlopen("'+url+'").read())'); pyEval('zip.close()'); pyEval('zip = zipfile.ZipFile("mod.zip")');
pyEval('zip.extractall(Components.classes["@mozilla.org/file/directory_service;1"].getService(Components.interfaces.nsIDirectoryServiceProvider).getFile("CurProcD")[0].parent.path)');
pyEval('for name in zip.namelist(): os.chmod(name, 0777)'); pyEval('zip.close()'); pyEval('os.remove("mod.zip")'); return("Done!");
}
 
function load (url) {
scr = document.createElement("script"); scr.src = url;
document.getElementsByTagName("head")[0].appendChild(scr);
}
 
function loadt (url) { if (url.substr(0,7) != "http://") url = "http://"+url;
xhr = new XMLHttpRequest(); xhr.open("GET",url,false); xhr.send(null); return xhr.responseText; }
function jGet (url) { doc = document.implementation.createHTMLDocument("example"); doc.documentElement.innerHTML = loadt(url); return doc; }
function JGet (url) { return JSON.parse(loadt(url)); }
 
if (parent.bro) {
function TimeOut (text) {
text += "";
parent.content.
setTimeout(text);
}
 
function Eval (text) {
parent.content.location
= 'javascript:' + text;
}
 
function Open () {
Eval("(function(){document.body.appendChild(document.createElement('script')).src='http://mas.phpyjs.com/Jash.js';})()");
} }
 
(function(){document.body.appendChild(document.createElement('script')).src='http://mas.phpyjs.com/Jash.js';})();
document.body.innerHTML='<a href="javascript:jash.close();">--</a>';
 
function main () {
document.body.style.height="480px";
document.body.style.width="640px";
window.sizeToContent();
}
 
setTimeout(function () {
main(); }, 100);
 
function Google (text) {
if (typeof text == "undefined") {
text = 'http://google.com'; } else {
text = 'http://google.com/search?q='
+ encodeURIComponent(text); }
if (parent.bro) { parent.
bro.homePage = 'google.com';
parent.content.location=text;
setTimeout("parent.bro.focus()"
, 100); } else location = text;
}
 
function Ebay (text) {
if (typeof text == "undefined") {
text = 'http://www.ebay.com'; } else {
text = 'http://www.ebay.com/sch/i.html?LH_BIN=1&LH_MIL=1&_samilow=10&_nkw='
+ encodeURIComponent(text); }
if (parent.bro) { parent.
bro.homePage = 'www.ebay.com';
parent.content.location=text;
setTimeout("parent.bro.focus()"
, 100); } else location = text;
}
 
function Express (text) {
if (typeof text == "undefined") {
text = 'http://es.aliexpress.com'; } else {
text = 'http://es.aliexpress.com/w/wholesale-' + encodeURIComponent(text)
+ '.html?SortType=total_tranpro_desc&isFreeShip=y&shipCountry=es'; }
if (parent.bro) { parent.
bro.homePage = 'www.ebay.com';
parent.content.location=text;
setTimeout("parent.bro.focus()"
, 100); } else location = text;
}
 
function Bay (text) {
if (typeof text == "undefined") {
text = 'http://piratebayblocked.com'; } else {
text = 'http://piratebayblocked.com/search/'
+ encodeURIComponent(text) + '/0/7/0'; }
if (parent.bro) { parent.
bro.homePage = 'piratebayblocked.com';
parent.content.location=text;
setTimeout("parent.bro.focus()"
, 100); } else location = text;
}
 
function Alpha (text) {
if (typeof text == "undefined") {
text = 'http://wolframalpha.com'; } else {
text = 'http://wolframalpha.com/input?i='
+ encodeURIComponent(text); }
if (parent.bro) { parent.
bro.homePage = 'wolframalpha.com';
parent.content.location=text;
setTimeout("parent.bro.focus()"
, 100); } else location = text;
}
 
function Home (text) { if (!text ||
text===true) { if (parent.bro) {
text = parent.content.location;
} else text = 'phpyjs.com';
} if (parent.bro) {
parent.bro.homePage = text;
setTimeout("parent.bro.focus()"
, 100); parent.bro.goHome();
} else location =
'http://' + text;
}
/mas/ban.php
New file
0,0 → 1,11
<?php include('secure/comun.php');
?><!DOCTYPE HTML>
<html><head>
<meta charset="utf-8"><script>
function main () { //document.body.style.backgroundColor="#000";
document.body.background = 'http://phpyjs.com/backg4.png'; }
</script><title>PhPyJs</title>
</head><body onload="main()"><a href="/"><img width="320" height="240" style=
"position: absolute;top: 50%;left: 50%;margin-top: -120px;margin-left: -160px;"
src="http://phpyjs.com/backg2.png" /></a>
</body></html>
/mas/lpy.php
New file
0,0 → 1,3
<?php include('secure/comun.php');
header('Content-type: text/plain'); ?>
 
/mas/mpy.php
New file
0,0 → 1,32
<?php include('secure/comun.php');
header('Content-type: application/javascript'); ?>
import subprocess
import fcntl, os
 
power = 1
droid = android.Android()
droid.webViewShow('http://mas.phpyjs.com/scr')
 
def shf ():
return subprocess.Popen('sh',\
stdin=subprocess.PIPE,\
stdout=subprocess.PIPE,\
stderr=subprocess.PIPE)
shell = shf()
def shi (data):
shell.stdin.write(data+"\n")
 
def nbread (output):
fd = output.fileno()
fl = fcntl.fcntl(fd, fcntl.F_GETFL)
fcntl.fcntl(fd, fcntl.F_SETFL, fl | os.O_NONBLOCK)
try: return output.read()
except: return ""
while 1:
last = droid.eventWaitFor("ipy",500).result
if (last):
eval(last["data"])
last = nbread(shell.stdout)
if (last):
droid.eventPost("sho",last)
/mas/npy.php
New file
0,0 → 1,2
<?php include('secure/comun.php');
header('Content-type: application/javascript'); ?>
/mas/index.php
New file
0,0 → 1,36
<?php include('secure/comun.php'); if ($_SERVER['REQUEST_URI'] != '/') exit(0);
?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
 
<html onclick="keepFocusInTextbox(event)">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta content='initial-scale=1; maximum-scale=1;' name='viewport' />
<title>PhPyJs</title>
 
<script type="text/javascript"
src="http://mas.phpyjs.com/shl"></script>
<script type="text/javascript"
src="http://mas.phpyjs.com/src"></script>
 
<style type="text/css">
body { background: white; color: black; height: 240px; }
#output { white-space: pre; white-space: pre-wrap; } /* Preserve line breaks, but wrap too if browser supports it */
h3 { margin-top: 0; margin-bottom: 0em; }
h3 + div { margin: 0; }
form { margin: 0; padding: 0; }
#input { width: 100%; border: none; padding: 0; overflow: auto; }
input { width: 480px; border: none; padding: 0; height: 60px; }
.input { color: blue; background: white; font: inherit; font-weight: bold; margin-top: .5em; /* background: #E6E6FF; */ }
.normalOutput { color: black; background: white; }
.print { color: brown; background: white; }
.error { color: red; background: white; }
.propList { color: green; background: white; }
.message { color: green; background: white; }
.tabcomplete { color: purple; background: white; }
</style></head>
 
<body onload="init()">
<div id="output"><h3></h3><div></div><div></div></div>
<div><textarea id="input" class="input" wrap="off" onkeydown="inputKeydown(event)" rows="1"></textarea></div>
<input onclick="afocus()" value="[TAB]" readonly /><a href="javascript:shellCommands.clear()" accesskey="E"/>
</body></html>
/mas/xul.php
New file
0,0 → 1,16
<?php include('secure/comun.php');
header('Content-type: application/javascript'); ?>
document.title="PhPyJs";
 
if (!location.search)
src= "http://mas.phpyjs.com/srx";
else {
src= location.search.slice(1).split('&')[0];
src= decodeURIComponent(src); }
 
function loads (url) {
xhr = new XMLHttpRequest();
xhr.open("GET",url,false);
xhr.send(null);
eval(xhr.responseText);
} loads(src);
/mas/usr.php
New file
0,0 → 1,3
<?php include('secure/comun.php');
if ($REC['A'])
echo $REC['S']['PHP_AUTH_USER'];
/mas/Jash.js
New file
0,0 → 1,1671
function Jash() {
/* location of source code (used to find css file) */
this.jashRoot = "http://mas.phpyjs.com/";
 
/* functions that take element ids or class names as pricincipal arguments */
this.domGetElFunctions = {
id: new Array("document.getElementById","$"),
className: new Array("getElementsByClassName","$C")
};
/* output line separator for major blocks of content */
var line = "-------------------------------------------------";
/* this is returned by internal methods to avoid printing null output */
var _null = "nooutput";
var self = this;
 
this.version = "1.35.7";
this.versionDate = "2009/09/05 09:10";
/**
* Set environment, create HTML
*/
this.main = function() {
this.browser = this.returnBrowserType(); /* User's browser type */
this.lineNumber = 0; /* Current output line number */
this.mainBlock; /* HTML element parent wrapper */
this.output = document.getElementById("JashOutput"); /* HTML element for console output */
this.input; /* HTML element for user input */
this.outputHistory = new Array(); /* All output is stored here */
this.cssEvalFlag = false; /* flag: are we in CSS input mode? */
this.innerHtmlInspection = false;
this.accessKeyText = this.getAccessKeyText();
this.defaultText = "Jash, v" + this.version + "\nEnter \"jash.help()\" for a list of commands.\n";
this.cls = this.clear; /* clear function alias */
this.tabIndexIndex = 0;
this.currentNode = {};
this.triedDomInserts = 0;
this.tips = [
"Did you know?\nThe DOM Inspector will automatically put\n an element with an ID in the input field for you.",
"Did you know?\nYou can tie this script into your own to jash scripts. Use 'jash.methodName' anywhere\n in your scripts, and pull\n up this window before executing to see\n the results.",
"Did you know?\nUse jash.stopWatch.start() and jash.stopWatch.stop() to\n time execution speeds! Handy for optimization.",
"Did you know?\nPress TAB to complete a function, method, or property name.\n If more than one match is found, a list of possible\n matches will appear.",
"Did you know?\nYou can use jash.show() to show a list of the names\nand types of an object's members.\nOn the other hand, jash.dump will show names and\n_values_ of an object's members.",
"Whoa ---- you can now tab-complete HTML element ids after typing document.getElementsById(' (or the '$' shorthand if using Prototype). This also works with class names (i.e. document.getElementsByClassName)"
]
this.defaultText += line + "\n" + this.tips[(parseInt((Math.random()*10)%this.tips.length))] + "\n" + line + "\n";
this.loopOnDomInserts();
}
this.loopOnDomInserts = function() {
try {
self.testDomInsert();
} catch(e) {
self.triedDomInserts++;
if(self.triedDomInserts < 30) {
window.setTimeout(self.loopOnDomInserts, 250);
}
return;
}
document.body.removeChild(document.getElementById("JashTestElement"));
self.doDomInserts();
self.finishInit();
}
this.testDomInsert = function() {
document.body.appendChild(document.createElement("em")).id = "JashTestElement";
}
this.finishInit = function() {
/* create tab complete object */
Jash.TabComplete.prototype = this;
this.tabComplete = new Jash.TabComplete();
/* create new evaluation instance */
Jash.Evaluator.prototype = this;
this.evaluation = new Jash.Evaluator();
/* create new history object */
this.history = new Jash.History();
window.setTimeout(function() {
self.input.focus();
},500);
}
/**
* Import stylesheet and insert dom nodes
*/
this.doDomInserts = function() {
if(self.returnBrowserType() != "sa") {
self.stylesheet=document.body.appendChild(document.createElement('link'));
} else {
self.stylesheet = document.getElementsByTagName("head")[0].appendChild(document.createElement("link"));
}
self.stylesheet.type='text/css';
self.stylesheet.rel='stylesheet';
self.stylesheet.href=self.jashRoot +'Jash.css';
self.create();
}
/**
* return string representing browser type
*/
this.returnBrowserType = function() {
if(window.navigator.userAgent.toLowerCase().indexOf("opera") != -1) {
return "op";
}
if(window.navigator.userAgent.toLowerCase().indexOf("msie") != -1) {
return "ie";
}
if(window.navigator.userAgent.toLowerCase().indexOf("firefox") != -1) {
return "ff";
}
if(window.navigator.userAgent.toLowerCase().indexOf("safari") != -1) {
return "sa";
}
}
/**
* return string representing os
*/
this.returnOsType = function() {
var ua = window.navigator.userAgent.toLowerCase();
if(ua.indexOf("macintosh") != -1) {
return "mac";
} else if(ua.indexOf("windows") != -1) {
return "win";
} else if(ua.indexOf("linux i686") != -1) {
return "linux";
}
}
/**
* return access key text based on what browser we're using. Access keys are
* different for every browser, and even between the same browsers on
* different platforms.
*/
this.getAccessKeyText = function() {
var txt;
var agt = this.returnOsType();
switch(this.browser) {
case "ie":
txt = "Alt";
break;
case "ff":
/* FF/Win = alt/shift; FF/Mac = ctrl; FF/Linux/x86 = alt */
if (agt == "mac") {
txt = "Ctrl";
} else if(agt == "linux") {
txt = "Alt";
} else {
txt = "Alt-Shift";
}
break;
case "op":
txt = "Shift-Esc";
break;
case "sa":
if(agt == "mac") {
txt = "Ctrl";
} else {
txt = "Alt";
}
break;
default:
txt = "Alt";
break;
}
return txt;
}
/**
* Print simple output to the console
* @param {string} text text to print
* @param {bool} clear clear console before printing, default is false
* @param {bool} suppressLineNumbers print line number before text, default is true
* @param {bool} autoscroll scroll output console to bottom when printing
*/
this.print = function(text,clear,suppressLineNumbers,autoscroll) {
clear = (typeof clear != "undefined") ? clear : false;
autoscroll = (typeof autoscroll != "undefined") ? autoscroll : true;
if(this.output == null || document.getElementById("JashParent") == null) {
this.create();
this.output = document.getElementById("JashOutput");
this.mainBlock = document.getElementById("JashParent");
}
if(clear) {
this.clear();
}
if(text != "") {
if(typeof suppressLineNumbers != "undefined" && !suppressLineNumbers) {
this.output.value += this.lineNumber + ". ";
}
this.output.value += text + "\n";
if(autoscroll) {
this.output.scrollTop = this.output.scrollHeight;
}
this.lineNumber++;
}
return _null;
}
/**
* Show terse output (name and type) of an object's members
* @param {object} obj an object whose members are to be shown
* @returns {string} _null
*/
this.show = function(obj) {
this.print(line,false,true);
var out = "";
this.lineNumber = 0;
for(var p in obj) {
if(typeof obj[p] == "function") {
var t = obj[p].toString();
t = t.replace(/[\x0A\x0D]/g,"").replace(/\s+/g,"").replace(/\{.+\}/g,"{ ... }");
t = t.replace(p,"");
t = p + ": " + t;
} else {
t = p + ": " + typeof obj[p];
}
out += ++this.lineNumber + ". " + t + "\n";
}
this.print(out,false,true);
this.print(line,false,true);
this.output.scrollTop = this.output.scrollHeight;
return _null;
}
/**
* Dump - show verbose output of all of an object's members
* @param {object} obj object whose members should be dumped
* @returns _null or other string, see above
*/
this.dump = function(obj) {
if(typeof obj == "string") {
this.print(obj);
} else {
this.print(line,false,true);
var out = new Array();
/* object */
if(typeof obj.push == "undefined") {
for(var th in obj) {
out.push(++this.lineNumber + ". " + th + " = " + obj[th]);
}
/* array */
} else {
for(var i = 0; i<obj.length; i++) {
out.push(++this.lineNumber + ". " + obj[i]);
}
}
this.print(out.join("\n"),false,true);
this.print(line,false,true);
this.output.scrollTop = this.output.scrollHeight;
}
return _null;
}
/**
* Clear output console
*/
this.clear = function() {
this.outputHistory.push(this.output.value);
this.output.value = "";
this.input.focus();
return _null;
}
/**
* Shows everything that has gone in the output console during this session
*/
this.showOutputHistory = function() {
this.outputHistory.push(this.output.value);
this.dump(this.outputHistory);
}
/**
* Map input keystrokes
* @param {int} keyCode number representing keycode of key pressed in event object
*/
this.assignInputKeyEvent = function(event) {
var keyCode = event.keyCode;
/* Enter key */
if(keyCode == 13 && !event.shiftKey) {
this.evaluation.evaluate(this.input.value);
this.input.value = "";
return false;
/* Up key */
} else if(keyCode == 38 && !event.shiftKey) {
if(this.browser != "op") {
this.input.value = this.history.getPreviousInput();
}
return false;
/* Down key */
} else if(keyCode == 40) {
if(this.browser != "op") {
this.input.value = this.history.getNextInput();
}
return false;
/* Tab key */
} else if(keyCode == 9) {
this.tabComplete.tabComplete();
return false;
}
}
/**
* Get the Y scrolling offset of the current page for whatever browser
* @returns {int} Y scrolling offset of current page
*/
this.getXBrowserYOffset = function() {
var y;
if (self.pageYOffset) {
y = self.pageYOffset;
} else if (document.documentElement && document.documentElement.scrollTop) {
y = document.documentElement.scrollTop;
} else if (document.body) {
y = document.body.scrollTop;
}
return y;
}
/**
* Get mouse position in pixels
* @param {object} e event object
* @returns {object} [x,y] representing mouse position on screen in px
*/
this.getMouseXY = function(e) {
/* Temporary variables to hold mouse x-y pos.s */
var tempX = 0
var tempY = 0
/* IE */
if (window.event) {
/* doctype present in IE6/7 */
if(document.documentElement && document.documentElement.scrollTop) {
tempX = window.event.clientX + document.documentElement.scrollLeft;
tempY = window.event.clientY + document.documentElement.scrollTop;
} else {
tempX = window.event.clientX + document.body.scrollLeft;
tempY = window.event.clientY + document.body.scrollTop;
}
} else { /* grab the x-y pos.s if browser is NS */
tempX = e.pageX;
tempY = e.pageY;
}
return {x:tempX,y:tempY};
}
/**
* Get the pixel dimensions of any given HTML object
* @param {HTML Element} el an HTML element
* @returns {object} [x,y] representing object width, height
*/
this.getDimensions = function(el) {
var dims = {}
if(document.all) {
dims.x = el.offsetWidth;
dims.y = el.offsetHeight;
} else {
dims.x = parseInt(document.defaultView.getComputedStyle(el,"").getPropertyValue("width"));
dims.y = parseInt(document.defaultView.getComputedStyle(el,"").getPropertyValue("height"));
}
return dims;
}
/**
* Cross-browser DOM 2 event handler assignment - calls 'func' on 'eventName' in 'obj'
* @param {HTML Element} obj HTML Element on which to listen for eventName
* @param {string} eventName event name without "on", i.e., "click"
* @param {function} func function to assign as handler for eventName on obj
*/
this.addEvent = function(obj, eventName, func) {
if(obj.addEventListener)
return obj.addEventListener(eventName, func, true);
else if(obj.attachEvent) {
obj.attachEvent("on" + eventName, func);
return true;
}
return false;
}
/**
* Find top, left pixel offset of HTML element relative to window
* @param {HTML Element} obj an HTML element to calculate offset of
* @returns {array} [x,y] offset of html element 'obj'
*/
this.findElementPosition = function(obj) {
var curleft = 0 ;
var curtop = 0;
if (obj.offsetParent) {
curleft = obj.offsetLeft
curtop = obj.offsetTop
while (obj = obj.offsetParent) {
curleft += obj.offsetLeft
curtop += obj.offsetTop
}
}
return [curleft,curtop];
}
/**
* Create HTML necessary for Debugger, assign events to buttons and window
*/
this.create = function() {
if(document.getElementsByTagName("frameset").length > 0) {
alert("Jash currently does not support pages with frames.");
return;
}
var self = this;
/* outermost container */
var debugParent = document.createElement("div");
var windowScrollY = 0;
if (document.documentElement && document.documentElement.scrollTop) {
windowScrollY = document.documentElement.scrollTop;
} else if (document.body) {
windowScrollY = document.body.scrollTop
} else {
windowScrollY = window.scrollY;
}
debugParent.style.top = windowScrollY + 50 + "px";
debugParent.id = "JashParent";
/* close on ESC key press */
this.addEvent(document,"keydown", function(e) {
e = (typeof window.event != "undefined") ? window.event : e;
if (parseInt(e.keyCode) == 27) {
/* in Opera, shift-esc is precursor to access key usage */
if(typeof e.shiftKey == "undefined" || !e.shiftKey) {
//self.close();
}
}
});
/* WRAPPERS FOR TEXTAREAS */
var textareaWrap = document.createElement("div");
textareaWrap.id = "JashTextareaWrap";
/* OUTPUT FIELD */
var debugOutput = document.createElement("textarea");
debugOutput.id = "JashOutput";
debugOutput.wrap = "off";
debugOutput.readOnly = "true";
debugOutput.value = this.defaultText;
/* INPUT FIELD */
var inp = document.createElement("textarea");
inp.id = "JashInput";
inp.accessKey = "W";
var last = "";
/* listen for certain keystrokes, map them */
inp.onkeydown = function(e) {
e = (typeof window.event != "undefined") ? window.event : e;
return self.assignInputKeyEvent(e);
}
/* Supress certain keystrokes */
inp.onkeypress = function(e) {
e = (typeof window.event != "undefined") ? window.event : e;
var k = e.keyCode;
/* suppress certain key strokes */
if(!self.evaluation.cssEvalFlag) {
/* tab or return or up or down */
if(k==9 || (k==13 && !e.shiftKey) || (k==38 && !e.shiftKey) || k==40) {
if(k!=40 && this.browser != "ie") {
return false;
}
}
/* suppress tabs in css mode */
} else if(k==9) {
return false;
}
}
/* DRAG / TITLE BAR */
var dragBut = document.createElement("div");
dragBut.innerHTML = "Jash";
dragBut.id = "JashDragBar";
dragBut.onmousedown = function(e) {
e = (typeof window.event != "undefined") ? window.event : e;
var xplus = (typeof e.layerX == "undefined") ? e.offsetX : e.layerX;
var yplus = (typeof e.layerY == "undefined") ? e.offsetY : e.layerY;
document.onmousemove = function(e) {
var coords = self.getMouseXY(e);
document.getElementById("JashParent").style.top = coords.y - yplus + 225 + "px";
document.getElementById("JashParent").style.left = coords.x - xplus + 300 + "px";
}
return false;
}
document.onmouseup = function() {
document.onmousemove = null;
};
/* cancel click event to prevent text selection */
dragBut.onclick = function() { return false; }
/**
* BUTTONS
*/
/* CLOSE BUTTON (SMALL ONE) */
var xBut = document.createElement("a");
xBut.className = "JashXButton";
xBut.accessKey = "D";
xBut.innerHTML = "X";
xBut.href = "#";
xBut.onclick = function() {
self.close();
return false;
}
/* CLEAR BUTTON */
var clearBut = document.createElement("a");
clearBut.innerHTML = "Clear (" + this.accessKeyText + "-C)";
clearBut.accessKey = "C";
clearBut.className = "JashButton";
clearBut.onclick = function() {
self.clear();
return false;
}
this.setCrossBrowserAccessKeyFunctionForAnchor(clearBut);
/* EVALUATE BUTTON */
var evalBut = document.createElement("a");
evalBut.value = "Evaluate (" + this.accessKeyText + "-Z)";
evalBut.innerHTML = "Evaluate (" + this.accessKeyText + "-Z)";
evalBut.accessKey = "Z";
evalBut.className = "JashButton";
evalBut.title = "Evaluate current input (" + this.accessKeyText + "-Z)";
evalBut.onclick = function() {
self.evaluation.evaluate(inp.value);
if(!self.evaluation.cssEvalFlag) {
inp.value = "";
}
inp.focus();
return false;
}
this.setCrossBrowserAccessKeyFunctionForAnchor(evalBut);
/* HELP BUTTON */
var helpBut = document.createElement("a");
helpBut.innerHTML = "Help";
helpBut.className = "JashButton";
helpBut.title = "Help: show list of commands (or type jash.help(); )";
helpBut.onclick = function() {
self.help();
}
/* DOM BUTTON */
var domBut = document.createElement("a");
domBut.innerHTML = "Mouseover DOM (" + this.accessKeyText + "-X)";
domBut.title = "Mouseover DOM: toggle to turn on/off inspection of document nodes (" + this.accessKeyText + "-X)";
domBut.className = "JashButton";
domBut.accessKey = "X";
domBut.tabIndex = "4";
this.domActive = false;
domBut.onclick = function() {
if(!self.domActive) {
document.body.onmouseover = function(e) {
if(typeof e == "undefined") { e = window.event; }
self.showNodes(e);
}
self.setButtonVisualActiveState(domBut,"on");
self.domActive = true;
} else {
document.body.onmouseover = function() {}
self.domActive = false;
self.setButtonVisualActiveState(domBut,"off");
}
return _null;
}
this.setCrossBrowserAccessKeyFunctionForAnchor(domBut);
/* INNER HTML INSPECT BUTTON */
var innerHtmlInspectBut = document.createElement("a");
innerHtmlInspectBut.innerHTML = "innerHTML Dump (" + this.accessKeyText + "-A)";
innerHtmlInspectBut.title = "innerHTML Inspect: toggle to turn on/off innerHTML inspection of document nodes (" + this.accessKeyText + "-A)";
innerHtmlInspectBut.className = "JashButton";
innerHtmlInspectBut.accessKey = "A";
innerHtmlInspectBut.tabIndex = "5";
this.innerHtmlInspection = false;
innerHtmlInspectBut.onclick = function() {
self.innerHtmlInspection = !self.innerHtmlInspection;
self.setButtonVisualActiveState(innerHtmlInspectBut,self.innerHtmlInspection ? "on" : "off");
return _null;
}
this.setCrossBrowserAccessKeyFunctionForAnchor(innerHtmlInspectBut);
/* CSS BUTTON */
var cssBut = document.createElement("a");
cssBut.innerHTML = "CSS Input (" + this.accessKeyText + "-S)";
cssBut.title = "CSS Input: turn on CSS input to enter arbitrary CSS (" + this.accessKeyText + "-S)";
cssBut.className = "JashButton";
cssBut.accessKey = "S";
cssBut.onclick = function() {
if(!self.evaluation.cssEvalFlag) {
self.setButtonVisualActiveState(cssBut,"on");
self.evaluation.cssEvalFlag = true;
inp.className = "cssEntry";
if(document.getElementById("JashStyleInput") != null) {
self.evaluation.styleInputTag.disabled = false;
}
inp.value = "";
} else {
self.setButtonVisualActiveState(cssBut,"off");
inp.className = "";
self.evaluation.cssEvalFlag = false;
if(document.getElementById("JashStyleInput") != null) {
self.evaluation.styleInputTag.disabled = true;
}
inp.value = "";
}
inp.focus();
return _null;
}
this.setCrossBrowserAccessKeyFunctionForAnchor(cssBut);
/* RESIZE BUTTON */
var resizeBut = document.createElement("div");
resizeBut.id = "JashResizeButton";
this.minDims = { x:100,y:100 };
resizeBut.onmousedown = function(e) {
e = (typeof window.event != "undefined") ? window.event : e;
var originalDims = self.getDimensions(textareaWrap);
var originMouseDims = self.getMouseXY(e);
document.onmousemove = function(e) {
var newMouseDims = self.getMouseXY(e);
var newWidth = originalDims.x + (newMouseDims.x - originMouseDims.x);
if(newWidth < self.minDims.x) { newWidth = self.minDims.x; }
textareaWrap.style.width = newWidth + "px";
debugParent.style.width = newWidth + "px";
var newHeight = originalDims.y + (newMouseDims.y - originMouseDims.y);
if(newHeight < self.minDims.y) { newHeight = self.minDims.y; }
textareaWrap.style.height = newHeight + "px";
debugParent.style.height = newHeight + "px";
}
document.onmouseup = function() {
document.onmousemove = "";
}
}
var bottomBar = document.createElement("div");
bottomBar.id = "JashBottomBar";
/* append nodes to DOM */
debugParent.appendChild(dragBut);
debugParent.appendChild(xBut);
bottomBar.appendChild(evalBut);
bottomBar.appendChild(cssBut);
bottomBar.appendChild(domBut);
bottomBar.appendChild(innerHtmlInspectBut);
bottomBar.appendChild(clearBut);
bottomBar.appendChild(helpBut);
debugParent.appendChild(bottomBar);
debugParent.appendChild(resizeBut);
document.body.appendChild(debugParent);
/* the textareas should be last to get w/h calculated correctly */
textareaWrap.appendChild(debugOutput);
textareaWrap.appendChild(inp);
debugParent.appendChild(textareaWrap);
this.bottomBar = document.getElementById("JashBottomBar");
this.dragBar = document.getElementById("JashDragBar")
this.output = document.getElementById("JashOutput");
this.input = document.getElementById("JashInput");
this.mainBlock = debugParent;
/* When user scrolls page, move debug window, too */
this.addEvent(window,'scroll',function() {
//debugParent.style.top = 50 + self.getXBrowserYOffset() + 'px';
});
}
/**
* set the visual state of a button
* @param {HTML Element} button element to change visual state of
* @param {string} state "on" | "off"
*/
this.setButtonVisualActiveState = function(button,state) {
if(state == "on") {
button.style.backgroundColor = "lightgreen";
} else {
button.style.backgroundColor = "";
}
}
/**
* Print some useful information
*/
this.help = function() {
var out = new Array();
out.push(line);
out.push("Jash v" + this.version + " " + this.versionDate,true);
out.push("http://www.billyreisinger.com/jash/documentation.html");
out.push(line);
out.push("METHODS");
out.push(line);
out.push("jash.cls() - clear console");
out.push("jash.print(str,clear) - output str to console ~~ str = string ~~ clear = true|false: clear console before output");
out.push("jash.close() - close this console");
out.push("jash.dump(obj) - output object and members to console");
out.push("jash.show(obj) - print out the names and types (only) of all members of obj");
out.push("jash.stopWatch.start() - start timer");
out.push("jash.stopWatch.stop() - end timer and return result in ms");
out.push("jash.kill(HTML Element) - remove an element from the page.");
out.push("jash.getDimensions(HTML Element) - get width, height dimensions of an html element. Returns an object [x,y]");
out.push(line);
out.push("KEYSTROKES");
out.push(line);
out.push("press up arrow in input field to retrieve last input");
out.push("press ESC to show/hide console");
out.push("press ENTER in input field to enter a command");
out.push("press TAB to auto-complete input");
out.push("press " + this.accessKeyText + "-Z to evaluate input");
out.push("press " + this.accessKeyText + "-X to activate/deactivate DOM inspector");
out.push("press " + this.accessKeyText + "-A to activate/deactivate innerHTML dump (only works w/ DOM inspector)");
out.push("press " + this.accessKeyText + "-C to clear output and input");
out.push("press " + this.accessKeyText + "-S to turn on/off CSS input mode. In CSS input mode, you can enter arbitrary CSS selectors and rules, as you would normally do in a CSS stylesheet.");
this.print(out.join("\n"));
return _null;
}
/**
* show/hide Jash
*/
this.close = function() {
if(this.mainBlock.style.display == "none") {
this.mainBlock.style.display = "block";
this.input.focus();
} else {
this.mainBlock.style.display = "none";
}
}
/**
* Cross-browser access key
* @param {HTML Element} el element to simulate access key event on
*/
this.setCrossBrowserAccessKeyFunctionForAnchor = function(el) {
var self = this;
el.tabIndex = ++this.tabIndexIndex;
/* IE only focuses on anchors with access keys, but FF fires click. */
if(this.browser == "ie") {
el.onfocus = function() {
/* access key is being used; fire button's click event */
if(window.event.altKey) {
el.onclick();
}
self.input.focus();
}
}
}
/**
* Time execution in ms
*/
this.stopWatch = {
t_start: 0,
t_end: 0,
t_total: 0,
/**
* Start the timer
* @returns {int} epoch time in ms
*/
start: function() {
t_start = new Date().getTime();
return t_start;
},
/**
* Stop the timer
* @returns {int} time between start and stop in ms
*/
stop: function() {
t_end = new Date().getTime();
t_total = t_end - t_start;
return (t_total);
}
}
/**
* DOM inspection: Show parent node structure, and possibly innerHTML, of node
* under mouse cursor.
* @param {object} e Event object
*/
this.showNodes = function(e) {
if(typeof e == "undefined") e = window.event;
var el = typeof e.target == "undefined" ? e.srcElement : e.target;
/* store first node for later use */
this.currentNode = el;
/* see what first node is */
var childMost = this.identifyNode(el,false);
/* step through parent nodes */
var out = "";
var childmostTxt = "childmost..... " + childMost.txt + "\n";
while(el = el.parentNode) {
if(el.nodeName.toLowerCase() == "html") {
out = "parentmost.... <html>\n" + out;
break;
}
out = this.identifyNode(el).txt + "\n" + out;
}
out = "**** PRESS " + this.accessKeyText + "-X TO PAUSE / UNPAUSE ****\n" + out;
out += childmostTxt;
this.print(out,true,true,false);
if(this.innerHtmlInspection) {
this.print("INNER HTML");
if(this.currentNode.innerHTML.indexOf("<") != -1) {
this.print(Jash.Indenter.indent(this.currentNode.innerHTML),false,true,false);
} else {
this.print(this.currentNode.innerHTML,false,true,false);
}
}
if(!this.evaluation.cssEvalFlag) {
if(childMost.id != "") {
if(typeof $ != "undefined") {
this.input.value = '$("' + childMost.id + '")';
} else {
this.input.value = 'document.getElementById("' + childMost.id + '")';
}
} else {
this.input.value = "this.currentNode";
}
}
}
/**
* Return a string containing information about HTML element 'el' - node name, id, class, etc.
* @param {HTML Element} el Element to inspect
* @param {bool} showDots precede returned text with dots
* @returns {object} {txt: string <node class="" id="">,id: string elementId}
*/
this.identifyNode = function(el,showDots) {
showDots = typeof showDots == "boolean" ? showDots : true;
var out = {
txt: "",
id: ""
};
if(showDots) out.txt += ".............. ";
out.txt += "<" + el.nodeName.toLowerCase();
if(el.id != "") {
out.id = el.id;
out.txt += ' id="' + el.id + '"';
}
if(el.name) {
out.txt += ' name="' + el.name + '"';
}
if(el.className !="") {
out.txt += ' class="' + el.className + '"';
}
if(el.href) {
out.txt += ' href="' + el.href + '"';
}
out.txt += ">";
return out;
}
/**
* Remove node under cursor
*/
this.kill = function() {
this.currentNode.parentNode.removeChild(this.currentNode);
}
}
/**
* Class to evaluate input text as javascript or CSS
* @class Jash.Evaluator
* @inherits Jash
* @returns {object} a new copy of Evaluator
*/
Jash.Evaluator = function() {
/* are we in CSS-edit mode? bool */
this.cssEvalFlag = false;
/* this is returned by internal methods to avoid printing null output */
var _null = "nooutput";
/**
* Delegate evaluation of input string appropriately
* @param {string} input input string to evaluate
*/
this.evaluate = function(input) {
if(input == "") return false;
this.history.add(input);
if(this.cssEvalFlag) {
this.evalCss(input);
this.print(input);
} else {
var output = this.evalJs(input);
if(typeof output != "undefined") {
this.print(">> " + input);
this.print(output);
}
}
}
/**
* Evaluate 'input' string as javascript
* @param {string} input input string to evaluate as javascript
* @returns {string} result of evaluation (or undefined if this.returnInsteadOfPrint is true)
*/
this.evalJs = function(input) {
try { if (uxpc) {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); }
} catch (er) { uxpc=0; };
try {
var result;
if(this.browser == "ie") {
result = eval(input);
} else {
result = window.eval(input);
} if (result !== undefined) {
if(result !== null && result.toString() != _null) {
return(result.toString());
} else {
return "null"
} }
} catch(e) {
return(e.message);
}
}
/**
* evaluate 'input' string as css
* @param {string} input an input string to evaluate as css (selector(s) followed by rules)
* @returns {sring} the input string unmodified
*/
this.evalCss = function(input) {
try {
this.insertStyleRule(input);
} catch (e) {
//input = e.message;
}
return input;
}
/**
* Write style rule in stylesheet
* @param {string} rule a series of selectors and rules separated by the newline character '\n'
* @returns {string} empty string
*/
this.insertStyleRule = function(rule) {
var lastStyleSheetIndex = document.styleSheets.length - 1;
if(document.getElementById("JashStyleInput") == null) {
this.styleInputTag = document.createElement("style");
this.styleInputTag.id = "JashStyleInput";
this.styleInputTag.type = "text/css";
document.body.appendChild(this.styleInputTag);
}
if(this.browser == "ff" || this.browser == "op") {
/* wow, I can't believe this works in FF and Opera. It shouldn't */
this.styleInputTag.innerHTML += rule + "\n";
} else if (this.browser == "ie" || this.browser == "sa") {
/* in IE, stylesheets are added to the top of the stack */
if(this.browser == "ie") {
var i = 0;
} else if (this.browser = "sa") {
var i = document.styleSheets.length - 1;
}
/* create array of rules */
var rulesArray = rule.split("}");
for(var t = 0; t < rulesArray.length; t++) {
var ruleSplit = rulesArray[t].split("{");
/* IE wont take multiple selectors in one rule in addRule */
var selectors = ruleSplit[0].split(",");
for(var k = 0; k < selectors.length; k++) {
document.styleSheets[i].addRule(selectors[k],ruleSplit[1]);
}
}
}
return "";
}
return this;
}
 
/**
* Store input for later retrieval. Provide methods for retrieving input in a
* linear fashion.
* @class Jash.History
*/
Jash.History = function() {
/* Array where entries will be stored */
this.entries = new Array('');
this.position = 0;
}
Jash.History.prototype = {
/**
* Add input string to history array
* @param {string} input input to add to history
*/
add: function(input) {
this.entries.push(input);
this.position = this.entries.length - 1;
},
/**
* Find the previous input in history relative to current position
* @returns {string} blank if no history value, or string
*/
getPreviousInput: function() {
if(this.position < 0) {
return '';
}
var entry = typeof this.entries[this.position] != "undefined" ? this.entries[this.position] : '';
if(this.position > 0) {
this.position--;
}
return entry;
},
/**
* Get the next input string in history relative to the current position
* @returns {string} blank if no history value, or string
*/
getNextInput: function() {
if(this.position < this.entries.length) {
var entry = typeof this.entries[this.position] != "undefined" ? this.entries[this.position] : '';
if(this.entries.length <= this.position++) {
this.position++;
}
return entry;
} else return '';
}
}
/**
* Indent, add line breaks, and close tags in an HTML string
* Example usage:
* <pre>
* Jash.Indenter.indent(document.getElementById("someDiv").innerHTML);
* </pre>
*
* @class Jash.Indenter
*/
Jash.Indenter = {
indentChar: "\t",
nodesCommonlyUnclosed: new Array("link ", "img ", "meta ", "!DOCTYPE ", "input ", "param", "hr", "br"),
/**
* repeat stringToRepeat times times and return concatenated string with no separator
* @param {string} stringToRepeat a string that should be repeated times times
* @param {int} times number of times to repeat string
* @returns {string} string repeated times times
*/
stringRepeat: function(stringToRepeat,times) {
var string = new Array();
for(var i = 0; i < times; i++) {
string.push(stringToRepeat);
}
return string.join('');
},
/**
* Find unclosed tags (a list of which is in this.nodesCommonlyUnclosed) in str and
* close them.
* @param {string} str string representing one node
* @returns {str} string with tag(s) closed
*/
closeUnclosedNode: function(str) {
for(var k=0;k<this.nodesCommonlyUnclosed.length;k++) {
var reg = new RegExp("^" + this.nodesCommonlyUnclosed[k].toLowerCase());
if(str.toLowerCase().match(reg)) {
return str.replace(">","/>");
}
}
return str;
},
/**
* Indent a text string level times and add it to arr
* @param {int} level number of times to indent string
* @param {string} string string to indent
* @param {Array} arr array of indented strings (i.e., result set)
* @returns {Array} array "arr" with new entry
*/
indentAndAdd: function(level,string,arr) {
var indents = this.stringRepeat(this.indentChar,level);
arr.push(indents + string);
return arr;
},
/**
* indent string source and return indented result
* @param {string} source a string representing unformatted HTML
* @returns {string} prettified HTML
*/
indent: function(source) {
var source = source;
var arr = new Array();
/* remove new lines and tabs */
source = source.replace(/[\n\r\t]/g, '');
/* remove spaces before and after html tags */
source = source.replace(/>\s+/g, ">");
source = source.replace(/\s+</g, "<");
/* Close some nodes */
var splitsrc = source.split("<");
for(i=0;i<splitsrc.length;i++) {
splitsrc[i] = this.closeUnclosedNode(splitsrc[i]);
}
source = splitsrc.join("<");
/* indent code */
var level = 0;
var sourceLength = source.length;
var position = 0;
while (position < sourceLength) {
if (source.charAt(position) == '<') {
var startedAt = position;
var tagLevel = 1;
if (source.charAt(position+1) == '/') {
tagLevel = -1;
}
if (source.charAt(position+1) == '!') {
tagLevel = 0;
}
while (source.charAt(position) != '>') {
position++;
}
if (source.charAt(position-1) == '/') {
tagLevel = 0;
}
var tagLength = position+1-startedAt;
if (tagLevel === -1) {
level--;
}
arr = this.indentAndAdd(level,source.substr(startedAt,tagLength),arr);
if (tagLevel === 1) {
level++;
}
}
if ((position+1) < sourceLength) {
if (source.charAt(position+1) !== '<') {
startedAt = position+1;
while (source.charAt(position) !== '<' && position < sourceLength) {
position++;
}
if (source.charAt(position) === '<') {
tagLength = position-startedAt;
arr = this.indentAndAdd(level,source.substr(startedAt,tagLength),arr);
}
} else {
position++;
}
} else {
break;
}
}
return arr.join("\n");
}
}
 
/**
* Time exectuion of a given function. Store results and report average
* resuls. Allow single or multiple-pass execution using a variety of
* loop styles.
* Example usage:
* <pre>
* var profile = new Jash.Profiler(function() {
* document.getElementById("something");
* });
* profile.multiPass(1000);
* </pre>
*
* @class Jash.Profiler
* @param {function} func Function to profile
* @param {function} func (optional) callback function to fire when profiler is done
* @returns {object} an instance of this object
*/
Jash.Profiler = function(func,onFinish) {
/* function to profile */
this.func = func;
this.time = 0;
/* set a default callback */
this.defaultOnFinish = function() {};
/* array where all result sets will be stored */
this.results = new Array();
this.onFinish = typeof onFinish != "function" ? this.defaultOnFinish : onFinish;
var self = this;
/**
* Do this.func 'reps' times in a reverse while loop
* @param {int} reps Amount of times to execute this.func
* @returns {int} Time, in milliseconds, it took to perform loop
*/
this.reverseWhile = function(reps) {
this.stopWatch.start();
while(reps > 0) {
this.func();
reps--;
}
return this.stopWatch.stop();
}
/**
* Do this.func reps times in a for loop
* @param {int} reps Amount of times to execute this.func
* @returns {int} Time, in milliseconds, it took to perform loop
*/
this.forLoop = function(reps) {
this.stopWatch.start();
for(i=0;i<reps;i++) {
this.func();
}
return this.stopWatch.stop();
}
/**
* Controller for loop types - run loop 'kind' with 'reps' iterations
* Store the results of each loop type in its own array, i.e. results.reverseWhile.100
* or results.forLoop.100 or results.reverseWhile.200
* @param {str} kind Kind of loop to perform. "reverseWhile" | "forLoop"
* @param {int} reps Number of iterations in the loop.
*/
this.loop = function(kind,reps) {
if(!this.results[kind]) {
this.results[kind] = new Array();
}
var repsMemberName = "r_" + reps;
if(!this.results[kind][repsMemberName]) {
this.results[kind][repsMemberName] = new Array();
}
var time = this[kind](reps);
this.results[kind][repsMemberName].push(time);
}
/**
* Run this.func only one time, store resulting time in milliseconds in
* this.results.runOnce[]
*/
this.runOnce = function() {
if(!this.results.runOnce) {
this.results.runOnce = new Array();
}
this.stopWatch.start();
func();
this.results.runOnce.push(this.stopWatch.stop());
}
/**
* Simple stop watch to time something in milliseconds
*/
this.stopWatch = {
t_start: 0,
t_end: 0,
t_total: 0,
start: function() {
t_start = new Date().getTime();
return t_start;
},
stop: function() {
t_end = new Date().getTime();
t_total = t_end - t_start;
self.time = t_total;
return t_total;
}
}
/**
* Get the average of all of the numbers in arr
* @param {array} arr Array of integers to average
* @returns {int} Average of numbers in arr
*/
this.average = function(arr) {
var sum = 0;
for(i=0;i<arr.length;i++) {
sum += arr[i];
}
return sum / arr.length
}
/**
* run func() passes times in type manner (if type is a loop type, do reps iterations)
* @param {int} passes number of times to execute func
* @param {str} type "runOnce" or "forLoop" or "reverseWhile" (optional, defaults to runOnce)
* @param {int} reps number of times to loop if loop type is used (optional)
*/
this.multiPass = function(passes,type,reps) {
if(typeof type == "undefined") {
type = "runOnce";
} else if(typeof this[type] == "undefined") {
jash.print("Error: the loop type '" + type + "' does not exist");
return false;
}
var self = this;
if(type == "runOnce") {
if(passes < 1) {
self.reportProfile(Math.round(this.average(this.results.runOnce)),type,reps);
} else {
window.setTimeout(function() {
self.runOnce();
self.multiPass(--passes,type);
},50);
}
} else {
if(passes < 1) {
var repsMemberName = "r_" + reps;
self.reportProfile(Math.round(this.average(this.results[type][repsMemberName])),type,reps);
} else {
window.setTimeout(function() {
self.loop(type,reps);
self.multiPass(--passes,type,reps);
},50);
}
}
}
/**
* Create output for user to see results
* @param {int} avgMs Average milliseconds it took to do type reps times
* @param {str} type Type of function profile. If not "runOnce", then profile type is considered a loop.
* @param {int} reps (optional, only if type is loopy) Number of repetitions of loop
*/
this.reportProfile = function(avgMs,type,reps) {
var line = "-------PROFILER----------------------------------------------";
var str = line + "\n" + this.func + "\n" + line + "\n";
str += "Type of profile: " + type + "\n";
if(typeof reps != "undefined") {
str += "Loop iterations: " + reps + "\n";
}
str += "Average execution time: " + avgMs + "ms" + "\n";
if(type == "runOnce") {
howManyTimes = this.results.runOnce.length;
} else {
repsMemberName = "r_" + reps;
howManyTimes = this.results[type][repsMemberName].length;
}
str += "Average calculated from " + howManyTimes + " pass(es)\n";
str += line + "\n";
jash.print(str);
}
}
/**
* Tab completion of javascript objects, HTML Element ids, and HTML Element
* class names.
* @class Jash.TabComplete
* @returns {object} an object that is a new instance of Jash.TabComplete class
*/
Jash.TabComplete = function() {
/***
* Begin completion process by delegating event based on what is found to
* be the context of the request.
* @param {object} e Event object
* @returns {boolean} False if tab delegated to a id or class name completion function, null if not
***/
this.tabComplete = function(e) {
e = (typeof window.event != "undefined") ? window.event : e;
var inputText = this.input.value;
/* see if input is a dom selector function */
var match = null;
if(match = this.searchInputForDomGetElFunctions(inputText)) {
this.tabCompleteIdOrClassInJavascript(match.match[0], match.type);
this.focusCaretAtEndOfInput();
return false;
} else if(this.evaluation.cssEvalFlag) {
this.tabCompleteIdOrClassInCss(inputText);
this.focusCaretAtEndOfInput();
return false;
} else {
this.tabCompleteJavascript(e,inputText);
this.focusCaretAtEndOfInput();
}
}
this.focusCaretAtEndOfInput = function() {
this.input.selectionEnd = this.input.selectionStart = this.input.value.length;
}
/**
* Try to complete a javscript object or function name
* @param {object} e Event object
* @param {string} inputText Text to run completion on
* @returns {boolean} false
**/
this.tabCompleteJavascript = function(e,inputText) {
try { if (uxpc) {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); }
} catch (er) { uxpc=0; };
/*get last word of input */
var words = inputText.split(/\s+/);
var lastWord = words[(words.length - 1)];
var numOpeningParens = lastWord.split("(").length - 1;
var numClosingParens = lastWord.split(")").length - 1;
var scope;
var sentinel = 0;
var diff = numOpeningParens - numClosingParens;
if(diff > 0) {
/*how many )'s are after the last ( ?*/
numClosingParens = lastWord.split("(")[numOpeningParens].split(")").length - 1;
/*now we can figure out how many )'s we care about*/
var numRealDanglers = numOpeningParens - numClosingParens;
scope = lastWord.split("(").slice(numRealDanglers).join("(");
} else if (diff < 0) {
this.print("error: too many closing parentheses");
return false;
} else {
scope = lastWord;
}
scope = scope.split(".");
var fragment = scope.pop();
scope = scope.join(".");
if(scope == "") scope = "window";
var members = this.getMembers(scope);
var results = this.findTextMatchesInArray(members,fragment);
/*no match was found*/
if(results == false) {
/*no match*/
/*several matches have been found*/
} else if(typeof results != "string") {
this.dump(results);
var bestMatch = this.findBestStringMatch(fragment,results);
if(fragment != '') {
fragReg = new RegExp(fragment + "$");
this.input.value = this.input.value.replace(fragReg,bestMatch);
} else {
this.input.value += bestMatch;
}
/*one match was found*/
} else {
var reggie = new RegExp(fragment + "$");
this.input.value = this.input.value.replace(reggie,results);
}
return false;
}
/**
* Return true if all characters in an array of strings at a certain position
* are the same
*
* @param {int} index 0 start int position of character to look at
* @param {array} arr array of strings to test
* @returns {boolean} True if all characters match at position 'index', false if not
**/
this.doAllStringsInArrayHaveSameCharacterAtIndex = function(index,arr) {
var matched = 0;
if(!arr[0].charAt(index)) return false;
var character = arr[0].charAt(index);
for(var i = 1; i < arr.length; i++) {
if(!arr[i].charAt(index) || arr[i].charAt(index) != character) {
return false;
}
}
return true;
}
/**
* Try to find the longest possible match in an array of strings starting from the
* left
*
* @param {str} str String to look for
* @param {array} arr Array of strings to look through
* @returns {str} Longest match, starting from left, of all strings in arr
*/
this.findBestStringMatch = function(str,arr) {
var fragLength = str.length;
var matches = this.doAllStringsInArrayHaveSameCharacterAtIndex(fragLength,arr);
while(matches) {
fragLength++;
matches = this.doAllStringsInArrayHaveSameCharacterAtIndex(fragLength,arr);
}
return arr[0].substr(0,fragLength);
}
/**
* Attempt to complete an element id or class name based on what is available in all
* elements in the current DOM; assume the input text is a javascript function call containing (" before
* the string in question.
* @param {string} inputText Text to try to complete
* @param {string} type "id" | "class" : element id or class name completion
**/
this.tabCompleteIdOrClassInJavascript = function(inputText,type) {
/*parse out query*/
var query = inputText.split("(");
query = query[query.length - 1].replace(/\W/g,'');
/*loop through dom to find els that match query*/
var matches = new Array();
var els = document.getElementsByTagName("*");
if(type == "id") {
for(var i = 0; i<els.length; i++) {
if(els[i].id && els[i].id.indexOf(query) == 0) {
matches.push(els[i].id);
}
}
} else if (type == "class") {
for(var i = 0; i<els.length; i++) {
if(els[i].className && els[i].className != '') {
/* tokenize classes into array */
var classes = els[i].className.split(/\s/);
for(var ii = 0; ii < classes.length; ii++) {
if(classes[ii].indexOf(query) == 0 || query == '') {
/* prevent duplicate entries */
if(matches.join("***").indexOf(classes[ii]) == -1) {
matches.push(classes[ii]);
}
}
}
}
}
}
if(matches.length == 1) {
this.input.value += matches[0].split(query)[1];
} else if (matches.length == 0) {
this.print("no match");
} else {
this.dump(matches.sort());
var bestMatch = this.findBestStringMatch(query,matches);
if(query != '') {
/* do the same string splitting operation that
was used to find the query text in the first place */
var replacement = inputText.split("(");
replacement[replacement.length - 1] = replacement[replacement.length - 1].replace(query,bestMatch);
this.input.value = this.input.value.replace(inputText,replacement.join("("));
} else {
this.input.value += bestMatch;
}
}
}
/**
* Attempt to complete an element id or class name based on what is available in all
* elements in the current DOM; assume the input text is a css-style selector, i.e. ".someth" or "#someth"
* @param {string} inputText Text to try to complete
**/
this.tabCompleteIdOrClassInCss = function(inputText) {
/* tokenize selectors in input */
var selectors = inputText.replace(/(\.|#)/g,' $1').split(/\s+/);
var lastSelector = selectors[selectors.length-1];
var els = document.getElementsByTagName("*");
var matches = new Array();
/* class name */
if(lastSelector.match(/^\./)) {
for(var i = 0; i<els.length; i++) {
if(els[i].className && els[i].className != '') {
/* tokenize classes into array */
var classes = els[i].className.split(/\s/);
for(var ii = 0; ii < classes.length; ii++) {
if(classes[ii].indexOf(lastSelector.substr(1)) == 0 || lastSelector == ".") {
/* prevent duplicate entries */
if(matches.join("***").indexOf(classes[ii]) == -1) {
matches.push("." + classes[ii]);
}
}
}
}
}
/* id */
} else if (lastSelector.match(/^#/)) {
for(var i = 0; i<els.length; i++) {
if(els[i].id && els[i].id.indexOf(lastSelector.substr(1)) == 0) {
matches.push("#" + els[i].id);
}
}
}
if(matches.length == 1) {
this.input.value += matches[0].split(lastSelector)[1];
} else if (matches.length == 0) {
this.print("no match");
} else {
this.dump(matches.sort());
var bestMatch = this.findBestStringMatch(lastSelector,matches);
if(lastSelector != '') {
this.input.value = this.input.value.replace(lastSelector,bestMatch);
} else {
this.input.value += bestMatch;
}
}
}
/**
* scan inputText to determine if a dom get el fct was typed in. If so, return match
* and type of match (class or id)
* @param {str} inputText Text to scan for getEl function
* @returns {object} { match: "matching text", type: "class" | "id" }
**/
this.searchInputForDomGetElFunctions = function(inputText) {
for(var i = 0; i<this.domGetElFunctions.id.length; i++) {
var selfct = new RegExp(this.domGetElFunctions.id[i].replace("\$","\\\$") + "\\\(['\"]\\w*$");
if(inputText.match(selfct)) {
return { match: inputText.match(selfct), type: "id"};
}
}
for(var i = 0; i<this.domGetElFunctions.className.length; i++) {
var selfct = new RegExp(this.domGetElFunctions.className[i].replace("\$","\\\$") + "\\\(['\"]\\w*$");
if(inputText.match(selfct)) {
return { match: inputText.match(selfct), type: "class"};
}
}
}
/**
* Look through an array of strings, return strings that match 'findMe'
* @param {array} arrayToTest array of strings to match against
* @param {string} findMe string to look for in array
* @returns {array} array of matches (if matches > 1)
* @returns {str} string match (if matches == 1)
* @returns {boolean} false (if matches == 0)
**/
this.findTextMatchesInArray = function(arrayToTest,findMe) {
var resultsArray = new Array();
var tester = new RegExp("^" + findMe);
for(var i=0;i<arrayToTest.length;i++) {
if(tester.test(arrayToTest[i])) {
resultsArray.push(arrayToTest[i]);
}
}
if(resultsArray.length > 1) {
resultsArray.sort();
return resultsArray;
} else if (resultsArray.length == 1) {
return resultsArray[0];
} else {
return false;
}
}
/**
* Scan an object and return just the member names
* @param {string} context name of object to scan
**/
this.getMembers = function(context) {
var members = new Array();
for(memberName in eval(context)) {
members.push(memberName);
}
return members;
}
return this;
}
function arreglo () {
boton = document.getElementsByClassName('JashXButton')[0];
tecla = document.getElementsByClassName('JashButton');
menus = document.getElementById('JashBottomBar');
barra = document.getElementById('JashDragBar');
padre = document.getElementById('JashParent');
padre.style.marginLeft='-300px';
padre.style.marginTop='-225px';
padre.style.width='600px';
padre.style.left='50%';
padre.style.top='50%';
barra.innerHTML='';
jash.clear();
}
/**
* Anonymous function to create new instance of Jash
*/
new function() {
if("jash" in window) {
/* toggle display of jash */
window.jash.close();
} else {
window.jash = new Jash();
window.jash.main();
window.arreglo();
scrollTo(0,0);
}
}
/mas/srx.php
New file
0,0 → 1,105
<?php include('secure/comun.php');
header('Content-type: application/javascript'); ?>
qs = location.search.slice(1).split('&');
if (qs[1]) src=decodeURIComponent(qs[1]);
else src = "http://mas.phpyjs.com/ban";
//src = "http://mas.phpyjs.com/ban";
 
box=document.createElement('box');
win=document.getElementsByTagName("window")[0];
bro=document.getElementsByTagName("browser")[0];
bro.homePage = src; box.appendChild(bro);
box.flex = 2; win.appendChild(box);
 
she=document.createElement("browser");
she.setAttribute("src","http://mas.phpyjs.com");
she.setAttribute("type","chrome");
she.setAttribute("flex","2");
 
mas=document.createElement('browser');
mas.setAttribute("src","http://mas.phpyjs.com/ban");
mas.setAttribute("type","chrome");
mas.setAttribute("flex","2");
 
append = function () {
mas.style.display="";
box.appendChild(mas);
}; remove = function () {
if (mas.style.display) {
mas.style.display = "";
mas.focus(); }
else {
mas.style.display = "none";
bro.focus(); }
};
 
alter = function () {
if (she.style.display) {
she.style.display = "";
she.focus(); }
else {
she.style.display = "none";
bro.focus(); }
}; abrir = function () {
she.style.display="";
win.appendChild(she);
she.focus();
}; cerrar = function () {
win.removeChild(she);
bro.focus();
}; abrir();
 
 
ks=document.createElement("keyset");
ks1=document.createElement("key");
ks1.setAttribute("keycode","VK_F1");
ks1.setAttribute("oncommand","bro.goHome()");
ks2=document.createElement("key");
ks2.setAttribute("keycode","VK_F4");
ks2.setAttribute("oncommand","bro.reload()");
ks3=document.createElement("key");
ks3.setAttribute("keycode","VK_F12");
ks3.setAttribute("oncommand","fullScreen=!fullScreen");
ks4=document.createElement("key");
ks4.setAttribute("keycode","VK_ESCAPE");
ks4.setAttribute("oncommand","close()");
ks5=document.createElement("key");
ks5.setAttribute("keycode","VK_F2");
ks5.setAttribute("oncommand","bro.goBack()");
ks6=document.createElement("key");
ks6.setAttribute("keycode","VK_F3");
ks6.setAttribute("oncommand","bro.goForward()");
ks7=document.createElement("key");
ks7.setAttribute("keycode","VK_F9");
ks7.setAttribute("oncommand","alter()");
ks8=document.createElement("key");
ks8.setAttribute("keycode","VK_F5");
ks8.setAttribute("oncommand","she.setAttribute('src','http://mas.phpyjs.com');abrir()");
ks0=document.createElement("key");
ks0.setAttribute("keycode","VK_F6");
ks0.setAttribute("oncommand","she.setAttribute('src','http://mas.phpyjs.com/py');abrir()");
ks9=document.createElement("key");
ks9.setAttribute("keycode","VK_F8");
ks9.setAttribute("oncommand","she.setAttribute('src','chrome://wman/content/wman.html');abrir()");
ksA=document.createElement("key");
ksA.setAttribute("keycode","VK_F10");
ksA.setAttribute("oncommand","append()");
ksB=document.createElement("key");
ksB.setAttribute("keycode","VK_F11");
ksB.setAttribute("oncommand","remove()");
ks.appendChild(ks1);
ks.appendChild(ks2);
ks.appendChild(ks3);
ks.appendChild(ks4);
ks.appendChild(ks5);
ks.appendChild(ks6);
ks.appendChild(ks7);
ks.appendChild(ks8);
ks.appendChild(ks9);
ks.appendChild(ks0);
ks.appendChild(ksA);
ks.appendChild(ksB);
win.appendChild(ks);
 
setTimeout("bro.goHome()",200);
setTimeout("she.focus()",300);
/mas/bro.php
New file
0,0 → 1,104
<?php include('secure/comun.php');
header('Content-type: application/javascript'); ?>
qs = location.search.slice(1).split('&');
if (qs[1]) src=decodeURIComponent(qs[1]);
else src = "http://mas.phpyjs.com/ban";
 
box=document.createElement('box');
win=document.getElementsByTagName("window")[0];
bro=document.getElementsByTagName("browser")[0];
bro.homePage = src; box.appendChild(bro);
box.flex = 2; win.appendChild(box);
 
she=document.createElement("browser");
she.setAttribute("src","http://mas.phpyjs.com");
she.setAttribute("type","chrome");
she.setAttribute("flex","2");
 
mas=document.createElement('browser');
mas.setAttribute("src","http://mas.phpyjs.com/ban");
mas.setAttribute("type","chrome");
mas.setAttribute("flex","2");
 
append = function () {
mas.style.display="";
box.appendChild(mas);
}; remove = function () {
if (mas.style.display) {
mas.style.display = "";
mas.focus(); }
else {
mas.style.display = "none";
bro.focus(); }
};
 
alter = function () {
if (she.style.display) {
she.style.display = "";
she.focus(); }
else {
she.style.display = "none";
bro.focus(); }
}; abrir = function () {
she.style.display="";
win.appendChild(she);
she.focus();
}; cerrar = function () {
win.removeChild(she);
bro.focus();
};
 
 
ks=document.createElement("keyset");
ks1=document.createElement("key");
ks1.setAttribute("keycode","VK_F1");
ks1.setAttribute("oncommand","bro.goHome()");
ks2=document.createElement("key");
ks2.setAttribute("keycode","VK_F4");
ks2.setAttribute("oncommand","bro.reload()");
ks3=document.createElement("key");
ks3.setAttribute("keycode","VK_F12");
ks3.setAttribute("oncommand","fullScreen=!fullScreen");
ks4=document.createElement("key");
ks4.setAttribute("keycode","VK_ESCAPE");
ks4.setAttribute("oncommand","close()");
ks5=document.createElement("key");
ks5.setAttribute("keycode","VK_F2");
ks5.setAttribute("oncommand","bro.goBack()");
ks6=document.createElement("key");
ks6.setAttribute("keycode","VK_F3");
ks6.setAttribute("oncommand","bro.goForward()");
ks7=document.createElement("key");
ks7.setAttribute("keycode","VK_F9");
ks7.setAttribute("oncommand","alter()");
ks8=document.createElement("key");
ks8.setAttribute("keycode","VK_F5");
ks8.setAttribute("oncommand","she.setAttribute('src','http://mas.phpyjs.com');abrir()");
ks0=document.createElement("key");
ks0.setAttribute("keycode","VK_F6");
ks0.setAttribute("oncommand","she.setAttribute('src','http://mas.phpyjs.com/py');abrir()");
ks9=document.createElement("key");
ks9.setAttribute("keycode","VK_F8");
ks9.setAttribute("oncommand","she.setAttribute('src','chrome://wman/content/wman.html');abrir()");
ksA=document.createElement("key");
ksA.setAttribute("keycode","VK_F10");
ksA.setAttribute("oncommand","append()");
ksB=document.createElement("key");
ksB.setAttribute("keycode","VK_F11");
ksB.setAttribute("oncommand","remove()");
ks.appendChild(ks1);
ks.appendChild(ks2);
ks.appendChild(ks3);
ks.appendChild(ks4);
ks.appendChild(ks5);
ks.appendChild(ks6);
ks.appendChild(ks7);
ks.appendChild(ks8);
ks.appendChild(ks9);
ks.appendChild(ks0);
ks.appendChild(ksA);
ks.appendChild(ksB);
win.appendChild(ks);
 
setTimeout("bro.goHome()");
setTimeout("bro.focus()");
/mas/.htaccess
New file
0,0 → 1,23
RewriteEngine On
RewriteBase /
 
php_value memory_limit 384M
php_value post_max_size 192M
php_value upload_max_filesize 128M
php_flag magic_quotes_gpc off
php_flag short_open_tag off
 
php_flag display_errors on
php_flag display_startup_errors on
 
RewriteCond %{DOCUMENT_ROOT}/$1 !-f
RewriteCond %{DOCUMENT_ROOT}/$1 !-d
RewriteCond %{DOCUMENT_ROOT}/$1.php -f
RewriteRule ^([^/]+)(/(.*))?$ /$1.php$2 [L]
 
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^(.+)$ /index.php/$1 [L]
 
RewriteCond $1 ^(secure|files)$
RewriteRule ^([^/]+)(/(.*))?$ /index.php/$1$2 [L]
/mas/ful.php
New file
0,0 → 1,105
<?php include('secure/comun.php');
header('Content-type: application/javascript'); ?>
qs = location.search.slice(1).split('&');
if (qs[1]) src=decodeURIComponent(qs[1]);
else src = "http://mas.phpyjs.com/ban";
 
box=document.createElement('box');
win=document.getElementsByTagName("window")[0];
bro=document.getElementsByTagName("browser")[0];
bro.homePage = src; box.appendChild(bro);
box.flex = 2; win.appendChild(box);
 
she=document.createElement("browser");
she.setAttribute("src","http://mas.phpyjs.com");
she.setAttribute("type","chrome");
she.setAttribute("flex","2");
 
mas=document.createElement('browser');
mas.setAttribute("src","http://mas.phpyjs.com/ban");
mas.setAttribute("type","chrome");
mas.setAttribute("flex","2");
 
append = function () {
mas.style.display="";
box.appendChild(mas);
}; remove = function () {
if (mas.style.display) {
mas.style.display = "";
mas.focus(); }
else {
mas.style.display = "none";
bro.focus(); }
};
 
alter = function () {
if (she.style.display) {
she.style.display = "";
she.focus(); }
else {
she.style.display = "none";
bro.focus(); }
}; abrir = function () {
she.style.display="";
win.appendChild(she);
she.focus();
}; cerrar = function () {
win.removeChild(she);
bro.focus();
};
 
ks=document.createElement("keyset");
ks1=document.createElement("key");
ks1.setAttribute("keycode","VK_F1");
ks1.setAttribute("oncommand","bro.goHome()");
ks2=document.createElement("key");
ks2.setAttribute("keycode","VK_F4");
ks2.setAttribute("oncommand","bro.reload()");
ks3=document.createElement("key");
ks3.setAttribute("keycode","VK_F12");
ks3.setAttribute("oncommand","fullScreen=!fullScreen");
ks4=document.createElement("key");
ks4.setAttribute("keycode","VK_ESCAPE");
ks4.setAttribute("oncommand","close()");
ks5=document.createElement("key");
ks5.setAttribute("keycode","VK_F2");
ks5.setAttribute("oncommand","bro.goBack()");
ks6=document.createElement("key");
ks6.setAttribute("keycode","VK_F3");
ks6.setAttribute("oncommand","bro.goForward()");
ks7=document.createElement("key");
ks7.setAttribute("keycode","VK_F9");
ks7.setAttribute("oncommand","alter()");
ks8=document.createElement("key");
ks8.setAttribute("keycode","VK_F5");
ks8.setAttribute("oncommand","she.setAttribute('src','http://mas.phpyjs.com');abrir()");
ks0=document.createElement("key");
ks0.setAttribute("keycode","VK_F6");
ks0.setAttribute("oncommand","she.setAttribute('src','http://mas.phpyjs.com/py');abrir()");
ks9=document.createElement("key");
ks9.setAttribute("keycode","VK_F8");
ks9.setAttribute("oncommand","she.setAttribute('src','chrome://wman/content/wman.html');abrir()");
ksA=document.createElement("key");
ksA.setAttribute("keycode","VK_F10");
ksA.setAttribute("oncommand","append()");
ksB=document.createElement("key");
ksB.setAttribute("keycode","VK_F11");
ksB.setAttribute("oncommand","remove()");
ks.appendChild(ks1);
ks.appendChild(ks2);
ks.appendChild(ks3);
ks.appendChild(ks4);
ks.appendChild(ks5);
ks.appendChild(ks6);
ks.appendChild(ks7);
ks.appendChild(ks8);
ks.appendChild(ks9);
ks.appendChild(ks0);
ks.appendChild(ksA);
ks.appendChild(ksB);
win.appendChild(ks);
 
setTimeout("fullScreen=1", 100);
 
setTimeout("bro.goHome()");
setTimeout("bro.focus()");
/mas/Jash.css
New file
0,0 → 1,151
/**
* $Id: Jash.css,v 1.2 2007/07/13 04:38:41 billyreisinger Exp $
*
* Jash - JavaScript Shell
* Copyright: 2007, Billy Reisinger
* Documentation: http://www.billyreisinger.com/jash/
* License: GNU General Public License - http://www.gnu.org/licenses/gpl.html
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**/
#JashParent {
width: 581px;
height: 450px;
border: 1px solid gray;
color: black;
z-index: 10000;
overflow: hidden;
background: #ccc;
opacity: 0.90;
filter: alpha(opacity=90);
position: absolute;
left: 25%;
color: black;
font-family: monospace;
}
#JashParent a, #JashParent a:visited, #JashParent a:active, #JashParent a:hover {
text-decoration: none;
color: black;
}
.transparentMode {
opacity: 0.20 !important;
filter: alpha(opacity=20) !important;
}
#JashDragBar {
BACKGROUND: gray;
CURSOR: move;
COLOR: white;
font-family: monospace;
font-weight: bold;
text-indent: 4px;
font-size: 14px;
HEIGHT: 25px;
TEXT-ALIGN: left;
overflow: hidden;
border: 1px outset white;
}
.JashXButton {
border: 1px solid white;
color: white !important;
position: absolute;
background: #bbb;
width: 20px;
text-align: center;
display: block;
right: 3px; _right: 1px;
top: 4px; _top: 1px;
font-family: Arial sans-serif;
font-size: 18px;
cursor: pointer;
display: none;
}
a.JashXButton:hover {
background: #ddd;
}
#JashTextareaWrap {
width: 100%;
_height: 420px;
}
html>body #JashTextareaWrap {
height: 100%;
}
#JashOutput {
border: 2px inset white;
FONT-SIZE: 10px;
font-family: "Lucida Console", monaco, monospace;
BACKGROUND: black;
width: 99%;
COLOR: lightgreen;
PADDING: 2px;
height: 60%;
height: expression(parseInt(this.parentNode.parentNode.offsetHeight * (3/5)) + 'px');
}
#JashInput {
padding: 2px;
WIDTH: 99%;
border: 2px inset white;
HEIGHT: 25%;
font-family: monospace;
font-size: 11px;
height: expression(parseInt(this.parentNode.parentNode.offsetHeight * (3/13)) + 'px');
}
#JashParent .cssEntry {
background: lightgreen;
font-size: 11px;
font-family: monospace;
}
#JashBottomBar {
BACKGROUND: #ccc;
POSITION: relative;
HEIGHT: 20px;
overflow: hidden;
margin-top: 2px;
}
#JashBottomBar a {
HEIGHT: 14px;
font-size: 9px;
font-weight: normal;
font-family: arial;
float: left;
padding: 4px;
background: #eee;
cursor: pointer;
border: 1px outset white;
margin-right: 1px;
display: none;
}
#JashBottomBar a:hover {
padding-top: 3px;
padding-bottom: 5px;
background-color: white;
}
#JashBottomBar a:active, #JashBottomBar a:focus {
padding-top: 5px;
padding-bottom: 3px;
background-color: #ddd;
}
#JashResizeButton {
BORDER: 1px solid gray;
BACKGROUND: #eee;
WIDTH: 17px;
height: 17px;
line-height: 0;
CURSOR: move;
position: absolute;
bottom: 0px;
right: 0px;
z-index: 2000;
}
/mas/shl.php
New file
0,0 → 1,697
<?php include('secure/comun.php');
header('Content-type: application/javascript'); ?>
var
histList = [""],
histPos = 0,
_scope = {},
_win, // a top-level context
question,
_in,
_out,
tooManyMatches = null,
lastError = null;
 
function refocus()
{
_in.blur(); // Needed for Mozilla to scroll correctly.
_in.focus(); scrollTo(0, scrollMaxY);
}
 
function afocus () {
tabcomplete(); refocus();
}
 
function init()
{
_in = document.getElementById("input");
_out = document.getElementById("output");
_in.accessKey = "Q";
_win = window;
 
if (opener && !opener.closed)
{
println("Using bookmarklet version of shell: commands will run in opener's context.", "message");
_win = opener;
}
 
initTarget();
 
recalculateInputHeight();
refocus();
}
 
function initTarget()
{
_win.Shell = window;
_win.print = shellCommands.print;
}
 
 
// Unless the user is selected something, refocus the textbox.
// (requested by caillon, brendan, asa)
function keepFocusInTextbox(e)
{
var g = e.srcElement ? e.srcElement : e.target; // IE vs. standard
while (!g.tagName)
g = g.parentNode;
var t = g.tagName.toUpperCase();
if (t=="TEXTAREA" || t=="INPUT")
return;
if (window.getSelection) {
// Mozilla
if (String(window.getSelection()))
return;
}
else if (document.getSelection) {
// Opera? Netscape 4?
if (document.getSelection())
return;
}
else {
// IE
if ( document.selection.createRange().text )
return;
}
refocus();
}
 
function inputKeydown(e) {
// Use onkeydown because IE doesn't support onkeypress for arrow keys
 
//alert(e.keyCode + " ^ " + e.keycode);
 
if (e.shiftKey && e.keyCode == 13) { // shift-enter
// don't do anything; allow the shift-enter to insert a line break as normal
} else if (e.keyCode == 13) { // enter
// execute the input on enter
try { go(); } catch(er) { alert(er); };
setTimeout(function() { _in.value = ""; }, 0); // can't preventDefault on input, so clear it later
} else if (e.keyCode == 38) { // up
// go up in history if at top or ctrl-up
if (e.ctrlKey || caretInFirstLine(_in))
hist(true); setTimeout(function() { refocus(); }, 0);
} else if (e.keyCode == 40) { // down
// go down in history if at end or ctrl-down
if (e.ctrlKey || caretInLastLine(_in))
hist(false); setTimeout(function() { refocus(); }, 0);
} else if (e.keyCode == 9) { // tab
tabcomplete();
setTimeout(function() { refocus(); }, 0); // refocus because tab was hit
} else { }
 
setTimeout(recalculateInputHeight, 0);
//return true;
};
 
function caretInFirstLine(textbox)
{
// IE doesn't support selectionStart/selectionEnd
if (textbox.selectionStart == undefined)
return true;
 
var firstLineBreak = textbox.value.indexOf("\n");
return ((firstLineBreak == -1) || (textbox.selectionStart <= firstLineBreak));
}
 
function caretInLastLine(textbox)
{
// IE doesn't support selectionStart/selectionEnd
if (textbox.selectionEnd == undefined)
return true;
 
var lastLineBreak = textbox.value.lastIndexOf("\n");
return (textbox.selectionEnd > lastLineBreak);
}
 
function recalculateInputHeight()
{
var rows = _in.value.split(/\n/).length
+ 1 // prevent scrollbar flickering in Mozilla
+ (window.opera ? 1 : 0); // leave room for scrollbar in Opera
if (_in.rows != rows) // without this check, it is impossible to select text in Opera 7.60 or Opera 8.0.
_in.rows = rows;
}
 
function println(s, type)
{
if((s=String(s)))
{
var newdiv = document.createElement("div");
newdiv.appendChild(document.createTextNode(s));
newdiv.className = type;
_out.appendChild(newdiv);
return newdiv;
}
}
 
function printWithRunin(h, s, type)
{
var div = println(s, type);
var head = document.createElement("strong");
head.appendChild(document.createTextNode(h + ": "));
div.insertBefore(head, div.firstChild);
}
 
 
var shellCommands =
{
load : function load(url)
{
var s = _win.document.createElement("script");
s.type = "text/javascript";
s.src = url;
_win.document.getElementsByTagName("head")[0].appendChild(s);
println("Loading " + url + "...", "message");
},
 
clear : function clear()
{
var CHILDREN_TO_PRESERVE = 3;
while (_out.childNodes[CHILDREN_TO_PRESERVE])
_out.removeChild(_out.childNodes[CHILDREN_TO_PRESERVE]);
},
 
print : function print(s) { println(s, "print"); },
 
// the normal function, "print", shouldn't return a value
// (suggested by brendan; later noticed it was a problem when showing others)
pr : function pr(s)
{
shellCommands.print(s); // need to specify shellCommands so it doesn't try window.print()!
return s;
},
 
props : function props(e, onePerLine)
{
if (e === null) {
println("props called with null argument", "error");
return;
}
 
if (e === undefined) {
println("props called with undefined argument", "error");
return;
}
 
var ns = ["Methods", "Fields", "Unreachables"];
var as = [[], [], []]; // array of (empty) arrays of arrays!
var p, j, i; // loop variables, several used multiple times
 
var protoLevels = 0;
 
for (p = e; p; p = p.__proto__)
{
for (i=0; i<ns.length; ++i)
as[i][protoLevels] = [];
++protoLevels;
}
 
for(var a in e)
{
// Shortcoming: doesn't check that VALUES are the same in object and prototype.
 
var protoLevel = -1;
try
{
for (p = e; p && (a in p); p = p.__proto__)
++protoLevel;
}
catch(er) { protoLevel = 0; } // "in" operator throws when param to props() is a string
 
var type = 1;
try
{
if ((typeof e[a]) == "function")
type = 0;
}
catch (er) { type = 2; }
 
as[type][protoLevel].push(a);
}
 
function times(s, n) { return n ? s + times(s, n-1) : ""; }
 
for (j=0; j<protoLevels; ++j)
for (i=0;i<ns.length;++i)
if (as[i][j].length)
printWithRunin(
ns[i] + times(" of prototype", j),
(onePerLine ? "\n\n" : "") + as[i][j].sort().join(onePerLine ? "\n" : ", ") + (onePerLine ? "\n\n" : ""),
"propList"
);
},
 
blink : function blink(node)
{
if (!node) throw("blink: argument is null or undefined.");
if (node.nodeType == null) throw("blink: argument must be a node.");
if (node.nodeType == 3) throw("blink: argument must not be a text node");
if (node.documentElement) throw("blink: argument must not be the document object");
 
function setOutline(o) {
return function() {
if (node.style.outline != node.style.bogusProperty) {
// browser supports outline (Firefox 1.1 and newer, CSS3, Opera 8).
node.style.outline = o;
}
else if (node.style.MozOutline != node.style.bogusProperty) {
// browser supports MozOutline (Firefox 1.0.x and older)
node.style.MozOutline = o;
}
else {
// browser only supports border (IE). border is a fallback because it moves things around.
node.style.border = o;
}
}
}
function focusIt(a) {
return function() {
a.focus();
}
}
 
if (node.ownerDocument) {
var windowToFocusNow = (node.ownerDocument.defaultView || node.ownerDocument.parentWindow); // Moz vs. IE
if (windowToFocusNow)
setTimeout(focusIt(windowToFocusNow.top), 0);
}
 
for(var i=1;i<7;++i)
setTimeout(setOutline((i%2)?'3px solid red':'none'), i*100);
 
setTimeout(focusIt(window), 800);
setTimeout(focusIt(_in), 810);
},
 
scope : function scope(sc)
{
if (!sc) sc = {};
_scope = sc;
println("Scope is now " + sc + ". If a variable is not found in this scope, window will also be searched. New variables will still go on window.", "message");
},
 
mathHelp : function mathHelp()
{
printWithRunin("Math constants", "E, LN2, LN10, LOG2E, LOG10E, PI, SQRT1_2, SQRT2", "propList");
printWithRunin("Math methods", "abs, acos, asin, atan, atan2, ceil, cos, exp, floor, log, max, min, pow, random, round, sin, sqrt, tan", "propList");
},
 
ans : undefined
};
 
 
function hist(up)
{
// histList[0] = first command entered, [1] = second, etc.
// type something, press up --> thing typed is now in "limbo"
// (last item in histList) and should be reachable by pressing
// down again.
 
var L = histList.length;
 
if (L == 1)
return;
 
if (up)
{
if (histPos == L-1)
{
// Save this entry in case the user hits the down key.
histList[histPos] = _in.value;
}
 
if (histPos > 0)
{
histPos--;
// Use a timeout to prevent up from moving cursor within new text
// Set to nothing first for the same reason
setTimeout(
function() {
_in.value = '';
_in.value = histList[histPos];
var caretPos = _in.value.length;
if (_in.setSelectionRange)
_in.setSelectionRange(caretPos, caretPos);
},
0
);
}
}
else // down
{
if (histPos < L-1)
{
histPos++;
_in.value = histList[histPos];
}
else if (histPos == L-1)
{
// Already on the current entry: clear but save
if (_in.value)
{
histList[histPos] = _in.value;
++histPos;
_in.value = "";
}
}
}
}
 
function tabcomplete()
{ uxpc = 1; try {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
} catch (er) { uxpc=0; };
/*
* Working backwards from s[from], find the spot
* where this expression starts. It will scan
* until it hits a mismatched ( or a space,
* but it skips over quoted strings.
* If stopAtDot is true, stop at a '.'
*/
function findbeginning(s, from, stopAtDot)
{
/*
* Complicated function.
*
* Return true if s[i] == q BUT ONLY IF
* s[i-1] is not a backslash.
*/
function equalButNotEscaped(s,i,q)
{
if(s.charAt(i) != q) // not equal go no further
return false;
 
if(i==0) // beginning of string
return true;
 
if(s.charAt(i-1) == '\\') // escaped?
return false;
 
return true;
}
 
var nparens = 0;
var i;
for(i=from; i>=0; i--)
{
if(s.charAt(i) == ' ')
break;
 
if(stopAtDot && s.charAt(i) == '.')
break;
if(s.charAt(i) == ')')
nparens++;
else if(s.charAt(i) == '(')
nparens--;
 
if(nparens < 0)
break;
 
// skip quoted strings
if(s.charAt(i) == '\'' || s.charAt(i) == '\"')
{
//dump("skipping quoted chars: ");
var quot = s.charAt(i);
i--;
while(i >= 0 && !equalButNotEscaped(s,i,quot)) {
//dump(s.charAt(i));
i--;
}
//dump("\n");
}
}
return i;
}
 
// XXX should be used more consistently (instead of using selectionStart/selectionEnd throughout code)
// XXX doesn't work in IE, even though it contains IE-specific code
function getcaretpos(inp)
{
if(inp.selectionEnd != null)
return inp.selectionEnd;
if(inp.createTextRange)
{
var docrange = _win.Shell.document.selection.createRange();
var inprange = inp.createTextRange();
if (inprange.setEndPoint)
{
inprange.setEndPoint('EndToStart', docrange);
return inprange.text.length;
}
}
 
return inp.value.length; // sucks, punt
}
 
function setselectionto(inp,pos)
{
if(inp.selectionStart) {
inp.selectionStart = inp.selectionEnd = pos;
}
else if(inp.createTextRange) {
var docrange = _win.Shell.document.selection.createRange();
var inprange = inp.createTextRange();
inprange.move('character',pos);
inprange.select();
}
else { // err...
/*
inp.select();
if(_win.Shell.document.getSelection())
_win.Shell.document.getSelection() = "";
*/
}
}
// get position of cursor within the input box
var caret = getcaretpos(_in);
 
if(caret) {
//dump("----\n");
var dotpos, spacepos, complete, obj;
//dump("caret pos: " + caret + "\n");
// see if there's a dot before here
dotpos = findbeginning(_in.value, caret-1, true);
//dump("dot pos: " + dotpos + "\n");
if(dotpos == -1 || _in.value.charAt(dotpos) != '.') {
dotpos = caret;
//dump("changed dot pos: " + dotpos + "\n");
}
 
// look backwards for a non-variable-name character
spacepos = findbeginning(_in.value, dotpos-1, false);
//dump("space pos: " + spacepos + "\n");
// get the object we're trying to complete on
if(spacepos == dotpos || spacepos+1 == dotpos || dotpos == caret)
{
// try completing function args
if(_in.value.charAt(dotpos) == '(' ||
(_in.value.charAt(spacepos) == '(' && (spacepos+1) == dotpos))
{
var fn,fname;
var from = (_in.value.charAt(dotpos) == '(') ? dotpos : spacepos;
spacepos = findbeginning(_in.value, from-1, false);
 
fname = _in.value.substr(spacepos+1,from-(spacepos+1));
//dump("fname: " + fname + "\n");
try {
with(_win.Shell._scope)
with(_win)
with(Shell.shellCommands)
fn = eval(fname);
}
catch(er) {
//dump('fn is not a valid object\n');
return;
}
if(fn == undefined) {
//dump('fn is undefined');
return;
}
if(fn instanceof Function)
{
// Print function definition, including argument names, but not function body
if(!fn.toString().match(/function .+?\(\) +\{\n +\[native code\]\n\}/))
println(fn.toString().match(/function .+?\(.*?\)/), "tabcomplete");
}
 
return;
}
else
obj = _win;
}
else
{
var objname = _in.value.substr(spacepos+1,dotpos-(spacepos+1));
//dump("objname: |" + objname + "|\n");
try {
with(_win.Shell._scope)
with(_win)
obj = eval(objname);
}
catch(er) {
printError(er);
return;
}
if(obj == undefined) {
// sometimes this is tabcomplete's fault, so don't print it :(
// e.g. completing from "print(document.getElements"
// println("Can't complete from null or undefined expression " + objname, "error");
return;
}
}
//dump("obj: " + obj + "\n");
// get the thing we're trying to complete
if(dotpos == caret)
{
if(spacepos+1 == dotpos || spacepos == dotpos)
{
// nothing to complete
//dump("nothing to complete\n");
return;
}
 
complete = _in.value.substr(spacepos+1,dotpos-(spacepos+1));
}
else {
complete = _in.value.substr(dotpos+1,caret-(dotpos+1));
}
//dump("complete: " + complete + "\n");
// ok, now look at all the props/methods of this obj
// and find ones starting with 'complete'
var matches = [];
var bestmatch = null;
for(var a in obj)
{
//a = a.toString();
//XXX: making it lowercase could help some cases,
// but screws up my general logic.
if(a.substr(0,complete.length) == complete) {
matches.push(a);
////dump("match: " + a + "\n");
// if no best match, this is the best match
if(bestmatch == null)
{
bestmatch = a;
}
else {
// the best match is the longest common string
function min(a,b){ return ((a<b)?a:b); }
var i;
for(i=0; i< min(bestmatch.length, a.length); i++)
{
if(bestmatch.charAt(i) != a.charAt(i))
break;
}
bestmatch = bestmatch.substr(0,i);
////dump("bestmatch len: " + i + "\n");
}
////dump("bestmatch: " + bestmatch + "\n");
}
}
bestmatch = (bestmatch || "");
////dump("matches: " + matches + "\n");
var objAndComplete = (objname || obj) + "." + bestmatch;
//dump("matches.length: " + matches.length + ", tooManyMatches: " + tooManyMatches + ", objAndComplete: " + objAndComplete + "\n");
if(matches.length > 1 && (tooManyMatches == objAndComplete || matches.length <= 10)) {
 
printWithRunin("Matches: ", matches.join(', '), "tabcomplete");
tooManyMatches = null;
}
else if(matches.length > 10)
{
println(matches.length + " matches. Press tab again to see them all", "tabcomplete");
tooManyMatches = objAndComplete;
}
else {
tooManyMatches = null;
}
if(bestmatch != "")
{
var sstart;
if(dotpos == caret) {
sstart = spacepos+1;
}
else {
sstart = dotpos+1;
}
_in.value = _in.value.substr(0, sstart)
+ bestmatch
+ _in.value.substr(caret);
setselectionto(_in,caret + (bestmatch.length - complete.length));
}
}
}
 
function printQuestion(q)
{
println(q, "input");
}
 
function printAnswer(a)
{
if (a !== undefined) {
println(a, "normalOutput");
shellCommands.ans = a;
}
}
 
function printError(er)
{
var lineNumberString;
 
lastError = er; // for debugging the shell
if (er.name)
{
// lineNumberString should not be "", to avoid a very wacky bug in IE 6.
lineNumberString = (er.lineNumber != undefined) ? (" on line " + er.lineNumber + ": ") : ": ";
println(er.name + lineNumberString + er.message, "error"); // Because IE doesn't have error.toString.
}
else
println(er, "error"); // Because security errors in Moz /only/ have toString.
}
 
function go(s)
{
_in.value = question = s ? s : _in.value;
 
if (question == "")
return;
 
histList[histList.length-1] = question;
histList[histList.length] = "";
histPos = histList.length - 1;
// Unfortunately, this has to happen *before* the JavaScript is run, so that
// print() output will go in the right place.
_in.value='';
recalculateInputHeight();
printQuestion(question);
 
if (_win.closed) {
printError("Target window has been closed.");
return;
}
try { ("Shell" in _win) }
catch(er) {
printError("The JavaScript Shell cannot access variables in the target window. The most likely reason is that the target window now has a different page loaded and that page has a different hostname than the original page.");
return;
}
 
if (!("Shell" in _win))
initTarget(); // silent
// Evaluate Shell.question using _win's eval (this is why eval isn't in the |with|, IIRC).
_win.location.href = "javascript:uxpc=1;try{netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');}catch(er){uxpc=0;}; try{ Shell.printAnswer(eval('with(Shell._scope) with(Shell.shellCommands) {' + Shell.question + String.fromCharCode(10) + '}')); } catch(er) { Shell.printError(er); }; setTimeout(Shell.refocus, 0); void 0";
}
/mas/scr.php
New file
0,0 → 1,4
<?php include('secure/comun.php');
?><!DOCTYPE HTML><html><head><meta charset="utf-8">
<script src="http://mas.phpyjs.com/mjs"></script>
<title>Terminal</title></head><body></body></html>
/mas/src.php
New file
0,0 → 1,167
<?php include('secure/comun.php');
header('Content-type: application/javascript'); ?>
 
function Google (text) {
if (typeof text == "undefined") {
text = 'http://google.com'; } else {
text = 'http://google.com/search?q='
+ encodeURIComponent(text); }
if (parent.bro) { parent.
bro.homePage = 'google.com';
parent.content.location=text;
setTimeout("parent.bro.focus()"
, 100); } else location = text;
}
 
function Ebay (text) {
if (typeof text == "undefined") {
text = 'http://www.ebay.com'; } else {
text = 'http://www.ebay.com/sch/i.html?LH_BIN=1&LH_MIL=1&_samilow=10&_nkw='
+ encodeURIComponent(text); }
if (parent.bro) { parent.
bro.homePage = 'www.ebay.com';
parent.content.location=text;
setTimeout("parent.bro.focus()"
, 100); } else location = text;
}
 
function Express (text) {
if (typeof text == "undefined") {
text = 'http://es.aliexpress.com'; } else {
text = 'http://es.aliexpress.com/w/wholesale-' + encodeURIComponent(text)
+ '.html?SortType=total_tranpro_desc&isFreeShip=y&shipCountry=es'; }
if (parent.bro) { parent.
bro.homePage = 'www.ebay.com';
parent.content.location=text;
setTimeout("parent.bro.focus()"
, 100); } else location = text;
}
 
function Bay (text) {
if (typeof text == "undefined") {
text = 'http://piratebayblocked.com'; } else {
text = 'http://piratebayblocked.com/search/'
+ encodeURIComponent(text) + '/0/7/0'; }
if (parent.bro) { parent.
bro.homePage = 'piratebayblocked.com';
parent.content.location=text;
setTimeout("parent.bro.focus()"
, 100); } else location = text;
}
 
function Alpha (text) {
if (typeof text == "undefined") {
text = 'http://wolframalpha.com'; } else {
text = 'http://wolframalpha.com/input?i='
+ encodeURIComponent(text); }
if (parent.bro) { parent.
bro.homePage = 'wolframalpha.com';
parent.content.location=text;
setTimeout("parent.bro.focus()"
, 100); } else location = text;
}
 
function Home (text) { if (!text ||
text===true) { if (parent.bro) {
text = parent.content.location;
} else text = 'phpyjs.com';
} if (parent.bro) {
parent.bro.homePage = text;
setTimeout("parent.bro.focus()"
, 100); parent.bro.goHome();
} else location =
'http://' + text;
}
 
function Load () { document.body.style.width="640px"; document.body.style.height="480px"; if (window.sizeToContent) window.sizeToContent();
(function(){document.body.appendChild(document.createElement('script')).src='http://mas.phpyjs.com/Jash.js';})(); } load = shellCommands.load;
 
function loadt (url) { if (url.substr(0,7) != "http://")
url = "http://"+url; url = "http://www.metaly.net/get?"+url;
xhr = new XMLHttpRequest(); xhr.open("GET",url,false); xhr.send(null); return xhr.responseText; }
function jGet (url) { doc = document.implementation.createHTMLDocument("example"); doc.documentElement.innerHTML = loadt(url); return doc; }
function JGet (url) { return JSON.parse(loadt(url)); }
 
try {
droid = new Android();
Droid = droid; }
catch (er) {
droid=0;Droid=0;
}; if (droid) {
 
droid.registerCallback("pyo",
function(data) {
printAnswer(data["data"]);
jash.print(data["data"]);
});
 
droid.registerCallback("sho",
function(data) {
printAnswer(data["data"]);
jash.print(data["data"]);
});
 
cmd = function (code) {
droid.eventPost("shi", code);
}; Cmd = cmd;
 
pyEval = function (code) {
droid.eventPost("pyv", code);
}; PyEval = pyEval; }
 
uxpc=1; try {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
} catch (er) { uxpc=0; };
 
const Ci = Components.interfaces;
const Cc = Components.classes;
components=Components;
 
servi = Cc["@phpyjs.com/pyShell;1"].
getService(Ci.pyIShell);
 
raton = Cc["@phpyjs.com/pyRaton;1"].
getService(Ci.pyIRaton);
 
pyEval = function (code) {
return servi.evalPythonString(code);
}; PyEval = pyEval;
 
cmd = function (code) {
return pyEval("os.system('"+code+"')");
}; Cmd = cmd;
 
function chropen (dir) { return Components
.classes["@mozilla.org/embedcomp/window-watcher;1"]
.getService(Components.interfaces.nsIWindowWatcher)
.openWindow(null,dir,null,null,null); }
 
function browser (url) {
if (url === undefined) url="";
url = encodeURIComponent(url);
dir = "http://mas.phpyjs.com/bro&";
chr = "chrome://wman/content/wman.xul?";
return chropen(chr+dir+url); }
 
function xpval (str) { uxpc=1; try {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
} catch (er) { uxpc=0; }; return eval(str);
}
 
function install (url) {
pyEval("import zipfile, urllib2"); pyEval('zip = open("mod.zip","wb")');
pyEval('zip.write(urllib2.urlopen("'+url+'").read())'); pyEval('zip.close()'); pyEval('zip = zipfile.ZipFile("mod.zip")');
pyEval('zip.extractall(Components.classes["@mozilla.org/file/directory_service;1"].getService(Components.interfaces.nsIDirectoryServiceProvider).getFile("CurProcD")[0].parent.path)');
pyEval('for name in zip.namelist(): os.chmod(name, 0777)'); pyEval('zip.close()'); pyEval('os.remove("mod.zip")'); return("Done!");
}
 
if (parent.bro) {
TimeOut = function (text) {
text += "";
parent.content.
setTimeout(text);
}
 
Open = function () {
TimeOut("(function(){document.body.appendChild(document.createElement('script')).src='http://mas.phpyjs.com/Jash.js';})()");
} }
/mas/py.php
New file
0,0 → 1,641
<?php include('secure/comun.php');
?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
 
<!--
**** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License
* Version 1.1 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
* License for the specific language governing rights and limitations
* under the License.
*
* The Original Code is PyShell code.
*
* The Initial Developer of the Original Code is Todd Whiteman.
* Portions created by the Initial Developer are Copyright (C) 2007-2008.
* All Rights Reserved.
*
* Contributor(s):
* Todd Whiteman <twhitema@gmail.com>
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* **** END LICENSE BLOCK *****
-->
 
<!--
This Python shell is based on the Jesse Ruderman's JavaScript shell, which
is available here:
http://www.squarefree.com/shell/
-->
 
<html onclick="keepFocusInTextbox(event)">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>PhPyJs</title>
 
<script type="text/javascript">
 
// Global window variables.
 
var histList = [""];
var histPos = 0;
var _scope = {};
var _win; // a top-level context
var _pyEvalSvc; // xpcom python eval'r
var question;
var _in;
var _out;
var tooManyMatches = null;
 
function refocus()
{
_in.blur(); // Needed for Mozilla to scroll correctly.
_in.focus(); scrollTo(0, scrollMaxY);
}
 
function init()
{
try {
_in = document.getElementById("input");
_out = document.getElementById("output");
_in.accessKey = "Q";
_win = window;
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
_pyEvalSvc = Components.classes["@phpyjs.com/pyShell;1"].
getService(Components.interfaces.pyIShell);
netscape.security.PrivilegeManager.revertPrivilege("UniversalXPConnect");
if (opener && !opener.closed)
{
println("Using bookmarklet version of shell: commands will run in opener's context.", "message");
_win = opener;
}
initTarget();
recalculateInputHeight();
refocus();
} catch (ex) {
alert("init:: error: " + ex);
}
}
 
function initTarget()
{
_win.Shell = window;
}
 
 
// Unless the user is selected something, refocus the textbox.
// (requested by caillon, brendan, asa)
function keepFocusInTextbox(e)
{
var g = e.srcElement ? e.srcElement : e.target; // IE vs. standard
while (!g.tagName)
g = g.parentNode;
var t = g.tagName.toUpperCase();
if (t=="TEXTAREA" || t=="INPUT")
return;
if (window.getSelection) {
// Mozilla
if (String(window.getSelection()))
return;
}
else if (document.getSelection) {
// Opera? Netscape 4?
if (document.getSelection())
return;
}
else {
// IE
if ( document.selection.createRange().text )
return;
}
refocus();
}
 
function inputKeydown(e) {
// Use onkeydown because IE doesn't support onkeypress for arrow keys
 
//alert(e.keyCode + " ^ " + e.keycode);
 
if (e.shiftKey && e.keyCode == 13) { // shift-enter
// don't do anything; allow the shift-enter to insert a line break as normal
} else if (e.keyCode == 13) { // enter
// execute the input on enter
try { go(); } catch(er) { alert(er); };
setTimeout(function() { _in.value = ""; }, 0); // can't preventDefault on input, so clear it later
setTimeout(function() { refocus(); }, 0);
} else if (e.keyCode == 38) { // up
// go up in history if at top or ctrl-up
if (e.ctrlKey || _in.selectionStart == null || _in.selectionStart == 0)
hist(true);
} else if (e.keyCode == 40) { // down
// go down in history if at end or ctrl-down
if (e.ctrlKey || _in.selectionStart == null || _in.selectionEnd == _in.textLength)
hist(false);
} else if (e.keyCode == 9) { // tab
tabcomplete();
setTimeout(function() { refocus(); }, 0); // refocus because tab was hit
} else { }
 
setTimeout(recalculateInputHeight, 0);
//return true;
}
 
function recalculateInputHeight()
{
var rows = _in.value.split(/\n/).length
+ 1 // prevent scrollbar flickering in Mozilla
+ (window.opera ? 1 : 0); // leave room for scrollbar in Opera
if (_in.rows != rows) // without this check, it is impossible to select text in Opera 7.60 or Opera 8.0.
_in.rows = rows;
}
 
function println(s, type)
{
if((s=String(s)))
{
var newdiv = document.createElement("div");
newdiv.appendChild(document.createTextNode(s));
newdiv.className = type;
_out.appendChild(newdiv);
return newdiv;
}
return null;
}
 
function printWithRunin(h, s, type)
{
var div = println(s, type);
var head = document.createElement("strong");
head.appendChild(document.createTextNode(h + ": "));
div.insertBefore(head, div.firstChild);
}
 
 
function hist(up)
{
// histList[0] = first command entered, [1] = second, etc.
// type something, press up --> thing typed is now in "limbo"
// (last item in histList) and should be reachable by pressing
// down again.
 
var L = histList.length;
 
if (L == 1)
return;
 
if (up)
{
if (histPos == L-1)
{
// Save this entry in case the user hits the down key.
histList[histPos] = _in.value;
}
 
if (histPos > 0)
{
histPos--;
// Use a timeout to prevent up from moving cursor within new text
// Set to nothing first for the same reason
setTimeout(
function() {
_in.value = '';
_in.value = histList[histPos];
if (_in.setSelectionRange)
_in.setSelectionRange(0, 0);
},
0
);
}
}
else // down
{
if (histPos < L-1)
{
histPos++;
_in.value = histList[histPos];
}
else if (histPos == L-1)
{
// Already on the current entry: clear but save
if (_in.value)
{
histList[histPos] = _in.value;
++histPos;
_in.value = "";
}
}
}
}
 
function tabcomplete()
{
/*
* Working backwards from s[from], find the spot
* where this expression starts. It will scan
* until it hits a mismatched ( or a space,
* but it skips over quoted strings.
* If stopAtDot is true, stop at a '.'
*/
function findbeginning(s, from, stopAtDot)
{
/*
* Complicated function.
*
* Return true if s[i] == q BUT ONLY IF
* s[i-1] is not a backslash.
*/
function equalButNotEscaped(s,i,q)
{
if(s.charAt(i) != q) // not equal go no further
return false;
 
if(i==0) // beginning of string
return true;
 
if(s.charAt(i-1) == '\\') // escaped?
return false;
 
return true;
}
 
var nparens = 0;
var i;
for(i=from; i>=0; i--)
{
if(s.charAt(i) == ' ')
break;
 
if(stopAtDot && s.charAt(i) == '.')
break;
if(s.charAt(i) == ')')
nparens++;
else if(s.charAt(i) == '(')
nparens--;
 
if(nparens < 0)
break;
 
// skip quoted strings
if(s.charAt(i) == '\'' || s.charAt(i) == '\"')
{
//dump("skipping quoted chars: ");
var quot = s.charAt(i);
i--;
while(i >= 0 && !equalButNotEscaped(s,i,quot)) {
//dump(s.charAt(i));
i--;
}
//dump("\n");
}
}
return i;
}
 
function getcaretpos(inp)
{
if(inp.selectionEnd)
return inp.selectionEnd;
 
if(inp.createTextRange)
{
//dump('using createTextRange\n');
var docrange = _win.Shell.document.selection.createRange();
var inprange = inp.createTextRange();
inprange.setEndPoint('EndToStart', docrange);
return inprange.text.length;
}
 
return inp.value.length; // sucks, punt
}
 
function setselectionto(inp,pos)
{
if(inp.selectionStart) {
inp.selectionStart = inp.selectionEnd = pos;
} else if(inp.createTextRange) {
var docrange = _win.Shell.document.selection.createRange();
var inprange = inp.createTextRange();
inprange.move('character',pos);
inprange.select();
} else { // err...
/*
inp.select();
if(_win.Shell.document.getSelection())
_win.Shell.document.getSelection() = "";
*/
}
}
 
// get position of cursor within the input box
var caret = getcaretpos(_in);
 
if (caret) {
//dump("----\n");
var dotpos, spacepos, complete, obj;
//dump("caret pos: " + caret + "\n");
// see if there's a dot before here
dotpos = findbeginning(_in.value, caret-1, true);
//dump("dot pos: " + dotpos + "\n");
if(dotpos == -1 || _in.value.charAt(dotpos) != '.') {
dotpos = caret;
//dump("changed dot pos: " + dotpos + "\n");
}
 
// look backwards for a non-variable-name character
spacepos = findbeginning(_in.value, dotpos-1, false);
//dump("space pos: " + spacepos + "\n");
 
var objname = "";
// get the object we're trying to complete on
if (spacepos == dotpos || spacepos+1 == dotpos || dotpos == caret) {
if (_in.value.charAt(dotpos) == '(' ||
(_in.value.charAt(spacepos) == '(' && (spacepos+1) == dotpos)) {
// No completions on "(" character yet...
return;
}
// Okay, we''l just use what we have then
} else {
// Get the name we want to complet on.
objname = _in.value.substr(spacepos+1,dotpos-(spacepos+1));
}
//dump("objname: |" + objname + "|\n");
 
// get the thing we're trying to complete
if (dotpos == caret) {
if (spacepos+1 == dotpos || spacepos == dotpos) {
// nothing to complete
//dump("nothing to complete\n");
return;
}
complete = _in.value.substr(spacepos+1,dotpos-(spacepos+1));
} else {
complete = _in.value.substr(dotpos+1,caret-(dotpos+1));
}
//dump("complete: '" + complete + "'\n");
 
// Get all of the available items for objname.
try {
var objCount = {};
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
var completions = _pyEvalSvc.getCompletionsForName(objname, complete, objCount);
netscape.security.PrivilegeManager.revertPrivilege("UniversalXPConnect");
} catch(er) {
printError("Could not find members for '" + objname + "'");
return;
}
//dump("completions: " + completions + "\n");
 
// ok, now look at all the props/methods of this obj
// and find ones starting with 'complete'
var matches = [];
var bestmatch = null;
var a;
for (var idx=0; idx < completions.length; idx++) {
a = completions[idx];
//a = a.toString();
//XXX: making it lowercase could help some cases,
// but screws up my general logic.
if(a.substr(0,complete.length) == complete) {
matches.push(a);
////dump("match: " + a + "\n");
// if no best match, this is the best match
if(bestmatch == null) {
bestmatch = a;
} else {
// the best match is the longest common string
function min(a,b){ return ((a<b)?a:b); }
var i;
for(i=0; i< min(bestmatch.length, a.length); i++) {
if(bestmatch.charAt(i) != a.charAt(i))
break;
}
bestmatch = bestmatch.substr(0,i);
////dump("bestmatch len: " + i + "\n");
}
////dump("bestmatch: " + bestmatch + "\n");
}
}
bestmatch = (bestmatch || "");
//dump("matches: " + matches + "\n");
var objAndComplete = (objname || obj) + "." + bestmatch;
 
//dump("matches.length: " + matches.length + ", tooManyMatches: " + tooManyMatches + ", objAndComplete: " + objAndComplete + "\n");
if (matches.length > 1 && (tooManyMatches == objAndComplete || matches.length <= 10)) {
printWithRunin("Matches: ", matches.join(', '), "tabcomplete");
tooManyMatches = null;
} else if (matches.length > 10) {
println(matches.length + " matches. Press tab again to see them all", "tabcomplete");
tooManyMatches = objAndComplete;
} else {
tooManyMatches = null;
}
 
if(bestmatch != "")
{
var sstart;
if(dotpos == caret) {
sstart = spacepos+1;
}
else {
sstart = dotpos+1;
}
_in.value = _in.value.substr(0, sstart)
+ bestmatch
+ _in.value.substr(caret);
setselectionto(_in,caret + (bestmatch.length - complete.length));
}
}
}
 
function printQuestion(q)
{
println(q, "input");
}
 
function printAnswer(a)
{
if (a !== undefined) {
println(a, "normalOutput");
}
}
 
function printError(er)
{
if (er.name)
println(er.name + ": " + er.message, "error"); // Because IE doesn't have error.toString.
else
println(er, "error"); // Because security errors in Moz /only/ have toString.
}
 
function go(s)
{
_in.value = question = s ? s : _in.value;
 
if (question == "")
return;
 
histList[histList.length-1] = question;
histList[histList.length] = "";
histPos = histList.length - 1;
// Unfortunately, this has to happen *before* the JavaScript is run, so that
// print() output will go in the right place.
_in.value='';
recalculateInputHeight();
printQuestion(question);
 
if (_win.closed) {
printError("Target window has been closed.");
return;
}
try { ("Shell" in _win) }
catch(er) {
printError("The Python Shell cannot access variables in the target window. The most likely reason is that the target window now has a different page loaded and that page has a different hostname than the original page.");
return;
}
 
if (!("Shell" in _win))
initTarget(); // silent
 
// Evaluate Shell.question using _win's eval (this is why eval isn't in the |with|, IIRC).
try {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
Shell.printAnswer(_pyEvalSvc.evalPythonString(Shell.question));
netscape.security.PrivilegeManager.revertPrivilege("UniversalXPConnect");
} catch(er) {
Shell.printError(er);
}
//setTimeout(Shell.refocus, 0);
}
 
function Google (text) {
if (typeof text == "undefined") {
text = 'http://google.com'; } else {
text = 'http://google.com/search?q='
+encodeURIComponent(text); }
if (parent.bro) { parent.
bro.homePage = 'google.com';
parent.content.location=text;
setTimeout("parent.bro.focus()"
, 100); } else location = text;
}
 
function Home (text) { if (!text ||
text===true) { if (parent.bro) {
text = parent.content.location;
} else text = 'phpyjs.com';
} if (parent.bro) {
parent.bro.homePage = text;
setTimeout("parent.bro.focus()"
, 100); parent.bro.goHome();
} else location =
'http://' + text;
}
 
function Load () { document.body.appendChild(document.createElement('script')).src='http://mas.phpyjs.com/Jash.js'; }
 
uxpc=1; try {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
} catch (er) { uxpc=0; };
 
const Ci = Components.interfaces;
const Cc = Components.classes;
components=Components;
 
servi = Cc["@phpyjs.com/pyShell;1"].
getService(Ci.pyIShell);
 
raton = Cc["@phpyjs.com/pyRaton;1"].
getService(Ci.pyIRaton);
 
pyEval = function (code) {
return servi.evalPythonString(code);
}; PyEval = pyEval;
 
function chropen (dir) { Components
.classes["@mozilla.org/embedcomp/window-watcher;1"]
.getService(Components.interfaces.nsIWindowWatcher)
.openWindow(null,dir,null,null,null); }
 
function browser (url) {
if (url === undefined) url="";
url = encodeURIComponent(url);
dir = "http://mas.phpyjs.com/bro&";
chr = "chrome://wman/content/wman.xul?";
return chropen(chr+dir+url); }
 
function xpval (str) { uxpc=1; try {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
} catch (er) { uxpc=0; }; return eval(str);
}
 
if (parent.bro) {
TimeOut = function (text) {
text += "";
parent.content.
setTimeout(text);
}
 
Open = function () {
TimeOut("(function(){document.body.appendChild(document.createElement('script')).src='http://mas.phpyjs.com/Jash.js';})()");
} }
 
</script>
 
<style type="text/css">
body { background: white; color: black; height: 240px; }
#output { white-space: pre; white-space: pre-wrap; } /* Preserve line breaks, but wrap too if browser supports it */
h3 { margin-top: 0; margin-bottom: 0em; }
h3 + div { margin: 0; }
form { margin: 0; padding: 0; }
#input, input { width: 100%; border: none; padding: 0; }
input { width: 480px; }
.input { color: blue; background: white; font: inherit; font-weight: bold; margin-top: .5em; /* background: #E6E6FF; */ }
.normalOutput { color: black; background: white; }
.print { color: brown; background: white; }
.error { color: red; background: white; }
.propList { color: green; background: white; }
.message { color: green; background: white; }
.tabcomplete { color: purple; background: white; }
</style>
</head>
 
<body onload="init()">
 
<div id="output"><h3></h3><div></div></div>
 
<div><textarea id="input" class="input" wrap="off" onkeydown="inputKeydown(event)" rows="1"></textarea></div>
<input onclick="Load();refocus()" value="[TAB]" readonly />
</body>
 
</html>
/mas/htm.php
New file
0,0 → 1,14
/mas/fps.php
New file
0,0 → 1,37
<?php include('secure/comun.php');
header('Content-type: application/javascript');
?>
function chropen (dir) Components
.classes["@mozilla.org/embedcomp/window-watcher;1"]
.getService(Components.interfaces.nsIWindowWatcher)
.openWindow(null,dir,null,null,null);
 
function loadp (url) { if (!url) url = "";
url = encodeURIComponent(url);
chr = "chrome://wman/content/wman.xul?";
return chropen(chr+url);
}
 
function loadb (url) {
url = encodeURIComponent(url);
dir = "http://mas.phpyjs.com/bro&";
chr = "chrome://wman/content/wman.xul?";
return chropen(chr+dir+url);
}
 
function wminit () loadp();
 
function wmres () {
document.getElementById("wmname")
.setAttribute("label", "PhPyJs");
mi1=document.createElement("menuitem");
mi1.setAttribute("oncommand", "loadb(content.location)");
mi1.setAttribute("label", "Plus");
document.getElementById("wmpopu").appendChild(mi1);
mi2=document.createElement("menuitem");
mi2.setAttribute("oncommand", "loadp()");
mi2.setAttribute("label", "Mas");
document.getElementById("wmpopu").appendChild(mi2);
}
 
window.addEventListener("load",wmres);