var UiControlerJSRevision="$Revision: 71 $".split(' ')[1] function changeButtonText(sBtnId,sNewText) { $("#" + sBtnId + " .ui-btn-text").text(sNewText); } function defineDisplayStatus(){ $("#pnlHeading").hide(); $("#pnlShopDetails").hide(); $("#pnlEntries").hide(); $("#lbHeading").text("???"); $("#btnHeadingLeft").hide(); $("#btnHeadingLeft").unbind(); changeButtonText("btnHeadingLeft"," "); $("#btnHeadingRight").hide(); $("#btnHeadingRight").unbind(); changeButtonText("btnHeadingRight","..."); $("#pnlShops").hide(); $("#pnlTransferQ").hide(); $("#pnlAbout").hide(); $("#pnlSettings").hide(); $("#pnlSettingsNav").hide(); } /* ---- FRW ------------ */ function deleteData(sType,sKey){ console.log("Delete data called",sType,sKey) } function addEntryToUi(sKey,sEntry){ if ($("#entry_" + sKey).length == 0) { // Avoid adding duplicated especially after branding $("#lstEntries").append("
  • " + sEntry + "
  • "); // $("#lstEntries").listview("refresh"); } } function showQItemDetail(Qkey,Type,data){ $("#txtTransferQDetails").text("Sorry, Unavailable for this object"); if ((Type=="DeleteEntry") || (Type=="ShopDeletion")) { $("#txtTransferQDetails").text("Deleted " + Type + ": " + data + " no more information available as item was deleted."); } if ((Type=="SendShop")||(Type=="SendEntry")) { if (Type=="SendEntry") { data=Number(data); } db.objectStore("Entry").get(data).done(function(result){ $("#txtTransferQDetails").text(JSON.stringify(result)); }).fail(function(result,event){ $("#txtTransferQDetails").text("Error loading Item."); console.log("[showQItemDetail] Error loading Entry Item: ",result,event); }) } } function addTransferQItemToUi(item){ if ($("#Qitem_" + item.key).length == 0) { // Avoid adding duplicated especially after branding $("#lstTransferQItems").append("
  • " + item.key + " -- "+ item.value.type + "
  • "); $("#lstTransferQItems").listview("refresh"); } } function deleteEntryFromUi(sKey){ $("#entry_" + sKey).remove(); $("#lstEntries").listview("refresh"); } function showSettings(){ setMode("Settings"); } function showTransferQ(){ setMode("TransferQ"); refreshTransferQDisplay(); } function refreshTransferQDisplay(){ $("#lstTransferQItems").empty(); db.objectStore("TransferQ").each(function(item){ if (null != item) { addTransferQItemToUi(item); } }).done(function (result, event){ console.log("[refreshTransferQDisplay] Success, filtered by shop " , shopGlobalId); }).fail( function (result, event){ console.log("[refreshTransferQDisplay] Failed: " , result , event ) }); } function loadAndShowEntries(shopGlobalId){ $("#lstEntries").empty(); $("#lstEntries").hide(); $.mobile.showPageLoadingMsg(); db.objectStore("Entry").each(function(item){ if (null != item) { if (item.value.shopGlobalId==shopGlobalId) { addEntryToUi(item.key,item.value.Description); } } }).done(function (result, event){ $("#lstEntries").listview("refresh"); console.log("[loadAndShowEntries] Success, filtered by shop " , shopGlobalId); $("#lstEntries").show(); $.mobile.hidePageLoadingMsg(); }).fail( function (result, event){ console.log("[loadAndShowEntries] Failed: " , result , event ) $("#lstEntries").show(); $.mobile.hidePageLoadingMsg(); }); } function getActiveShopGlobalId() { shopGlobalId=$("#pnlShops>ul>li>a.ui-btn-active").parent().attr("id"); if (null!=shopGlobalId) { shopGlobalId=shopGlobalId.split("_")[1]; } else { shopGlobalId=null; } return(shopGlobalId) } function changeShop(newShop){ var newShopId=null; if (null != newShop) { newShopId=$(newShop).parent().attr('id').split("_")[1]; } console.log("[changeShop] switching to newShopId " , newShopId); db.objectStore("Config").put({Id:"ActiveShopId",value:newShopId}); loadAndShowEntries(newShopId); } function addShop(){ $('#tbShopName').removeAttr('globalid') $("#tbShopName").val(""); setMode("AddShop"); } function editShop(theShop){ var theShopGlobalId=$(theShop).attr('id').split("_")[1]; db.objectStore("Shop").get(theShopGlobalId).done(function(result){ $("#tbShopName").val(result.Description); $("#tbShopName").attr("globalid",theShopGlobalId); }) setMode("EditShop"); } function loadAndShowShops(shopGlobalId){ var activeNav=shopGlobalId || getActiveShopGlobalId(); var parent=$("#pnlShops").parent(); $("#pnlShops").remove(); $(parent).append("