mirror of
https://github.com/lubosz/overte.git
synced 2025-08-08 03:08:00 +02:00
Tons of fixes and improvements!
This commit is contained in:
parent
b2c5a1f899
commit
4f85923517
3 changed files with 33 additions and 15 deletions
|
@ -24,6 +24,7 @@ Rectangle {
|
||||||
HifiConstants { id: hifi; }
|
HifiConstants { id: hifi; }
|
||||||
|
|
||||||
id: checkoutRoot;
|
id: checkoutRoot;
|
||||||
|
property string itemId;
|
||||||
// Style
|
// Style
|
||||||
color: hifi.colors.baseGray;
|
color: hifi.colors.baseGray;
|
||||||
|
|
||||||
|
@ -241,7 +242,7 @@ Rectangle {
|
||||||
width: parent.width/2 - anchors.leftMargin*2;
|
width: parent.width/2 - anchors.leftMargin*2;
|
||||||
text: "Cancel"
|
text: "Cancel"
|
||||||
onClicked: {
|
onClicked: {
|
||||||
sendToScript({method: 'checkout_cancelClicked'});
|
sendToScript({method: 'checkout_cancelClicked', params: itemId});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -258,7 +259,7 @@ Rectangle {
|
||||||
width: parent.width/2 - anchors.rightMargin*2;
|
width: parent.width/2 - anchors.rightMargin*2;
|
||||||
text: "Buy"
|
text: "Buy"
|
||||||
onClicked: {
|
onClicked: {
|
||||||
sendToScript({method: 'checkout_buyClicked'});
|
sendToScript({method: 'checkout_buyClicked', params: itemId});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -285,6 +286,7 @@ Rectangle {
|
||||||
function fromScript(message) {
|
function fromScript(message) {
|
||||||
switch (message.method) {
|
switch (message.method) {
|
||||||
case 'updateCheckoutQML':
|
case 'updateCheckoutQML':
|
||||||
|
itemId = message.params.itemId;
|
||||||
itemNameText.text = message.params.itemName;
|
itemNameText.text = message.params.itemName;
|
||||||
itemAuthorText.text = message.params.itemAuthor;
|
itemAuthorText.text = message.params.itemAuthor;
|
||||||
itemPriceText.text = message.params.itemPrice;
|
itemPriceText.text = message.params.itemPrice;
|
||||||
|
|
|
@ -67,7 +67,7 @@
|
||||||
|
|
||||||
// Footer actions.
|
// Footer actions.
|
||||||
$("#back-button").on("click", function () {
|
$("#back-button").on("click", function () {
|
||||||
(window.history.state != null) ? window.history.back() : window.location = "https://metaverse.highfidelity.com/marketplace?";
|
(document.referrer !== "") ? window.history.back() : window.location = "https://metaverse.highfidelity.com/marketplace?";
|
||||||
});
|
});
|
||||||
$("#all-markets").on("click", function () {
|
$("#all-markets").on("click", function () {
|
||||||
EventBridge.emitWebEvent(GOTO_DIRECTORY);
|
EventBridge.emitWebEvent(GOTO_DIRECTORY);
|
||||||
|
@ -89,35 +89,45 @@
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function buyButtonClicked(name, author, price) {
|
function buyButtonClicked(id, name, author, price) {
|
||||||
EventBridge.emitWebEvent(JSON.stringify({
|
EventBridge.emitWebEvent(JSON.stringify({
|
||||||
type: "CHECKOUT",
|
type: "CHECKOUT",
|
||||||
|
itemId: id,
|
||||||
itemName: name,
|
itemName: name,
|
||||||
itemAuthor: author,
|
itemAuthor: author,
|
||||||
itemPrice: price
|
itemPrice: price
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function injectBuyButtonOnMainPage() {
|
||||||
|
$('.grid-item').find('#price-or-edit').find('a').attr('href', '#');
|
||||||
|
$('.grid-item').find('#price-or-edit').find('.price').text("BUY");
|
||||||
|
$('.grid-item').find('#price-or-edit').find('a').on('click', function () {
|
||||||
|
buyButtonClicked($(this).closest('.grid-item').attr('data-item-id'),
|
||||||
|
$(this).closest('.grid-item').find('.item-title').text(),
|
||||||
|
$(this).closest('.grid-item').find('.creator').find('.value').text(),
|
||||||
|
10);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function injectHiFiCode() {
|
function injectHiFiCode() {
|
||||||
if (confirmPurchases) {
|
if (confirmPurchases) {
|
||||||
var target = document.getElementById('templated-items');
|
var target = document.getElementById('templated-items');
|
||||||
// MutationObserver is necessary because the DOM is populated after the page is loaded.
|
// MutationObserver is necessary because the DOM is populated after the page is loaded.
|
||||||
// We're searching for changes to the element whose ID is '#templated-items' - this is
|
// We're searching for changes to the element whose ID is '#templated-items' - this is
|
||||||
// the element that gets filled in by the AJAX.
|
// the element that gets filled in by the AJAX.
|
||||||
var observer = new MutationObserver(function (mutations) {
|
var observer = new MutationObserver(function (mutations) {
|
||||||
mutations.forEach(function (mutation) {
|
mutations.forEach(function (mutation) {
|
||||||
console.log(mutation.type);
|
injectBuyButtonOnMainPage();
|
||||||
$('.grid-item').find('#price-or-edit').find('a').attr('href', '#');
|
|
||||||
$('.grid-item').find('#price-or-edit').find('.price').text("BUY");
|
|
||||||
$('.grid-item').find('#price-or-edit').find('a').on('click', function () {
|
|
||||||
buyButtonClicked($(this).closest('.grid-item').find('.item-title').text(), $(this).closest('.grid-item').find('.creator').find('.value').text(), 10);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
//observer.disconnect();
|
//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);
|
||||||
|
|
||||||
|
// Try this here in case it works (it will if the user just pressed the "back" button,
|
||||||
|
// since that doesn't trigger another AJAX request.
|
||||||
|
injectBuyButtonOnMainPage();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -126,7 +136,10 @@
|
||||||
$('#side-info').find('.btn').attr('href', '#');
|
$('#side-info').find('.btn').attr('href', '#');
|
||||||
$('#side-info').find('.btn').html('<span class="glyphicon glyphicon-download"></span>Buy Item ');
|
$('#side-info').find('.btn').html('<span class="glyphicon glyphicon-download"></span>Buy Item ');
|
||||||
$('#side-info').find('.btn').on('click', function () {
|
$('#side-info').find('.btn').on('click', function () {
|
||||||
buyButtonClicked($('#top-center').find('h1').text(), $('#creator').find('.value').text(), 10);
|
buyButtonClicked(window.location.pathname.split("/")[3],
|
||||||
|
$('#top-center').find('h1').text(),
|
||||||
|
$('#creator').find('.value').text(),
|
||||||
|
10);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -192,10 +192,13 @@
|
||||||
function fromQml(message) {
|
function fromQml(message) {
|
||||||
switch (message.method) {
|
switch (message.method) {
|
||||||
case 'checkout_cancelClicked':
|
case 'checkout_cancelClicked':
|
||||||
tablet.popFromStack();
|
tablet.gotoWebScreen(MARKETPLACE_URL + '/items/' + message.params, MARKETPLACES_INJECT_SCRIPT_URL);
|
||||||
|
// TODO: Make Marketplace a QML app that's a WebView wrapper so we can use the app stack.
|
||||||
|
// I don't think this is trivial to do since we also want to inject some JS into the DOM.
|
||||||
|
//tablet.popFromStack();
|
||||||
break;
|
break;
|
||||||
case 'checkout_buyClicked':
|
case 'checkout_buyClicked':
|
||||||
tablet.popFromStack();
|
//tablet.popFromStack();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
print('Unrecognized message from Checkout.qml: ' + JSON.stringify(message));
|
print('Unrecognized message from Checkout.qml: ' + JSON.stringify(message));
|
||||||
|
|
Loading…
Reference in a new issue