From e67dc79fb3efffef50636b2a0a467a7f126cc8c7 Mon Sep 17 00:00:00 2001 From: Rick Companje Date: Tue, 20 Jun 2017 21:42:49 +0200 Subject: [PATCH] cleanup BoxPage.js --- js/BoxPage.js | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/js/BoxPage.js b/js/BoxPage.js index 1f336d6..90d9969 100644 --- a/js/BoxPage.js +++ b/js/BoxPage.js @@ -12,8 +12,10 @@ var _title; var _intro; var _drawItem; + var _printItem; var _updateItem; var _settingsItem; + var _controlItem; var _joinNetworkItem; var _defaultItems; @@ -38,8 +40,10 @@ _drawItem = _list.find("#drawItem"); _updateItem = _list.find("#updateItem"); _settingsItem = _list.find("#settingsItem"); + _controlItem = _list.find("#controlItem"); _joinNetworkItem = _list.find("#joinNetworkItem"); - + _printItem = _list.find("#printItem"); + // make sure draw link is opened in same WebApp (added to homescreen) // and it doesn't start a browser $.stayInWebApp("#box #drawItem a",true); @@ -64,6 +68,8 @@ setNetworkStatus(NetworkAPI.STATUS.CONNECTED); retrieveNetworkStatus(); + + }); $.mobile.document.on( "pagebeforehide", PAGE_ID, function( event, data ) { clearTimeout(_retryRetrieveStatusDelay); @@ -89,6 +95,7 @@ // display the right buttons _defaultItems.toggleClass("ui-screen-hidden",false); + _printItem.toggleClass("ui-screen-hidden",false); _joinNetworkItem.toggleClass("ui-screen-hidden",true); //update link @@ -103,7 +110,7 @@ introText = "Please connect your WiFi-Box to the internet. You can also use it offline, but then you won't be able to update."; _drawItem.find("a").text("Draw / Sketch (local)"); - + // display the right buttons _defaultItems.toggleClass("ui-screen-hidden",true); _drawItem.toggleClass("ui-screen-hidden",false); @@ -124,6 +131,23 @@ _settingsItem.find("a").attr("href",settingsLink); _settingsItem.toggleClass("ui-screen-hidden",false); + //settingsLink + var controlLink = _controlItem.find("a").attr("href"); + controlLink = d3d.util.replaceURLParameters(controlLink,_boxData); + _controlItem.find("a").attr("href",controlLink); + _controlItem.toggleClass("ui-screen-hidden",false); + + //printLink + var printLink = _printItem.find("a").attr("href"); + printLink = d3d.util.replaceURLParameters(printLink,_boxData); + _printItem.find("a").attr("href",printLink); + + if (d3d && d3d.pageParams && d3d.pageParams.uuid) { + _printItem.show(); + } else { + _printItem.hide(); + } + // ToDo: update footer with network info _list.listview('refresh'); // jQuery mobile enhance content