|
73 | 73 | * @returns {?SupportTests} Support tests, or null if not set or older than 1 week. |
74 | 74 | */ |
75 | 75 | function getSessionSupportTests() { |
76 | | - if ( |
77 | | - typeof sessionStorage !== 'undefined' && |
78 | | - sessionStorageKey in sessionStorage |
79 | | - ) { |
80 | | - try { |
81 | | - /** @type {SessionSupportTests} */ |
82 | | - var item = JSON.parse( |
83 | | - sessionStorage.getItem( sessionStorageKey ) |
84 | | - ); |
85 | | - if ( |
86 | | - typeof item === 'object' && |
87 | | - typeof item.timestamp === 'number' && |
88 | | - new Date().valueOf() < item.timestamp + 604800 && // Note: Number is a week in seconds. |
89 | | - typeof item.supportTests === 'object' |
90 | | - ) { |
91 | | - return item.supportTests; |
92 | | - } |
93 | | - } catch ( e ) {} |
94 | | - } |
| 76 | + try { |
| 77 | + /** @type {SessionSupportTests} */ |
| 78 | + var item = JSON.parse( |
| 79 | + sessionStorage.getItem( sessionStorageKey ) |
| 80 | + ); |
| 81 | + if ( |
| 82 | + typeof item === 'object' && |
| 83 | + typeof item.timestamp === 'number' && |
| 84 | + new Date().valueOf() < item.timestamp + 604800 && // Note: Number is a week in seconds. |
| 85 | + typeof item.supportTests === 'object' |
| 86 | + ) { |
| 87 | + return item.supportTests; |
| 88 | + } |
| 89 | + } catch ( e ) {} |
95 | 90 | return null; |
96 | 91 | } |
97 | 92 |
|
|
105 | 100 | * @param {SupportTests} supportTests Support tests. |
106 | 101 | */ |
107 | 102 | function setSessionSupportTests( supportTests ) { |
108 | | - if ( typeof sessionStorage !== 'undefined' ) { |
109 | | - try { |
110 | | - /** @type {SessionSupportTests} */ |
111 | | - var item = { |
112 | | - supportTests: supportTests, |
113 | | - timestamp: new Date().valueOf() |
114 | | - }; |
| 103 | + try { |
| 104 | + /** @type {SessionSupportTests} */ |
| 105 | + var item = { |
| 106 | + supportTests: supportTests, |
| 107 | + timestamp: new Date().valueOf() |
| 108 | + }; |
115 | 109 |
|
116 | | - sessionStorage.setItem( |
117 | | - sessionStorageKey, |
118 | | - JSON.stringify( item ) |
119 | | - ); |
120 | | - } catch ( e ) {} |
121 | | - } |
| 110 | + sessionStorage.setItem( |
| 111 | + sessionStorageKey, |
| 112 | + JSON.stringify( item ) |
| 113 | + ); |
| 114 | + } catch ( e ) {} |
122 | 115 | } |
123 | 116 |
|
124 | 117 | /** |
|
0 commit comments