Added support for numerical table keys to env vars browser

This commit is contained in:
rxi 2014-04-12 21:01:30 +01:00
parent 7826ec0a13
commit 09203d201e

View File

@ -244,8 +244,9 @@ end
k = "<a href='#' onclick=\"setEnvPath('" + fullpath + "')\">" +
k + "</a>";
}
var v = "<a href='#' onclick=\"insertVar('" + fullpath + "');\">" +
x.value + "</a>"
var v = "<a href='#' onclick=\"insertVar('" +
fullpath.replace(/\.(-?[0-9])+/g, "[$1]") +
"');\">" + x.value + "</a>"
html += "<tr><td>" + k + "</td><td>" + v + "</td></tr>";
}
html += "</table>";
@ -278,7 +279,7 @@ lovebird.pages["env.json"] = [[
p = p:gsub("%.+", "%."):match("^[%.]*(.*)[%.]*$")
if p ~= "" then
for x in p:gmatch("[^%.]+") do
t = t[x]
t = t[x] or t[tonumber(x)]
-- Return early if path does not exist
if type(t) ~= "table" then
echo('{ "valid": false, "path": ' .. string.format("%q", p) .. ' }')