sending and recieving jump to event

This commit is contained in:
Faye Li 2017-02-01 10:34:54 -08:00
parent 59aea60be0
commit fc1e588588
2 changed files with 39 additions and 4 deletions

View file

@ -217,7 +217,7 @@
</div>
<div class="modal-footer">
<input type="button" data-dismiss="modal" value="Cancel">
<input type="button" data-dismiss="modal" value="OK">
<input type="button" data-dismiss="modal" id="jump-to-confirm-button" value="OK">
</div>
</div>
</div>
@ -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);

View file

@ -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);