Added javascript truncation to long env keys

This commit is contained in:
rxi 2014-04-12 19:54:50 +01:00
parent c47412b846
commit 24328d5adb

View File

@ -158,13 +158,9 @@ end
<script>
document.getElementById("inputbox").focus();
var updateDivContent = function(id, content) {
var div = document.getElementById(id);
if (div.innerHTML != content) {
div.innerHTML = content;
return true;
}
return false;
var truncate = function(str, len) {
if (str.length <= len) return str;
return str.substring(0, len - 3) + "...";
}
var geturl = function(url, onComplete, onFail) {
@ -182,6 +178,15 @@ end
req.send();
}
var updateDivContent = function(id, content) {
var div = document.getElementById(id);
if (div.innerHTML != content) {
div.innerHTML = content;
return true;
}
return false;
}
var onInputSubmit = function() {
var b = document.getElementById("inputbox");
var req = new XMLHttpRequest();
@ -219,7 +224,7 @@ end
for (var i = 0; i < p.length; i++) {
acc += "." + p[i];
html += " <a href='#' onclick=\"setEnvPath('" + acc + "')\">" +
p[i] + "</a>";
truncate(p[i], 10) + "</a>";
}
updateDivContent("envheader", html);
@ -234,7 +239,7 @@ end
for (var i = 0; json.vars[i]; i++) {
var x = json.vars[i];
var fullpath = (json.path + "." + x.key).replace(/^\./, "");
var k = x.key;
var k = truncate(x.key, 15);
if (x.type == "table") {
k = "<a href='#' onclick=\"setEnvPath('" + fullpath + "')\">" +
k + "</a>";
@ -377,7 +382,7 @@ end
function lovebird.truncate(str, len)
if #str < len then
if #str <= len then
return str
end
return str:sub(1, len - 3) .. "..."