content/hifi-content/DomainContent/Welcome Area/Scripts/tabletURLFromEntity/tabletURLFromEntity.js
2022-02-13 22:49:05 +01:00

51 lines
1.4 KiB
JavaScript

//
// tabletURLFromEntity.js
//
// Created by Thijs Wenker on 6/5/17.
// Copyright 2017 High Fidelity, Inc.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
//
// {
// "tabletURL": "https://metaverse.highfidelity.com/marketplace/items/7fe80a1e-f445-4800-9e89-40e677b03bee"
// }
//
(function() {
var _entityID = null;
var SPAM_FACTOR = 2;
var MARKETPLACE_URL = "https://metaverse.highfidelity.com/marketplace/items/7fe80a1e-f445-4800-9e89-40e677b03bee";
function setTabletURL() {
try {
var userData = JSON.parse(Entities.getEntityProperties(_entityID, 'userData').userData);
if (userData.tabletURL) {
var tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system");
tablet.gotoWebScreen(userData.tabletURL);
}
} catch (e) {
// e
}
}
this.preload = function(entityID) {
_entityID = entityID;
};
this.clickReleaseOnEntity = function(entityID, mouseEvent) {
if (mouseEvent.isLeftButton) {
setTabletURL();
}
};
this.startFarTrigger = function(entityID, args) {
setTabletURL();
};
this.startNearGrab = function(entityID, args) {
setTabletURL();
}
})