mirror of
https://github.com/rxi/lovebird.git
synced 2024-11-27 12:04:21 +00:00
Added env tree view as right-panel on index page
This commit is contained in:
parent
1051c058e3
commit
127f7b46ea
76
lovebird.lua
76
lovebird.lua
@ -48,9 +48,20 @@ end
|
|||||||
form {
|
form {
|
||||||
margin-bottom: 0px;
|
margin-bottom: 0px;
|
||||||
}
|
}
|
||||||
|
a {
|
||||||
|
color: #000000;
|
||||||
|
}
|
||||||
|
a:hover {
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
.timestamp {
|
.timestamp {
|
||||||
color: #909090;
|
color: #909090;
|
||||||
}
|
}
|
||||||
|
.greybordered {
|
||||||
|
margin: 12px;
|
||||||
|
background: #F0F0F0;
|
||||||
|
border: 1px solid #E0E0E0;
|
||||||
|
}
|
||||||
#header {
|
#header {
|
||||||
background: #101010;
|
background: #101010;
|
||||||
height: 25px;
|
height: 25px;
|
||||||
@ -76,12 +87,9 @@ end
|
|||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
padding-top: 4px;
|
padding-top: 4px;
|
||||||
}
|
}
|
||||||
#content {
|
#console {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
margin: 12px;
|
top: 40px; bottom: 0px; left: 0px; right: 252px;
|
||||||
top: 40px; bottom: 0px; left: 0px; right: 0px;
|
|
||||||
background: #F0F0F0;
|
|
||||||
border: 1px solid #E0E0E0;
|
|
||||||
}
|
}
|
||||||
#input {
|
#input {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
@ -97,6 +105,17 @@ end
|
|||||||
margin: 10px;
|
margin: 10px;
|
||||||
top: 0px; bottom: 36px; left: 0px; right: 0px;
|
top: 0px; bottom: 36px; left: 0px; right: 0px;
|
||||||
}
|
}
|
||||||
|
#env {
|
||||||
|
position: absolute;
|
||||||
|
top: 40px; bottom: 0px; right: 0px;
|
||||||
|
width: 240px;
|
||||||
|
font-size: 12px;
|
||||||
|
overflow-y: scroll;
|
||||||
|
}
|
||||||
|
#envheader {
|
||||||
|
padding: 5px;
|
||||||
|
background: #E0E0E0;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
@ -107,13 +126,16 @@ end
|
|||||||
</div>
|
</div>
|
||||||
<div id="status">connected ●</div>
|
<div id="status">connected ●</div>
|
||||||
</div>
|
</div>
|
||||||
<div id="content">
|
<div id="console" class="greybordered">
|
||||||
<div id="output"> <?lua echo(lovebird.buffer) ?> </div>
|
<div id="output"> <?lua echo(lovebird.buffer) ?> </div>
|
||||||
<div id="input">
|
<div id="input">
|
||||||
<form method="post">
|
<form method="post">
|
||||||
<input id="inputbox" name="input" type="text"></input>
|
<input id="inputbox" name="input" type="text"></input>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
<div id="env" class="greybordered">
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<script>
|
<script>
|
||||||
document.getElementById("inputbox").focus();
|
document.getElementById("inputbox").focus();
|
||||||
@ -132,12 +154,13 @@ end
|
|||||||
req.onreadystatechange = function() {
|
req.onreadystatechange = function() {
|
||||||
if (req.readyState != 4) return;
|
if (req.readyState != 4) return;
|
||||||
if (req.status == 200) {
|
if (req.status == 200) {
|
||||||
onComplete(req.responseText)
|
if (onComplete) onComplete(req.responseText);
|
||||||
} else {
|
} else {
|
||||||
onFail(req.responseText)
|
if (onFail) onFail(req.responseText);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
req.open("GET", url + "?_=" + Math.random(), true);
|
url += (url.indexOf("?") > -1 ? "&_=" : "?_=") + Math.random();
|
||||||
|
req.open("GET", url, true);
|
||||||
req.send();
|
req.send();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -149,9 +172,8 @@ end
|
|||||||
scrolloutput()
|
scrolloutput()
|
||||||
|
|
||||||
/* Refresh output buffer and status */
|
/* Refresh output buffer and status */
|
||||||
var refresh = function() {
|
var refreshOutput = function() {
|
||||||
getPage("/buffer",
|
getPage("/buffer", function(text) {
|
||||||
function(text) {
|
|
||||||
updateDivContent("status", "connected ●");
|
updateDivContent("status", "connected ●");
|
||||||
if (updateDivContent("output", text)) {
|
if (updateDivContent("output", text)) {
|
||||||
scrolloutput();
|
scrolloutput();
|
||||||
@ -159,10 +181,19 @@ end
|
|||||||
},
|
},
|
||||||
function(text) {
|
function(text) {
|
||||||
updateDivContent("status", "disconnected ○");
|
updateDivContent("status", "disconnected ○");
|
||||||
|
});
|
||||||
}
|
}
|
||||||
);
|
setInterval(refreshOutput, <?lua echo(lovebird.refreshrate) ?> * 1000);
|
||||||
|
|
||||||
|
/* Refresh env view */
|
||||||
|
var envPath = "";
|
||||||
|
var refreshEnv = function() {
|
||||||
|
getPage("/tree?p=" + envPath, function(text) {
|
||||||
|
updateDivContent("env", text);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
setInterval(refresh, <?lua echo(lovebird.refreshrate) ?> * 1000);
|
var onTreeLink = function(p) { envPath = p; refreshEnv(); }
|
||||||
|
setInterval(refreshEnv, <?lua echo(lovebird.refreshrate) ?> * 1000);
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
@ -183,6 +214,18 @@ lovebird.pages["tree"] = [[
|
|||||||
end
|
end
|
||||||
?>
|
?>
|
||||||
|
|
||||||
|
<div id="envheader">
|
||||||
|
<a href="#" onclick="onTreeLink('')">root</a>
|
||||||
|
<?lua local acc = "" ?>
|
||||||
|
<?lua for x in p:gmatch("[^%.]+") do ?>
|
||||||
|
<?lua acc = acc .. "." .. x ?>
|
||||||
|
.
|
||||||
|
<a href="#" onclick="onTreeLink('<?lua echo(acc)?>')">
|
||||||
|
<?lua echo(x) ?>
|
||||||
|
</a>
|
||||||
|
<?lua end ?>
|
||||||
|
</div>
|
||||||
|
|
||||||
<table>
|
<table>
|
||||||
<?lua
|
<?lua
|
||||||
local keys = {}
|
local keys = {}
|
||||||
@ -191,11 +234,12 @@ lovebird.pages["tree"] = [[
|
|||||||
for _, k in pairs(keys) do
|
for _, k in pairs(keys) do
|
||||||
local v = t[k]
|
local v = t[k]
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
<td>
|
||||||
<?lua if type(v) == "table" then ?>
|
<?lua if type(v) == "table" then ?>
|
||||||
<a href="<?lua echo("?p="..p.."."..k) ?>"> <?lua echo(k) ?> </a>
|
<a href="#" onclick="onTreeLink('<?lua echo(p.."."..k)?>')">
|
||||||
|
<?lua echo(k) ?>
|
||||||
|
</a>
|
||||||
<?lua else ?>
|
<?lua else ?>
|
||||||
<?lua echo(k) ?>
|
<?lua echo(k) ?>
|
||||||
<?lua end ?>
|
<?lua end ?>
|
||||||
|
Loading…
Reference in New Issue
Block a user