From 7d4fd995f29529c32547fe795d62292625ec6ff3 Mon Sep 17 00:00:00 2001 From: Zach Fox Date: Mon, 7 Aug 2017 14:29:47 -0700 Subject: [PATCH] First steps --- scripts/system/html/js/marketplacesInject.js | 20 +++++++++++++++++++- scripts/system/marketplaces/marketplaces.js | 5 +++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/scripts/system/html/js/marketplacesInject.js b/scripts/system/html/js/marketplacesInject.js index 8a8cf62008..89caa02d9e 100644 --- a/scripts/system/html/js/marketplacesInject.js +++ b/scripts/system/html/js/marketplacesInject.js @@ -87,8 +87,26 @@ }); } + function buyButtonClicked(name, author, price) { + EventBridge.emitWebEvent(JSON.stringify({ + type: "CHECKOUT", + itemName: name, + itemAuthor: author, + itemPrice: price + })); + } + function injectHiFiCode() { - // Nothing to do. + $('#side-info').find('.btn').attr('href', '#') + $('#side-info').find('.btn').on('click', function () { + buyButtonClicked("TEST ITEM", "Zach Fox", 10); + }); + + $('.item-footer').find('#price-or-edit').find('a').attr('href', '#') + $('.item-footer').find('#price-or-edit').find('a').on('click', function () { + buyButtonClicked("TEST ITEM", "Zach Fox", 10); + }); + } function updateClaraCode() { diff --git a/scripts/system/marketplaces/marketplaces.js b/scripts/system/marketplaces/marketplaces.js index 7b25589e92..3eebd044e5 100644 --- a/scripts/system/marketplaces/marketplaces.js +++ b/scripts/system/marketplaces/marketplaces.js @@ -59,6 +59,11 @@ tablet.gotoWebScreen(MARKETPLACE_URL_INITIAL, MARKETPLACES_INJECT_SCRIPT_URL); tablet.webEventReceived.connect(function (message) { + if (message.type === "CHECKOUT") { + print("ZRF: Buy Button Clicked: ", JSON.stringify(message)); + //tablet.pushOntoStack(""); + } + if (message === GOTO_DIRECTORY) { tablet.gotoWebScreen(MARKETPLACES_URL, MARKETPLACES_INJECT_SCRIPT_URL); }