3 keys in each row

This commit is contained in:
yamanq 2016-04-21 21:05:32 -04:00
parent 156f6cfcfe
commit 063d599a80

View File

@ -39,6 +39,8 @@ function createTable() {
} }
function keyLegend() { function keyLegend() {
var rowlength = 3;
// Get theme // Get theme
var theme = settings["displayTheme"]; var theme = settings["displayTheme"];
var index = choices[1].indexOf(theme); var index = choices[1].indexOf(theme);
@ -47,16 +49,20 @@ function keyLegend() {
// id for CSS // id for CSS
tbl.id = "keylegend"; tbl.id = "keylegend";
for (var i = 0; i < Object.keys(keyColors[index]).length; i++) { for (var i = 0; i < Object.keys(keyColors[index]).length; i+=rowlength) {
var tr = tbl.insertRow(); var tr = tbl.insertRow();
var keycolor = tr.insertCell(); for (var x = 0; x < rowlength; x++) {
keycolor.className = "keycolor"; if ((i + x) < Object.keys(keyColors[index]).length) {
keycolor.style.backgroundColor = keyColors[index][Object.keys(keyColors[index])[i]]; var keycolor = tr.insertCell();
keycolor.className = "keycolor";
keycolor.style.backgroundColor = keyColors[index][Object.keys(keyColors[index])[i + x]];
var keyname = tr.insertCell(); var keyname = tr.insertCell();
keyvalue = document.createTextNode(Object.keys(keyColors[index])[i]); keyvalue = document.createTextNode(Object.keys(keyColors[index])[i + x]);
keyname.appendChild(keyvalue); keyname.appendChild(keyvalue);
keyname.className = "keyvalue"; keyname.className = "keyvalue";
}
}
}; };
get("key").appendChild(tbl); get("key").appendChild(tbl);