mirror of
https://github.com/overte-org/overte.git
synced 2025-04-26 17:56:15 +02:00
* canRez(Tmp)Certified() * CertifiedItem beginnings * Skeleton of verifyOwnerChallenge() * Controlled failure; updateLocation() skeletion * Controlled failure on checkout page with ctrl+f * Skeleton Purchases first-use tutorial * Initial progress on new setup * Security pic tip * Skeleton Certificate page * Updates to Certificate * General progress; setup is nearly complete * Better buttons; last step almost done * Initial progress on wallet home * Completed recent transactions * Security page * Scrollbar * Fix auth error text * PassphraseSelection * Change security pic * Minor layout changes; beginnings of emulated header * Various layout changes; wallet nav bar * Help screen * Quick onaccepted change * First pass at new purchases * Small style updates * Some error progress * Lightbox in purchases * Collapse other help answers when clicking on another * REZZED notif * Commerce Lightbox * Lots of new interactions in Purchases * Hook up 'view certificate' * Fix errors, fix close button on cert * Purchases timer; much faster filter * Add debugCheckout * Purchase updates * GlyphButton; separator; Checkout Success; Ledger fix; debug modes * Lock glyph below security pic should be white * Various fixes, round 1 * Circular mask * Passphrase change button fix; TextField error edge highlighting * Recent Activity fixes * Various changes * Standard Security Pic location * Color changes * Filter bar changes * Styling for multiple owned items * Minor language change * Header dropdown (harder than expected) * Small fixes * View backup instructions * marketplaces.js onCommerceScreen * Beginnign of new injection * Marketplace injection changes * Purchase button style changes * More button styling * MY PURCHASES button * marketplace onUsernameChanged * New help QA * Help text changes etc * Downscale security image, reducing filesize * Lots of bugfixes * Cleanup before PR * Only open cert during inspection if commerce switch is on * Help text changes * Purchase status incl. change to confirmed; Help text; Open Explorer to hifikey * Quick glyph change * New 'wallet not set up' flow for when entering Purchases or Checkout without set-up wallet
173 lines
6.1 KiB
JavaScript
173 lines
6.1 KiB
JavaScript
"use strict";
|
|
/*jslint vars:true, plusplus:true, forin:true*/
|
|
/* eslint indent: ["error", 4, { "outerIIFEBody": 0 }] */
|
|
//
|
|
// wallet.js
|
|
//
|
|
// Created by Zach Fox on 2017-08-17
|
|
// Copyright 2017 High Fidelity, Inc
|
|
//
|
|
// Distributed under the Apache License, Version 2.0
|
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
|
//
|
|
|
|
/*global XXX */
|
|
|
|
(function () { // BEGIN LOCAL_SCOPE
|
|
Script.include("/~/system/libraries/accountUtils.js");
|
|
|
|
// Function Name: onButtonClicked()
|
|
//
|
|
// Description:
|
|
// -Fired when the app button is pressed.
|
|
//
|
|
// Relevant Variables:
|
|
// -WALLET_QML_SOURCE: The path to the Wallet QML
|
|
// -onWalletScreen: true/false depending on whether we're looking at the app.
|
|
var WALLET_QML_SOURCE = Script.resourcesPath() + "qml/hifi/commerce/wallet/Wallet.qml";
|
|
var MARKETPLACE_PURCHASES_QML_PATH = Script.resourcesPath() + "qml/hifi/commerce/purchases/Purchases.qml";
|
|
var onWalletScreen = false;
|
|
function onButtonClicked() {
|
|
if (!tablet) {
|
|
print("Warning in buttonClicked(): 'tablet' undefined!");
|
|
return;
|
|
}
|
|
if (onWalletScreen) {
|
|
// for toolbar-mode: go back to home screen, this will close the window.
|
|
tablet.gotoHomeScreen();
|
|
} else {
|
|
tablet.loadQMLSource(WALLET_QML_SOURCE);
|
|
}
|
|
}
|
|
|
|
// Function Name: sendToQml()
|
|
//
|
|
// Description:
|
|
// -Use this function to send a message to the QML (i.e. to change appearances). The "message" argument is what is sent to
|
|
// the QML in the format "{method, params}", like json-rpc. See also fromQml().
|
|
function sendToQml(message) {
|
|
tablet.sendToQml(message);
|
|
}
|
|
|
|
// Function Name: fromQml()
|
|
//
|
|
// Description:
|
|
// -Called when a message is received from SpectatorCamera.qml. The "message" argument is what is sent from the QML
|
|
// in the format "{method, params}", like json-rpc. See also sendToQml().
|
|
var isHmdPreviewDisabled = true;
|
|
var MARKETPLACES_INJECT_SCRIPT_URL = Script.resolvePath("../html/js/marketplacesInject.js");
|
|
function fromQml(message) {
|
|
switch (message.method) {
|
|
case 'passphrasePopup_cancelClicked':
|
|
case 'walletSetup_cancelClicked':
|
|
case 'needsLogIn_cancelClicked':
|
|
tablet.gotoHomeScreen();
|
|
break;
|
|
case 'needsLogIn_loginClicked':
|
|
openLoginWindow();
|
|
break;
|
|
case 'disableHmdPreview':
|
|
isHmdPreviewDisabled = Menu.isOptionChecked("Disable Preview");
|
|
Menu.setIsOptionChecked("Disable Preview", true);
|
|
break;
|
|
case 'maybeEnableHmdPreview':
|
|
Menu.setIsOptionChecked("Disable Preview", isHmdPreviewDisabled);
|
|
break;
|
|
case 'passphraseReset':
|
|
onButtonClicked();
|
|
onButtonClicked();
|
|
break;
|
|
case 'walletReset':
|
|
onButtonClicked();
|
|
onButtonClicked();
|
|
break;
|
|
case 'transactionHistory_linkClicked':
|
|
tablet.gotoWebScreen(message.marketplaceLink, MARKETPLACES_INJECT_SCRIPT_URL);
|
|
break;
|
|
case 'goToPurchases':
|
|
tablet.pushOntoStack(MARKETPLACE_PURCHASES_QML_PATH);
|
|
break;
|
|
default:
|
|
print('Unrecognized message from QML:', JSON.stringify(message));
|
|
}
|
|
}
|
|
|
|
// Function Name: wireEventBridge()
|
|
//
|
|
// Description:
|
|
// -Used to connect/disconnect the script's response to the tablet's "fromQml" signal. Set the "on" argument to enable or
|
|
// disable to event bridge.
|
|
//
|
|
// Relevant Variables:
|
|
// -hasEventBridge: true/false depending on whether we've already connected the event bridge.
|
|
var hasEventBridge = false;
|
|
function wireEventBridge(on) {
|
|
if (!tablet) {
|
|
print("Warning in wireEventBridge(): 'tablet' undefined!");
|
|
return;
|
|
}
|
|
if (on) {
|
|
if (!hasEventBridge) {
|
|
tablet.fromQml.connect(fromQml);
|
|
hasEventBridge = true;
|
|
}
|
|
} else {
|
|
if (hasEventBridge) {
|
|
tablet.fromQml.disconnect(fromQml);
|
|
hasEventBridge = false;
|
|
}
|
|
}
|
|
}
|
|
|
|
// Function Name: onTabletScreenChanged()
|
|
//
|
|
// Description:
|
|
// -Called when the TabletScriptingInterface::screenChanged() signal is emitted. The "type" argument can be either the string
|
|
// value of "Home", "Web", "Menu", "QML", or "Closed". The "url" argument is only valid for Web and QML.
|
|
function onTabletScreenChanged(type, url) {
|
|
onWalletScreen = (type === "QML" && url === WALLET_QML_SOURCE);
|
|
wireEventBridge(onWalletScreen);
|
|
// Change button to active when window is first openend, false otherwise.
|
|
if (button) {
|
|
button.editProperties({ isActive: onWalletScreen });
|
|
}
|
|
}
|
|
|
|
//
|
|
// Manage the connection between the button and the window.
|
|
//
|
|
var button;
|
|
var buttonName = "WALLET";
|
|
var tablet = null;
|
|
var walletEnabled = Settings.getValue("commerce", false);
|
|
function startup() {
|
|
if (walletEnabled) {
|
|
tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system");
|
|
button = tablet.addButton({
|
|
text: buttonName,
|
|
icon: "icons/tablet-icons/wallet-i.svg",
|
|
activeIcon: "icons/tablet-icons/wallet-a.svg",
|
|
sortOrder: 10
|
|
});
|
|
button.clicked.connect(onButtonClicked);
|
|
tablet.screenChanged.connect(onTabletScreenChanged);
|
|
}
|
|
}
|
|
function shutdown() {
|
|
button.clicked.disconnect(onButtonClicked);
|
|
tablet.removeButton(button);
|
|
if (tablet) {
|
|
tablet.screenChanged.disconnect(onTabletScreenChanged);
|
|
if (onWalletScreen) {
|
|
tablet.gotoHomeScreen();
|
|
}
|
|
}
|
|
}
|
|
|
|
//
|
|
// Run the functions.
|
|
//
|
|
startup();
|
|
Script.scriptEnding.connect(shutdown);
|
|
|
|
}()); // END LOCAL_SCOPE
|