Update entities list as search radius value is changed

This commit is contained in:
David Rowe 2015-08-27 11:11:05 -07:00
parent d628a88f52
commit a553022adf
2 changed files with 16 additions and 2 deletions

View file

@ -20,7 +20,9 @@
elRefresh = document.getElementById("refresh");
elDelete = document.getElementById("delete");
elTeleport = document.getElementById("teleport");
elRadius = document.getElementById("radius");
elNoEntitiesMessage = document.getElementById("no-entities");
elNoEntitiesRadius = document.getElementById("no-entities-radius");
document.getElementById("entity-name").onclick = function() {
setSortColumn('name');
@ -186,6 +188,13 @@
}
}, false);
elRadius.onchange = function () {
elRadius.value = Math.max(elRadius.value, 0);
EventBridge.emitWebEvent(JSON.stringify({ type: 'radius', radius: elRadius.value }));
refreshEntities();
elNoEntitiesRadius.firstChild.nodeValue = elRadius.value;
}
if (window.EventBridge !== undefined) {
EventBridge.scriptEventReceived.connect(function(data) {
data = JSON.parse(data);
@ -247,7 +256,7 @@
</table>
</div>
<div id="no-entities">
No entities found within 50 meter radius. Try moving to a different location and refreshing.
No entities found within a <span id="no-entities-radius">50</span> meter radius. Try moving to a different location and refreshing.
</div>
</body>
</html>

View file

@ -4,6 +4,8 @@ EntityListTool = function(opts) {
var url = Script.resolvePath('html/entityList.html');
var webView = new WebWindow('Entities', url, 200, 280, true);
var searchDiameter = 100;
var visible = false;
webView.setVisible(visible);
@ -33,7 +35,7 @@ EntityListTool = function(opts) {
that.sendUpdate = function() {
var entities = [];
var ids = Entities.findEntities(MyAvatar.position, 100);
var ids = Entities.findEntities(MyAvatar.position, searchDiameter);
for (var i = 0; i < ids.length; i++) {
var id = ids[i];
var properties = Entities.getEntityProperties(id);
@ -80,6 +82,9 @@ EntityListTool = function(opts) {
}
} else if (data.type == "delete") {
deleteSelectedEntities();
} else if (data.type === "radius") {
searchDiameter = 2 * data.radius;
that.sendUpdate();
}
});