mirror of
https://github.com/lubosz/overte.git
synced 2025-04-09 13:12:57 +02:00
Merge pull request #13987 from zfox23/discovery_appUi
Discovery Notifications Project Checkpoint: Discovery apps now use AppUI module; PEOPLE app notifications
This commit is contained in:
commit
3b1e0dc7d9
14 changed files with 2251 additions and 2193 deletions
83
interface/resources/icons/tablet-icons/people-a-msg.svg
Normal file
83
interface/resources/icons/tablet-icons/people-a-msg.svg
Normal file
|
@ -0,0 +1,83 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Generator: Adobe Illustrator 19.2.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||
|
||||
<svg
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
version="1.1"
|
||||
x="0px"
|
||||
y="0px"
|
||||
viewBox="0 0 50 50"
|
||||
style="enable-background:new 0 0 50 50;"
|
||||
xml:space="preserve"
|
||||
id="svg2"
|
||||
inkscape:version="0.91 r13725"
|
||||
sodipodi:docname="people-a.svg"><metadata
|
||||
id="metadata24"><rdf:RDF><cc:Work
|
||||
rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title></dc:title></cc:Work></rdf:RDF></metadata><defs
|
||||
id="defs22" /><sodipodi:namedview
|
||||
pagecolor="#ff0000"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1"
|
||||
objecttolerance="10"
|
||||
gridtolerance="10"
|
||||
guidetolerance="10"
|
||||
inkscape:pageopacity="0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:window-width="852"
|
||||
inkscape:window-height="480"
|
||||
id="namedview20"
|
||||
showgrid="false"
|
||||
inkscape:zoom="4.72"
|
||||
inkscape:cx="25"
|
||||
inkscape:cy="25"
|
||||
inkscape:window-x="0"
|
||||
inkscape:window-y="0"
|
||||
inkscape:window-maximized="0"
|
||||
inkscape:current-layer="svg2" /><style
|
||||
type="text/css"
|
||||
id="style4">
|
||||
.st0{fill:#FFFFFF;}
|
||||
.st1{fill:#EF3B4E;}
|
||||
</style>
|
||||
<circle class="st1" cx="44.1" cy="6" r="5.6"/>
|
||||
<g
|
||||
id="Layer_2" /><g
|
||||
id="Layer_1"
|
||||
style="fill:#000000;fill-opacity:1"><circle
|
||||
class="st0"
|
||||
cx="25.6"
|
||||
cy="14.8"
|
||||
r="8.1"
|
||||
id="circle8"
|
||||
style="fill:#000000;fill-opacity:1" /><path
|
||||
class="st0"
|
||||
d="M31.4,27h-11c-4.6,0-8.2,3.9-8.2,8.5v4.3c3.8,2.8,8.1,4.5,13.1,4.5c5.6,0,10.6-2.1,14.4-5.6v-3.2 C39.6,30.9,35.9,27,31.4,27z"
|
||||
id="path10"
|
||||
style="fill:#000000;fill-opacity:1" /><circle
|
||||
class="st0"
|
||||
cx="41.6"
|
||||
cy="17.1"
|
||||
r="3.5"
|
||||
id="circle12"
|
||||
style="fill:#000000;fill-opacity:1" /><path
|
||||
class="st0"
|
||||
d="M43.9,23.9h-4.1c-0.9,0-1.7,0.4-2.3,1c1.2,0.6,2.3,1.6,3.1,2.5c1,1.2,1.5,2.7,1.7,4.3c0.3,0.9,0.4,1.8,0.2,2.8 v0.6c1.6-2.2,3.3-6,4-8.1v-0.3C46.5,25.7,45.3,23.9,43.9,23.9z"
|
||||
id="path14"
|
||||
style="fill:#000000;fill-opacity:1" /><circle
|
||||
class="st0"
|
||||
cx="9.4"
|
||||
cy="18"
|
||||
r="3.5"
|
||||
id="circle16"
|
||||
style="fill:#000000;fill-opacity:1" /><path
|
||||
class="st0"
|
||||
d="M8.5,35.7c-0.1-0.7-0.1-1.4,0-2.1l0.1-0.2c0-0.2,0-0.4,0-0.6c0-0.2,0-0.3,0.1-0.5c0-0.2,0-0.3,0-0.5 c0.2-2.1,1.6-4.4,3.2-5.7c0.4-0.4,0.9-0.6,1.4-0.9c-0.5-0.5-1.3-0.7-2-0.7H7c-1.4,0-2.6,1.8-2.4,2.7v0.3 C5.1,29.8,6.8,33.5,8.5,35.7z"
|
||||
id="path18"
|
||||
style="fill:#000000;fill-opacity:1" /></g></svg>
|
After Width: | Height: | Size: 2.9 KiB |
24
interface/resources/icons/tablet-icons/people-i-msg.svg
Normal file
24
interface/resources/icons/tablet-icons/people-i-msg.svg
Normal file
|
@ -0,0 +1,24 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Generator: Adobe Illustrator 19.2.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
||||
viewBox="0 0 50 50" style="enable-background:new 0 0 50 50;" xml:space="preserve">
|
||||
<style type="text/css">
|
||||
.st0{fill:#FFFFFF;}
|
||||
.st1{fill:#EF3B4E;}
|
||||
</style>
|
||||
<circle class="st1" cx="44.1" cy="6" r="5.6"/>
|
||||
<g id="Layer_2">
|
||||
</g>
|
||||
<g id="Layer_1">
|
||||
<circle class="st0" cx="25.6" cy="14.8" r="8.1"/>
|
||||
<path class="st0" d="M31.4,27h-11c-4.6,0-8.2,3.9-8.2,8.5v4.3c3.8,2.8,8.1,4.5,13.1,4.5c5.6,0,10.6-2.1,14.4-5.6v-3.2
|
||||
C39.6,30.9,35.9,27,31.4,27z"/>
|
||||
<circle class="st0" cx="41.6" cy="17.1" r="3.5"/>
|
||||
<path class="st0" d="M43.9,23.9h-4.1c-0.9,0-1.7,0.4-2.3,1c1.2,0.6,2.3,1.6,3.1,2.5c1,1.2,1.5,2.7,1.7,4.3c0.3,0.9,0.4,1.8,0.2,2.8
|
||||
v0.6c1.6-2.2,3.3-6,4-8.1v-0.3C46.5,25.7,45.3,23.9,43.9,23.9z"/>
|
||||
<circle class="st0" cx="9.4" cy="18" r="3.5"/>
|
||||
<path class="st0" d="M8.5,35.7c-0.1-0.7-0.1-1.4,0-2.1l0.1-0.2c0-0.2,0-0.4,0-0.6c0-0.2,0-0.3,0.1-0.5c0-0.2,0-0.3,0-0.5
|
||||
c0.2-2.1,1.6-4.4,3.2-5.7c0.4-0.4,0.9-0.6,1.4-0.9c-0.5-0.5-1.3-0.7-2-0.7H7c-1.4,0-2.6,1.8-2.4,2.7v0.3
|
||||
C5.1,29.8,6.8,33.5,8.5,35.7z"/>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 1.2 KiB |
|
@ -271,6 +271,8 @@ Rectangle {
|
|||
connectionsUserModel.getFirstPage();
|
||||
}
|
||||
activeTab = "connectionsTab";
|
||||
connectionsOnlineDot.visible = false;
|
||||
pal.sendToScript({method: 'hideNotificationDot'});
|
||||
connectionsHelpText.color = hifi.colors.blueAccent;
|
||||
}
|
||||
}
|
||||
|
@ -298,6 +300,16 @@ Rectangle {
|
|||
}
|
||||
}
|
||||
}
|
||||
Rectangle {
|
||||
id: connectionsOnlineDot;
|
||||
visible: false;
|
||||
width: 10;
|
||||
height: width;
|
||||
radius: width;
|
||||
color: "#EF3B4E"
|
||||
anchors.left: parent.left;
|
||||
anchors.verticalCenter: parent.verticalCenter;
|
||||
}
|
||||
// "CONNECTIONS" text
|
||||
RalewaySemiBold {
|
||||
id: connectionsTabSelectorText;
|
||||
|
@ -305,7 +317,11 @@ Rectangle {
|
|||
// Text size
|
||||
size: hifi.fontSizes.tabularData;
|
||||
// Anchors
|
||||
anchors.fill: parent;
|
||||
anchors.left: connectionsOnlineDot.visible ? connectionsOnlineDot.right : parent.left;
|
||||
anchors.leftMargin: connectionsOnlineDot.visible ? 4 : 0;
|
||||
anchors.top: parent.top;
|
||||
anchors.bottom: parent.bottom;
|
||||
anchors.right: parent.right;
|
||||
// Style
|
||||
font.capitalization: Font.AllUppercase;
|
||||
color: activeTab === "connectionsTab" ? hifi.colors.blueAccent : hifi.colors.baseGray;
|
||||
|
@ -326,7 +342,7 @@ Rectangle {
|
|||
anchors.left: connectionsTabSelectorTextContainer.left;
|
||||
anchors.top: connectionsTabSelectorTextContainer.top;
|
||||
anchors.topMargin: 1;
|
||||
anchors.leftMargin: connectionsTabSelectorTextMetrics.width + 42;
|
||||
anchors.leftMargin: connectionsTabSelectorTextMetrics.width + 42 + connectionsOnlineDot.width + connectionsTabSelectorText.anchors.leftMargin;
|
||||
RalewayRegular {
|
||||
id: connectionsHelpText;
|
||||
text: "[?]";
|
||||
|
@ -1267,6 +1283,9 @@ Rectangle {
|
|||
case 'http.response':
|
||||
http.handleHttpResponse(message);
|
||||
break;
|
||||
case 'changeConnectionsDotStatus':
|
||||
connectionsOnlineDot.visible = message.shouldShowDot;
|
||||
break;
|
||||
default:
|
||||
console.log('Unrecognized message:', JSON.stringify(message));
|
||||
}
|
||||
|
|
|
@ -408,9 +408,7 @@ Rectangle {
|
|||
|
||||
Connections {
|
||||
onSendSignalToWallet: {
|
||||
if (msg.method === 'walletReset' || msg.method === 'passphraseReset') {
|
||||
sendToScript(msg);
|
||||
} else if (msg.method === 'walletSecurity_changeSecurityImage') {
|
||||
if (msg.method === 'walletSecurity_changeSecurityImage') {
|
||||
securityImageChange.initModel();
|
||||
root.activeView = "securityImageChange";
|
||||
}
|
||||
|
|
|
@ -252,12 +252,6 @@ bool ContextOverlayInterface::destroyContextOverlay(const EntityItemID& entityIt
|
|||
void ContextOverlayInterface::contextOverlays_mousePressOnOverlay(const OverlayID& overlayID, const PointerEvent& event) {
|
||||
if (overlayID == _contextOverlayID && event.getButton() == PointerEvent::PrimaryButton) {
|
||||
qCDebug(context_overlay) << "Clicked Context Overlay. Entity ID:" << _currentEntityWithContextOverlay << "Overlay ID:" << overlayID;
|
||||
Setting::Handle<bool> _settingSwitch{ "commerce", true };
|
||||
if (_settingSwitch.get()) {
|
||||
openInspectionCertificate();
|
||||
} else {
|
||||
openMarketplace();
|
||||
}
|
||||
emit contextOverlayClicked(_currentEntityWithContextOverlay);
|
||||
_contextOverlayJustClicked = true;
|
||||
}
|
||||
|
@ -390,34 +384,6 @@ void ContextOverlayInterface::requestOwnershipVerification(const QUuid& entityID
|
|||
}
|
||||
}
|
||||
|
||||
static const QString INSPECTION_CERTIFICATE_QML_PATH = "hifi/commerce/inspectionCertificate/InspectionCertificate.qml";
|
||||
void ContextOverlayInterface::openInspectionCertificate() {
|
||||
// lets open the tablet to the inspection certificate QML
|
||||
if (!_currentEntityWithContextOverlay.isNull() && _entityMarketplaceID.length() > 0) {
|
||||
setLastInspectedEntity(_currentEntityWithContextOverlay);
|
||||
auto tablet = dynamic_cast<TabletProxy*>(_tabletScriptingInterface->getTablet("com.highfidelity.interface.tablet.system"));
|
||||
tablet->loadQMLSource(INSPECTION_CERTIFICATE_QML_PATH);
|
||||
_hmdScriptingInterface->openTablet();
|
||||
}
|
||||
}
|
||||
|
||||
static const QString MARKETPLACE_BASE_URL = NetworkingConstants::METAVERSE_SERVER_URL().toString() + "/marketplace/items/";
|
||||
|
||||
void ContextOverlayInterface::openMarketplace() {
|
||||
// lets open the tablet and go to the current item in
|
||||
// the marketplace (if the current entity has a
|
||||
// marketplaceID)
|
||||
if (!_currentEntityWithContextOverlay.isNull() && _entityMarketplaceID.length() > 0) {
|
||||
auto tablet = dynamic_cast<TabletProxy*>(_tabletScriptingInterface->getTablet("com.highfidelity.interface.tablet.system"));
|
||||
// construct the url to the marketplace item
|
||||
QString url = MARKETPLACE_BASE_URL + _entityMarketplaceID;
|
||||
QString MARKETPLACES_INJECT_SCRIPT_PATH = "file:///" + qApp->applicationDirPath() + "/scripts/system/html/js/marketplacesInject.js";
|
||||
tablet->gotoWebScreen(url, MARKETPLACES_INJECT_SCRIPT_PATH);
|
||||
_hmdScriptingInterface->openTablet();
|
||||
_isInMarketplaceInspectionMode = true;
|
||||
}
|
||||
}
|
||||
|
||||
void ContextOverlayInterface::enableEntityHighlight(const EntityItemID& entityItemID) {
|
||||
_selectionScriptingInterface->addToSelectedItemsList("contextOverlayHighlightList", "entity", entityItemID);
|
||||
}
|
||||
|
|
|
@ -94,8 +94,6 @@ private:
|
|||
|
||||
bool _isInMarketplaceInspectionMode { false };
|
||||
|
||||
void openInspectionCertificate();
|
||||
void openMarketplace();
|
||||
void enableEntityHighlight(const EntityItemID& entityItemID);
|
||||
void disableEntityHighlight(const EntityItemID& entityItemID);
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
"use strict";
|
||||
/*global Tablet, Script*/
|
||||
/* global Tablet, Script */
|
||||
//
|
||||
// libraries/appUi.js
|
||||
//
|
||||
|
@ -11,6 +11,7 @@
|
|||
//
|
||||
|
||||
function AppUi(properties) {
|
||||
var request = Script.require('request').request;
|
||||
/* Example development order:
|
||||
1. var AppUi = Script.require('appUi');
|
||||
2. Put appname-i.svg, appname-a.svg in graphicsDirectory (where non-default graphicsDirectory can be added in #3).
|
||||
|
@ -31,37 +32,63 @@ function AppUi(properties) {
|
|||
var that = this;
|
||||
function defaultButton(name, suffix) {
|
||||
var base = that[name] || (that.buttonPrefix + suffix);
|
||||
that[name] = (base.indexOf('/') >= 0) ? base : (that.graphicsDirectory + base); //poor man's merge
|
||||
that[name] = (base.indexOf('/') >= 0) ? base : (that.graphicsDirectory + base); // poor man's merge
|
||||
}
|
||||
|
||||
// Defaults:
|
||||
that.tabletName = "com.highfidelity.interface.tablet.system";
|
||||
that.inject = "";
|
||||
that.graphicsDirectory = "icons/tablet-icons/"; // Where to look for button svgs. See below.
|
||||
that.additionalAppScreens = [];
|
||||
that.checkIsOpen = function checkIsOpen(type, tabletUrl) { // Are we active? Value used to set isOpen.
|
||||
return (type === that.type) && that.currentUrl && (tabletUrl.indexOf(that.currentUrl) >= 0); // Actual url may have prefix or suffix.
|
||||
// Actual url may have prefix or suffix.
|
||||
return (type === that.currentVisibleScreenType) &&
|
||||
that.currentVisibleUrl &&
|
||||
((that.home.indexOf(that.currentVisibleUrl) > -1) ||
|
||||
(that.additionalAppScreens.indexOf(that.currentVisibleUrl) > -1));
|
||||
};
|
||||
that.setCurrentData = function setCurrentData(url) {
|
||||
that.currentUrl = url;
|
||||
that.type = /.qml$/.test(url) ? 'QML' : 'Web';
|
||||
}
|
||||
that.open = function open(optionalUrl) { // How to open the app.
|
||||
that.setCurrentVisibleScreenMetadata = function setCurrentVisibleScreenMetadata(type, url) {
|
||||
that.currentVisibleScreenType = type;
|
||||
that.currentVisibleUrl = url;
|
||||
};
|
||||
that.open = function open(optionalUrl, optionalInject) { // How to open the app.
|
||||
var url = optionalUrl || that.home;
|
||||
that.setCurrentData(url);
|
||||
if (that.isQML()) {
|
||||
var inject = optionalInject || that.inject;
|
||||
|
||||
if (that.isQMLUrl(url)) {
|
||||
that.tablet.loadQMLSource(url);
|
||||
} else {
|
||||
that.tablet.gotoWebScreen(url, that.inject);
|
||||
that.tablet.gotoWebScreen(url, inject);
|
||||
}
|
||||
};
|
||||
// Opens some app on top of the current app (on desktop, opens new window)
|
||||
that.openNewAppOnTop = function openNewAppOnTop(url, optionalInject) {
|
||||
var inject = optionalInject || "";
|
||||
if (that.isQMLUrl(url)) {
|
||||
that.tablet.loadQMLOnTop(url);
|
||||
} else {
|
||||
that.tablet.loadWebScreenOnTop(url, inject);
|
||||
}
|
||||
};
|
||||
that.close = function close() { // How to close the app.
|
||||
that.currentUrl = "";
|
||||
that.currentVisibleUrl = "";
|
||||
// for toolbar-mode: go back to home screen, this will close the window.
|
||||
that.tablet.gotoHomeScreen();
|
||||
};
|
||||
that.buttonActive = function buttonActive(isActive) { // How to make the button active (white).
|
||||
that.button.editProperties({isActive: isActive});
|
||||
};
|
||||
that.isQMLUrl = function isQMLUrl(url) {
|
||||
var type = /.qml$/.test(url) ? 'QML' : 'Web';
|
||||
return type === 'QML';
|
||||
};
|
||||
that.isCurrentlyOnQMLScreen = function isCurrentlyOnQMLScreen() {
|
||||
return that.currentVisibleScreenType === 'QML';
|
||||
};
|
||||
|
||||
//
|
||||
// START Notification Handling Defaults
|
||||
//
|
||||
that.messagesWaiting = function messagesWaiting(isWaiting) { // How to indicate a message light on button.
|
||||
// Note that waitingButton doesn't have to exist unless someone explicitly calls this with isWaiting true.
|
||||
that.button.editProperties({
|
||||
|
@ -69,16 +96,124 @@ function AppUi(properties) {
|
|||
activeIcon: isWaiting ? that.activeMessagesButton : that.activeButton
|
||||
});
|
||||
};
|
||||
that.isQML = function isQML() { // We set type property in onClick.
|
||||
return that.type === 'QML';
|
||||
that.notificationPollTimeout = false;
|
||||
that.notificationPollTimeoutMs = 60000;
|
||||
that.notificationPollEndpoint = false;
|
||||
that.notificationPollStopPaginatingConditionMet = false;
|
||||
that.notificationDataProcessPage = function (data) {
|
||||
return data;
|
||||
};
|
||||
that.eventSignal = function eventSignal() { // What signal to hook onMessage to.
|
||||
return that.isQML() ? that.tablet.fromQml : that.tablet.webEventReceived;
|
||||
that.notificationPollCallback = that.ignore;
|
||||
that.notificationPollCaresAboutSince = false;
|
||||
that.notificationInitialCallbackMade = false;
|
||||
that.notificationDisplayBanner = function (message) {
|
||||
Window.displayAnnouncement(message);
|
||||
};
|
||||
//
|
||||
// END Notification Handling Defaults
|
||||
//
|
||||
|
||||
// Handlers
|
||||
that.onScreenChanged = function onScreenChanged(type, url) {
|
||||
// Set isOpen, wireEventBridge, set buttonActive as appropriate,
|
||||
// and finally call onOpened() or onClosed() IFF defined.
|
||||
that.setCurrentVisibleScreenMetadata(type, url);
|
||||
if (that.checkIsOpen(type, url)) {
|
||||
that.wireEventBridge(true);
|
||||
if (!that.isOpen) {
|
||||
that.buttonActive(true);
|
||||
if (that.onOpened) {
|
||||
that.onOpened();
|
||||
}
|
||||
that.isOpen = true;
|
||||
}
|
||||
} else { // Not us. Should we do something for type Home, Menu, and particularly Closed (meaning tablet hidden?
|
||||
that.wireEventBridge(false);
|
||||
if (that.isOpen) {
|
||||
that.buttonActive(false);
|
||||
if (that.onClosed) {
|
||||
that.onClosed();
|
||||
}
|
||||
that.isOpen = false;
|
||||
}
|
||||
}
|
||||
console.debug(that.buttonName + " app reports: Tablet screen changed.\nNew screen type: " + type +
|
||||
"\nNew screen URL: " + url + "\nCurrent app open status: " + that.isOpen + "\n");
|
||||
};
|
||||
|
||||
// Overwrite with the given properties:
|
||||
Object.keys(properties).forEach(function (key) { that[key] = properties[key]; });
|
||||
|
||||
//
|
||||
// START Notification Handling
|
||||
//
|
||||
var METAVERSE_BASE = Account.metaverseServerURL;
|
||||
var currentDataPageToRetrieve = 1;
|
||||
var concatenatedServerResponse = new Array();
|
||||
that.notificationPoll = function () {
|
||||
if (!that.notificationPollEndpoint) {
|
||||
return;
|
||||
}
|
||||
|
||||
// User is "appearing offline"
|
||||
if (GlobalServices.findableBy === "none") {
|
||||
that.notificationPollTimeout = Script.setTimeout(that.notificationPoll, that.notificationPollTimeoutMs);
|
||||
return;
|
||||
}
|
||||
|
||||
var url = METAVERSE_BASE + that.notificationPollEndpoint;
|
||||
|
||||
if (that.notificationPollCaresAboutSince) {
|
||||
url = url + "&since=" + (new Date().getTime());
|
||||
}
|
||||
|
||||
console.debug(that.buttonName, 'polling for notifications at endpoint', url);
|
||||
|
||||
function requestCallback(error, response) {
|
||||
if (error || (response.status !== 'success')) {
|
||||
print("Error: unable to get", url, error || response.status);
|
||||
that.notificationPollTimeout = Script.setTimeout(that.notificationPoll, that.notificationPollTimeoutMs);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!that.notificationPollStopPaginatingConditionMet || that.notificationPollStopPaginatingConditionMet(response)) {
|
||||
that.notificationPollTimeout = Script.setTimeout(that.notificationPoll, that.notificationPollTimeoutMs);
|
||||
|
||||
var notificationData;
|
||||
if (concatenatedServerResponse.length) {
|
||||
notificationData = concatenatedServerResponse;
|
||||
} else {
|
||||
notificationData = that.notificationDataProcessPage(response);
|
||||
}
|
||||
console.debug(that.buttonName, 'notification data for processing:', JSON.stringify(notificationData));
|
||||
that.notificationPollCallback(notificationData);
|
||||
that.notificationInitialCallbackMade = true;
|
||||
currentDataPageToRetrieve = 1;
|
||||
concatenatedServerResponse = new Array();
|
||||
} else {
|
||||
concatenatedServerResponse = concatenatedServerResponse.concat(that.notificationDataProcessPage(response));
|
||||
currentDataPageToRetrieve++;
|
||||
request({ uri: (url + "&page=" + currentDataPageToRetrieve) }, requestCallback);
|
||||
}
|
||||
}
|
||||
|
||||
request({ uri: url }, requestCallback);
|
||||
};
|
||||
|
||||
// This won't do anything if there isn't a notification endpoint set
|
||||
that.notificationPoll();
|
||||
|
||||
function availabilityChanged() {
|
||||
if (that.notificationPollTimeout) {
|
||||
Script.clearTimeout(that.notificationPollTimeout);
|
||||
that.notificationPollTimeout = false;
|
||||
}
|
||||
that.notificationPoll();
|
||||
}
|
||||
//
|
||||
// END Notification Handling
|
||||
//
|
||||
|
||||
// Properties:
|
||||
that.tablet = Tablet.getTablet(that.tabletName);
|
||||
// Must be after we gather properties.
|
||||
|
@ -100,65 +235,58 @@ function AppUi(properties) {
|
|||
}
|
||||
that.button = that.tablet.addButton(buttonOptions);
|
||||
that.ignore = function ignore() { };
|
||||
|
||||
// Handlers
|
||||
that.onScreenChanged = function onScreenChanged(type, url) {
|
||||
// Set isOpen, wireEventBridge, set buttonActive as appropriate,
|
||||
// and finally call onOpened() or onClosed() IFF defined.
|
||||
console.debug(that.buttonName, 'onScreenChanged', type, url, that.isOpen);
|
||||
if (that.checkIsOpen(type, url)) {
|
||||
if (!that.isOpen) {
|
||||
that.wireEventBridge(true);
|
||||
that.buttonActive(true);
|
||||
if (that.onOpened) {
|
||||
that.onOpened();
|
||||
}
|
||||
that.isOpen = true;
|
||||
}
|
||||
|
||||
} else { // Not us. Should we do something for type Home, Menu, and particularly Closed (meaning tablet hidden?
|
||||
if (that.isOpen) {
|
||||
that.wireEventBridge(false);
|
||||
that.buttonActive(false);
|
||||
if (that.onClosed) {
|
||||
that.onClosed();
|
||||
}
|
||||
that.isOpen = false;
|
||||
}
|
||||
}
|
||||
};
|
||||
that.hasEventBridge = false;
|
||||
that.hasOutboundEventBridge = false;
|
||||
that.hasInboundQmlEventBridge = false;
|
||||
that.hasInboundHtmlEventBridge = false;
|
||||
// HTML event bridge uses strings, not objects. Here we abstract over that.
|
||||
// (Although injected javascript still has to use JSON.stringify/JSON.parse.)
|
||||
that.sendToHtml = function (messageObject) { that.tablet.emitScriptEvent(JSON.stringify(messageObject)); };
|
||||
that.fromHtml = function (messageString) { that.onMessage(JSON.parse(messageString)); };
|
||||
that.sendToHtml = function (messageObject) {
|
||||
that.tablet.emitScriptEvent(JSON.stringify(messageObject));
|
||||
};
|
||||
that.fromHtml = function (messageString) {
|
||||
var parsedMessage = JSON.parse(messageString);
|
||||
parsedMessage.messageSrc = "HTML";
|
||||
that.onMessage(parsedMessage);
|
||||
};
|
||||
that.sendMessage = that.ignore;
|
||||
that.wireEventBridge = function wireEventBridge(on) {
|
||||
// Uniquivocally sets that.sendMessage(messageObject) to do the right thing.
|
||||
// Sets hasEventBridge and wires onMessage to eventSignal as appropriate, IFF onMessage defined.
|
||||
var handler, isQml = that.isQML();
|
||||
// Sets has*EventBridge and wires onMessage to the proper event bridge as appropriate, IFF onMessage defined.
|
||||
var isCurrentlyOnQMLScreen = that.isCurrentlyOnQMLScreen();
|
||||
// Outbound (always, regardless of whether there is an inbound handler).
|
||||
if (on) {
|
||||
that.sendMessage = isQml ? that.tablet.sendToQml : that.sendToHtml;
|
||||
that.sendMessage = isCurrentlyOnQMLScreen ? that.tablet.sendToQml : that.sendToHtml;
|
||||
that.hasOutboundEventBridge = true;
|
||||
} else {
|
||||
that.sendMessage = that.ignore;
|
||||
that.hasOutboundEventBridge = false;
|
||||
}
|
||||
|
||||
if (!that.onMessage) { return; }
|
||||
if (!that.onMessage) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Inbound
|
||||
handler = isQml ? that.onMessage : that.fromHtml;
|
||||
if (on) {
|
||||
if (!that.hasEventBridge) {
|
||||
console.debug(that.buttonName, 'connecting', that.eventSignal());
|
||||
that.eventSignal().connect(handler);
|
||||
that.hasEventBridge = true;
|
||||
if (isCurrentlyOnQMLScreen && !that.hasInboundQmlEventBridge) {
|
||||
console.debug(that.buttonName, 'connecting', that.tablet.fromQml);
|
||||
that.tablet.fromQml.connect(that.onMessage);
|
||||
that.hasInboundQmlEventBridge = true;
|
||||
} else if (!isCurrentlyOnQMLScreen && !that.hasInboundHtmlEventBridge) {
|
||||
console.debug(that.buttonName, 'connecting', that.tablet.webEventReceived);
|
||||
that.tablet.webEventReceived.connect(that.fromHtml);
|
||||
that.hasInboundHtmlEventBridge = true;
|
||||
}
|
||||
} else {
|
||||
if (that.hasEventBridge) {
|
||||
console.debug(that.buttonName, 'disconnecting', that.eventSignal());
|
||||
that.eventSignal().disconnect(handler);
|
||||
that.hasEventBridge = false;
|
||||
if (that.hasInboundQmlEventBridge) {
|
||||
console.debug(that.buttonName, 'disconnecting', that.tablet.fromQml);
|
||||
that.tablet.fromQml.disconnect(that.onMessage);
|
||||
that.hasInboundQmlEventBridge = false;
|
||||
}
|
||||
if (that.hasInboundHtmlEventBridge) {
|
||||
console.debug(that.buttonName, 'disconnecting', that.tablet.webEventReceived);
|
||||
that.tablet.webEventReceived.disconnect(that.fromHtml);
|
||||
that.hasInboundHtmlEventBridge = false;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -175,6 +303,7 @@ function AppUi(properties) {
|
|||
} : that.ignore;
|
||||
that.onScriptEnding = function onScriptEnding() {
|
||||
// Close if necessary, clean up any remaining handlers, and remove the button.
|
||||
GlobalServices.findableByChanged.disconnect(availabilityChanged);
|
||||
if (that.isOpen) {
|
||||
that.close();
|
||||
}
|
||||
|
@ -185,10 +314,15 @@ function AppUi(properties) {
|
|||
}
|
||||
that.tablet.removeButton(that.button);
|
||||
}
|
||||
if (that.notificationPollTimeout) {
|
||||
Script.clearInterval(that.notificationPollTimeout);
|
||||
that.notificationPollTimeout = false;
|
||||
}
|
||||
};
|
||||
// Set up the handlers.
|
||||
that.tablet.screenChanged.connect(that.onScreenChanged);
|
||||
that.button.clicked.connect(that.onClicked);
|
||||
Script.scriptEnding.connect(that.onScriptEnding);
|
||||
GlobalServices.findableByChanged.connect(availabilityChanged);
|
||||
}
|
||||
module.exports = AppUi;
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,5 +1,5 @@
|
|||
"use strict";
|
||||
|
||||
/* eslint indent: ["error", 4, { "outerIIFEBody": 0 }] */
|
||||
//
|
||||
// help.js
|
||||
// scripts/system/
|
||||
|
@ -12,50 +12,18 @@
|
|||
//
|
||||
/* globals Tablet, Script, HMD, Controller, Menu */
|
||||
|
||||
(function() { // BEGIN LOCAL_SCOPE
|
||||
|
||||
var HOME_BUTTON_TEXTURE = Script.resourcesPath() + "meshes/tablet-with-home-button.fbx/tablet-with-home-button.fbm/button-root.png";
|
||||
var HELP_URL = Script.resourcesPath() + "html/tabletHelp.html";
|
||||
var buttonName = "HELP";
|
||||
var onHelpScreen = false;
|
||||
var tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system");
|
||||
var button = tablet.addButton({
|
||||
icon: "icons/tablet-icons/help-i.svg",
|
||||
activeIcon: "icons/tablet-icons/help-a.svg",
|
||||
text: buttonName,
|
||||
sortOrder: 6
|
||||
(function () { // BEGIN LOCAL_SCOPE
|
||||
var AppUi = Script.require('appUi');
|
||||
|
||||
var HELP_URL = Script.resourcesPath() + "html/tabletHelp.html";
|
||||
var HELP_BUTTON_NAME = "HELP";
|
||||
var ui;
|
||||
function startup() {
|
||||
ui = new AppUi({
|
||||
buttonName: HELP_BUTTON_NAME,
|
||||
sortOrder: 6,
|
||||
home: HELP_URL
|
||||
});
|
||||
|
||||
var enabled = false;
|
||||
function onClicked() {
|
||||
if (onHelpScreen) {
|
||||
tablet.gotoHomeScreen();
|
||||
} else {
|
||||
if (HMD.tabletID) {
|
||||
Entities.editEntity(HMD.tabletID, {textures: JSON.stringify({"tex.close" : HOME_BUTTON_TEXTURE})});
|
||||
}
|
||||
Menu.triggerOption('Help...');
|
||||
onHelpScreen = true;
|
||||
}
|
||||
}
|
||||
|
||||
function onScreenChanged(type, url) {
|
||||
onHelpScreen = type === "Web" && (url.indexOf(HELP_URL) === 0);
|
||||
button.editProperties({ isActive: onHelpScreen });
|
||||
}
|
||||
|
||||
button.clicked.connect(onClicked);
|
||||
tablet.screenChanged.connect(onScreenChanged);
|
||||
|
||||
Script.scriptEnding.connect(function () {
|
||||
if (onHelpScreen) {
|
||||
tablet.gotoHomeScreen();
|
||||
}
|
||||
button.clicked.disconnect(onClicked);
|
||||
tablet.screenChanged.disconnect(onScreenChanged);
|
||||
if (tablet) {
|
||||
tablet.removeButton(button);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
startup();
|
||||
}()); // END LOCAL_SCOPE
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
/* global $, window, MutationObserver */
|
||||
|
||||
//
|
||||
// marketplacesInject.js
|
||||
//
|
||||
|
@ -11,7 +13,6 @@
|
|||
//
|
||||
|
||||
(function () {
|
||||
|
||||
// Event bridge messages.
|
||||
var CLARA_IO_DOWNLOAD = "CLARA.IO DOWNLOAD";
|
||||
var CLARA_IO_STATUS = "CLARA.IO STATUS";
|
||||
|
@ -24,7 +25,7 @@
|
|||
|
||||
var canWriteAssets = false;
|
||||
var xmlHttpRequest = null;
|
||||
var isPreparing = false; // Explicitly track download request status.
|
||||
var isPreparing = false; // Explicitly track download request status.
|
||||
|
||||
var commerceMode = false;
|
||||
var userIsLoggedIn = false;
|
||||
|
@ -33,7 +34,6 @@
|
|||
var messagesWaiting = false;
|
||||
|
||||
function injectCommonCode(isDirectoryPage) {
|
||||
|
||||
// Supporting styles from marketplaces.css.
|
||||
// Glyph font family, size, and spacing adjusted because HiFi-Glyphs cannot be used cross-domain.
|
||||
$("head").append(
|
||||
|
@ -74,7 +74,9 @@
|
|||
(document.referrer !== "") ? window.history.back() : window.location = (marketplaceBaseURL + "/marketplace?");
|
||||
});
|
||||
$("#all-markets").on("click", function () {
|
||||
EventBridge.emitWebEvent(GOTO_DIRECTORY);
|
||||
EventBridge.emitWebEvent(JSON.stringify({
|
||||
type: GOTO_DIRECTORY
|
||||
}));
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -94,11 +96,11 @@
|
|||
});
|
||||
}
|
||||
|
||||
emitWalletSetupEvent = function() {
|
||||
var emitWalletSetupEvent = function () {
|
||||
EventBridge.emitWebEvent(JSON.stringify({
|
||||
type: "WALLET_SETUP"
|
||||
}));
|
||||
}
|
||||
};
|
||||
|
||||
function maybeAddSetupWalletButton() {
|
||||
if (!$('body').hasClass("walletsetup-injected") && userIsLoggedIn && walletNeedsSetup) {
|
||||
|
@ -285,7 +287,7 @@
|
|||
$(this).closest('.col-xs-3').prev().attr("class", 'col-xs-6');
|
||||
$(this).closest('.col-xs-3').attr("class", 'col-xs-6');
|
||||
|
||||
var priceElement = $(this).find('.price')
|
||||
var priceElement = $(this).find('.price');
|
||||
priceElement.css({
|
||||
"padding": "3px 5px",
|
||||
"height": "40px",
|
||||
|
@ -355,12 +357,12 @@
|
|||
function injectAddScrollbarToCategories() {
|
||||
$('#categories-dropdown').on('show.bs.dropdown', function () {
|
||||
$('body > div.container').css('display', 'none')
|
||||
$('#categories-dropdown > ul.dropdown-menu').css({ 'overflow': 'auto', 'height': 'calc(100vh - 110px)' })
|
||||
$('#categories-dropdown > ul.dropdown-menu').css({ 'overflow': 'auto', 'height': 'calc(100vh - 110px)' });
|
||||
});
|
||||
|
||||
$('#categories-dropdown').on('hide.bs.dropdown', function () {
|
||||
$('body > div.container').css('display', '')
|
||||
$('#categories-dropdown > ul.dropdown-menu').css({ 'overflow': '', 'height': '' })
|
||||
$('body > div.container').css('display', '');
|
||||
$('#categories-dropdown > ul.dropdown-menu').css({ 'overflow': '', 'height': '' });
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -382,7 +384,6 @@
|
|||
mutations.forEach(function (mutation) {
|
||||
injectBuyButtonOnMainPage();
|
||||
});
|
||||
//observer.disconnect();
|
||||
});
|
||||
var config = { attributes: true, childList: true, characterData: true };
|
||||
observer.observe(target, config);
|
||||
|
@ -451,8 +452,8 @@
|
|||
"itemPage",
|
||||
urlParams.get('edition'),
|
||||
type);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
maybeAddPurchasesButton();
|
||||
}
|
||||
}
|
||||
|
@ -503,127 +504,142 @@
|
|||
$(".top-title .col-sm-4").append(downloadContainer);
|
||||
downloadContainer.append(downloadFBX);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Automatic download to High Fidelity.
|
||||
function startAutoDownload() {
|
||||
// Automatic download to High Fidelity.
|
||||
function startAutoDownload() {
|
||||
// One file request at a time.
|
||||
if (isPreparing) {
|
||||
console.log("WARNING: Clara.io FBX: Prepare only one download at a time");
|
||||
return;
|
||||
}
|
||||
|
||||
// One file request at a time.
|
||||
if (isPreparing) {
|
||||
console.log("WARNING: Clara.io FBX: Prepare only one download at a time");
|
||||
return;
|
||||
}
|
||||
// User must be able to write to Asset Server.
|
||||
if (!canWriteAssets) {
|
||||
console.log("ERROR: Clara.io FBX: File download cancelled because no permissions to write to Asset Server");
|
||||
EventBridge.emitWebEvent(JSON.stringify({
|
||||
type: WARN_USER_NO_PERMISSIONS
|
||||
}));
|
||||
return;
|
||||
}
|
||||
|
||||
// User must be able to write to Asset Server.
|
||||
if (!canWriteAssets) {
|
||||
console.log("ERROR: Clara.io FBX: File download cancelled because no permissions to write to Asset Server");
|
||||
EventBridge.emitWebEvent(WARN_USER_NO_PERMISSIONS);
|
||||
return;
|
||||
}
|
||||
// User must be logged in.
|
||||
var loginButton = $("#topnav a[href='/signup']");
|
||||
if (loginButton.length > 0) {
|
||||
loginButton[0].click();
|
||||
return;
|
||||
}
|
||||
|
||||
// User must be logged in.
|
||||
var loginButton = $("#topnav a[href='/signup']");
|
||||
if (loginButton.length > 0) {
|
||||
loginButton[0].click();
|
||||
return;
|
||||
}
|
||||
// Obtain zip file to download for requested asset.
|
||||
// Reference: https://clara.io/learn/sdk/api/export
|
||||
|
||||
// Obtain zip file to download for requested asset.
|
||||
// Reference: https://clara.io/learn/sdk/api/export
|
||||
//var XMLHTTPREQUEST_URL = "https://clara.io/api/scenes/{uuid}/export/fbx?zip=true¢erScene=true&alignSceneGround=true&fbxUnit=Meter&fbxVersion=7&fbxEmbedTextures=true&imageFormat=WebGL";
|
||||
// 13 Jan 2017: Specify FBX version 5 and remove some options in order to make Clara.io site more likely to
|
||||
// be successful in generating zip files.
|
||||
var XMLHTTPREQUEST_URL = "https://clara.io/api/scenes/{uuid}/export/fbx?fbxUnit=Meter&fbxVersion=5&fbxEmbedTextures=true&imageFormat=WebGL";
|
||||
|
||||
//var XMLHTTPREQUEST_URL = "https://clara.io/api/scenes/{uuid}/export/fbx?zip=true¢erScene=true&alignSceneGround=true&fbxUnit=Meter&fbxVersion=7&fbxEmbedTextures=true&imageFormat=WebGL";
|
||||
// 13 Jan 2017: Specify FBX version 5 and remove some options in order to make Clara.io site more likely to
|
||||
// be successful in generating zip files.
|
||||
var XMLHTTPREQUEST_URL = "https://clara.io/api/scenes/{uuid}/export/fbx?fbxUnit=Meter&fbxVersion=5&fbxEmbedTextures=true&imageFormat=WebGL";
|
||||
var uuid = location.href.match(/\/view\/([a-z0-9\-]*)/)[1];
|
||||
var url = XMLHTTPREQUEST_URL.replace("{uuid}", uuid);
|
||||
|
||||
var uuid = location.href.match(/\/view\/([a-z0-9\-]*)/)[1];
|
||||
var url = XMLHTTPREQUEST_URL.replace("{uuid}", uuid);
|
||||
xmlHttpRequest = new XMLHttpRequest();
|
||||
var responseTextIndex = 0;
|
||||
var zipFileURL = "";
|
||||
|
||||
xmlHttpRequest = new XMLHttpRequest();
|
||||
var responseTextIndex = 0;
|
||||
var zipFileURL = "";
|
||||
xmlHttpRequest.onreadystatechange = function () {
|
||||
// Messages are appended to responseText; process the new ones.
|
||||
var message = this.responseText.slice(responseTextIndex);
|
||||
var statusMessage = "";
|
||||
|
||||
xmlHttpRequest.onreadystatechange = function () {
|
||||
// Messages are appended to responseText; process the new ones.
|
||||
var message = this.responseText.slice(responseTextIndex);
|
||||
var statusMessage = "";
|
||||
if (isPreparing) { // Ignore messages in flight after finished/cancelled.
|
||||
var lines = message.split(/[\n\r]+/);
|
||||
|
||||
if (isPreparing) { // Ignore messages in flight after finished/cancelled.
|
||||
var lines = message.split(/[\n\r]+/);
|
||||
for (var i = 0, length = lines.length; i < length; i++) {
|
||||
if (lines[i].slice(0, 5) === "data:") {
|
||||
// Parse line.
|
||||
var data;
|
||||
try {
|
||||
data = JSON.parse(lines[i].slice(5));
|
||||
}
|
||||
catch (e) {
|
||||
data = {};
|
||||
}
|
||||
|
||||
for (var i = 0, length = lines.length; i < length; i++) {
|
||||
if (lines[i].slice(0, 5) === "data:") {
|
||||
// Parse line.
|
||||
var data;
|
||||
try {
|
||||
data = JSON.parse(lines[i].slice(5));
|
||||
}
|
||||
catch (e) {
|
||||
data = {};
|
||||
}
|
||||
// Extract status message.
|
||||
if (data.hasOwnProperty("message") && data.message !== null) {
|
||||
statusMessage = data.message;
|
||||
console.log("Clara.io FBX: " + statusMessage);
|
||||
}
|
||||
|
||||
// Extract status message.
|
||||
if (data.hasOwnProperty("message") && data.message !== null) {
|
||||
statusMessage = data.message;
|
||||
console.log("Clara.io FBX: " + statusMessage);
|
||||
}
|
||||
|
||||
// Extract zip file URL.
|
||||
if (data.hasOwnProperty("files") && data.files.length > 0) {
|
||||
zipFileURL = data.files[0].url;
|
||||
if (zipFileURL.slice(-4) !== ".zip") {
|
||||
console.log(JSON.stringify(data)); // Data for debugging.
|
||||
}
|
||||
}
|
||||
// Extract zip file URL.
|
||||
if (data.hasOwnProperty("files") && data.files.length > 0) {
|
||||
zipFileURL = data.files[0].url;
|
||||
if (zipFileURL.slice(-4) !== ".zip") {
|
||||
console.log(JSON.stringify(data)); // Data for debugging.
|
||||
}
|
||||
}
|
||||
|
||||
if (statusMessage !== "") {
|
||||
// Update the UI with the most recent status message.
|
||||
EventBridge.emitWebEvent(CLARA_IO_STATUS + " " + statusMessage);
|
||||
}
|
||||
}
|
||||
|
||||
responseTextIndex = this.responseText.length;
|
||||
};
|
||||
|
||||
// Note: onprogress doesn't have computable total length so can't use it to determine % complete.
|
||||
|
||||
xmlHttpRequest.onload = function () {
|
||||
var statusMessage = "";
|
||||
|
||||
if (!isPreparing) {
|
||||
return;
|
||||
}
|
||||
|
||||
isPreparing = false;
|
||||
|
||||
var HTTP_OK = 200;
|
||||
if (this.status !== HTTP_OK) {
|
||||
statusMessage = "Zip file request terminated with " + this.status + " " + this.statusText;
|
||||
console.log("ERROR: Clara.io FBX: " + statusMessage);
|
||||
EventBridge.emitWebEvent(CLARA_IO_STATUS + " " + statusMessage);
|
||||
} else if (zipFileURL.slice(-4) !== ".zip") {
|
||||
statusMessage = "Error creating zip file for download.";
|
||||
console.log("ERROR: Clara.io FBX: " + statusMessage + ": " + zipFileURL);
|
||||
EventBridge.emitWebEvent(CLARA_IO_STATUS + " " + statusMessage);
|
||||
} else {
|
||||
EventBridge.emitWebEvent(CLARA_IO_DOWNLOAD + " " + zipFileURL);
|
||||
console.log("Clara.io FBX: File download initiated for " + zipFileURL);
|
||||
}
|
||||
|
||||
xmlHttpRequest = null;
|
||||
}
|
||||
|
||||
isPreparing = true;
|
||||
|
||||
console.log("Clara.io FBX: Request zip file for " + uuid);
|
||||
EventBridge.emitWebEvent(CLARA_IO_STATUS + " Initiating download");
|
||||
|
||||
xmlHttpRequest.open("POST", url, true);
|
||||
xmlHttpRequest.setRequestHeader("Accept", "text/event-stream");
|
||||
xmlHttpRequest.send();
|
||||
if (statusMessage !== "") {
|
||||
// Update the UI with the most recent status message.
|
||||
EventBridge.emitWebEvent(JSON.stringify({
|
||||
type: CLARA_IO_STATUS,
|
||||
status: statusMessage
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
responseTextIndex = this.responseText.length;
|
||||
};
|
||||
|
||||
// Note: onprogress doesn't have computable total length so can't use it to determine % complete.
|
||||
|
||||
xmlHttpRequest.onload = function () {
|
||||
var statusMessage = "";
|
||||
|
||||
if (!isPreparing) {
|
||||
return;
|
||||
}
|
||||
|
||||
isPreparing = false;
|
||||
|
||||
var HTTP_OK = 200;
|
||||
if (this.status !== HTTP_OK) {
|
||||
statusMessage = "Zip file request terminated with " + this.status + " " + this.statusText;
|
||||
console.log("ERROR: Clara.io FBX: " + statusMessage);
|
||||
EventBridge.emitWebEvent(JSON.stringify({
|
||||
type: CLARA_IO_STATUS,
|
||||
status: statusMessage
|
||||
}));
|
||||
} else if (zipFileURL.slice(-4) !== ".zip") {
|
||||
statusMessage = "Error creating zip file for download.";
|
||||
console.log("ERROR: Clara.io FBX: " + statusMessage + ": " + zipFileURL);
|
||||
EventBridge.emitWebEvent(JSON.stringify({
|
||||
type: CLARA_IO_STATUS,
|
||||
status: (statusMessage + ": " + zipFileURL)
|
||||
}));
|
||||
} else {
|
||||
EventBridge.emitWebEvent(JSON.stringify({
|
||||
type: CLARA_IO_DOWNLOAD
|
||||
}));
|
||||
console.log("Clara.io FBX: File download initiated for " + zipFileURL);
|
||||
}
|
||||
|
||||
xmlHttpRequest = null;
|
||||
}
|
||||
|
||||
isPreparing = true;
|
||||
|
||||
console.log("Clara.io FBX: Request zip file for " + uuid);
|
||||
EventBridge.emitWebEvent(JSON.stringify({
|
||||
type: CLARA_IO_STATUS,
|
||||
status: "Initiating download"
|
||||
}));
|
||||
|
||||
xmlHttpRequest.open("POST", url, true);
|
||||
xmlHttpRequest.setRequestHeader("Accept", "text/event-stream");
|
||||
xmlHttpRequest.send();
|
||||
}
|
||||
|
||||
function injectClaraCode() {
|
||||
|
@ -663,7 +679,9 @@
|
|||
updateClaraCodeInterval = undefined;
|
||||
});
|
||||
|
||||
EventBridge.emitWebEvent(QUERY_CAN_WRITE_ASSETS);
|
||||
EventBridge.emitWebEvent(JSON.stringify({
|
||||
type: QUERY_CAN_WRITE_ASSETS
|
||||
}));
|
||||
}
|
||||
|
||||
function cancelClaraDownload() {
|
||||
|
@ -673,7 +691,9 @@
|
|||
xmlHttpRequest.abort();
|
||||
xmlHttpRequest = null;
|
||||
console.log("Clara.io FBX: File download cancelled");
|
||||
EventBridge.emitWebEvent(CLARA_IO_CANCELLED_DOWNLOAD);
|
||||
EventBridge.emitWebEvent(JSON.stringify({
|
||||
type: CLARA_IO_CANCELLED_DOWNLOAD
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -708,25 +728,22 @@
|
|||
|
||||
function onLoad() {
|
||||
EventBridge.scriptEventReceived.connect(function (message) {
|
||||
if (message.slice(0, CAN_WRITE_ASSETS.length) === CAN_WRITE_ASSETS) {
|
||||
canWriteAssets = message.slice(-4) === "true";
|
||||
} else if (message.slice(0, CLARA_IO_CANCEL_DOWNLOAD.length) === CLARA_IO_CANCEL_DOWNLOAD) {
|
||||
message = JSON.parse(message);
|
||||
if (message.type === CAN_WRITE_ASSETS) {
|
||||
canWriteAssets = message.canWriteAssets;
|
||||
} else if (message.type === CLARA_IO_CANCEL_DOWNLOAD) {
|
||||
cancelClaraDownload();
|
||||
} else {
|
||||
var parsedJsonMessage = JSON.parse(message);
|
||||
|
||||
if (parsedJsonMessage.type === "marketplaces") {
|
||||
if (parsedJsonMessage.action === "commerceSetting") {
|
||||
commerceMode = !!parsedJsonMessage.data.commerceMode;
|
||||
userIsLoggedIn = !!parsedJsonMessage.data.userIsLoggedIn;
|
||||
walletNeedsSetup = !!parsedJsonMessage.data.walletNeedsSetup;
|
||||
marketplaceBaseURL = parsedJsonMessage.data.metaverseServerURL;
|
||||
if (marketplaceBaseURL.indexOf('metaverse.') !== -1) {
|
||||
marketplaceBaseURL = marketplaceBaseURL.replace('metaverse.', '');
|
||||
}
|
||||
messagesWaiting = parsedJsonMessage.data.messagesWaiting;
|
||||
injectCode();
|
||||
} else if (message.type === "marketplaces") {
|
||||
if (message.action === "commerceSetting") {
|
||||
commerceMode = !!message.data.commerceMode;
|
||||
userIsLoggedIn = !!message.data.userIsLoggedIn;
|
||||
walletNeedsSetup = !!message.data.walletNeedsSetup;
|
||||
marketplaceBaseURL = message.data.metaverseServerURL;
|
||||
if (marketplaceBaseURL.indexOf('metaverse.') !== -1) {
|
||||
marketplaceBaseURL = marketplaceBaseURL.replace('metaverse.', '');
|
||||
}
|
||||
messagesWaiting = message.data.messagesWaiting;
|
||||
injectCode();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -739,6 +756,6 @@
|
|||
}
|
||||
|
||||
// Load / unload.
|
||||
window.addEventListener("load", onLoad); // More robust to Web site issues than using $(document).ready().
|
||||
window.addEventListener("page:change", onLoad); // Triggered after Marketplace HTML is changed
|
||||
window.addEventListener("load", onLoad); // More robust to Web site issues than using $(document).ready().
|
||||
window.addEventListener("page:change", onLoad); // Triggered after Marketplace HTML is changed
|
||||
}());
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,6 +1,9 @@
|
|||
"use strict";
|
||||
/*jslint vars:true, plusplus:true, forin:true*/
|
||||
/*global Tablet, Settings, Script, AvatarList, Users, Entities, MyAvatar, Camera, Overlays, Vec3, Quat, HMD, Controller, Account, UserActivityLogger, Messages, Window, XMLHttpRequest, print, location, getControllerWorldLocation*/
|
||||
/* jslint vars:true, plusplus:true, forin:true */
|
||||
/* global Tablet, Settings, Script, AvatarList, Users, Entities,
|
||||
MyAvatar, Camera, Overlays, Vec3, Quat, HMD, Controller, Account,
|
||||
UserActivityLogger, Messages, Window, XMLHttpRequest, print, location, getControllerWorldLocation
|
||||
*/
|
||||
/* eslint indent: ["error", 4, { "outerIIFEBody": 0 }] */
|
||||
//
|
||||
// pal.js
|
||||
|
@ -20,7 +23,7 @@ var AppUi = Script.require('appUi');
|
|||
var populateNearbyUserList, color, textures, removeOverlays,
|
||||
controllerComputePickRay, off,
|
||||
receiveMessage, avatarDisconnected, clearLocalQMLDataAndClosePAL,
|
||||
CHANNEL, getConnectionData, findableByChanged,
|
||||
CHANNEL, getConnectionData,
|
||||
avatarAdded, avatarRemoved, avatarSessionChanged; // forward references;
|
||||
|
||||
// hardcoding these as it appears we cannot traverse the originalTextures in overlays??? Maybe I've missed
|
||||
|
@ -318,6 +321,10 @@ function fromQml(message) { // messages are {method, params}, like json-rpc. See
|
|||
break;
|
||||
case 'http.request':
|
||||
break; // Handled by request-service.
|
||||
case 'hideNotificationDot':
|
||||
shouldShowDot = false;
|
||||
ui.messagesWaiting(shouldShowDot);
|
||||
break;
|
||||
default:
|
||||
print('Unrecognized message from Pal.qml:', JSON.stringify(message));
|
||||
}
|
||||
|
@ -361,8 +368,8 @@ function getProfilePicture(username, callback) { // callback(url) if successfull
|
|||
});
|
||||
}
|
||||
var SAFETY_LIMIT = 400;
|
||||
function getAvailableConnections(domain, callback) { // callback([{usename, location}...]) if successfull. (Logs otherwise)
|
||||
var url = METAVERSE_BASE + '/api/v1/users?per_page=' + SAFETY_LIMIT + '&';
|
||||
function getAvailableConnections(domain, callback, numResultsPerPage) { // callback([{usename, location}...]) if successfull. (Logs otherwise)
|
||||
var url = METAVERSE_BASE + '/api/v1/users?per_page=' + (numResultsPerPage || SAFETY_LIMIT) + '&';
|
||||
if (domain) {
|
||||
url += 'status=' + domain.slice(1, -1); // without curly braces
|
||||
} else {
|
||||
|
@ -713,7 +720,7 @@ function tabletVisibilityChanged() {
|
|||
if (!ui.tablet.tabletShown && ui.isOpen) {
|
||||
ui.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var UPDATE_INTERVAL_MS = 100;
|
||||
var updateInterval;
|
||||
|
@ -725,10 +732,14 @@ function createUpdateInterval() {
|
|||
|
||||
var previousContextOverlay = ContextOverlay.enabled;
|
||||
var previousRequestsDomainListData = Users.requestsDomainListData;
|
||||
function on() {
|
||||
function palOpened() {
|
||||
ui.sendMessage({
|
||||
method: 'changeConnectionsDotStatus',
|
||||
shouldShowDot: shouldShowDot
|
||||
});
|
||||
|
||||
previousContextOverlay = ContextOverlay.enabled;
|
||||
previousRequestsDomainListData = Users.requestsDomainListData
|
||||
previousRequestsDomainListData = Users.requestsDomainListData;
|
||||
ContextOverlay.enabled = false;
|
||||
Users.requestsDomainListData = true;
|
||||
|
||||
|
@ -807,14 +818,98 @@ function avatarSessionChanged(avatarID) {
|
|||
sendToQml({ method: 'palIsStale', params: [avatarID, 'avatarSessionChanged'] });
|
||||
}
|
||||
|
||||
function notificationDataProcessPage(data) {
|
||||
return data.data.users;
|
||||
}
|
||||
|
||||
var shouldShowDot = false;
|
||||
var storedOnlineUsersArray = [];
|
||||
function notificationPollCallback(connectionsArray) {
|
||||
//
|
||||
// START logic for handling online/offline user changes
|
||||
//
|
||||
var i, j;
|
||||
var newlyOnlineConnectionsArray = [];
|
||||
for (i = 0; i < connectionsArray.length; i++) {
|
||||
var currentUser = connectionsArray[i];
|
||||
|
||||
if (connectionsArray[i].online) {
|
||||
var indexOfStoredOnlineUser = -1;
|
||||
for (j = 0; j < storedOnlineUsersArray.length; j++) {
|
||||
if (currentUser.username === storedOnlineUsersArray[j].username) {
|
||||
indexOfStoredOnlineUser = j;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// If the user record isn't already presesnt inside `storedOnlineUsersArray`...
|
||||
if (indexOfStoredOnlineUser < 0) {
|
||||
storedOnlineUsersArray.push(currentUser);
|
||||
newlyOnlineConnectionsArray.push(currentUser);
|
||||
}
|
||||
} else {
|
||||
var indexOfOfflineUser = -1;
|
||||
for (j = 0; j < storedOnlineUsersArray.length; j++) {
|
||||
if (currentUser.username === storedOnlineUsersArray[j].username) {
|
||||
indexOfOfflineUser = j;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (indexOfOfflineUser >= 0) {
|
||||
storedOnlineUsersArray.splice(indexOfOfflineUser);
|
||||
}
|
||||
}
|
||||
}
|
||||
// If there's new data, the light should turn on.
|
||||
// If the light is already on and you have connections online, the light should stay on.
|
||||
// In all other cases, the light should turn off or stay off.
|
||||
shouldShowDot = newlyOnlineConnectionsArray.length > 0 || (storedOnlineUsersArray.length > 0 && shouldShowDot);
|
||||
//
|
||||
// END logic for handling online/offline user changes
|
||||
//
|
||||
|
||||
if (!ui.isOpen) {
|
||||
ui.messagesWaiting(shouldShowDot);
|
||||
ui.sendMessage({
|
||||
method: 'changeConnectionsDotStatus',
|
||||
shouldShowDot: shouldShowDot
|
||||
});
|
||||
|
||||
if (newlyOnlineConnectionsArray.length > 0) {
|
||||
var message;
|
||||
if (!ui.notificationInitialCallbackMade) {
|
||||
message = newlyOnlineConnectionsArray.length + " of your connections " +
|
||||
(newlyOnlineConnectionsArray.length === 1 ? "is" : "are") + " online. Open PEOPLE to join them!";
|
||||
ui.notificationDisplayBanner(message);
|
||||
} else {
|
||||
for (i = 0; i < newlyOnlineConnectionsArray.length; i++) {
|
||||
message = newlyOnlineConnectionsArray[i].username + " is available in " +
|
||||
newlyOnlineConnectionsArray[i].location.root.name + ". Open PEOPLE to join them!";
|
||||
ui.notificationDisplayBanner(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function isReturnedDataEmpty(data) {
|
||||
var usersArray = data.data.users;
|
||||
return usersArray.length === 0;
|
||||
}
|
||||
|
||||
function startup() {
|
||||
ui = new AppUi({
|
||||
buttonName: "PEOPLE",
|
||||
sortOrder: 7,
|
||||
home: "hifi/Pal.qml",
|
||||
onOpened: on,
|
||||
onOpened: palOpened,
|
||||
onClosed: off,
|
||||
onMessage: fromQml
|
||||
onMessage: fromQml,
|
||||
notificationPollEndpoint: "/api/v1/users?filter=connections&per_page=10",
|
||||
notificationPollTimeoutMs: 60000,
|
||||
notificationDataProcessPage: notificationDataProcessPage,
|
||||
notificationPollCallback: notificationPollCallback,
|
||||
notificationPollStopPaginatingConditionMet: isReturnedDataEmpty,
|
||||
notificationPollCaresAboutSince: false
|
||||
});
|
||||
Window.domainChanged.connect(clearLocalQMLDataAndClosePAL);
|
||||
Window.domainConnectionRefused.connect(clearLocalQMLDataAndClosePAL);
|
||||
|
|
|
@ -7,28 +7,19 @@
|
|||
// Distributed under the Apache License, Version 2.0
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
/* globals Tablet, Script, HMD, Settings, DialogsManager, Menu, Reticle, OverlayWebWindow, Desktop, Account, MyAvatar, Snapshot */
|
||||
/* globals Tablet, Script, HMD, Settings, DialogsManager, Menu, Reticle,
|
||||
OverlayWebWindow, Desktop, Account, MyAvatar, Snapshot */
|
||||
/* eslint indent: ["error", 4, { "outerIIFEBody": 0 }] */
|
||||
|
||||
(function () { // BEGIN LOCAL_SCOPE
|
||||
Script.include("/~/system/libraries/accountUtils.js");
|
||||
var AppUi = Script.require('appUi');
|
||||
|
||||
var SNAPSHOT_DELAY = 500; // 500ms
|
||||
var FINISH_SOUND_DELAY = 350;
|
||||
var resetOverlays;
|
||||
var reticleVisible;
|
||||
|
||||
var buttonName = "SNAP";
|
||||
var buttonConnected = false;
|
||||
|
||||
var tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system");
|
||||
var button = tablet.addButton({
|
||||
icon: "icons/tablet-icons/snap-i.svg",
|
||||
activeIcon: "icons/tablet-icons/snap-a.svg",
|
||||
text: buttonName,
|
||||
sortOrder: 5
|
||||
});
|
||||
|
||||
var snapshotOptions = {};
|
||||
var imageData = [];
|
||||
var storyIDsToMaybeDelete = [];
|
||||
|
@ -52,8 +43,6 @@ try {
|
|||
print('Failed to resolve request api, error: ' + err);
|
||||
}
|
||||
|
||||
|
||||
|
||||
function removeFromStoryIDsToMaybeDelete(story_id) {
|
||||
storyIDsToMaybeDelete.splice(storyIDsToMaybeDelete.indexOf(story_id), 1);
|
||||
print('storyIDsToMaybeDelete[] now:', JSON.stringify(storyIDsToMaybeDelete));
|
||||
|
@ -73,33 +62,32 @@ function onMessage(message) {
|
|||
// 2. Although we currently use a single image, we would like to take snapshot, a selfie, a 360 etc. all at the
|
||||
// same time, show the user all of them, and have the user deselect any that they do not want to share.
|
||||
// So we'll ultimately be receiving a set of objects, perhaps with different post processing for each.
|
||||
message = JSON.parse(message);
|
||||
if (message.type !== "snapshot") {
|
||||
return;
|
||||
}
|
||||
|
||||
switch (message.action) {
|
||||
case 'ready': // DOM is ready and page has loaded
|
||||
tablet.emitScriptEvent(JSON.stringify({
|
||||
ui.sendMessage({
|
||||
type: "snapshot",
|
||||
action: "captureSettings",
|
||||
setting: Settings.getValue("alsoTakeAnimatedSnapshot", true)
|
||||
}));
|
||||
});
|
||||
if (Snapshot.getSnapshotsLocation() !== "") {
|
||||
isDomainOpen(Settings.getValue("previousSnapshotDomainID"), function (canShare) {
|
||||
tablet.emitScriptEvent(JSON.stringify({
|
||||
ui.sendMessage({
|
||||
type: "snapshot",
|
||||
action: "showPreviousImages",
|
||||
options: snapshotOptions,
|
||||
image_data: imageData,
|
||||
canShare: canShare
|
||||
}));
|
||||
});
|
||||
});
|
||||
} else {
|
||||
tablet.emitScriptEvent(JSON.stringify({
|
||||
ui.sendMessage({
|
||||
type: "snapshot",
|
||||
action: "showSetupInstructions"
|
||||
}));
|
||||
});
|
||||
Settings.setValue("previousStillSnapPath", "");
|
||||
Settings.setValue("previousStillSnapStoryID", "");
|
||||
Settings.setValue("previousStillSnapBlastingDisabled", false);
|
||||
|
@ -124,7 +112,7 @@ function onMessage(message) {
|
|||
|| (!HMD.active && Settings.getValue("desktopTabletBecomesToolbar", true))) {
|
||||
Desktop.show("hifi/dialogs/GeneralPreferencesDialog.qml", "GeneralPreferencesDialog");
|
||||
} else {
|
||||
tablet.loadQMLOnTop("hifi/tablet/TabletGeneralPreferences.qml");
|
||||
ui.openNewAppOnTop("hifi/tablet/TabletGeneralPreferences.qml");
|
||||
}
|
||||
break;
|
||||
case 'captureStillAndGif':
|
||||
|
@ -284,7 +272,6 @@ var POLAROID_RATE_LIMIT_MS = 1000;
|
|||
var polaroidPrintingIsRateLimited = false;
|
||||
|
||||
function printToPolaroid(image_url) {
|
||||
|
||||
// Rate-limit printing
|
||||
if (polaroidPrintingIsRateLimited) {
|
||||
return;
|
||||
|
@ -376,19 +363,6 @@ function fillImageDataFromPrevious() {
|
|||
}
|
||||
}
|
||||
|
||||
var SNAPSHOT_REVIEW_URL = Script.resolvePath("html/SnapshotReview.html");
|
||||
var isInSnapshotReview = false;
|
||||
function onButtonClicked() {
|
||||
if (isInSnapshotReview){
|
||||
// for toolbar-mode: go back to home screen, this will close the window.
|
||||
tablet.gotoHomeScreen();
|
||||
} else {
|
||||
fillImageDataFromPrevious();
|
||||
tablet.gotoWebScreen(SNAPSHOT_REVIEW_URL);
|
||||
HMD.openTablet();
|
||||
}
|
||||
}
|
||||
|
||||
function snapshotUploaded(isError, reply) {
|
||||
if (!isError) {
|
||||
var replyJson = JSON.parse(reply),
|
||||
|
@ -409,12 +383,12 @@ function snapshotUploaded(isError, reply) {
|
|||
}
|
||||
if ((isGif && !ignoreGifSnapshotData) || (!isGif && !ignoreStillSnapshotData)) {
|
||||
print('SUCCESS: Snapshot uploaded! Story with audience:for_url created! ID:', storyID);
|
||||
tablet.emitScriptEvent(JSON.stringify({
|
||||
ui.sendMessage({
|
||||
type: "snapshot",
|
||||
action: "snapshotUploadComplete",
|
||||
story_id: storyID,
|
||||
image_url: imageURL,
|
||||
}));
|
||||
});
|
||||
if (isGif) {
|
||||
Settings.setValue("previousAnimatedSnapStoryID", storyID);
|
||||
} else {
|
||||
|
@ -429,10 +403,10 @@ function snapshotUploaded(isError, reply) {
|
|||
}
|
||||
var href, snapshotDomainID;
|
||||
function takeSnapshot() {
|
||||
tablet.emitScriptEvent(JSON.stringify({
|
||||
ui.sendMessage({
|
||||
type: "snapshot",
|
||||
action: "clearPreviousImages"
|
||||
}));
|
||||
});
|
||||
Settings.setValue("previousStillSnapPath", "");
|
||||
Settings.setValue("previousStillSnapStoryID", "");
|
||||
Settings.setValue("previousStillSnapBlastingDisabled", false);
|
||||
|
@ -471,10 +445,6 @@ function takeSnapshot() {
|
|||
} else {
|
||||
Window.stillSnapshotTaken.connect(stillSnapshotTaken);
|
||||
}
|
||||
if (buttonConnected) {
|
||||
button.clicked.disconnect(onButtonClicked);
|
||||
buttonConnected = false;
|
||||
}
|
||||
|
||||
// hide overlays if they are on
|
||||
if (resetOverlays) {
|
||||
|
@ -538,10 +508,6 @@ function stillSnapshotTaken(pathStillSnapshot, notify) {
|
|||
Menu.setIsOptionChecked("Show Overlays", true);
|
||||
}
|
||||
Window.stillSnapshotTaken.disconnect(stillSnapshotTaken);
|
||||
if (!buttonConnected) {
|
||||
button.clicked.connect(onButtonClicked);
|
||||
buttonConnected = true;
|
||||
}
|
||||
|
||||
// A Snapshot Review dialog might be left open indefinitely after taking the picture,
|
||||
// during which time the user may have moved. So stash that info in the dialog so that
|
||||
|
@ -559,12 +525,12 @@ function stillSnapshotTaken(pathStillSnapshot, notify) {
|
|||
isLoggedIn: isLoggedIn
|
||||
};
|
||||
imageData = [{ localPath: pathStillSnapshot, href: href }];
|
||||
tablet.emitScriptEvent(JSON.stringify({
|
||||
ui.sendMessage({
|
||||
type: "snapshot",
|
||||
action: "addImages",
|
||||
options: snapshotOptions,
|
||||
image_data: imageData
|
||||
}));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -572,10 +538,10 @@ function snapshotDirChanged(snapshotPath) {
|
|||
Window.browseDirChanged.disconnect(snapshotDirChanged);
|
||||
if (snapshotPath !== "") { // not cancelled
|
||||
Snapshot.setSnapshotsLocation(snapshotPath);
|
||||
tablet.emitScriptEvent(JSON.stringify({
|
||||
ui.sendMessage({
|
||||
type: "snapshot",
|
||||
action: "snapshotLocationChosen"
|
||||
}));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -603,22 +569,18 @@ function processingGifStarted(pathStillSnapshot) {
|
|||
isLoggedIn: isLoggedIn
|
||||
};
|
||||
imageData = [{ localPath: pathStillSnapshot, href: href }];
|
||||
tablet.emitScriptEvent(JSON.stringify({
|
||||
ui.sendMessage({
|
||||
type: "snapshot",
|
||||
action: "addImages",
|
||||
options: snapshotOptions,
|
||||
image_data: imageData
|
||||
}));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function processingGifCompleted(pathAnimatedSnapshot) {
|
||||
isLoggedIn = Account.isLoggedIn();
|
||||
Window.processingGifCompleted.disconnect(processingGifCompleted);
|
||||
if (!buttonConnected) {
|
||||
button.clicked.connect(onButtonClicked);
|
||||
buttonConnected = true;
|
||||
}
|
||||
|
||||
Settings.setValue("previousAnimatedSnapPath", pathAnimatedSnapshot);
|
||||
|
||||
|
@ -631,12 +593,12 @@ function processingGifCompleted(pathAnimatedSnapshot) {
|
|||
canBlast: location.domainID === Settings.getValue("previousSnapshotDomainID"),
|
||||
};
|
||||
imageData = [{ localPath: pathAnimatedSnapshot, href: href }];
|
||||
tablet.emitScriptEvent(JSON.stringify({
|
||||
ui.sendMessage({
|
||||
type: "snapshot",
|
||||
action: "addImages",
|
||||
options: snapshotOptions,
|
||||
image_data: imageData
|
||||
}));
|
||||
});
|
||||
});
|
||||
}
|
||||
function maybeDeleteSnapshotStories() {
|
||||
|
@ -655,28 +617,16 @@ function maybeDeleteSnapshotStories() {
|
|||
});
|
||||
storyIDsToMaybeDelete = [];
|
||||
}
|
||||
function onTabletScreenChanged(type, url) {
|
||||
var wasInSnapshotReview = isInSnapshotReview;
|
||||
isInSnapshotReview = (type === "Web" && url === SNAPSHOT_REVIEW_URL);
|
||||
button.editProperties({ isActive: isInSnapshotReview });
|
||||
if (isInSnapshotReview !== wasInSnapshotReview) {
|
||||
if (isInSnapshotReview) {
|
||||
tablet.webEventReceived.connect(onMessage);
|
||||
} else {
|
||||
tablet.webEventReceived.disconnect(onMessage);
|
||||
}
|
||||
}
|
||||
}
|
||||
function onUsernameChanged() {
|
||||
fillImageDataFromPrevious();
|
||||
isDomainOpen(Settings.getValue("previousSnapshotDomainID"), function (canShare) {
|
||||
tablet.emitScriptEvent(JSON.stringify({
|
||||
ui.sendMessage({
|
||||
type: "snapshot",
|
||||
action: "showPreviousImages",
|
||||
options: snapshotOptions,
|
||||
image_data: imageData,
|
||||
canShare: canShare
|
||||
}));
|
||||
});
|
||||
});
|
||||
if (isLoggedIn) {
|
||||
if (shareAfterLogin) {
|
||||
|
@ -705,10 +655,10 @@ function onUsernameChanged() {
|
|||
|
||||
function snapshotLocationSet(location) {
|
||||
if (location !== "") {
|
||||
tablet.emitScriptEvent(JSON.stringify({
|
||||
ui.sendMessage({
|
||||
type: "snapshot",
|
||||
action: "snapshotLocationChosen"
|
||||
}));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -733,36 +683,36 @@ function processRezPermissionChange(canRez) {
|
|||
action = 'setPrintButtonDisabled';
|
||||
}
|
||||
|
||||
tablet.emitScriptEvent(JSON.stringify({
|
||||
ui.sendMessage({
|
||||
type: "snapshot",
|
||||
action : action
|
||||
}));
|
||||
});
|
||||
}
|
||||
|
||||
button.clicked.connect(onButtonClicked);
|
||||
buttonConnected = true;
|
||||
function startup() {
|
||||
ui = new AppUi({
|
||||
buttonName: "SNAP",
|
||||
sortOrder: 5,
|
||||
home: Script.resolvePath("html/SnapshotReview.html"),
|
||||
onOpened: fillImageDataFromPrevious,
|
||||
onMessage: onMessage
|
||||
});
|
||||
|
||||
Window.snapshotShared.connect(snapshotUploaded);
|
||||
tablet.screenChanged.connect(onTabletScreenChanged);
|
||||
GlobalServices.myUsernameChanged.connect(onUsernameChanged);
|
||||
Snapshot.snapshotLocationSet.connect(snapshotLocationSet);
|
||||
Entities.canRezChanged.connect(updatePrintPermissions);
|
||||
Entities.canRezTmpChanged.connect(updatePrintPermissions);
|
||||
GlobalServices.myUsernameChanged.connect(onUsernameChanged);
|
||||
Snapshot.snapshotLocationSet.connect(snapshotLocationSet);
|
||||
Window.snapshotShared.connect(snapshotUploaded);
|
||||
}
|
||||
startup();
|
||||
|
||||
Entities.canRezChanged.connect(updatePrintPermissions);
|
||||
Entities.canRezTmpChanged.connect(updatePrintPermissions);
|
||||
|
||||
Script.scriptEnding.connect(function () {
|
||||
if (buttonConnected) {
|
||||
button.clicked.disconnect(onButtonClicked);
|
||||
buttonConnected = false;
|
||||
}
|
||||
if (tablet) {
|
||||
tablet.removeButton(button);
|
||||
tablet.screenChanged.disconnect(onTabletScreenChanged);
|
||||
}
|
||||
function shutdown() {
|
||||
Window.snapshotShared.disconnect(snapshotUploaded);
|
||||
Snapshot.snapshotLocationSet.disconnect(snapshotLocationSet);
|
||||
GlobalServices.myUsernameChanged.disconnect(onUsernameChanged);
|
||||
Entities.canRezChanged.disconnect(updatePrintPermissions);
|
||||
Entities.canRezTmpChanged.disconnect(updatePrintPermissions);
|
||||
});
|
||||
}
|
||||
Script.scriptEnding.connect(shutdown);
|
||||
|
||||
}()); // END LOCAL_SCOPE
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
"use strict";
|
||||
/*jslint vars:true, plusplus:true, forin:true*/
|
||||
/*global Window, Script, Tablet, HMD, Controller, Account, XMLHttpRequest, location, print*/
|
||||
/* jslint vars:true, plusplus:true, forin:true */
|
||||
/* eslint indent: ["error", 4, { "outerIIFEBody": 0 }] */
|
||||
/* global Window, Script, Tablet, HMD, Controller, Account, XMLHttpRequest, location, print */
|
||||
|
||||
//
|
||||
// goto.js
|
||||
// tablet-goto.js
|
||||
// scripts/system/
|
||||
//
|
||||
// Created by Dante Ruiz on 8 February 2017
|
||||
|
@ -14,148 +15,118 @@
|
|||
//
|
||||
|
||||
(function () { // BEGIN LOCAL_SCOPE
|
||||
var request = Script.require('request').request;
|
||||
var AppUi = Script.require('appUi');
|
||||
var DEBUG = false;
|
||||
function debug() {
|
||||
if (!DEBUG) {
|
||||
return;
|
||||
}
|
||||
print('tablet-goto.js:', [].map.call(arguments, JSON.stringify));
|
||||
}
|
||||
|
||||
var request = Script.require('request').request;
|
||||
var DEBUG = false;
|
||||
function debug() {
|
||||
if (!DEBUG) {
|
||||
var stories = {}, pingPong = false;
|
||||
function expire(id) {
|
||||
var options = {
|
||||
uri: Account.metaverseServerURL + '/api/v1/user_stories/' + id,
|
||||
method: 'PUT',
|
||||
json: true,
|
||||
body: {expire: "true"}
|
||||
};
|
||||
request(options, function (error, response) {
|
||||
debug('expired story', options, 'error:', error, 'response:', response);
|
||||
if (error || (response.status !== 'success')) {
|
||||
print("ERROR expiring story: ", error || response.status);
|
||||
}
|
||||
});
|
||||
}
|
||||
var PER_PAGE_DEBUG = 10;
|
||||
var PER_PAGE_NORMAL = 100;
|
||||
function pollForAnnouncements() {
|
||||
// We could bail now if !Account.isLoggedIn(), but what if we someday have system-wide announcments?
|
||||
var actions = 'announcement';
|
||||
var count = DEBUG ? PER_PAGE_DEBUG : PER_PAGE_NORMAL;
|
||||
var options = [
|
||||
'now=' + new Date().toISOString(),
|
||||
'include_actions=' + actions,
|
||||
'restriction=' + (Account.isLoggedIn() ? 'open,hifi' : 'open'),
|
||||
'require_online=true',
|
||||
'protocol=' + encodeURIComponent(Window.protocolSignature()),
|
||||
'per_page=' + count
|
||||
];
|
||||
var url = Account.metaverseServerURL + '/api/v1/user_stories?' + options.join('&');
|
||||
request({
|
||||
uri: url
|
||||
}, function (error, data) {
|
||||
debug(url, error, data);
|
||||
if (error || (data.status !== 'success')) {
|
||||
print("Error: unable to get", url, error || data.status);
|
||||
return;
|
||||
}
|
||||
print('tablet-goto.js:', [].map.call(arguments, JSON.stringify));
|
||||
}
|
||||
|
||||
var gotoQmlSource = "hifi/tablet/TabletAddressDialog.qml";
|
||||
var buttonName = "GOTO";
|
||||
var onGotoScreen = false;
|
||||
var shouldActivateButton = false;
|
||||
function ignore() { }
|
||||
|
||||
var tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system");
|
||||
var NORMAL_ICON = "icons/tablet-icons/goto-i.svg";
|
||||
var NORMAL_ACTIVE = "icons/tablet-icons/goto-a.svg";
|
||||
var WAITING_ICON = "icons/tablet-icons/goto-msg.svg";
|
||||
var button = tablet.addButton({
|
||||
icon: NORMAL_ICON,
|
||||
activeIcon: NORMAL_ACTIVE,
|
||||
text: buttonName,
|
||||
sortOrder: 8
|
||||
});
|
||||
|
||||
function messagesWaiting(isWaiting) {
|
||||
button.editProperties({
|
||||
icon: isWaiting ? WAITING_ICON : NORMAL_ICON
|
||||
// No need for a different activeIcon, because we issue messagesWaiting(false) when the button goes active anyway.
|
||||
});
|
||||
}
|
||||
|
||||
function onClicked() {
|
||||
if (onGotoScreen) {
|
||||
// for toolbar-mode: go back to home screen, this will close the window.
|
||||
tablet.gotoHomeScreen();
|
||||
} else {
|
||||
shouldActivateButton = true;
|
||||
tablet.loadQMLSource(gotoQmlSource);
|
||||
onGotoScreen = true;
|
||||
}
|
||||
}
|
||||
|
||||
function onScreenChanged(type, url) {
|
||||
ignore(type);
|
||||
if (url === gotoQmlSource) {
|
||||
onGotoScreen = true;
|
||||
shouldActivateButton = true;
|
||||
button.editProperties({isActive: shouldActivateButton});
|
||||
messagesWaiting(false);
|
||||
} else {
|
||||
shouldActivateButton = false;
|
||||
onGotoScreen = false;
|
||||
button.editProperties({isActive: shouldActivateButton});
|
||||
}
|
||||
}
|
||||
button.clicked.connect(onClicked);
|
||||
tablet.screenChanged.connect(onScreenChanged);
|
||||
|
||||
var stories = {}, pingPong = false;
|
||||
function expire(id) {
|
||||
var options = {
|
||||
uri: Account.metaverseServerURL + '/api/v1/user_stories/' + id,
|
||||
method: 'PUT',
|
||||
json: true,
|
||||
body: {expire: "true"}
|
||||
};
|
||||
request(options, function (error, response) {
|
||||
debug('expired story', options, 'error:', error, 'response:', response);
|
||||
if (error || (response.status !== 'success')) {
|
||||
print("ERROR expiring story: ", error || response.status);
|
||||
var didNotify = false, key;
|
||||
pingPong = !pingPong;
|
||||
data.user_stories.forEach(function (story) {
|
||||
var stored = stories[story.id], storedOrNew = stored || story;
|
||||
debug('story exists:', !!stored, storedOrNew);
|
||||
if ((storedOrNew.username === Account.username) && (storedOrNew.place_name !== location.placename)) {
|
||||
if (storedOrNew.audience === 'for_connections') { // Only expire if we haven't already done so.
|
||||
expire(story.id);
|
||||
}
|
||||
return; // before marking
|
||||
}
|
||||
});
|
||||
}
|
||||
function pollForAnnouncements() {
|
||||
// We could bail now if !Account.isLoggedIn(), but what if we someday have system-wide announcments?
|
||||
var actions = 'announcement';
|
||||
var count = DEBUG ? 10 : 100;
|
||||
var options = [
|
||||
'now=' + new Date().toISOString(),
|
||||
'include_actions=' + actions,
|
||||
'restriction=' + (Account.isLoggedIn() ? 'open,hifi' : 'open'),
|
||||
'require_online=true',
|
||||
'protocol=' + encodeURIComponent(Window.protocolSignature()),
|
||||
'per_page=' + count
|
||||
];
|
||||
var url = Account.metaverseServerURL + '/api/v1/user_stories?' + options.join('&');
|
||||
request({
|
||||
uri: url
|
||||
}, function (error, data) {
|
||||
debug(url, error, data);
|
||||
if (error || (data.status !== 'success')) {
|
||||
print("Error: unable to get", url, error || data.status);
|
||||
storedOrNew.pingPong = pingPong;
|
||||
if (stored) { // already seen
|
||||
return;
|
||||
}
|
||||
var didNotify = false, key;
|
||||
pingPong = !pingPong;
|
||||
data.user_stories.forEach(function (story) {
|
||||
var stored = stories[story.id], storedOrNew = stored || story;
|
||||
debug('story exists:', !!stored, storedOrNew);
|
||||
if ((storedOrNew.username === Account.username) && (storedOrNew.place_name !== location.placename)) {
|
||||
if (storedOrNew.audience == 'for_connections') { // Only expire if we haven't already done so.
|
||||
expire(story.id);
|
||||
}
|
||||
return; // before marking
|
||||
}
|
||||
storedOrNew.pingPong = pingPong;
|
||||
if (stored) { // already seen
|
||||
return;
|
||||
}
|
||||
stories[story.id] = story;
|
||||
var message = story.username + " " + story.action_string + " in " + story.place_name + ". Open GOTO to join them.";
|
||||
Window.displayAnnouncement(message);
|
||||
didNotify = true;
|
||||
});
|
||||
for (key in stories) { // Any story we were tracking that was not marked, has expired.
|
||||
if (stories[key].pingPong !== pingPong) {
|
||||
debug('removing story', key);
|
||||
delete stories[key];
|
||||
}
|
||||
}
|
||||
if (didNotify) {
|
||||
messagesWaiting(true);
|
||||
if (HMD.isHandControllerAvailable()) {
|
||||
var STRENGTH = 1.0, DURATION_MS = 60, HAND = 2; // both hands
|
||||
Controller.triggerHapticPulse(STRENGTH, DURATION_MS, HAND);
|
||||
}
|
||||
} else if (!Object.keys(stories).length) { // If there's nothing being tracked, then any messageWaiting has expired.
|
||||
messagesWaiting(false);
|
||||
}
|
||||
stories[story.id] = story;
|
||||
var message = story.username + " " + story.action_string + " in " +
|
||||
story.place_name + ". Open GOTO to join them.";
|
||||
Window.displayAnnouncement(message);
|
||||
didNotify = true;
|
||||
});
|
||||
}
|
||||
var ANNOUNCEMENTS_POLL_TIME_MS = (DEBUG ? 10 : 60) * 1000;
|
||||
var pollTimer = Script.setInterval(pollForAnnouncements, ANNOUNCEMENTS_POLL_TIME_MS);
|
||||
|
||||
Script.scriptEnding.connect(function () {
|
||||
Script.clearInterval(pollTimer);
|
||||
button.clicked.disconnect(onClicked);
|
||||
tablet.removeButton(button);
|
||||
tablet.screenChanged.disconnect(onScreenChanged);
|
||||
for (key in stories) { // Any story we were tracking that was not marked, has expired.
|
||||
if (stories[key].pingPong !== pingPong) {
|
||||
debug('removing story', key);
|
||||
delete stories[key];
|
||||
}
|
||||
}
|
||||
if (didNotify) {
|
||||
ui.messagesWaiting(true);
|
||||
if (HMD.isHandControllerAvailable()) {
|
||||
var STRENGTH = 1.0, DURATION_MS = 60, HAND = 2; // both hands
|
||||
Controller.triggerHapticPulse(STRENGTH, DURATION_MS, HAND);
|
||||
}
|
||||
} else if (!Object.keys(stories).length) { // If there's nothing being tracked, then any messageWaiting has expired.
|
||||
ui.messagesWaiting(false);
|
||||
}
|
||||
});
|
||||
}
|
||||
var MS_PER_SEC = 1000;
|
||||
var DEBUG_POLL_TIME_SEC = 10;
|
||||
var NORMAL_POLL_TIME_SEC = 60;
|
||||
var ANNOUNCEMENTS_POLL_TIME_MS = (DEBUG ? DEBUG_POLL_TIME_SEC : NORMAL_POLL_TIME_SEC) * MS_PER_SEC;
|
||||
var pollTimer = Script.setInterval(pollForAnnouncements, ANNOUNCEMENTS_POLL_TIME_MS);
|
||||
|
||||
function gotoOpened() {
|
||||
ui.messagesWaiting(false);
|
||||
}
|
||||
|
||||
var ui;
|
||||
var GOTO_QML_SOURCE = "hifi/tablet/TabletAddressDialog.qml";
|
||||
var BUTTON_NAME = "GOTO";
|
||||
function startup() {
|
||||
ui = new AppUi({
|
||||
buttonName: BUTTON_NAME,
|
||||
sortOrder: 8,
|
||||
onOpened: gotoOpened,
|
||||
home: GOTO_QML_SOURCE
|
||||
});
|
||||
}
|
||||
|
||||
function shutdown() {
|
||||
Script.clearInterval(pollTimer);
|
||||
}
|
||||
|
||||
startup();
|
||||
Script.scriptEnding.connect(shutdown);
|
||||
}()); // END LOCAL_SCOPE
|
||||
|
|
Loading…
Reference in a new issue