Vous êtes sur la page 1sur 17

<html>

<head>
<script type="text/javascript" charset="utf-8" src="cordova.js"></script>
<script src="datajs-1.1.2.min.js"></script>
<script src="scripts/index.js"></script>
<script src="scripts/platformOverrides.js"></script>
<script>
var appId = "com.cnj.rigsrv"; // Change this to app id on server
var applicationContext = null;
var smpServerProtocol = "https";
var smpServerHost = "mobile-bd35f4f3c.us1.hana.ondemand.com";
var smpServerPort = "443";
var authStr = "";
var store = null; //Offline OData store
var startTime = null;
var online = navigator.onLine;
// Optional initial connection context
var context = {
"serverHost": smpServerHost, //Place your SMP 3.0 server name here
"https": smpServerProtocol == "https",
"serverPort": smpServerPort,
"user": "rakamath"
};
window.onerror = onError;
function onError(msg, url, line) {
var idx = url.lastIndexOf("/");
var file = "unknown";
if (idx > -1) {
file = url.substring(idx + 1);
}
alert("An error occurred in " + file + " (at line # " + line + "): " + m
sg);
return false; //suppressErrorAlert;
}
function init() {
if (sap.Logger) {
sap.Logger.setLogLevel(sap.Logger.DEBUG); //enables the display of
debug log messages from the Kapsel plugins.
sap.Logger.debug("Log level set to DEBUG");
}
register()
console.log("init completed");
}
function register() {
updateStatus2("register called");
sap.Logon.init(logonSuccessCallback, logonErrorCallback, appId, context)
;
}
function logonSuccessCallback(result) {
console.log("logonSuccessCallback " + JSON.stringify(result));
updateStatus2("Successfully REGISTERED");
applicationContext = result;

//oHeaders['X-SMP-APPCID'] = applicationContext. requestUri : sURL. OData.applicationEndpointURL + "/ServiceOrderSet ?$expand=NavBillableItem&orderBy=OrderNum desc". startTime = new Date().stringify(result)).stringify(e)). } function read() { updateStatus2("read request started"). } function errorCallback(e) { // alert("An error occurred " + JSON.user + ":" + applicationContext. errorC allback). } function logonErrorCallback(error) { //this method is called if the user c ancels the registration.stringify(error)).//alternatively the authproxy and logon plugincan provide this if SAPKap selHandleHttpRequests=true. var oHeaders = {}. readSuccessCallback.Popups. //this header is provided by the logon plugin var request = { headers : oHeaders.log("An error occurred: " + JSON. console. sap.app. var msg = new Windows.log("read using " + sURL). clearTable().log("An error occurred " + JSON. console. clearTable().registrationContext.registrationContext. } var sURL = applicationContext. applicationContext = null. oHeaders['Authorization'] = authStr. } } function unRegister() { updateStatus2("unregister called").password).applicationConnectionId. console. console. if (!haveAppId()) { return. method : "GET" }.core. if (device.log("logonUnregisterSuccessCallback " + JSON. } function logonUnregisterSuccessCallback(result) { updateStatus2("Successfully UNREGISTERED"). .Logon. (it is by default on iOS) authStr = "Basic " + btoa(applicationContext.stringify(e)).UI. msg.platform == "Android") { //Not supported on iOS navigator. updateStatus1("").exitApp().read(request. errorCallback).showAsync().stringify(e)).MessageDialog("An error occurred " + JSO N.deleteRegistration(logonUnregisterSuccessCallback.

insertCell(1).getElementById("ProductsTable"). var cell2 = row.results[i].insertCell(0). cell1.results[i].OrderNumber.NavBillableItem.insertCell(1).results.innerHTML = data. var cell3 = row. var cell1 = row.OrderDesc.OrderNumber. var cell3 = row.length. cell2. updateStatus2("Read " + data.results[i].insertCell(0).innerHTML = data. updateStatus2("store.OrderDesc. var duration = (endTime .getElementById("ProductsTable").innerHTML = data.NavBillableItem. while(productsTable. } */ } function clearTable() { var productsTable = document. cell3. for (var i = 0.results[i]. var cell3 = row. cell2.NavBillableItem. } } /* var productsTable = document.results[j].OrderNumber. for (var i = 0. for (var j = 0.results[j].innerHTML = data.length + " records in " + duration + " seconds").results[i]. cell2. var cell1 = row.Pri ce. response) { var endTime = new Date(). } startTime = new Date().results[i]. j < data. i < data.innerHTML = data.rows.} function readSuccessCallback(data.Status.insertCell(0). } } function openStore() { if (!haveAppId()) { return.insertCell(1). .results[i]. var categoriesTable = document.innerHTML = data.insertCell(2). var productsTable = document. i++) { var row = categoriesTable.results[i].Ite mId. // j++) { var row = productsTable.getElementById("ProductsTable").insertCell(2). cell1. debugger.insertRow(1). cell1. var cell2 = row. i < data.innerHTML = data.results.getElementById("CategoriesTable"). cell3.results[i]. var cell1 = row.length > 1) { productsTable.insertRow(1).innerHTML = data.Status.startTime)/1000.insertRow(1). cell3.insertCell(2).innerHTML = data.length.deleteRow(1). var cell2 = row.results.results.length.results[i].open called"). i++) { var row = productsTable.

errorCallback/*. } . } store. store. sap. //Offline OData calls can now be made agai nst datajs.OData. var duration = (endTime . var duration = (endTime .var properties = { "name": "ProductsOfflineStore".startTime)/1000.close called"). return. updateStatus2("Store closed in " + duration + " seconds"). "definingRequests" : { "ProductsDR": "/ServiceOrderSet". errorCallback).removeHttpClient(). "https": applicationContext. store = null.serverPort.https.applyHttpClient(). //var options = {}.serverHost. updateStatus1("Store is OPEN."). updateStatus2("store. } startTime = new Date().open(openStoreSuccessCallback. } function openStoreSuccessCallback() { var endTime = new Date(). return.createOfflineStore(properties). } function closeStoreSuccessCallback() { sap.startTime)/1000. errorCallback). } //Removes the physical store from the filesystem function clearStore() { if (!store) { updateStatus2("The store must be closed before it can be cleared").registrationContext. updateStatus2("Store is CLEARED").OData. } function clearStoreSuccessCallback() { updateStatus1(""). store = sap. "host": applicationContext. "CategoriesDR": "/JobHeaderSet" } }. store. options*/).close(closeStoreSuccessCallback.registrationContext. var endTime = new Date(). "serviceRoot" : appId. updateStatus1("Store is CLOSED. "port": applicationContext. } function closeStore() { if (!store) { updateStatus2("The store must be opened before it can be closed"). updateStatus2("Store opened in " + duration + " seconds").").registrationContext.OData.clear(clearStoreSuccessCallback.

} function batchRequest() { var oHeaders = { }. updateStatus1(""). } function updateStatus1(msg) { document.getElementById('statusID2'). /* var params = { __batchRequests: [{ .getSeconds()).innerHTML = msg + " " + getDeviceSta tusString(). } else { return "Device is OFFLINE". } function deviceOffline() { online = false. } } function deviceOnline() { online = true.log(msg + " " + getDeviceStatusString()).getMinutes()) + ".innerHTML = msg + " at " + addZero( d. console.getSeconds())). document.getHours()) + ":" + addZero(d.applicationEndpointURL.getHours()) + ":" + addZero(d. } return input. } function updateStatus2(msg) { var d = new Date().log(msg + " at " + addZero(d." + addZero(d. } function getDeviceStatusString() { if (online) { return "Device is ONLINE". } function getEndPointURL() { return applicationContext. console. updateStatus1(""). return false. } return true." + addZero(d.getMi nutes()) + ".function haveAppId() { if (!applicationContext) { alert("Please register with the SMP Server before proceeding").getElementById('statusID'). } function addZero(input) { if (input < 10) { return "0" + input.

"TurnKey": "EEE". "Pad": "CCC". "CreatedOn": "\/Date(1198908717056)\/". "Api": "PO BOX 100000". "JobDescription": "Service Standard Material". "Well": "Customer Services". "Address": "225 PO BOX 100000. "ItemDesc": "ACID TANK (3 DAY MIN)". "SalesOrg": "EP11". "County": "India". data: { "OrderNumber": "1000040". "EquipmentNo": "000000000010000001". method: "POST". method: "POST". "OrderDesc": "Test Order Short Desc". "BidPrice": "20". "CustShortCodeDesc": "Group1". A225". "ChangedOn": "\/Date(1198908717056)\/". "BillTo": "Test". "State": "Georgia". "FunctionDesc": "Transportation". "Customer": "Ranger Supplies". data: { "ItemId": "ACIDT3".__changeRequests: [{ requestUri: getEndPointURL() + "/ServiceOrderSet". "Lease": "Main Street". "CustomerShortCode": "AAA". "CustomerNo": "0000100000". "CostCenterDesc": "Trial". { requestUri: "$1/NavBillableItem". "ShortDesc": "ACID TANK (3 DAY MIN)". headers: { "Content-ID": "1" }. "EquipmentDesc": "BBB". "BillToName": "Name". "SalesOrgDesc": "OFS SALES ORG 1". "ChangedAt": "PT06H34M19S". "Customer": "Customer Services". "CreatedOn": "\/Date(1198908717056)\/". . "WellNo": "0000100000" } } }. "Latitude": "225". "CostCenter": "20". "Well": "Ranger Supplies". "PlantDesc": "OFS Plant 1". "NavJobHeader": { "OrderNumber": "1000040". "SalesTaxServices": "DDD". "Function": "M12". "Plant": "P011". "WellDepth": "FFF". "Status": "In-Progress". "Longitude": "A225". "StateCode": "GA".

"BillTo": "Test". "EquipmentNo": "000000000010000001". "Well": "Customer Services". method: "POST". "CustomerShortCode": "RE4". "Function": "M11". "PriceDate": "\/Date(1198908717056)\/". "Lease": "Main Street". "CreatedOn": "\/Date(1198908717056)\/". A225". "County": "India". "OrderDesc": "Test Order Short Desc". headers: {}. "Customer": "Ranger Supplies". "JobDescription": "Service Standard Material". "Status": "In-Progress". "FunctionDesc": "Transportation".000". "CustomerNo": "0000100000". "Plant": "P011". */ var params = { __batchRequests: [{ __changeRequests: [{ requestUri: getEndPointURL() + "/ServiceOrderSet". "FunctionDesc": "Rig Services" } } ] } ] }. "ChangedOn": "\/Date(1198908717056)\/". "ChangedAt": "PT06H34M19S". "BillingQty": "1. "Pad": "CCC". "CustShortCodeDesc": "Test Short Code 4". "Customer": "Customer Services". "Price": "100. "BidPrice": "20". "Latitude": "225".000". "SalesOrg": "EP11". ."Uom": "EA". "BillToName": "Name". "Longitude": "A225". "CreatedOn": "\/Date(1198908717056)\/". "Address": "225 PO BOX 100000. "EquipmentDesc": "BBB". "Amount": "100. "Api": "PO BOX 100000". "CostCenterDesc": "Trial". "SalesOrgDesc": "OFS SALES ORG 1". "CustomerShortCode": "AAA".000". "NavJobHeader": { "OrderNumber": "1000040". "PlantDesc": "OFS Plant 1". "CustShortCodeDesc": "Group1". "Function": "M12". data: { "OrderNumber": "1000040". "CostCenter": "20".

method: "POST". "CustShortCodeDesc": "Test Short Code 4". "ItemDesc": "ACID TANK (3 DAY MIN)". "Function": "M11".000". "BillingQty": "1. "TurnKey": "EEE".000". "FunctionDesc": "Rig Services" } } ] } ] }. /* var params = { __batchRequests: [{ __changeRequests: [{ requestUri: getEndPointURL() + "/ServiceOrderSet". "CustomerShortCode": "RE4". "PriceDate": "\/Date(1198908717056)\/". "State": "Georgia". . "BillingQty": "1. "Amount": "100. method: "POST". "Price": "150.000"."SalesTaxServices": "DDD". "Uom": "H". "Price": "100. "Function": "M11".000". "ShortDesc": "Service Standard Material". "Well": "Ranger Supplies". "CustShortCodeDesc": "Test Short Code 4".000". headers: {}. "Uom": "EA". "Amount": "150. method: "POST". data: { "ItemId": "ACIDT3". { requestUri: "ServiceOrderSet('1000040')/NavBillableItem". "FunctionDesc": "Rig Services" } }. "ItemDesc": "Service Standard Material". "PriceDate": "\/Date(1198908717056)\/". "CustomerShortCode": "RE4". data: { "ItemId": "CNJ101". "ShortDesc": "ACID TANK (3 DAY MIN)". data: { "OrderNumber": "1000040". "StateCode": "GA". "WellNo": "0000100000" } } }.000". "WellDepth": "FFF". { requestUri: "ServiceOrderSet('1000040')/NavBillableItem".

"SalesOrg": "EP11". "CustShortCodeDesc": "Group1". "WellNo": "0000100000" } } }] }] }. "CostCenter": "20". "CustomerNo": "0000100000". "BidPrice": "20". "Function": "M12". "Longitude": "A225". "State": "Georgia". requestUri: getEndPointURL() + "/$batch". "TurnKey": "EEE". "Latitude": "225". "SalesOrgDesc": "OFS SALES ORG 1". A225". "CustomerShortCode": "AAA". "BillToName": "Name". "EquipmentDesc": "BBB". . "Address": "225 PO BOX 100000. "NavJobHeader": { "OrderNumber": "1000040". "Status": "In-Progress". "CreatedOn": "\/Date(1198908717056)\/". "SalesTaxServices": "DDD". method: "POST". "CostCenterDesc": "Trial". "Lease": "Main Street". "JobDescription": "Service Standard Material". "WellDepth": "FFF". "Pad": "CCC". "Plant": "P011". */ oHeaders['Authorization'] = authStr. "EquipmentNo": "000000000010000001". "Well": "Customer Services". var request = { headers: oHeaders. "PlantDesc": "OFS Plant 1". "ChangedOn": "\/Date(1198908717056)\/". "StateCode": "GA". data: params }. "CreatedOn": "\/Date(1198908717056)\/". "FunctionDesc": "Transportation"."OrderDesc": "Test Order Short Desc". "Customer": "Ranger Supplies". "ChangedAt": "PT06H34M19S". "BillTo": "Test". "Well": "Ranger Supplies". "Api": "PO BOX 100000". "Customer": "Customer Services". "County": "India".

store. document. } startTime = new Date().__batchResponses. deviceOnline.flush called"). } //After calling this the store will receive any changes from the OData produ cer.log("Batch response length: " + data. updateStatus2("Store refreshed in " + duration + " seconds").flush(flushStoreSuccessCallback. var duration = (endTime . init. store.log("Data responses : " + data. return."> <h1>Offline OData Sample</h1> <button id="register" onclick="register()">Register</button> <button id="unregister" onclick="unRegister()">Unregister</button> . updateStatus2("Store flushed in " + duration + " seconds"). // // } //Sends pending modification requests to the server. console. updateStatus2("store. function flushStore() { if (!store) { updateStatus2("The store must be open before it can be flushed"). } function refreshStoreCallback() { var endTime = new Date().__batchResponses[0]. errorCallback).startTime) / 1000. var duration = (endTime . } function flushStoreSuccessCallback() { var endTime = new Date().log("Change Response : " + changeResponses).length). updateStatus2("store.addEventListener("offline". } startTime = new Date().startTime) / 1000. false). return.addEventListener("online". false). errorCallback).addEventListener("deviceready". document.refresh called"). </script> </head> <body onload="updateStatus1('').OData. responseCallback. } function responseCallback(data. deviceOffline. response) { console.__changeResponses. var changeResponses = data. console. } document.__batchResponses) debugger. OData.batchHandl er). function refreshStore() { if (!store) { updateStatus2("The store must be open before it can be refreshed"). false).request(request.refresh(refreshStoreCallback. errorCallback.

function onError(msg.<button <button <button <button id="read" onclick="read()">Read</button><br> id="openStore" onclick="openStore()">Open Offline Store</button> id="closeStore" onclick="closeStore()">Close Offline Store</button> id="clearStore" onclick="clearStore()">Clear Offline Store</button>< br> <button id="batchRequest" onclick="batchRequest()">Batch request .ondemand. return false. var file = "unknown". //Offline OData store var startTime = null.onLine.js"></script> <script> var appId = "com.js"></script> <script src="scripts/index. var store = null.js"></script> <script src="datajs-1.2. url.js"></script> <script src="scripts/platformOverrides. //Place your SMP 3. window.batch". line) { var idx = url.sap. } function init() { . if (idx > -1) { file = url. var smpServerHost = "hcpms-p1941799502trial. // Change this to app id on server var applicationContext = null.lastIndexOf("/"). var online = navigator. //suppressErrorAlert. var smpServerProtocol = "https".Insert</b utton><br> <button id="flushStore" onclick="flushStore()">Flush Store</button> <button id="refreshStore" onclick="refreshStore()">Refresh Store</button> <span id="statusID"></span><br> <span id="statusID2"></span> <table id="CategoriesTable"><tr><th align="left">OrderNumber</th><th align=" left">OrderDesc</th><th align="left">Status</th></tr></table> <table id="ProductsTable"><tr><th align="left">OrderNumber</th><th align="le ft">ItemId</th><th align="left">Price</th></tr></table> </body> </html> <!-<html> <head> <script type="text/javascript" charset="utf-8" src="cordova. } alert("An error occurred in " + file + " (at line # " + line + "): " + m sg).0 server name here "https": smpServerProtocol == "https".substring(idx + 1).hanatrial.1. // Optional initial connection context var context = { "serverHost": smpServerHost. var authStr = "".com". "user": "milton" }.onerror = onError. var smpServerPort = "443". "serverPort": smpServerPort.min.

registrationContext.stringify(result)).stringify(e)).Logon. .log("An error occurred: " + JSON.password). var msg = new Windows. } function read() { updateStatus2("read request started"). applicationContext = null. sap.Logger.Logger.Logon.log("logonSuccessCallback " + JSON.stringify(error)).log("An error occurred " + JSON. appId. } function logonSuccessCallback(result) { console. updateStatus1(""). //enables the display of debug log messages from the Kapsel plugins.stringify(result)). logonErrorCallback. //alternatively the authproxy and logon plugincan provide this if SAPKap selHandleHttpRequests=true.Popups. } function logonErrorCallback(error) { //this method is called if the user c ancels the registration. startTime = new Date(). updateStatus2("Successfully REGISTERED"). sap.Logger.stringify(e)).deleteRegistration(logonUnregisterSuccessCallback. } function logonUnregisterSuccessCallback(result) { updateStatus2("Successfully UNREGISTERED").app. (it is by default on iOS) authStr = "Basic " + btoa(applicationContext.MessageDialog("An error occurred " + JSON. errorC allback). } function errorCallback(e) { // alert("An error occurred " + JSON. } } function unRegister() { updateStatus2("unregister called").setLogLevel(sap.exitApp(). clearTable(). console.user + ":" + applicationContext.debug("Log level set to DEBUG").platform == "Android") { //Not supported on iOS navigator. } register() console. console.core. console.init(logonSuccessCallback.registrationContext. if (device. } function register() { updateStatus2("register called"). context) .stringify(e)). msg.log("init completed"). applicationContext = result.UI.DEBUG). sap.Logger) { sap.log("logonUnregisterSuccessCallback " + JSON.if (sap.showAsync().

var cell3 = row. } } function clearTable() { var productsTable = document.results.insertCell(1).startTime)/1000. cell1. var duration = (endTime . //this header is provided by the logon plugin var request = { headers : oHeaders.insertCell(0). var cell2 = row.https. "https": applicationContext. if (!haveAppId()) { return. method : "GET" }. var productsTable = document. "host": applicationContext. } function readSuccessCallback(data. updateStatus2("Read " + data.results[i].getElementById("ProductsTable"). oHeaders['Authorization'] = authStr. console.log("read using " + sURL).innerHTML = data.clearTable().registrationContext. requestUri : sURL. errorCallback).applicationConnectionId.Note.read(request.length. updateStatus2("store. } var sURL = applicationContext.open called").applicationEndpointURL + "/SalesOrderSet?$ orderby=SalesOrderID desc".getElementById("ProductsTable").innerHTML = data. "serviceRoot" : appId. cell2. readSuccessCallback.registrationContext.registrationContext. while(productsTable.innerHTML = data. i++) { var row = productsTable.length + " records in " + duration + " seconds"). "port": applicationContext. for (var i = 0. OData.results[i].insertRow(1).results[i]. cell3.SalesOrderID.deleteRow(1). i < data. } startTime = new Date().rows.length > 1) { productsTable. response) { var endTime = new Date(). //oHeaders['X-SMP-APPCID'] = applicationContext. } } function openStore() { if (!haveAppId()) { return. var oHeaders = {}.results. "definingRequests" : { .CustomerName. var properties = { "name": "ProductsOfflineStore".insertCell(2).serverHost.serverPort. var cell1 = row.

var duration = (endTime .close(closeStoreSuccessCallback. updateStatus2("Store is CLEARED")."). } function closeStoreSuccessCallback() { sap.applyHttpClient(). store = sap. } function openStoreSuccessCallback() { var endTime = new Date(). errorCallback). } function haveAppId() { if (!applicationContext) { alert("Please register with the SMP Server before proceeding"). store."). updateStatus1("Store is CLOSED. } //Removes the physical store from the filesystem function clearStore() { if (!store) { updateStatus2("The store must be closed before it can be cleared"). "CategoriesDR": "/SalesOrderLineItemSet" } }. options*/).close called").open(openStoreSuccessCallback. updateStatus2("Store opened in " + duration + " seconds"). return. } function clearStoreSuccessCallback() { updateStatus1("").createOfflineStore(properties).startTime)/1000. var endTime = new Date().OData. } . var duration = (endTime . } startTime = new Date()."ProductsDR": "/SalesOrderSet". updateStatus2("Store closed in " + duration + " seconds"). //Offline OData calls can now be made agai nst datajs. } store. return false. errorCallback/*. sap.OData.startTime)/1000.clear(clearStoreSuccessCallback. //var options = {}. return. } return true. updateStatus1("Store is OPEN. errorCallback).OData. } function closeStore() { if (!store) { updateStatus2("The store must be opened before it can be closed"). updateStatus2("store. store = null. store.removeHttpClient().

innerHTML = msg + " at " + addZero( d. console. updateStatus1("").getElementById('statusID').getMi nutes()) + ".getSeconds())). } return input. document.getSeconds())." + addZero(d.log(msg + " " + getDeviceStatusString()).getMinutes()) + ". console.function updateStatus1(msg) { document. } function batchRequest() { var oHeaders = { }. } function addZero(input) { if (input < 10) { return "0" + input.getHours()) + ":" + addZero(d.log(msg + " at " + addZero(d. } function getDeviceStatusString() { if (online) { return "Device is ONLINE". } function updateStatus2(msg) { var d = new Date(). } } function deviceOnline() { online = true. } function deviceOffline() { online = false. } else { return "Device is OFFLINE". method: "POST". } function getEndPointURL() { return applicationContext." + addZero(d.applicationEndpointURL. var params = { __batchRequests: [{ __changeRequests: [{ requestUri: getEndPointURL() + "/SalesOrderSet". updateStatus1("").innerHTML = msg + " " + getDeviceSta tusString().getElementById('statusID2'). data: { "SalesOrderID": "0600000000". headers: { "Content-ID": "1" }. "Note": "EPM DG: SO ID 0500000019 Deliver as fast as pos .getHours()) + ":" + addZero(d.

"ItemPosition": "0000000010". "CustomerName": "Telecomunicaciones Star" } }.length).log("Change Response length: " + changeResponses.5 } } ] } ] }. var duration = (endTime .request(request.sible". data: params }. store.flush(flushStoreSuccessCallback. "DeliveryDate": "\/Date(1198908717056)\/".length). method: "POST". } //After calling this the store will receive any changes from the OData produ . requestUri: getEndPointURL() + "/$batch". responseCallback. method: "POST". } function responseCallback(data.__changeResponses. } startTime = new Date(). errorCallback. data: { "SalesOrderID": "0600000000".flush called"). var request = { headers: oHeaders. updateStatus2("Store flushed in " + duration + " seconds"). // console.startTime) / 1000.log("Batch response length: " + data. OData. errorCallback).__batchResponses[0]. updateStatus2("store. "Quantity": 3. } //Sends pending modification requests to the server. { requestUri: "SalesOrderSet('0600000000')/ToLineItems". "ProductID": "HT-1000". oHeaders['Authorization'] = authStr. return. OData.batchHandl er).__batchResponses. "CustomerID": "0100000009". function flushStore() { if (!store) { updateStatus2("The store must be open before it can be flushed"). var changeResponses = data. response) { console. } function flushStoreSuccessCallback() { var endTime = new Date().

} function refreshStoreCallback() { var endTime = new Date(). store. document.cer. false). errorCallback).addEventListener("online". return. false). </script> </head> <body onload="updateStatus1('')."> <h1>Offline OData Sample</h1> <button id="register" onclick="register()">Register</button> <button id="unregister" onclick="unRegister()">Unregister</button> <button id="read" onclick="read()">Read</button><br> <button id="openStore" onclick="openStore()">Open Offline Store</button> <button id="closeStore" onclick="closeStore()">Close Offline Store</button> <button id="clearStore" onclick="clearStore()">Clear Offline Store</button>< br> <button id="batchRequest" onclick="batchRequest()">Batch request .addEventListener("offline". updateStatus2("store. deviceOffline.startTime) / 1000. document. false).refresh called"). updateStatus2("Store refreshed in " + duration + " seconds"). deviceOnline.addEventListener("deviceready".refresh(refreshStoreCallback. var duration = (endTime .Insert</b utton><br> <button id="flushStore" onclick="flushStore()">Flush Store</button> <button id="refreshStore" onclick="refreshStore()">Refresh Store</button> <span id="statusID"></span><br> <span id="statusID2"></span> <table id="ProductsTable"><tr><th align="left">Name</th><th align="left">Des cription</th><th align="left">Price</th></tr></table> </body> </html> --> . init. } document. } startTime = new Date(). function refreshStore() { if (!store) { updateStatus2("The store must be open before it can be refreshed").