From d3a6a411fb74d6acdedf1e515f838564a77b1068 Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Fri, 16 Jan 2015 16:23:29 -0800 Subject: [PATCH] Update entity list to use list.js more directly --- examples/html/entityList.html | 61 ++++++++++++++++------------------- examples/html/style.css | 16 ++++----- 2 files changed, 33 insertions(+), 44 deletions(-) diff --git a/examples/html/entityList.html b/examples/html/entityList.html index 26a302cb41..6c9846f5e4 100644 --- a/examples/html/entityList.html +++ b/examples/html/entityList.html @@ -1,4 +1,3 @@ - @@ -14,6 +13,8 @@ var DESC_STRING = ' ▴'; function loaded() { + entityList = new List('entity-list', { valueNames: ['type', 'url']}); + entityList.clear(); elEntityTable = document.getElementById("entity-table"); elEntityTableBody = document.getElementById("entity-table-body"); elRefresh = document.getElementById("refresh"); @@ -37,7 +38,8 @@ selectedEntities = selection; - entities[id].el.className = 'selected'; + this.className = 'selected'; + EventBridge.emitWebEvent(JSON.stringify({ type: "selectionUpdate", focus: false, @@ -46,8 +48,6 @@ } function onRowDoubleClicked() { - var id = this.dataset.entityId; - EventBridge.emitWebEvent(JSON.stringify({ type: "selectionUpdate", focus: true, @@ -60,21 +60,21 @@ var urlParts = url.split('/'); var filename = urlParts[urlParts.length - 1]; - var el = document.createElement('tr'); - el.setAttribute('id', 'entity_' + id); - el.innerHTML += "" + type + ""; - el.innerHTML += "
" + filename + "
"; - el.dataset.entityId = id; - el.onclick = onRowClicked; - el.ondblclick = onRowDoubleClicked; - elEntityTableBody.appendChild(el); - - // Add element to local dict - entities[id] = { - id: id, - name: id, - el: el, - }; + entityList.add([{ id: id, type: type, url: filename }], function(items) { + var el = items[0].elm; + var id = items[0]._values.id; + entities[id] = { + id: id, + name: id, + el: el, + }; + el.setAttribute('id', 'entity_' + id); + el.setAttribute('title', url); + el.dataset.entityId = id; + el.onclick = onRowClicked; + el.ondblclick = onRowDoubleClicked; + el.innerHTML + }); if (refreshEntityListTimer) { clearTimeout(refreshEntityListTimer); @@ -91,10 +91,8 @@ } function clearEntities() { - for (id in entities) { - elEntityTableBody.removeChild(entities[id].el); - } entities = {}; + entityList.clear(); } var elSortOrder = { @@ -122,7 +120,6 @@ function refreshEntityListObject() { refreshEntityListTimer = null; - entityList = new List('entity-list', { valueNames: ['type', 'url']}); entityList.sort(currentSortColumn, { order: currentSortOrder }); entityList.search(document.getElementById("filter").value); } @@ -174,15 +171,6 @@ } }); } - - // var _id = 0; - // setInterval(function() { - // for(var i = 0; i < 2; i++) { - // addEntity(_id, ['Model', 'Light'][i], 'http' + _id); - // _id++; - // } - // }, 5000); - setTimeout(refreshEntities, 1); } @@ -198,11 +186,16 @@ - - + + + + + + +
Type  ▾URL Type  ▾URL
Type
URL
diff --git a/examples/html/style.css b/examples/html/style.css index 42cf37d34a..ad78d0234c 100644 --- a/examples/html/style.css +++ b/examples/html/style.css @@ -5,9 +5,10 @@ body { margin: 0; padding: 0; - background-color: #efefef; + background-color: rgb(76, 76, 76); + color: rgb(204, 204, 204); font-family: Arial; - font-size: 11.5px; + font-size: 11px; -webkit-touch-callout: none; -webkit-user-select: none; @@ -17,12 +18,6 @@ body { user-select: none; } -body.properties { - background-color: rgb(76, 76, 76); - color: rgb(204, 204, 204); - font-size: 11px; -} - .selectable { -webkit-touch-callout: text; -webkit-user-select: text; @@ -117,13 +112,13 @@ input.coord { table#entity-table { border-collapse: collapse; font-family: Sans-Serif; - /* font-size: 12px; */ + font-size: 10px; width: 100%; } #entity-table tr { cursor: pointer; - border-bottom: 1px solid #e5e5e5; + border-bottom: 1px solid rgb(63, 63, 63) } #entity-table tr.selected { @@ -140,6 +135,7 @@ table#entity-table { } #entity-table td { + font-size: 11px; border: 0px black solid; word-wrap: nowrap; white-space: nowrap;