From 0cee4fc2f85a3d6bf6a6a94739446721f0e436e1 Mon Sep 17 00:00:00 2001 From: Skylar Ittner Date: Mon, 5 Sep 2016 01:00:14 -0600 Subject: [PATCH] Smooth out bugs in IAP, check for incomplete purchases at startup --- www/js/shop.js | 15 ++- www/screens/home.html | 265 +++++++++++++++++++++++------------------- 2 files changed, 157 insertions(+), 123 deletions(-) diff --git a/www/js/shop.js b/www/js/shop.js index 463dd9e..89b5204 100644 --- a/www/js/shop.js +++ b/www/js/shop.js @@ -74,8 +74,8 @@ function buycoins(productId) { }); }) .then(function () { - loadstorefront(); - showShopMessage("Thanks for your purchase!", true); + showShopMessage("Thanks for your purchase!", false); + refreshcoins(); }) .catch(function (err) { console.log("Error: " + err.message); @@ -157,9 +157,6 @@ function setcoinhtmlfromiap(coinsjson) { + ""; }); $('#coin-list').html(coinsHtml); - /* - [{ productId: 'com.yourapp.prod1', 'title': '...', description: '...', price: '...' }, ...] - */ }) .catch(function (err) { console.log(err.message); @@ -187,4 +184,12 @@ function loadstorefront() { }); loadinventory(); // Make sure purchases stay in sync // Put it last in case it fails, so it doesn't crash stuff badly +} + +function refreshcoins() { + $.getJSON(mkApiUrl('shopitems'), function (data) { + if (data.status == 'OK') { + $('#coinbalance').text(data.balance); + } + }); } \ No newline at end of file diff --git a/www/screens/home.html b/www/screens/home.html index 9752ee9..0f46cc5 100644 --- a/www/screens/home.html +++ b/www/screens/home.html @@ -15,122 +15,151 @@ See the License for the specific language governing permissions and limitations under the License. --> -
-
- -

- Acquiring Location... -
-
-

-
-
-
- -
-

GPS location inaccurate. -
-
- Waiting for better accuracy...

-
- - - -
-

-
-
-
-
-

Life

- -
- -
-
- Menu -
-
- Scan Code -
-
- -
-
- -
-
- -
-
- -
-
- -
-
- -
-
- -
-
- -
-
- -
-
-
-
-
-
-
- -
-
-
-
- - - - + + + + \ No newline at end of file