mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 22:36:57 +02:00
Lots of changes; marketplaces.js working now
This commit is contained in:
parent
de2548d926
commit
01073ca18d
7 changed files with 1747 additions and 1711 deletions
|
@ -252,12 +252,6 @@ bool ContextOverlayInterface::destroyContextOverlay(const EntityItemID& entityIt
|
||||||
void ContextOverlayInterface::contextOverlays_mousePressOnOverlay(const OverlayID& overlayID, const PointerEvent& event) {
|
void ContextOverlayInterface::contextOverlays_mousePressOnOverlay(const OverlayID& overlayID, const PointerEvent& event) {
|
||||||
if (overlayID == _contextOverlayID && event.getButton() == PointerEvent::PrimaryButton) {
|
if (overlayID == _contextOverlayID && event.getButton() == PointerEvent::PrimaryButton) {
|
||||||
qCDebug(context_overlay) << "Clicked Context Overlay. Entity ID:" << _currentEntityWithContextOverlay << "Overlay ID:" << overlayID;
|
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);
|
emit contextOverlayClicked(_currentEntityWithContextOverlay);
|
||||||
_contextOverlayJustClicked = true;
|
_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) {
|
void ContextOverlayInterface::enableEntityHighlight(const EntityItemID& entityItemID) {
|
||||||
_selectionScriptingInterface->addToSelectedItemsList("contextOverlayHighlightList", "entity", entityItemID);
|
_selectionScriptingInterface->addToSelectedItemsList("contextOverlayHighlightList", "entity", entityItemID);
|
||||||
}
|
}
|
||||||
|
|
|
@ -94,8 +94,6 @@ private:
|
||||||
|
|
||||||
bool _isInMarketplaceInspectionMode { false };
|
bool _isInMarketplaceInspectionMode { false };
|
||||||
|
|
||||||
void openInspectionCertificate();
|
|
||||||
void openMarketplace();
|
|
||||||
void enableEntityHighlight(const EntityItemID& entityItemID);
|
void enableEntityHighlight(const EntityItemID& entityItemID);
|
||||||
void disableEntityHighlight(const EntityItemID& entityItemID);
|
void disableEntityHighlight(const EntityItemID& entityItemID);
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
"use strict";
|
"use strict";
|
||||||
/*global Tablet, Script*/
|
/* global Tablet, Script */
|
||||||
//
|
//
|
||||||
// libraries/appUi.js
|
// libraries/appUi.js
|
||||||
//
|
//
|
||||||
|
@ -31,53 +31,49 @@ function AppUi(properties) {
|
||||||
var that = this;
|
var that = this;
|
||||||
function defaultButton(name, suffix) {
|
function defaultButton(name, suffix) {
|
||||||
var base = that[name] || (that.buttonPrefix + 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:
|
// Defaults:
|
||||||
that.tabletName = "com.highfidelity.interface.tablet.system";
|
that.tabletName = "com.highfidelity.interface.tablet.system";
|
||||||
that.inject = "";
|
that.inject = "";
|
||||||
that.graphicsDirectory = "icons/tablet-icons/"; // Where to look for button svgs. See below.
|
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.
|
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.setCurrentVisibleScreenMetadata = function setCurrentVisibleScreenMetadata(type, url) {
|
||||||
that.currentUrl = url;
|
that.currentVisibleScreenType = type;
|
||||||
that.type = /.qml$/.test(url) ? 'QML' : 'Web';
|
that.currentVisibleUrl = url;
|
||||||
}
|
};
|
||||||
that.open = function open(optionalUrl) { // How to open the app.
|
that.open = function open(optionalUrl, optionalInject) { // How to open the app.
|
||||||
var url = optionalUrl || that.home;
|
var url = optionalUrl || that.home;
|
||||||
that.setCurrentData(url);
|
var inject = that.inject;
|
||||||
if (that.isQML()) {
|
if (optionalUrl && optionalInject) {
|
||||||
|
inject = optionalInject;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (that.isQMLUrl(url)) {
|
||||||
that.tablet.loadQMLSource(url);
|
that.tablet.loadQMLSource(url);
|
||||||
} else {
|
} else {
|
||||||
that.tablet.gotoWebScreen(url, that.inject);
|
that.tablet.gotoWebScreen(url, inject);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
that.openNewApp = function openNewApp(url, optionalInject) { // Opens some app and replaces the current app
|
// Opens some app on top of the current app (on desktop, opens new window)
|
||||||
if (that.isQML(url)) {
|
that.openNewAppOnTop = function openNewAppOnTop(url, optionalInject) {
|
||||||
that.tablet.pushOntoStack(url);
|
var inject = optionalInject || "";
|
||||||
} else {
|
if (that.isQMLUrl(url)) {
|
||||||
if (optionalInject) {
|
|
||||||
that.tablet.gotoWebScreen(url, optionalInject);
|
|
||||||
} else {
|
|
||||||
that.tablet.gotoWebScreen(url);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
that.openNewAppOnTop = function openNewAppOnTop(url, optionalInject) { // Opens some app on top of the current app (on desktop, opens new window)
|
|
||||||
if (that.isQML(url)) {
|
|
||||||
that.tablet.loadQMLOnTop(url);
|
that.tablet.loadQMLOnTop(url);
|
||||||
} else {
|
} else {
|
||||||
if (optionalInject) {
|
that.tablet.loadWebScreenOnTop(url, inject);
|
||||||
that.tablet.loadWebScreenOnTop(url, optionalInject);
|
|
||||||
} else {
|
|
||||||
that.tablet.loadWebScreenOnTop(url);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
that.close = function close() { // How to close the app.
|
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.
|
// for toolbar-mode: go back to home screen, this will close the window.
|
||||||
that.tablet.gotoHomeScreen();
|
that.tablet.gotoHomeScreen();
|
||||||
};
|
};
|
||||||
|
@ -91,15 +87,40 @@ function AppUi(properties) {
|
||||||
activeIcon: isWaiting ? that.activeMessagesButton : that.activeButton
|
activeIcon: isWaiting ? that.activeMessagesButton : that.activeButton
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
that.isQML = function isQML(optionalUrl) { // We set type property in onClick.
|
that.isQMLUrl = function isQMLUrl(url) {
|
||||||
if (optionalUrl) {
|
var type = /.qml$/.test(url) ? 'QML' : 'Web';
|
||||||
var type = /.qml$/.test(optionalUrl) ? 'QML' : 'Web';
|
return type === 'QML';
|
||||||
return type === 'QML';
|
|
||||||
}
|
|
||||||
return that.type === 'QML';
|
|
||||||
};
|
};
|
||||||
that.eventSignal = function eventSignal() { // What signal to hook onMessage to.
|
that.isCurrentlyOnQMLScreen = function isCurrentlyOnQMLScreen() {
|
||||||
return that.isQML() ? that.tablet.fromQml : that.tablet.webEventReceived;
|
return that.currentVisibleScreenType === 'QML';
|
||||||
|
};
|
||||||
|
|
||||||
|
// 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:
|
// Overwrite with the given properties:
|
||||||
|
@ -126,65 +147,55 @@ function AppUi(properties) {
|
||||||
}
|
}
|
||||||
that.button = that.tablet.addButton(buttonOptions);
|
that.button = that.tablet.addButton(buttonOptions);
|
||||||
that.ignore = function ignore() { };
|
that.ignore = function ignore() { };
|
||||||
|
that.hasQmlEventBridge = false;
|
||||||
// Handlers
|
that.hasHtmlEventBridge = false;
|
||||||
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;
|
|
||||||
// HTML event bridge uses strings, not objects. Here we abstract over that.
|
// HTML event bridge uses strings, not objects. Here we abstract over that.
|
||||||
// (Although injected javascript still has to use JSON.stringify/JSON.parse.)
|
// (Although injected javascript still has to use JSON.stringify/JSON.parse.)
|
||||||
that.sendToHtml = function (messageObject) { that.tablet.emitScriptEvent(JSON.stringify(messageObject)); };
|
that.sendToHtml = function (messageObject) {
|
||||||
that.fromHtml = function (messageString) { that.onMessage(JSON.parse(messageString)); };
|
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.sendMessage = that.ignore;
|
||||||
that.wireEventBridge = function wireEventBridge(on) {
|
that.wireEventBridge = function wireEventBridge(on) {
|
||||||
// Uniquivocally sets that.sendMessage(messageObject) to do the right thing.
|
// Uniquivocally sets that.sendMessage(messageObject) to do the right thing.
|
||||||
// Sets hasEventBridge and wires onMessage to eventSignal as appropriate, IFF onMessage defined.
|
// Sets has*EventBridge and wires onMessage to the proper event bridge as appropriate, IFF onMessage defined.
|
||||||
var handler, isQml = that.isQML();
|
var isCurrentlyOnQMLScreen = that.isCurrentlyOnQMLScreen();
|
||||||
// Outbound (always, regardless of whether there is an inbound handler).
|
// Outbound (always, regardless of whether there is an inbound handler).
|
||||||
if (on) {
|
if (on) {
|
||||||
that.sendMessage = isQml ? that.tablet.sendToQml : that.sendToHtml;
|
that.sendMessage = isCurrentlyOnQMLScreen ? that.tablet.sendToQml : that.sendToHtml;
|
||||||
} else {
|
} else {
|
||||||
that.sendMessage = that.ignore;
|
that.sendMessage = that.ignore;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!that.onMessage) { return; }
|
if (!that.onMessage) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Inbound
|
// Inbound
|
||||||
handler = isQml ? that.onMessage : that.fromHtml;
|
|
||||||
if (on) {
|
if (on) {
|
||||||
if (!that.hasEventBridge) {
|
if (isCurrentlyOnQMLScreen && !that.hasQmlEventBridge) {
|
||||||
console.debug(that.buttonName, 'connecting', that.eventSignal());
|
console.debug(that.buttonName, 'connecting', that.tablet.fromQml);
|
||||||
that.eventSignal().connect(handler);
|
that.tablet.fromQml.connect(that.onMessage);
|
||||||
that.hasEventBridge = true;
|
that.hasQmlEventBridge = true;
|
||||||
|
} else if (!isCurrentlyOnQMLScreen && !that.hasHtmlEventBridge) {
|
||||||
|
console.debug(that.buttonName, 'connecting', that.tablet.webEventReceived);
|
||||||
|
that.tablet.webEventReceived.connect(that.fromHtml);
|
||||||
|
that.hasHtmlEventBridge = true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (that.hasEventBridge) {
|
if (that.hasQmlEventBridge) {
|
||||||
console.debug(that.buttonName, 'disconnecting', that.eventSignal());
|
console.debug(that.buttonName, 'disconnecting', that.tablet.fromQml);
|
||||||
that.eventSignal().disconnect(handler);
|
that.tablet.fromQml.disconnect(that.onMessage);
|
||||||
that.hasEventBridge = false;
|
that.hasQmlEventBridge = false;
|
||||||
|
}
|
||||||
|
if (that.hasHtmlEventBridge) {
|
||||||
|
console.debug(that.buttonName, 'disconnecting', that.tablet.webEventReceived);
|
||||||
|
that.tablet.webEventReceived.disconnect(that.fromHtml);
|
||||||
|
that.hasHtmlEventBridge = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,3 +1,5 @@
|
||||||
|
/* global $, window, MutationObserver */
|
||||||
|
|
||||||
//
|
//
|
||||||
// marketplacesInject.js
|
// marketplacesInject.js
|
||||||
//
|
//
|
||||||
|
@ -11,7 +13,6 @@
|
||||||
//
|
//
|
||||||
|
|
||||||
(function () {
|
(function () {
|
||||||
|
|
||||||
// Event bridge messages.
|
// Event bridge messages.
|
||||||
var CLARA_IO_DOWNLOAD = "CLARA.IO DOWNLOAD";
|
var CLARA_IO_DOWNLOAD = "CLARA.IO DOWNLOAD";
|
||||||
var CLARA_IO_STATUS = "CLARA.IO STATUS";
|
var CLARA_IO_STATUS = "CLARA.IO STATUS";
|
||||||
|
@ -24,7 +25,7 @@
|
||||||
|
|
||||||
var canWriteAssets = false;
|
var canWriteAssets = false;
|
||||||
var xmlHttpRequest = null;
|
var xmlHttpRequest = null;
|
||||||
var isPreparing = false; // Explicitly track download request status.
|
var isPreparing = false; // Explicitly track download request status.
|
||||||
|
|
||||||
var commerceMode = false;
|
var commerceMode = false;
|
||||||
var userIsLoggedIn = false;
|
var userIsLoggedIn = false;
|
||||||
|
@ -33,7 +34,6 @@
|
||||||
var messagesWaiting = false;
|
var messagesWaiting = false;
|
||||||
|
|
||||||
function injectCommonCode(isDirectoryPage) {
|
function injectCommonCode(isDirectoryPage) {
|
||||||
|
|
||||||
// Supporting styles from marketplaces.css.
|
// Supporting styles from marketplaces.css.
|
||||||
// Glyph font family, size, and spacing adjusted because HiFi-Glyphs cannot be used cross-domain.
|
// Glyph font family, size, and spacing adjusted because HiFi-Glyphs cannot be used cross-domain.
|
||||||
$("head").append(
|
$("head").append(
|
||||||
|
@ -74,7 +74,9 @@
|
||||||
(document.referrer !== "") ? window.history.back() : window.location = (marketplaceBaseURL + "/marketplace?");
|
(document.referrer !== "") ? window.history.back() : window.location = (marketplaceBaseURL + "/marketplace?");
|
||||||
});
|
});
|
||||||
$("#all-markets").on("click", function () {
|
$("#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({
|
EventBridge.emitWebEvent(JSON.stringify({
|
||||||
type: "WALLET_SETUP"
|
type: "WALLET_SETUP"
|
||||||
}));
|
}));
|
||||||
}
|
};
|
||||||
|
|
||||||
function maybeAddSetupWalletButton() {
|
function maybeAddSetupWalletButton() {
|
||||||
if (!$('body').hasClass("walletsetup-injected") && userIsLoggedIn && walletNeedsSetup) {
|
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').prev().attr("class", 'col-xs-6');
|
||||||
$(this).closest('.col-xs-3').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({
|
priceElement.css({
|
||||||
"padding": "3px 5px",
|
"padding": "3px 5px",
|
||||||
"height": "40px",
|
"height": "40px",
|
||||||
|
@ -355,12 +357,12 @@
|
||||||
function injectAddScrollbarToCategories() {
|
function injectAddScrollbarToCategories() {
|
||||||
$('#categories-dropdown').on('show.bs.dropdown', function () {
|
$('#categories-dropdown').on('show.bs.dropdown', function () {
|
||||||
$('body > div.container').css('display', 'none')
|
$('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 () {
|
$('#categories-dropdown').on('hide.bs.dropdown', function () {
|
||||||
$('body > div.container').css('display', '')
|
$('body > div.container').css('display', '');
|
||||||
$('#categories-dropdown > ul.dropdown-menu').css({ 'overflow': '', 'height': '' })
|
$('#categories-dropdown > ul.dropdown-menu').css({ 'overflow': '', 'height': '' });
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -382,7 +384,6 @@
|
||||||
mutations.forEach(function (mutation) {
|
mutations.forEach(function (mutation) {
|
||||||
injectBuyButtonOnMainPage();
|
injectBuyButtonOnMainPage();
|
||||||
});
|
});
|
||||||
//observer.disconnect();
|
|
||||||
});
|
});
|
||||||
var config = { attributes: true, childList: true, characterData: true };
|
var config = { attributes: true, childList: true, characterData: true };
|
||||||
observer.observe(target, config);
|
observer.observe(target, config);
|
||||||
|
@ -451,8 +452,8 @@
|
||||||
"itemPage",
|
"itemPage",
|
||||||
urlParams.get('edition'),
|
urlParams.get('edition'),
|
||||||
type);
|
type);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
maybeAddPurchasesButton();
|
maybeAddPurchasesButton();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -503,127 +504,142 @@
|
||||||
$(".top-title .col-sm-4").append(downloadContainer);
|
$(".top-title .col-sm-4").append(downloadContainer);
|
||||||
downloadContainer.append(downloadFBX);
|
downloadContainer.append(downloadFBX);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Automatic download to High Fidelity.
|
// Automatic download to High Fidelity.
|
||||||
function startAutoDownload() {
|
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.
|
// User must be able to write to Asset Server.
|
||||||
if (isPreparing) {
|
if (!canWriteAssets) {
|
||||||
console.log("WARNING: Clara.io FBX: Prepare only one download at a time");
|
console.log("ERROR: Clara.io FBX: File download cancelled because no permissions to write to Asset Server");
|
||||||
return;
|
EventBridge.emitWebEvent(JSON.stringify({
|
||||||
}
|
type: WARN_USER_NO_PERMISSIONS
|
||||||
|
}));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// User must be able to write to Asset Server.
|
// User must be logged in.
|
||||||
if (!canWriteAssets) {
|
var loginButton = $("#topnav a[href='/signup']");
|
||||||
console.log("ERROR: Clara.io FBX: File download cancelled because no permissions to write to Asset Server");
|
if (loginButton.length > 0) {
|
||||||
EventBridge.emitWebEvent(WARN_USER_NO_PERMISSIONS);
|
loginButton[0].click();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// User must be logged in.
|
// Obtain zip file to download for requested asset.
|
||||||
var loginButton = $("#topnav a[href='/signup']");
|
// Reference: https://clara.io/learn/sdk/api/export
|
||||||
if (loginButton.length > 0) {
|
|
||||||
loginButton[0].click();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Obtain zip file to download for requested asset.
|
//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";
|
||||||
// Reference: https://clara.io/learn/sdk/api/export
|
// 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";
|
var uuid = location.href.match(/\/view\/([a-z0-9\-]*)/)[1];
|
||||||
// 13 Jan 2017: Specify FBX version 5 and remove some options in order to make Clara.io site more likely to
|
var url = XMLHTTPREQUEST_URL.replace("{uuid}", uuid);
|
||||||
// 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];
|
xmlHttpRequest = new XMLHttpRequest();
|
||||||
var url = XMLHTTPREQUEST_URL.replace("{uuid}", uuid);
|
var responseTextIndex = 0;
|
||||||
|
var zipFileURL = "";
|
||||||
|
|
||||||
xmlHttpRequest = new XMLHttpRequest();
|
xmlHttpRequest.onreadystatechange = function () {
|
||||||
var responseTextIndex = 0;
|
// Messages are appended to responseText; process the new ones.
|
||||||
var zipFileURL = "";
|
var message = this.responseText.slice(responseTextIndex);
|
||||||
|
var statusMessage = "";
|
||||||
|
|
||||||
xmlHttpRequest.onreadystatechange = function () {
|
if (isPreparing) { // Ignore messages in flight after finished/cancelled.
|
||||||
// Messages are appended to responseText; process the new ones.
|
var lines = message.split(/[\n\r]+/);
|
||||||
var message = this.responseText.slice(responseTextIndex);
|
|
||||||
var statusMessage = "";
|
|
||||||
|
|
||||||
if (isPreparing) { // Ignore messages in flight after finished/cancelled.
|
for (var i = 0, length = lines.length; i < length; i++) {
|
||||||
var lines = message.split(/[\n\r]+/);
|
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++) {
|
// Extract status message.
|
||||||
if (lines[i].slice(0, 5) === "data:") {
|
if (data.hasOwnProperty("message") && data.message !== null) {
|
||||||
// Parse line.
|
statusMessage = data.message;
|
||||||
var data;
|
console.log("Clara.io FBX: " + statusMessage);
|
||||||
try {
|
}
|
||||||
data = JSON.parse(lines[i].slice(5));
|
|
||||||
}
|
|
||||||
catch (e) {
|
|
||||||
data = {};
|
|
||||||
}
|
|
||||||
|
|
||||||
// Extract status message.
|
// Extract zip file URL.
|
||||||
if (data.hasOwnProperty("message") && data.message !== null) {
|
if (data.hasOwnProperty("files") && data.files.length > 0) {
|
||||||
statusMessage = data.message;
|
zipFileURL = data.files[0].url;
|
||||||
console.log("Clara.io FBX: " + statusMessage);
|
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;
|
if (statusMessage !== "") {
|
||||||
|
// Update the UI with the most recent status message.
|
||||||
console.log("Clara.io FBX: Request zip file for " + uuid);
|
EventBridge.emitWebEvent(JSON.stringify({
|
||||||
EventBridge.emitWebEvent(CLARA_IO_STATUS + " Initiating download");
|
type: CLARA_IO_STATUS,
|
||||||
|
status: statusMessage
|
||||||
xmlHttpRequest.open("POST", url, true);
|
}));
|
||||||
xmlHttpRequest.setRequestHeader("Accept", "text/event-stream");
|
}
|
||||||
xmlHttpRequest.send();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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() {
|
function injectClaraCode() {
|
||||||
|
@ -663,7 +679,9 @@
|
||||||
updateClaraCodeInterval = undefined;
|
updateClaraCodeInterval = undefined;
|
||||||
});
|
});
|
||||||
|
|
||||||
EventBridge.emitWebEvent(QUERY_CAN_WRITE_ASSETS);
|
EventBridge.emitWebEvent(JSON.stringify({
|
||||||
|
type: QUERY_CAN_WRITE_ASSETS
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
function cancelClaraDownload() {
|
function cancelClaraDownload() {
|
||||||
|
@ -673,7 +691,9 @@
|
||||||
xmlHttpRequest.abort();
|
xmlHttpRequest.abort();
|
||||||
xmlHttpRequest = null;
|
xmlHttpRequest = null;
|
||||||
console.log("Clara.io FBX: File download cancelled");
|
console.log("Clara.io FBX: File download cancelled");
|
||||||
EventBridge.emitWebEvent(CLARA_IO_CANCELLED_DOWNLOAD);
|
EventBridge.emitWebEvent(JSON.stringify({
|
||||||
|
type: CLARA_IO_CANCELLED_DOWNLOAD
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -708,26 +728,22 @@
|
||||||
|
|
||||||
function onLoad() {
|
function onLoad() {
|
||||||
EventBridge.scriptEventReceived.connect(function (message) {
|
EventBridge.scriptEventReceived.connect(function (message) {
|
||||||
message = JSON.stringify(message);
|
message = JSON.parse(message);
|
||||||
if (message.slice(0, CAN_WRITE_ASSETS.length) === CAN_WRITE_ASSETS) {
|
if (message.type === CAN_WRITE_ASSETS) {
|
||||||
canWriteAssets = message.slice(-4) === "true";
|
canWriteAssets = message.canWriteAssets;
|
||||||
} else if (message.slice(0, CLARA_IO_CANCEL_DOWNLOAD.length) === CLARA_IO_CANCEL_DOWNLOAD) {
|
} else if (message.type === CLARA_IO_CANCEL_DOWNLOAD) {
|
||||||
cancelClaraDownload();
|
cancelClaraDownload();
|
||||||
} else {
|
} else if (message.type === "marketplaces") {
|
||||||
var parsedJsonMessage = JSON.parse(message);
|
if (message.action === "commerceSetting") {
|
||||||
|
commerceMode = !!message.data.commerceMode;
|
||||||
if (parsedJsonMessage.type === "marketplaces") {
|
userIsLoggedIn = !!message.data.userIsLoggedIn;
|
||||||
if (parsedJsonMessage.action === "commerceSetting") {
|
walletNeedsSetup = !!message.data.walletNeedsSetup;
|
||||||
commerceMode = !!parsedJsonMessage.data.commerceMode;
|
marketplaceBaseURL = message.data.metaverseServerURL;
|
||||||
userIsLoggedIn = !!parsedJsonMessage.data.userIsLoggedIn;
|
if (marketplaceBaseURL.indexOf('metaverse.') !== -1) {
|
||||||
walletNeedsSetup = !!parsedJsonMessage.data.walletNeedsSetup;
|
marketplaceBaseURL = marketplaceBaseURL.replace('metaverse.', '');
|
||||||
marketplaceBaseURL = parsedJsonMessage.data.metaverseServerURL;
|
|
||||||
if (marketplaceBaseURL.indexOf('metaverse.') !== -1) {
|
|
||||||
marketplaceBaseURL = marketplaceBaseURL.replace('metaverse.', '');
|
|
||||||
}
|
|
||||||
messagesWaiting = parsedJsonMessage.data.messagesWaiting;
|
|
||||||
injectCode();
|
|
||||||
}
|
}
|
||||||
|
messagesWaiting = message.data.messagesWaiting;
|
||||||
|
injectCode();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -740,6 +756,6 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load / unload.
|
// Load / unload.
|
||||||
window.addEventListener("load", onLoad); // More robust to Web site issues than using $(document).ready().
|
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("page:change", onLoad); // Triggered after Marketplace HTML is changed
|
||||||
}());
|
}());
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -713,7 +713,7 @@ function tabletVisibilityChanged() {
|
||||||
if (!ui.tablet.tabletShown && ui.isOpen) {
|
if (!ui.tablet.tabletShown && ui.isOpen) {
|
||||||
ui.close();
|
ui.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var UPDATE_INTERVAL_MS = 100;
|
var UPDATE_INTERVAL_MS = 100;
|
||||||
var updateInterval;
|
var updateInterval;
|
||||||
|
|
Loading…
Reference in a new issue