From fc1e5885888a84525613f50899446d456f5dfb71 Mon Sep 17 00:00:00 2001 From: Faye Li Date: Wed, 1 Feb 2017 10:34:54 -0800 Subject: [PATCH] sending and recieving jump to event --- scripts/system/html/users.html | 12 +++++++++++- scripts/system/users.js | 31 ++++++++++++++++++++++++++++--- 2 files changed, 39 insertions(+), 4 deletions(-) diff --git a/scripts/system/html/users.html b/scripts/system/html/users.html index 98c3db38c7..f3e1a96309 100644 --- a/scripts/system/html/users.html +++ b/scripts/system/html/users.html @@ -217,7 +217,7 @@ @@ -328,6 +328,16 @@ modal.find(".modal-title").text("Jump to " + username + " @ " + placename); }) + $("#jump-to-confirm-button").click(function() { + var jumpToObject = { + "type": "jump-to", + "data": { + "username": "Alan_" + } + } + EventBridge.emitWebEvent(JSON.stringify(jumpToObject)); + }); + // Listen for events from hifi EventBridge.scriptEventReceived.connect(onScriptEventReceived); diff --git a/scripts/system/users.js b/scripts/system/users.js index 7930892395..b952795570 100644 --- a/scripts/system/users.js +++ b/scripts/system/users.js @@ -12,10 +12,26 @@ (function() { // BEGIN LOCAL_SCOPE var USERS_URL = "https://hifi-content.s3.amazonaws.com/faye/tablet-dev/users.html"; + var FRIENDS_WINDOW_URL = "https://metaverse.highfidelity.com/user/friends"; var FRIENDS_WINDOW_WIDTH = 290; var FRIENDS_WINDOW_HEIGHT = 500; var FRIENDS_WINDOW_TITLE = "Add/Remove Friends"; + + // Initialise visibility based on global service + var VISIBILITY_VALUES_SET = {}; + VISIBILITY_VALUES_SET["all"] = true; + VISIBILITY_VALUES_SET["friends"] = true; + VISIBILITY_VALUES_SET["none"] = true; + var myVisibility; + if (GlobalServices.findableBy in VISIBILITY_VALUES_SET) { + myVisibility = GlobalServices.findableBy; + } else { + // default to friends if it can't be determined + myVisibility = "friends"; + GlobalServices.findableBy = myVisibilty; + } + var tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system"); var button = tablet.addButton({ icon: "icons/tablet-icons/people-i.svg", @@ -35,10 +51,13 @@ // send username to html var myUsername = GlobalServices.username; var object = { - "type": "sendUsername", - "data": {"username": myUsername} + "type": "user-info", + "data": { + "username": myUsername, + "visibility": myVisibility + } }; - print("sending username: " + myUsername); + print("sending user info: " + JSON.stringify(object)); tablet.emitScriptEvent(JSON.stringify(object)); } if (event.type === "manage-friends") { @@ -53,6 +72,12 @@ friendsWindow.setVisible(true); friendsWindow.raise(); } + if (event.type === "jump-to") { + if (typeof event.data.username !== undefined) { + // teleport to selected user from the online users list + location.goToUser(event.data.username); + } + } } button.clicked.connect(onClicked);