@@ -9,6 +9,8 @@ PostBackOptions.ConnectionErrorMessage = "Connection Error";
99PostBackOptions . AutoSetSubmitOnClick = true ;
1010PostBackOptions . SendDataOnlyByPostMethod = false ;
1111PostBackOptions . ResponseLocation = null ;
12+ PostBackOptions . WebFormsTagsBackgroundColor = "#eee" ;
13+ PostBackOptions . SetResponseInsideDivTag = true ;
1214
1315function cb_SetResponseLocation ( )
1416{
@@ -52,9 +54,23 @@ function cb_SetPostBackFunctionToSubmit(obj)
5254window . onload = function ( )
5355{
5456 cb_SetResponseLocation ( ) ;
55- cb_SetPostBackFunctionToSubmit ( ) ;
57+ cb_Initialization ( ) ;
5658} ;
5759
60+ function cb_Initialization ( obj )
61+ {
62+ if ( obj )
63+ {
64+ cb_SetPostBackFunctionToSubmit ( obj ) ;
65+ cb_SetWebFormsTagsValue ( obj ) ;
66+ }
67+ else
68+ {
69+ cb_SetPostBackFunctionToSubmit ( ) ;
70+ cb_SetWebFormsTagsValue ( ) ;
71+ }
72+ }
73+
5874/* End Event */
5975
6076/* Start Post-Back */
@@ -131,15 +147,32 @@ function PostBack(obj, ViewState)
131147 if ( ViewState )
132148 {
133149 if ( typeof ViewState === "string" )
134- cb_GetElementByElementPlace ( ViewState ) . innerHTML = TmpDiv . outerHTML ;
150+ {
151+ var ViewStateObject = cb_GetElementByElementPlace ( ViewState ) ;
152+ ViewStateObject . innerHTML = TmpDiv . outerHTML ;
153+ cb_Initialization ( ViewStateObject . getElementsByTagName ( "div" ) [ 0 ] ) ;
154+ if ( ! PostBackOptions . SetResponseInsideDivTag )
155+ ViewStateObject . getElementsByTagName ( "div" ) [ 0 ] . outerHTML = ViewStateObject . getElementsByTagName ( "div" ) [ 0 ] . innerHTML ;
156+ }
157+ else if ( typeof ViewState === "object" )
158+ {
159+ ViewState . innerHTML = TmpDiv . outerHTML ;
160+ cb_Initialization ( ViewState . getElementsByTagName ( "div" ) [ 0 ] ) ;
161+ if ( ! PostBackOptions . SetResponseInsideDivTag )
162+ ViewState . getElementsByTagName ( "div" ) [ 0 ] . outerHTML = ViewState . getElementsByTagName ( "div" ) [ 0 ] . innerHTML ;
163+ }
135164 else
165+ {
136166 PostBackOptions . ResponseLocation . prepend ( TmpDiv ) ;
137- cb_SetPostBackFunctionToSubmit ( PostBackOptions . ResponseLocation . getElementsByTagName ( "div" ) [ 0 ] ) ;
167+ cb_Initialization ( PostBackOptions . ResponseLocation . getElementsByTagName ( "div" ) [ 0 ] ) ;
168+ if ( ! PostBackOptions . SetResponseInsideDivTag )
169+ PostBackOptions . ResponseLocation . getElementsByTagName ( "div" ) [ 0 ] . outerHTML = PostBackOptions . ResponseLocation . getElementsByTagName ( "div" ) [ 0 ] . innerHTML ;
170+ }
138171 }
139172 else
140173 {
141- PostBackOptions . ResponseLocation . innerHTML = TmpDiv . outerHTML ;
142- cb_SetPostBackFunctionToSubmit ( PostBackOptions . ResponseLocation ) ;
174+ PostBackOptions . ResponseLocation . innerHTML = ( PostBackOptions . SetResponseInsideDivTag ) ? TmpDiv . outerHTML : TmpDiv . innerHTML ;
175+ cb_Initialization ( PostBackOptions . ResponseLocation ) ;
143176 }
144177
145178 Form . focus ( ) ;
@@ -241,18 +274,33 @@ function GetBack(FormAction, ViewState)
241274 if ( ViewState )
242275 {
243276 if ( typeof ViewState === "string" )
244- cb_GetElementByElementPlace ( ViewState ) . innerHTML = TmpDiv . outerHTML ;
277+ {
278+ var ViewStateObject = cb_GetElementByElementPlace ( ViewState ) ;
279+ ViewStateObject . innerHTML = TmpDiv . outerHTML ;
280+ cb_Initialization ( ViewStateObject . getElementsByTagName ( "div" ) [ 0 ] ) ;
281+ if ( ! PostBackOptions . SetResponseInsideDivTag )
282+ ViewStateObject . getElementsByTagName ( "div" ) [ 0 ] . outerHTML = ViewStateObject . getElementsByTagName ( "div" ) [ 0 ] . innerHTML ;
283+ }
284+ else if ( typeof ViewState === "object" )
285+ {
286+ ViewState . innerHTML = TmpDiv . outerHTML ;
287+ cb_Initialization ( ViewState . getElementsByTagName ( "div" ) [ 0 ] ) ;
288+ if ( ! PostBackOptions . SetResponseInsideDivTag )
289+ ViewState . getElementsByTagName ( "div" ) [ 0 ] . outerHTML = ViewState . getElementsByTagName ( "div" ) [ 0 ] . innerHTML ;
290+ }
245291 else
292+ {
246293 PostBackOptions . ResponseLocation . prepend ( TmpDiv ) ;
247- cb_SetPostBackFunctionToSubmit ( PostBackOptions . ResponseLocation . getElementsByTagName ( "div" ) [ 0 ] ) ;
294+ cb_Initialization ( PostBackOptions . ResponseLocation . getElementsByTagName ( "div" ) [ 0 ] ) ;
295+ if ( ! PostBackOptions . SetResponseInsideDivTag )
296+ PostBackOptions . ResponseLocation . getElementsByTagName ( "div" ) [ 0 ] . outerHTML = PostBackOptions . ResponseLocation . getElementsByTagName ( "div" ) [ 0 ] . innerHTML ;
297+ }
248298 }
249299 else
250300 {
251- PostBackOptions . ResponseLocation . innerHTML = TmpDiv . outerHTML ;
252- cb_SetPostBackFunctionToSubmit ( PostBackOptions . ResponseLocation ) ;
301+ PostBackOptions . ResponseLocation . innerHTML = ( PostBackOptions . SetResponseInsideDivTag ) ? TmpDiv . outerHTML : TmpDiv . innerHTML ;
302+ cb_Initialization ( PostBackOptions . ResponseLocation ) ;
253303 }
254-
255- Form . focus ( ) ;
256304 }
257305 }
258306 }
@@ -519,11 +567,44 @@ function cb_HasFileInput(Form)
519567
520568/* End Progress Bar */
521569
570+ /* Start Web-Forms Tags */
571+
572+ function cb_SetWebFormsTagsValue ( obj )
573+ {
574+ const WebFormsTags = ( obj ) ? obj . querySelectorAll ( 'web-forms' ) : document . querySelectorAll ( 'web-forms' ) ;
575+
576+ WebFormsTags . forEach ( function ( WebForms )
577+ {
578+ if ( WebForms . hasAttribute ( "src" ) )
579+ {
580+ WebForms . style . backgroundColor = PostBackOptions . WebFormsTagsBackgroundColor ;
581+ if ( WebForms . hasAttribute ( "width" ) )
582+ WebForms . style . width = WebForms . getAttribute ( "width" ) ;
583+ if ( WebForms . hasAttribute ( "height" ) )
584+ WebForms . style . height = WebForms . getAttribute ( "height" ) ;
585+
586+ var Src = WebForms . getAttribute ( "src" ) ;
587+ if ( Src )
588+ GetBack ( Src , WebForms ) ;
589+ }
590+
591+ if ( WebForms . hasAttribute ( "ac" ) )
592+ {
593+ var ActionControl = WebForms . getAttribute ( "ac" ) ;
594+ if ( ActionControl )
595+ cb_SetWebFormsValues ( ActionControl . Replace ( "$[dq];" , "\"" ) , false , true ) ;
596+ }
597+ } ) ;
598+ }
599+
600+ /* End Web-Forms Tags */
601+
522602/* Start Fetch Web-Forms */
523603
524- function cb_SetWebFormsValues ( WebFormsValues , UsePostBack )
604+ function cb_SetWebFormsValues ( WebFormsValues , UsePostBack , WithoutWebFormsSection )
525605{
526- WebFormsValues = WebFormsValues . substring ( 11 ) ;
606+ if ( ! WithoutWebFormsSection )
607+ WebFormsValues = WebFormsValues . substring ( 11 ) ;
527608
528609 var WebFormsList = ( UsePostBack ) ? WebFormsValues . split ( '\n' ) : WebFormsValues . split ( "$[sln];" ) ;
529610
@@ -532,13 +613,32 @@ function cb_SetWebFormsValues(WebFormsValues, UsePostBack)
532613 if ( ! WebFormsList [ i ] . FullTrim ( ) )
533614 continue ;
534615
616+ var PreRunner = new Array ( ) ;
617+ var FirstChar = WebFormsList [ i ] . substring ( 0 , 1 ) ;
618+ var PreRunnerIndexer = 0 ;
619+ while ( ( FirstChar == '→' ) || ( FirstChar == '↑' ) )
620+ {
621+ PreRunner [ PreRunnerIndexer ++ ] = WebFormsList [ i ] . GetTextBefore ( ")" ) ;
622+ WebFormsList [ i ] = WebFormsList [ i ] . GetTextAfter ( ")" ) ;
623+ FirstChar = WebFormsList [ i ] . substring ( 0 , 1 ) ;
624+ }
625+
626+ switch ( FirstChar )
627+ {
628+ case '_' :
629+ var ScriptValue = WebFormsList [ i ] . GetTextAfter ( "=" ) . Replace ( "$[ln];" , "\n" ) . FullTrim ( ) ;
630+ cb_SetPreRunnerQueueForEval ( PreRunner , ScriptValue ) ;
631+ continue ;
632+ }
633+
634+
535635 var ActionName = WebFormsList [ i ] . substring ( 0 , 2 ) ;
536636 var ActionValue = WebFormsList [ i ] . substring ( 2 ) ;
537637
538638 var ActionOperation = ActionName . substring ( 0 , 1 ) ;
539639 var ActionFeature = ActionName . substring ( 1 , 2 ) ;
540640
541- cb_SetValueToInput ( ActionOperation , ActionFeature , ActionValue ) ;
641+ cb_SetPreRunnerQueueForSetValueToInput ( PreRunner , ActionOperation , ActionFeature , ActionValue ) ;
542642 }
543643}
544644
@@ -700,7 +800,7 @@ function cb_SetValueToInput(ActionOperation, ActionFeature, ActionValue)
700800 break ;
701801 case 't' :
702802 CurrentElement . innerHTML = CurrentElement . innerHTML + Value . Replace ( "$[ln];" , "\n" ) . toDOM ( ) ;
703- cb_SetPostBackFunctionToSubmit ( CurrentElement ) ;
803+ cb_Initialization ( CurrentElement ) ;
704804 break ;
705805 case 'a' :
706806 var AttrName = Value ;
@@ -897,7 +997,7 @@ function cb_SetValueToInput(ActionOperation, ActionFeature, ActionValue)
897997 break ;
898998
899999 CurrentElement . innerHTML = Value . Replace ( "$[ln];" , "\n" ) . toDOM ( ) ;
900- cb_SetPostBackFunctionToSubmit ( CurrentElement ) ;
1000+ cb_Initialization ( CurrentElement ) ;
9011001 break ;
9021002 case 'a' :
9031003 var AttrName = Value ;
@@ -1084,7 +1184,13 @@ function cb_SetValueToInput(ActionOperation, ActionFeature, ActionValue)
10841184 case "mn" : CurrentElement . setAttribute ( "minlength" , Value ) ; break ;
10851185 case "mx" : CurrentElement . setAttribute ( "maxlength" , Value ) ; break ;
10861186 case "ts" : CurrentElement . value = Value ; break ;
1087- case "ti" : CurrentElement . selectedIndex = Value ; break ;
1187+ case "ti" :
1188+ var SelectedIndex = parseInt ( Value ) ;
1189+ if ( SelectedIndex >= 0 )
1190+ CurrentElement . selectedIndex = SelectedIndex ;
1191+ else
1192+ CurrentElement . selectedIndex = ( CurrentElement . getElementsByTagName ( "option" ) . length + SelectedIndex ) ;
1193+ break ;
10881194 case "ks" :
10891195 var CheckBoxValue = Value . GetTextBefore ( "|" ) ;
10901196 var CheckBoxChecked = Value . GetTextAfter ( "|" ) ;
@@ -1093,9 +1199,10 @@ function cb_SetValueToInput(ActionOperation, ActionFeature, ActionValue)
10931199 CurrentElement . querySelectorAll ( 'input[type="checkbox"][value="' + CheckBoxValue + '"]' ) [ 0 ] . checked = ( CheckBoxChecked == "1" ) ;
10941200 break ;
10951201 case "ki" :
1096- var CheckBoxIndex = Value . GetTextBefore ( "|" ) ;
1202+ var CheckBoxIndex = parseInt ( Value . GetTextBefore ( "|" ) ) ;
10971203 var CheckBoxChecked = Value . GetTextAfter ( "|" ) ;
1098- var CheckBoxTag = CurrentElement . querySelectorAll ( 'input[type="checkbox"]' ) [ CheckBoxIndex ] ;
1204+ var CheckBoxTags = CurrentElement . querySelectorAll ( 'input[type="checkbox"]' ) ;
1205+ var CheckBoxTag = ( ClassIndex >= 0 ) ? CheckBoxTags [ CheckBoxIndex ] : CheckBoxTags [ CheckBoxTags . length + CheckBoxIndex ] ;
10991206 if ( CheckBoxTag )
11001207 CheckBoxTag . checked = ( CheckBoxChecked == "1" ) ;
11011208 break ;
@@ -1110,6 +1217,8 @@ function cb_SetValueToInput(ActionOperation, ActionFeature, ActionValue)
11101217 }
11111218 else
11121219 CurrentElement . appendChild ( document . createElement ( Value ) ) ;
1220+ break ;
1221+ case "lu" : GetBack ( Value , ElementPlace ) ;
11131222 }
11141223 }
11151224}
@@ -1124,18 +1233,27 @@ function cb_GetElementByElementPlace(ElementPlace, obj)
11241233 {
11251234 case '<' :
11261235 var TagName = ElementPlace . substring ( 1 ) . GetTextBefore ( ">" ) ;
1127- var TagIndex = ( ElementPlace . length > ( TagName . length + 2 ) ) ? ElementPlace . substring ( TagName . length + 2 ) : 0 ;
1128- return FromPlace . getElementsByTagName ( TagName ) [ TagIndex ] ;
1236+ var TagIndex = ( ElementPlace . length > ( TagName . length + 2 ) ) ? parseInt ( ElementPlace . substring ( TagName . length + 2 ) ) : 0 ;
1237+ if ( TagIndex >= 0 )
1238+ return FromPlace . getElementsByTagName ( TagName ) [ TagIndex ] ;
1239+ else
1240+ return FromPlace . getElementsByTagName ( TagName ) [ FromPlace . getElementsByTagName ( TagName ) . length + TagIndex ] ;
11291241
11301242 case '(' :
11311243 var TagNameAttr = ElementPlace . substring ( 1 ) . GetTextBefore ( ")" ) ;
1132- var TagNameIndex = ( ElementPlace . length > ( TagNameAttr . length + 2 ) ) ? ElementPlace . substring ( TagNameAttr . length + 2 ) : 0 ;
1133- return FromPlace . getElementsByName ( TagNameAttr ) [ TagNameIndex ] ;
1244+ var TagNameIndex = ( ElementPlace . length > ( TagNameAttr . length + 2 ) ) ? parseInt ( ElementPlace . substring ( TagNameAttr . length + 2 ) ) : 0 ;
1245+ if ( TagNameIndex >= 0 )
1246+ return FromPlace . getElementsByName ( TagNameAttr ) [ TagNameIndex ] ;
1247+ else
1248+ return FromPlace . getElementsByName ( TagNameAttr ) [ FromPlace . getElementsByName ( TagNameAttr ) . length + TagNameIndex ] ;
11341249
11351250 case '{' :
11361251 var ClassName = ElementPlace . substring ( 1 ) . GetTextBefore ( "}" ) ;
1137- var ClassIndex = ( ElementPlace . length > ( ClassName . length + 2 ) ) ? ElementPlace . substring ( ClassName . length + 2 ) : 0 ;
1138- return FromPlace . getElementsByClassName ( ClassName ) [ ClassIndex ] ;
1252+ var ClassIndex = ( ElementPlace . length > ( ClassName . length + 2 ) ) ? parseInt ( ElementPlace . substring ( ClassName . length + 2 ) ) : 0 ;
1253+ if ( ClassIndex >= 0 )
1254+ return FromPlace . getElementsByClassName ( ClassName ) [ ClassIndex ] ;
1255+ else
1256+ return FromPlace . getElementsByClassName ( ClassName ) [ FromPlace . getElementsByClassName ( ClassName ) . length + ClassIndex ] ;
11391257
11401258 case '*' :
11411259 var Query = ElementPlace . substring ( 1 ) ;
@@ -1325,3 +1443,55 @@ String.prototype.GetUnit = function ()
13251443} ;
13261444
13271445/* End Extension Methods */
1446+
1447+ /* Start Pre Runner Queue Methods */
1448+
1449+ function cb_SetPreRunnerQueueForEval ( PreRunner , ScriptValue )
1450+ {
1451+ if ( PreRunner . length < 1 )
1452+ {
1453+ eval ( ScriptValue ) ;
1454+ return ;
1455+ }
1456+
1457+ var FirstChar = PreRunner [ 0 ] . substring ( 0 , 1 ) ;
1458+
1459+ switch ( FirstChar )
1460+ {
1461+ case "↑" :
1462+ PeriodMiliSecond = parseFloat ( PreRunner [ 0 ] . GetTextAfter ( "↑" ) ) * 1000 ;
1463+ PreRunner . shift ( ) ;
1464+ setInterval ( function ( ) { cb_SetPreRunnerQueueForEval ( PreRunner , ScriptValue ) ; } , PeriodMiliSecond ) ;
1465+ break ;
1466+ case "→" :
1467+ DelayMiliSecond = parseFloat ( PreRunner [ 0 ] . GetTextAfter ( "→" ) ) * 1000 ;
1468+ PreRunner . shift ( ) ;
1469+ setTimeout ( function ( ) { cb_SetPreRunnerQueueForEval ( PreRunner , ScriptValue ) ; } , DelayMiliSecond ) ;
1470+ }
1471+ }
1472+
1473+ function cb_SetPreRunnerQueueForSetValueToInput ( PreRunner , ActionOperation , ActionFeature , ActionValue )
1474+ {
1475+ if ( PreRunner . length < 1 )
1476+ {
1477+ cb_SetValueToInput ( ActionOperation , ActionFeature , ActionValue ) ;
1478+ return ;
1479+ }
1480+
1481+ var FirstChar = PreRunner [ 0 ] . substring ( 0 , 1 ) ;
1482+
1483+ switch ( FirstChar )
1484+ {
1485+ case "↑" :
1486+ PeriodMiliSecond = parseFloat ( PreRunner [ 0 ] . GetTextAfter ( "↑" ) ) * 1000 ;
1487+ PreRunner . shift ( ) ;
1488+ setInterval ( function ( ) { cb_SetPreRunnerQueueForSetValueToInput ( PreRunner , ActionOperation , ActionFeature , ActionValue ) ; } , PeriodMiliSecond ) ;
1489+ break ;
1490+ case "→" :
1491+ DelayMiliSecond = parseFloat ( PreRunner [ 0 ] . GetTextAfter ( "→" ) ) * 1000 ;
1492+ PreRunner . shift ( ) ;
1493+ setTimeout ( function ( ) { cb_SetPreRunnerQueueForSetValueToInput ( PreRunner , ActionOperation , ActionFeature , ActionValue ) ; } , DelayMiliSecond ) ;
1494+ }
1495+ }
1496+
1497+ /* End Pre Runner Queue Methods */
0 commit comments