mirror of
https://github.com/rxi/lovebird.git
synced 2024-11-27 12:04:21 +00:00
Added support for numerical table keys to env vars browser
This commit is contained in:
parent
7826ec0a13
commit
09203d201e
@ -238,14 +238,15 @@ end
|
|||||||
var html = "<table>";
|
var html = "<table>";
|
||||||
for (var i = 0; json.vars[i]; i++) {
|
for (var i = 0; json.vars[i]; i++) {
|
||||||
var x = json.vars[i];
|
var x = json.vars[i];
|
||||||
var fullpath = (json.path + "." + x.key).replace(/^\./, "");
|
var fullpath = (json.path + "." + x.key) .replace(/^\./, "");
|
||||||
var k = truncate(x.key, 15);
|
var k = truncate(x.key, 15);
|
||||||
if (x.type == "table") {
|
if (x.type == "table") {
|
||||||
k = "<a href='#' onclick=\"setEnvPath('" + fullpath + "')\">" +
|
k = "<a href='#' onclick=\"setEnvPath('" + fullpath + "')\">" +
|
||||||
k + "</a>";
|
k + "</a>";
|
||||||
}
|
}
|
||||||
var v = "<a href='#' onclick=\"insertVar('" + fullpath + "');\">" +
|
var v = "<a href='#' onclick=\"insertVar('" +
|
||||||
x.value + "</a>"
|
fullpath.replace(/\.(-?[0-9])+/g, "[$1]") +
|
||||||
|
"');\">" + x.value + "</a>"
|
||||||
html += "<tr><td>" + k + "</td><td>" + v + "</td></tr>";
|
html += "<tr><td>" + k + "</td><td>" + v + "</td></tr>";
|
||||||
}
|
}
|
||||||
html += "</table>";
|
html += "</table>";
|
||||||
@ -278,7 +279,7 @@ lovebird.pages["env.json"] = [[
|
|||||||
p = p:gsub("%.+", "%."):match("^[%.]*(.*)[%.]*$")
|
p = p:gsub("%.+", "%."):match("^[%.]*(.*)[%.]*$")
|
||||||
if p ~= "" then
|
if p ~= "" then
|
||||||
for x in p:gmatch("[^%.]+") do
|
for x in p:gmatch("[^%.]+") do
|
||||||
t = t[x]
|
t = t[x] or t[tonumber(x)]
|
||||||
-- Return early if path does not exist
|
-- Return early if path does not exist
|
||||||
if type(t) ~= "table" then
|
if type(t) ~= "table" then
|
||||||
echo('{ "valid": false, "path": ' .. string.format("%q", p) .. ' }')
|
echo('{ "valid": false, "path": ' .. string.format("%q", p) .. ' }')
|
||||||
|
Loading…
Reference in New Issue
Block a user