@@ -114,13 +114,12 @@ function PostBack(obj, ViewState)
114114
115115 var OldObjectType ;
116116 if ( obj . getAttribute ( "type" ) )
117- if ( obj . getAttribute ( "type" ) != "button ")
117+ if ( obj . getAttribute ( "type" ) == "submit ")
118118 {
119119 OldObjectType = obj . type ;
120120 obj . setAttribute ( "type" , "button" ) ;
121121 }
122122
123-
124123 // Create Request Name
125124 var RequestName = "" ;
126125 if ( obj . getAttribute ( "name" ) )
@@ -130,6 +129,9 @@ function PostBack(obj, ViewState)
130129 var SessionCacheValue = sessionStorage . getItem ( RequestName ) ;
131130 if ( SessionCacheValue )
132131 {
132+ // Reset Input Type
133+ setTimeout ( function ( ) { ( OldObjectType == "submit" ) ? obj . type = "submit" : obj . type ; } , 1 ) ;
134+
133135 cb_SetWebFormsValues ( "" , SessionCacheValue , true , true ) ;
134136 return ;
135137 }
@@ -145,6 +147,9 @@ function PostBack(obj, ViewState)
145147
146148 if ( CacheDate . getTime ( ) > CurrentDate . getTime ( ) )
147149 {
150+ // Reset Input Type
151+ setTimeout ( function ( ) { ( OldObjectType == "submit" ) ? obj . type = "submit" : obj . type ; } , 1 ) ;
152+
148153 cb_SetWebFormsValues ( "" , LocalCacheValue , true , true ) ;
149154 return ;
150155 }
@@ -156,12 +161,14 @@ function PostBack(obj, ViewState)
156161 }
157162 else
158163 {
164+ // Reset Input Type
165+ setTimeout ( function ( ) { ( OldObjectType == "submit" ) ? obj . type = "submit" : obj . type ; } , 1 ) ;
166+
159167 cb_SetWebFormsValues ( "" , LocalCacheValue , true , true ) ;
160168 return ;
161169 }
162170 }
163171
164-
165172 var XMLHttp = new XMLHttpRequest ( ) ;
166173 XMLHttp . onreadystatechange = function ( )
167174 {
@@ -252,7 +259,7 @@ function PostBack(obj, ViewState)
252259
253260 XMLHttp . setRequestHeader ( "Post-Back" , "true" ) ;
254261
255- XMLHttp . send ( cb_FormDataSerialize ( Form , obj . getAttribute ( "name" ) , TagSubmitValue , FormIsMultiPart ) ) ;
262+ XMLHttp . send ( cb_FormDataSerialize ( Form , obj . getAttribute ( "name" ) , TagSubmitValue , OldObjectType , FormIsMultiPart ) ) ;
256263}
257264
258265/* End Post-Back */
@@ -408,8 +415,8 @@ function GetBack(FormAction, ViewState)
408415
409416/* End Get-Back */
410417
411- function cb_FormDataSerialize ( form , TagSubmitName , TagSubmitValue , FormIsMultiPart )
412- {
418+ function cb_FormDataSerialize ( form , TagSubmitName , TagSubmitValue , TagSubmitType , FormIsMultiPart )
419+ {
413420 var FormString = "" ;
414421 var TmpFormData = new FormData ( ) ;
415422
@@ -530,10 +537,16 @@ function cb_FormDataSerialize(form, TagSubmitName, TagSubmitValue, FormIsMultiPa
530537 }
531538 }
532539
533- if ( FormIsMultiPart )
534- TmpFormData . append ( TagSubmitName , TagSubmitValue ) ;
535- else
536- FormString += TagSubmitName + "=" + TagSubmitValue ;
540+ if ( TagSubmitType == "submit" )
541+ {
542+ if ( FormIsMultiPart )
543+ TmpFormData . append ( TagSubmitName , TagSubmitValue ) ;
544+ else
545+ FormString += TagSubmitName + "=" + TagSubmitValue ;
546+ }
547+ else if ( ! FormIsMultiPart )
548+ if ( FormString . length > 0 )
549+ FormString = FormString . substring ( 0 , FormString . length - 1 ) ;
537550
538551 return ( FormIsMultiPart ) ? TmpFormData : FormString ;
539552}
@@ -654,6 +667,11 @@ function cb_SetWebFormsTagsValue(obj)
654667
655668 WebFormsTags . forEach ( function ( WebForms )
656669 {
670+ if ( WebForms . hasAttribute ( "done" ) )
671+ return ;
672+
673+ WebForms . setAttribute ( "done" , "true" ) ;
674+
657675 if ( WebForms . hasAttribute ( "src" ) )
658676 {
659677 WebForms . style . backgroundColor = PostBackOptions . WebFormsTagsBackgroundColor ;
@@ -691,7 +709,9 @@ function cb_SetWebFormsValues(RequestName, WebFormsValues, UsePostBack, WithoutW
691709
692710 for ( var i = 0 ; i < WebFormsList . length ; i ++ )
693711 {
694- if ( ! WebFormsList [ i ] . FullTrim ( ) )
712+ WebFormsList [ i ] = WebFormsList [ i ] . FullTrim ( ) ;
713+
714+ if ( ! WebFormsList [ i ] )
695715 continue ;
696716
697717 var PreRunner = new Array ( ) ;
@@ -712,6 +732,10 @@ function cb_SetWebFormsValues(RequestName, WebFormsValues, UsePostBack, WithoutW
712732 cb_SetPreRunnerQueueForEval ( PreRunner , ScriptValue ) ;
713733 continue ;
714734
735+ case `@` :
736+ cb_SaveValue ( WebFormsList [ i ] . substring ( 1 , 2 ) , WebFormsList [ i ] . substring ( 2 , 3 ) , WebFormsList [ i ] . substring ( 3 ) ) ;
737+ continue ;
738+
715739 case 'r' :
716740 var CacheKeyValue = WebFormsList [ i ] . GetTextAfter ( "=" ) ;
717741 switch ( SecondChar )
@@ -752,6 +776,9 @@ function cb_SetWebFormsValues(RequestName, WebFormsValues, UsePostBack, WithoutW
752776 localStorage . setItem ( RequestName + "-date" , UntilDate ) ;
753777 }
754778 continue ;
779+ case 'u' :
780+ window . history . replaceState ( { } , null , WebFormsList [ i ] . GetTextAfter ( "=" ) ) ;
781+ continue ;
755782 }
756783 }
757784
@@ -769,8 +796,17 @@ function cb_SetValueToInput(ActionOperation, ActionFeature, ActionValue)
769796{
770797 var ElementPlace = ActionValue . GetTextBefore ( "=" ) ;
771798 var Value = ActionValue . GetTextAfter ( "=" ) . FullTrim ( ) ;
772- var LabelForIndexer = 0 ;
773799
800+ // Set Dynamic Value
801+ var ValueArray = Value . split ( "|" ) ;
802+ for ( var ValueArrayIndex = 0 ; ValueArrayIndex < ValueArray . length ; ValueArrayIndex ++ )
803+ if ( ValueArray [ ValueArrayIndex ] . length > 0 )
804+ if ( ValueArray [ ValueArrayIndex ] . substring ( 0 , 1 ) == '@' )
805+ ValueArray [ ValueArrayIndex ] = cb_FetchValue ( ValueArray [ ValueArrayIndex ] ) ;
806+
807+ Value = ValueArray . join ( "|" ) ;
808+
809+ var LabelForIndexer = 0 ;
774810 var ElementPlaceList ;
775811
776812 if ( ElementPlace . substring ( 0 , 1 ) == '[' )
@@ -1174,10 +1210,24 @@ function cb_SetValueToInput(ActionOperation, ActionFeature, ActionValue)
11741210 }
11751211 break ;
11761212 case 'o' :
1213+ if ( Value == '*' )
1214+ {
1215+ var OptionList = CurrentElement . querySelectorAll ( 'option' ) ;
1216+ for ( var OptionIndex = 0 ; OptionIndex < OptionList . length ; OptionIndex ++ )
1217+ OptionList [ OptionIndex ] . outerHTML = "" ;
1218+ break ;
1219+ }
11771220 if ( CurrentElement . querySelectorAll ( 'option[value="' + Value + '"]' ) . length > 0 )
11781221 CurrentElement . querySelectorAll ( 'option[value="' + Value + '"]' ) [ 0 ] . outerHTML = "" ;
11791222 break ;
11801223 case 'k' :
1224+ if ( Value == '*' )
1225+ {
1226+ var CheckBoxList = CurrentElement . querySelectorAll ( 'input[type="checkbox"]' ) ;
1227+ for ( var CheckBoxTagIndex = 0 ; CheckBoxTagIndex < CheckBoxList . length ; CheckBoxTagIndex ++ )
1228+ CheckBoxList [ CheckBoxTagIndex ] . outerHTML = "" ;
1229+ break ;
1230+ }
11811231 var CheckBoxTagLength = CurrentElement . querySelectorAll ( 'input[type="checkbox"][value="' + Value + '"]' ) . length ;
11821232 if ( CheckBoxTagLength > 0 )
11831233 {
@@ -1197,14 +1247,12 @@ function cb_SetValueToInput(ActionOperation, ActionFeature, ActionValue)
11971247
11981248 break ;
11991249 }
1200-
12011250 if ( CurrentElement . id )
12021251 {
12031252 var LabelTag = document . querySelector ( 'label[for="' + CurrentElement . id + '"]' ) ;
12041253 if ( LabelTag )
12051254 LabelTag . outerHTML = "" ;
12061255 }
1207-
12081256 break ;
12091257 case 't' :
12101258 if ( Value == "1" )
@@ -1304,6 +1352,7 @@ function cb_SetValueToInput(ActionOperation, ActionFeature, ActionValue)
13041352 case "ta" : CurrentElement . style . textAlign = Value ; break ;
13051353 case "sr" : ( Value == "1" ) ? CurrentElement . setAttribute ( "readonly" , "" ) : CurrentElement . removeAttribute ( "readonly" ) ; break ;
13061354 case "sd" : ( Value == "1" ) ? CurrentElement . setAttribute ( "disabled" , "" ) : CurrentElement . removeAttribute ( "disabled" ) ; break ;
1355+ case "sf" : ( Value == "1" ) ? CurrentElement . focus ( ) : CurrentElement . blur ( ) ; break ;
13071356 case "mn" : CurrentElement . setAttribute ( "minlength" , Value ) ; break ;
13081357 case "mx" : CurrentElement . setAttribute ( "maxlength" , Value ) ; break ;
13091358 case "ts" : CurrentElement . value = Value ; break ;
@@ -1418,6 +1467,152 @@ function cb_GetElementByElementPlace(ElementPlace, obj)
14181467 }
14191468}
14201469
1470+ function cb_FetchValue ( Value )
1471+ {
1472+ Value = Value . substring ( 1 ) ;
1473+
1474+ if ( ! Value )
1475+ return Value ;
1476+
1477+ var ActionOperation = Value . substring ( 0 , 1 ) ;
1478+ var ActionFeature = Value . substring ( 1 , 2 ) ;
1479+
1480+ if ( ActionOperation == '_' )
1481+ return eval ( Value . substring ( 1 ) . Replace ( "$[ln];" , "\n" ) . FullTrim ( ) ) ;
1482+
1483+ Value = Value . substring ( 2 ) ;
1484+
1485+ switch ( ActionOperation )
1486+ {
1487+ case 'm' :
1488+ switch ( ActionFeature )
1489+ {
1490+ case 'r' :
1491+ if ( Value . Contains ( ',' ) )
1492+ return Math . floor ( Math . random ( ) * Value . GetTextBefore ( ',' ) ) + Value . GetTextAfter ( ',' ) ;
1493+ else
1494+ return Math . floor ( Math . random ( ) * Value . GetTextBefore ( ',' ) ) ;
1495+ }
1496+
1497+ case 'd' :
1498+ var CurrentDate = new Date ( ) ;
1499+ switch ( ActionFeature )
1500+ {
1501+ case 'y' : return CurrentDate . getFullYear ( ) ;
1502+ case 'm' : return CurrentDate . getMonth ( ) ;
1503+ case 'd' : return CurrentDate . getDay ( ) ;
1504+ case 'h' : return CurrentDate . getHours ( ) ;
1505+ case 'i' : return CurrentDate . getMinutes ( ) ;
1506+ case 's' : return CurrentDate . getSeconds ( ) ;
1507+ case 'l' : return CurrentDate . getMilliseconds ( ) ;
1508+ }
1509+
1510+ case 'c' :
1511+ switch ( ActionFeature )
1512+ {
1513+ case 's' :
1514+ case 'l' :
1515+ if ( Value . Contains ( ',' ) )
1516+ {
1517+ if ( sessionStorage . getItem ( Value . GetTextBefore ( ',' ) ) )
1518+ {
1519+ var TmpValue = sessionStorage . getItem ( Value . GetTextBefore ( ',' ) ) ;
1520+ if ( ActionFeature == 'l' )
1521+ sessionStorage . removeItem ( Value . GetTextBefore ( ',' ) ) ;
1522+
1523+ return TmpValue ;
1524+ }
1525+ else
1526+ return sessionStorage . getItem ( Value . GetTextAfter ( ',' ) ) ;
1527+ }
1528+ else
1529+ {
1530+ var TmpValue = sessionStorage . getItem ( Value ) ;
1531+ if ( ActionFeature == 't' )
1532+ sessionStorage . removeItem ( Value ) ;
1533+
1534+ return TmpValue ;
1535+ }
1536+ case 'd' :
1537+ case 't' :
1538+ if ( Value . Contains ( ',' ) )
1539+ {
1540+ if ( localStorage . getItem ( Value . GetTextBefore ( ',' ) ) )
1541+ {
1542+ var TmpValue = localStorage . getItem ( Value . GetTextBefore ( ',' ) ) ;
1543+ if ( ActionFeature == 't' )
1544+ localStorage . removeItem ( Value . GetTextBefore ( ',' ) ) ;
1545+
1546+ return TmpValue ;
1547+ }
1548+ else
1549+ return localStorage . getItem ( Value . GetTextAfter ( ',' ) ) ;
1550+ }
1551+ else
1552+ {
1553+ var TmpValue = localStorage . getItem ( Value ) ;
1554+ if ( ActionFeature == 't' )
1555+ localStorage . removeItem ( Value ) ;
1556+
1557+ return TmpValue ;
1558+ }
1559+ }
1560+ }
1561+ }
1562+
1563+ function cb_SaveValue ( ActionOperation , ActionFeature , ActionValue )
1564+ {
1565+ var CurrentElement = cb_GetElementByElementPlace ( ActionValue . GetTextBefore ( '=' ) ) ;
1566+ var Name = ActionValue . GetTextAfter ( '=' ) ;
1567+
1568+ switch ( ActionOperation )
1569+ {
1570+ case 'g' :
1571+ switch ( ActionFeature )
1572+ {
1573+ case 'i' : cb_SetSession ( Name , CurrentElement . id ) ; break ;
1574+ case 'n' : cb_SetSession ( Name , CurrentElement . name ) ; break ;
1575+ case 'v' : cb_SetSession ( Name , CurrentElement . value ) ; break ;
1576+ case 'e' : cb_SetSession ( Name , CurrentElement . value . length ) ; break ;
1577+ case 'c' : cb_SetSession ( Name , CurrentElement . className ) ; break ;
1578+ case 's' : cb_SetSession ( Name , CurrentElement . style ) ; break ;
1579+ case 'l' : cb_SetSession ( Name , CurrentElement . id ) ; break ;
1580+ if ( ! CurrentElement . tagName . IsInput ( ) )
1581+ {
1582+ if ( CurrentElement . hasAttribute ( "title" ) )
1583+ cb_SetSession ( Name , CurrentElement . getAttribute ( "title" ) ) ;
1584+ break ;
1585+ }
1586+ if ( CurrentElement . id )
1587+ {
1588+ var LabelTag = document . querySelector ( 'label[for="' + CurrentElement . id + '"]' ) ;
1589+ if ( LabelTag )
1590+ cb_SetSession ( Name , CurrentElement . getAttribute ( LabelTag . outerHTML ) ) ;
1591+ }
1592+ break ;
1593+ case 't' : cb_SetSession ( Name , CurrentElement . innerHTML ) ; break ;
1594+ case 'g' : cb_SetSession ( Name , CurrentElement . innerHTML . length ) ; break ;
1595+ case 'a' : cb_SetSession ( Name . GetTextBefore ( '|' ) , CurrentElement , getAttribute ( Name . GetTextAfter ( '|' ) ) ) ; break ;
1596+ case 'w' : cb_SetSession ( Name , CurrentElement . style . width ) ; break ;
1597+ case 'h' : cb_SetSession ( Name , CurrentElement . style . height ) ; break ;
1598+ case 'r' : cb_SetSession ( Name , ( CurrentElemen . hasAttribute ( "readonly" ) ? "true" : "false" ) ) ; break ;
1599+ case 'x' : cb_SetSession ( Name , CurrentElement . selectedIndex ) ;
1600+ }
1601+ }
1602+
1603+ switch ( ActionOperation + ActionFeature )
1604+ {
1605+ case "ta" : cb_SetSession ( Name , CurrentElement . style . textAlign ) ; break ;
1606+ case "nl" : cb_SetSession ( Name , CurrentElement . childNodes . length ) ; break ;
1607+ case "vi" : cb_SetSession ( Name , ( ( urrentElement . style . visibility == "hidden" ) ? "true" : "false" ) ) ;
1608+ }
1609+ }
1610+
1611+ function cb_SetSession ( Name , Value )
1612+ {
1613+ sessionStorage . setItem ( Name , Value ) ;
1614+ }
1615+
14211616/* End Fetch Web-Forms */
14221617
14231618/* Start Extension Methods */
0 commit comments