Changeset 7416
- Timestamp:
- 02/22/07 23:10:01 (21 months ago)
- Location:
- trunk
- Files:
-
- 8 modified
-
demos/storage/editor.html (modified) (1 diff)
-
demos/storage/editor.js (modified) (3 diffs)
-
dot/proxy/client.c (modified) (1 diff)
-
dot/proxy/local.c (modified) (1 diff)
-
dot/proxy/off.h (modified) (1 diff)
-
src/off.js (modified) (5 diffs)
-
src/off/ui.js (modified) (2 diffs)
-
src/storage/browser.js (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/demos/storage/editor.html
r7385 r7416 10 10 var djConfig = 11 11 { 12 isDebug: false,12 isDebug: true, 13 13 parseWidgets: false, 14 14 searchIds: ["storageValue"] -
trunk/demos/storage/editor.js
r7385 r7416 13 13 // set our application name 14 14 dojo.off.ui.appName = "Moxie"; 15 16 // we aren't going to need a real offline cache for now;17 // we will just have our server return good HTTP/1.118 // caching headers and rely on the browser's native cache19 dojo.off.requireOfflineCache = false;20 15 21 16 // add our list resources we need offline … … 368 363 var self = this; 369 364 dojo.sync.log.onCommand = function(command){ 370 dojo.debug("Moxie.onCommand="+command);371 dojo.debug("command.name="+command.name);372 365 if(command.name == "save"){ 373 366 self._save(command.key, command.value); … … 377 370 // setup how we download our data from the server 378 371 dojo.sync.doDownload = function(){ 379 dojo.debug("Moxie.doDownload");380 372 // actually download our data 381 373 self._downloadData(); -
trunk/dot/proxy/client.c
r7413 r7416 729 729 HTTPConditionPtr condition; 730 730 HTTPRangeRec range; 731 732 printf("httpClientRequest\n");733 731 734 732 referer = NULL; -
trunk/dot/proxy/local.c
r7413 r7416 229 229 isRunning, getVersion 230 230 */ 231 printf("results=%s\n", host_ptr);232 231 if(matchUrl("/polipo/offline?addOfflineHost", object)){ 233 232 status = addOfflineHost(host_ptr); -
trunk/dot/proxy/off.h
r7413 r7416 25 25 Example: 26 26 27 durableCacheCallback("isRunning", true);27 window.offlineCacheCallback("isRunning", true); 28 28 */ 29 #define OFF_JAVASCRIPT_CALLBACK " durableCacheCallback"29 #define OFF_JAVASCRIPT_CALLBACK "window.offlineCacheCallback" 30 30 31 31 /* -
trunk/src/off.js
r7385 r7416 71 71 doNetworkChecking: true, 72 72 73 // hasOfflineCache: boolean 74 // Determines if an offline cache is available or installed; 75 // an offline cache is a facility that can truely cache offline 76 // resources, such as JavaScript, HTML, etc. in such a way that 77 // they won't be removed from the cache inappropriately like 78 // a browser cache would. If this is false, and 79 // dojo.off.requireOfflineCache is true, then an offline cache 80 // will be installed 81 hasOfflineCache: null, 82 83 _OFFLINE_CACHE_URL: "http://localhost:8123/polipo/offline?", 84 73 85 _onLoadListeners: new Array(), 74 86 _storageLoaded: false, 75 87 _pageLoaded: false, 76 77 hasOfflineCache: function(){ /* boolean */78 // summary:79 // Returns whether we have an offline cache available80 // description:81 // Determines if an offline cache is available or installed;82 // an offline cache is a facility that can truely cache offline83 // resources, such as JavaScript, HTML, etc. in such a way that84 // they won't be removed from the cache inappropriately like85 // a browser cache would. If this is false, and86 // dojo.off.requireOfflineCache is true, then an offline cache87 // will be installed88 89 // FIXME: Implement90 return false;91 },92 88 93 89 onOnline: function(){ /* void */ … … 238 234 }, 239 235 236 addOfflineHost: function(resultsCallback /* Function(successful) */){ 237 // summary: 238 // Makes the this web application's host name, such as 239 // "sitepen.com", offline-enabled with a true offline cache. 240 // description: 241 // If a true offline cache is available on this platform, this 242 // means this hosts resources are made truly available 243 // offline and will not disappear from the offline cache 244 // as it might from a browser cache. The host name this 245 // page was served from is the host that is used, such 246 // as "sitepen.com". 247 // resultsCallback: 248 // A Function that will be called with the results of this 249 // add attempt; if it was successful, you will get true; if 250 // not, you will receive false 251 if(this.requireOfflineCache == false){ 252 resultsCallback(true); 253 } 254 255 if(this.hasOfflineCache != true){ 256 resultsCallback(false); 257 } 258 259 this._talkToOfflineCache("addOfflineHost", resultsCallback); 260 }, 261 262 removeOfflineHost: function(resultsCallback /* Function(successful) */){ 263 // summary: 264 // Removes this web application's host name, such as "sitepen.com", 265 // from being offline enabled. 266 // description: 267 // If a true offline cache is available on this platform, this 268 // means this hosts resources are made truly available 269 // offline and will not disappear from the offline cache 270 // as it might from a browser cache. The host name this 271 // page was served from is the host that is used, such 272 // as "sitepen.com". 273 // resultsCallback: 274 // A Function that will be called with the results of this 275 // remove attempt; if it was successful, you will get true; if 276 // not, you will receive false 277 if(this.requireOfflineCache == false){ 278 resultsCallback(true); 279 } 280 281 if(this.hasOfflineCache != true){ 282 resultsCallback(false); 283 } 284 285 this._talkToOfflineCache("removeOfflineHost", resultsCallback); 286 }, 287 288 standardSaveHandler: function(status, isCoreSave, dataStore, item){ 289 // summary: 290 // Called by portions of the Dojo Offline framework 291 // as a standard way to handle local save's; this method 292 // is 'package private' and should not be used outside 293 // of the Dojo Offline package. 294 if(status == dojo.storage.FAILED 295 && isCoreSave == true){ 296 this.coreSaveFailed = true; 297 this.enabled = false; 298 } 299 300 if(this.onSave){ 301 onSave(status, isCoreSave, dataStore, item); 302 } 303 }, 304 305 _checkOfflineCacheAvailable: function(finishedCallback){ 306 var self = this; 307 308 // is an true, offline cache running on this machine as a 309 // local web proxy distributed with DOT? 310 if(this.requireOfflineCache == false){ 311 self.hasOfflineCache = false; 312 resultsCallback(); 313 return; 314 } 315 316 // give the local proxy 200 milliseconds to respond 317 var timer = setTimeout(function(){ 318 self.hasOfflineCache = false; 319 finishedCallback(); 320 }, 200); 321 322 this._talkToOfflineCache("isRunning", function(results){ 323 self.hasOfflineCache = true; 324 window.clearTimeout(timer); 325 finishedCallback(); 326 }); 327 }, 328 240 329 _onLoad: function(){ 241 330 //dojo.debug("dojo.off._onLoad"); … … 249 338 // load framework data; when we are finished, continue 250 339 // initializing ourselves 340 this.load(dojo.lang.hitch(this, this._onFrameworkDataLoaded)); 341 }, 342 343 _onFrameworkDataLoaded: function(){ 344 // this method is part of our _onLoad series of startup tasks 345 346 // see if we have an offline cache; when done, move 347 // on to the rest of our startup tasks 348 this._checkOfflineCacheAvailable(dojo.lang.hitch(this, this._onOfflineCacheChecked)); 349 }, 350 351 _onOfflineCacheChecked: function(){ 352 // this method is part of our _onLoad series of startup tasks 353 354 // if we have an offline cache, try to add ourselves to this list of available 355 // offline web apps 356 if(this.hasOfflineCache == true){ 357 this.addOfflineHost(dojo.lang.hitch(this, this._finishStartingUp)); 358 }else{ 359 this._finishStartingUp(); 360 } 361 }, 362 363 _finishStartingUp: function(){ 364 // this method is part of our _onLoad series of startup tasks 365 366 // kick off a thread to check network status on 367 // a regular basis 368 this._startNetworkThread(); 369 370 // try to go online 251 371 var self = this; 252 this.load(function(){ 253 // kick off a thread to check network status on 254 // a regular basis 255 self._startNetworkThread(); 256 257 // try to go online 258 self.goOnline(function(){ 259 // indicate we are ready to be used 260 for(var i = 0; i < self._onLoadListeners.length; i++){ 261 self._onLoadListeners[i](); 262 } 263 }); 372 this.goOnline(function(){ 373 // indicate we are ready to be used 374 for(var i = 0; i < self._onLoadListeners.length; i++){ 375 self._onLoadListeners[i](); 376 } 264 377 }); 265 378 }, … … 328 441 }, 329 442 330 standardSaveHandler: function(status, isCoreSave, dataStore, item){331 // summary:332 // Called by portions of the Dojo Offline framework333 // as a standard way to handle local save's; this method334 // is 'package private' and should not be used outside335 // of the Dojo Offline package.336 if(status == dojo.storage.FAILED337 && isCoreSave == true){338 this.coreSaveFailed = true;339 this.enabled = false;340 }341 342 if(this.onSave){343 onSave(status, isCoreSave, dataStore, item);344 }345 },346 347 443 _startNetworkThread: function(){ 348 444 // kick off a thread that does periodic … … 390 486 391 487 return url; 488 }, 489 490 _talkToOfflineCache: function(methodName, resultsCallback){ 491 var head = document.getElementsByTagName("head")[0]; 492 var script = document.createElement("script"); 493 var url = this._OFFLINE_CACHE_URL + methodName; 494 script.setAttribute("src", url); 495 window.offlineCacheCallback = function(name, results){ 496 if(name == "UnknownMethod"){ 497 dojo.raise("Programming error in dojo.off._talkToOfflineCache: " + name); 498 return; 499 } 500 501 // avoid memory leaks on IE 502 head = null; 503 script = null; 504 505 resultsCallback(results); 506 } 507 508 head.appendChild(script); 392 509 } 393 510 }); -
trunk/src/off/ui.js
r7298 r7416 321 321 // check offline cache settings 322 322 if(dojo.off.requireOfflineCache == true 323 && dojo.off.hasOfflineCache ()== false){323 && dojo.off.hasOfflineCache == false){ 324 324 this._needsOfflineCache(); 325 325 return; … … 397 397 this.learnHowPath += "?appName=" + encodeURIComponent(this.appName) 398 398 + "&requireOfflineCache=" + dojo.off.requireOfflineCache 399 + "&hasOfflineCache=" + dojo.off.hasOfflineCache ()399 + "&hasOfflineCache=" + dojo.off.hasOfflineCache 400 400 + "&runLink=" + encodeURIComponent(this.runLink) 401 401 + "&runLinkText=" + encodeURIComponent(this.runLinkText); -
trunk/src/storage/browser.js
r7327 r7416 82 82 var self = this; 83 83 var storageListener = function(evt){ 84 dojo.debug("storage event, evt="+evt);85 86 84 // remove any old storage event listener we might have added 87 85 // to the window on old put() requests; Firefox has a bug