mirror of
https://github.com/Esri/offline-editor-js.git
synced 2025-12-15 15:20:05 +00:00
consolidate offline event handlers
This commit is contained in:
parent
2e8984ba4e
commit
9fa12b16a6
@ -381,9 +381,9 @@
|
||||
// Refer to "Using the Proxy Page" for more information: https://developers.arcgis.com/en/javascript/jshelp/ags_proxy.html
|
||||
offlineFeaturesManager.proxyPath = null;
|
||||
|
||||
offlineFeaturesManager.on(offlineFeaturesManager.events.EDITS_ENQUEUED, updateStatus);
|
||||
offlineFeaturesManager.on(offlineFeaturesManager.events.EDITS_ENQUEUED, editsEnqueued);
|
||||
offlineFeaturesManager.on(offlineFeaturesManager.events.EDITS_SENT, updateStatus);
|
||||
offlineFeaturesManager.on(offlineFeaturesManager.events.ALL_EDITS_SENT, updateStatus);
|
||||
offlineFeaturesManager.on(offlineFeaturesManager.events.ALL_EDITS_SENT, allEditsSent);
|
||||
|
||||
offlineFeaturesManager.extend(busStopFeatureLayer);
|
||||
console.log("offlineFeaturesManager initialized.");
|
||||
@ -415,32 +415,6 @@
|
||||
}
|
||||
}
|
||||
|
||||
function updateStatus(){
|
||||
if( editsStore.hasPendingEdits())
|
||||
{
|
||||
var edits = editsStore.retrieveEditsQueue();
|
||||
pendingEdits.innerHTML = edits.length;
|
||||
|
||||
if(busStopFeatureLayer != null && typeof busStopFeatureLayer.getPhantomLayerGraphics !== "undefined") {
|
||||
var graphics = busStopFeatureLayer.getPhantomLayerGraphics(function(result){
|
||||
localStorage.offlinePhantomGraphics = result;
|
||||
});
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
pendingEdits.innerHTML = "0";
|
||||
}
|
||||
}
|
||||
|
||||
function updatePhantomGraphicsLayer(){
|
||||
var phantomLocalGraphics = localStorage.offlinePhantomGraphics;
|
||||
if(phantomLocalGraphics != ""){
|
||||
var graphics = JSON.parse(phantomLocalGraphics);
|
||||
busStopFeatureLayer.setPhantomLayerGraphics(graphics);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Display modal popup when someone clicks on a feature
|
||||
*/
|
||||
@ -733,6 +707,65 @@
|
||||
req.send(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* ***********************************************
|
||||
* OFFLINE FEATURE MANAGER - EVENT MANAGEMENT CODE
|
||||
* ***********************************************å
|
||||
*/
|
||||
|
||||
function editsEnqueued(){
|
||||
if( editsStore.hasPendingEdits())
|
||||
{
|
||||
var edits = editsStore.retrieveEditsQueue();
|
||||
pendingEdits.innerHTML = edits.length;
|
||||
|
||||
//Make sure we store phantom layer graphics so that we have them if the browser is restarted
|
||||
if(busStopFeatureLayer != null && typeof busStopFeatureLayer.getPhantomLayerGraphics !== "undefined") {
|
||||
var graphics = busStopFeatureLayer.getPhantomLayerGraphics(function(result){
|
||||
localStorage.offlinePhantomGraphics = result;
|
||||
});
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
pendingEdits.innerHTML = "0";
|
||||
}
|
||||
}
|
||||
|
||||
function allEditsSent(){
|
||||
if( editsStore.hasPendingEdits())
|
||||
{
|
||||
var edits = editsStore.retrieveEditsQueue();
|
||||
pendingEdits.innerHTML = edits.length;
|
||||
}
|
||||
else
|
||||
{
|
||||
pendingEdits.innerHTML = "0";
|
||||
// Clear out the phantom layer
|
||||
localStorage.setItem("offlinePhantomGraphics","");
|
||||
}
|
||||
}
|
||||
|
||||
function updateStatus(){
|
||||
if( editsStore.hasPendingEdits())
|
||||
{
|
||||
var edits = editsStore.retrieveEditsQueue();
|
||||
pendingEdits.innerHTML = edits.length;
|
||||
}
|
||||
else
|
||||
{
|
||||
pendingEdits.innerHTML = "0";
|
||||
}
|
||||
}
|
||||
|
||||
function updatePhantomGraphicsLayer(){
|
||||
var phantomLocalGraphics = localStorage.offlinePhantomGraphics;
|
||||
if(phantomLocalGraphics){
|
||||
var graphics = JSON.parse(phantomLocalGraphics);
|
||||
busStopFeatureLayer.setPhantomLayerGraphics(graphics);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* ************************************
|
||||
* APPCACHE MANAGEMENT CODE
|
||||
@ -759,7 +792,7 @@
|
||||
|
||||
function cacheErrorHandler(evt){
|
||||
console.log("CACHE ERROR: " + JSON.stringify(evt));
|
||||
alert("There was a problem loading the cache. Try reloading the app. ")
|
||||
alert("There was a problem loading the cache. ")
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user