1- /* WebFormsJS 1.3 - Providing Infrastructure For Web Controls In CodeBehind Framework Owned By Elanat (elanat.net) */
1+ /* WebFormsJS 1.4 - Providing Infrastructure For Web Controls In CodeBehind Framework Owned By Elanat (elanat.net) */
22
33/* Start Options */
44
@@ -121,6 +121,47 @@ function PostBack(obj, ViewState)
121121 }
122122
123123
124+ // Create Request Name
125+ var RequestName = "" ;
126+ if ( obj . getAttribute ( "name" ) )
127+ RequestName = obj . getAttribute ( "name" ) + "|" + TagSubmitValue + "|" + FormAction ;
128+
129+ // Check Cache
130+ var SessionCacheValue = sessionStorage . getItem ( RequestName ) ;
131+ if ( SessionCacheValue )
132+ {
133+ cb_SetWebFormsValues ( "" , SessionCacheValue , true , true ) ;
134+ return ;
135+ }
136+
137+ var LocalCacheValue = localStorage . getItem ( RequestName ) ;
138+ if ( LocalCacheValue )
139+ {
140+ var LocalCacheDateValue = localStorage . getItem ( RequestName + "-date" ) ;
141+ if ( LocalCacheDateValue )
142+ {
143+ var CacheDate = new Date ( LocalCacheDateValue ) ;
144+ var CurrentDate = new Date ( ) ;
145+
146+ if ( CacheDate . getTime ( ) > CurrentDate . getTime ( ) )
147+ {
148+ cb_SetWebFormsValues ( "" , LocalCacheValue , true , true ) ;
149+ return ;
150+ }
151+ else
152+ {
153+ localStorage . removeItem ( RequestName ) ;
154+ localStorage . removeItem ( RequestName + "-date" ) ;
155+ }
156+ }
157+ else
158+ {
159+ cb_SetWebFormsValues ( "" , LocalCacheValue , true , true ) ;
160+ return ;
161+ }
162+ }
163+
164+
124165 var XMLHttp = new XMLHttpRequest ( ) ;
125166 XMLHttp . onreadystatechange = function ( )
126167 {
@@ -135,7 +176,7 @@ function PostBack(obj, ViewState)
135176 IsWebForms = true ;
136177
137178 if ( IsWebForms )
138- cb_SetWebFormsValues ( HttpResult , true ) ;
179+ cb_SetWebFormsValues ( RequestName , HttpResult , true ) ;
139180 else
140181 {
141182 var TmpDiv = document . createElement ( "div" ) ;
@@ -248,6 +289,46 @@ function GetBack(FormAction, ViewState)
248289 else
249290 FormAction = "" ;
250291
292+
293+ // Create Request Name
294+ var RequestName = ( FormAction == "" ) ? window . location . href : FormAction ;
295+
296+ // Check Cache
297+ var SessionCacheValue = sessionStorage . getItem ( RequestName ) ;
298+ if ( SessionCacheValue )
299+ {
300+ cb_SetWebFormsValues ( "" , SessionCacheValue , true , true ) ;
301+ return ;
302+ }
303+
304+ var LocalCacheValue = localStorage . getItem ( RequestName ) ;
305+ if ( LocalCacheValue )
306+ {
307+ var LocalCacheDateValue = localStorage . getItem ( RequestName + "-date" ) ;
308+ if ( LocalCacheDateValue )
309+ {
310+ var CacheDate = new Date ( LocalCacheDateValue ) ;
311+ var CurrentDate = new Date ( ) ;
312+
313+ if ( CacheDate . getTime ( ) > CurrentDate . getTime ( ) )
314+ {
315+ cb_SetWebFormsValues ( "" , LocalCacheValue , true , true ) ;
316+ return ;
317+ }
318+ else
319+ {
320+ localStorage . removeItem ( RequestName ) ;
321+ localStorage . removeItem ( RequestName + "-date" ) ;
322+ }
323+ }
324+ else
325+ {
326+ cb_SetWebFormsValues ( "" , LocalCacheValue , true , true ) ;
327+ return ;
328+ }
329+ }
330+
331+
251332 var XMLHttp = new XMLHttpRequest ( ) ;
252333 XMLHttp . onreadystatechange = function ( )
253334 {
@@ -262,7 +343,7 @@ function GetBack(FormAction, ViewState)
262343 IsWebForms = true ;
263344
264345 if ( IsWebForms )
265- cb_SetWebFormsValues ( HttpResult , true ) ;
346+ cb_SetWebFormsValues ( RequestName , HttpResult , true ) ;
266347 else
267348 {
268349 var TmpDiv = document . createElement ( "div" ) ;
@@ -592,7 +673,7 @@ function cb_SetWebFormsTagsValue(obj)
592673 {
593674 var ActionControl = WebForms . getAttribute ( "ac" ) ;
594675 if ( ActionControl )
595- cb_SetWebFormsValues ( ActionControl . Replace ( "$[dq];" , "\"" ) , false , true ) ;
676+ cb_SetWebFormsValues ( "" , ActionControl . Replace ( "$[dq];" , "\"" ) , false , true ) ;
596677 }
597678 } ) ;
598679}
@@ -601,7 +682,7 @@ function cb_SetWebFormsTagsValue(obj)
601682
602683/* Start Fetch Web-Forms */
603684
604- function cb_SetWebFormsValues ( WebFormsValues , UsePostBack , WithoutWebFormsSection )
685+ function cb_SetWebFormsValues ( RequestName , WebFormsValues , UsePostBack , WithoutWebFormsSection )
605686{
606687 if ( ! WithoutWebFormsSection )
607688 WebFormsValues = WebFormsValues . substring ( 11 ) ;
@@ -623,14 +704,56 @@ function cb_SetWebFormsValues(WebFormsValues, UsePostBack, WithoutWebFormsSectio
623704 FirstChar = WebFormsList [ i ] . substring ( 0 , 1 ) ;
624705 }
625706
707+ var SecondChar = WebFormsList [ i ] . substring ( 1 , 2 ) ;
626708 switch ( FirstChar )
627709 {
628710 case '_' :
629711 var ScriptValue = WebFormsList [ i ] . GetTextAfter ( "=" ) . Replace ( "$[ln];" , "\n" ) . FullTrim ( ) ;
630712 cb_SetPreRunnerQueueForEval ( PreRunner , ScriptValue ) ;
631713 continue ;
632- }
633714
715+ case 'r' :
716+ var CacheKeyValue = WebFormsList [ i ] . GetTextAfter ( "=" ) ;
717+ switch ( SecondChar )
718+ {
719+ case 's' :
720+ if ( CacheKeyValue == '*' )
721+ sessionStorage . clear ( ) ;
722+ else
723+ sessionStorage . removeItem ( CacheKeyValue ) ;
724+ continue ;
725+ case 'd' :
726+ if ( CacheKeyValue == '*' )
727+ localStorage . clear ( ) ;
728+ else
729+ localStorage . removeItem ( CacheKeyValue ) ;
730+ continue ;
731+ }
732+
733+ case 'c' :
734+ switch ( SecondChar )
735+ {
736+ case 's' :
737+ if ( ! RequestName )
738+ continue ;
739+ sessionStorage . setItem ( RequestName , WebFormsValues ) ;
740+ continue ;
741+ case 'd' :
742+ if ( ! RequestName )
743+ continue ;
744+ localStorage . setItem ( RequestName , WebFormsValues ) ;
745+ var DurationValue = WebFormsList [ i ] . GetTextAfter ( "=" ) ;
746+
747+ if ( DurationValue != '*' )
748+ {
749+ var UntilDate = new Date ( ) ;
750+ UntilDate . setSeconds ( UntilDate . getSeconds ( ) + parseInt ( DurationValue ) ) ;
751+
752+ localStorage . setItem ( RequestName + "-date" , UntilDate ) ;
753+ }
754+ continue ;
755+ }
756+ }
634757
635758 var ActionName = WebFormsList [ i ] . substring ( 0 , 2 ) ;
636759 var ActionValue = WebFormsList [ i ] . substring ( 2 ) ;
0 commit comments