SessionStorage.html 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5. <title>The source code</title>
  6. <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
  7. <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
  8. <style type="text/css">
  9. .highlight { display: block; background-color: #ddd; }
  10. </style>
  11. <script type="text/javascript">
  12. function highlight() {
  13. document.getElementById(location.hash.replace(/#/, "")).className = "highlight";
  14. }
  15. </script>
  16. </head>
  17. <body onload="prettyPrint(); highlight();">
  18. <pre class="prettyprint lang-js"><span id='Ext-data-proxy-SessionStorage'>/**
  19. </span> * @author Ed Spencer
  20. *
  21. * Proxy which uses HTML5 session storage as its data storage/retrieval mechanism. If this proxy is used in a browser
  22. * where session storage is not supported, the constructor will throw an error. A session storage proxy requires a
  23. * unique ID which is used as a key in which all record data are stored in the session storage object.
  24. *
  25. * It's important to supply this unique ID as it cannot be reliably determined otherwise. If no id is provided but the
  26. * attached store has a storeId, the storeId will be used. If neither option is presented the proxy will throw an error.
  27. *
  28. * Proxies are almost always used with a {@link Ext.data.Store store}:
  29. *
  30. * new Ext.data.Store({
  31. * proxy: {
  32. * type: 'sessionstorage',
  33. * id : 'myProxyKey'
  34. * }
  35. * });
  36. *
  37. * Alternatively you can instantiate the Proxy directly:
  38. *
  39. * new Ext.data.proxy.SessionStorage({
  40. * id : 'myOtherProxyKey'
  41. * });
  42. *
  43. * Note that session storage is different to local storage (see {@link Ext.data.proxy.LocalStorage}) - if a browser
  44. * session is ended (e.g. by closing the browser) then all data in a SessionStorageProxy are lost. Browser restarts
  45. * don't affect the {@link Ext.data.proxy.LocalStorage} - the data are preserved.
  46. */
  47. Ext.define('Ext.data.proxy.SessionStorage', {
  48. extend: 'Ext.data.proxy.WebStorage',
  49. alias: 'proxy.sessionstorage',
  50. alternateClassName: 'Ext.data.SessionStorageProxy',
  51. //inherit docs
  52. getStorageObject: function() {
  53. return window.sessionStorage;
  54. }
  55. });
  56. </pre>
  57. </body>
  58. </html>