@@ -510,6 +510,34 @@ const EasyCoder_Browser = {
510
510
}
511
511
} ,
512
512
513
+ Focus : {
514
+
515
+ compile : ( compiler ) => {
516
+ const lino = compiler . getLino ( ) ;
517
+ if ( compiler . nextIsSymbol ( ) ) {
518
+ const symbol = compiler . getToken ( ) ;
519
+ compiler . next ( ) ;
520
+ compiler . addCommand ( {
521
+ domain : `browser` ,
522
+ keyword : `focus` ,
523
+ lino,
524
+ symbol
525
+ } ) ;
526
+ return true ;
527
+ }
528
+ compiler . addWarning ( `Unrecognised syntax in 'focus'` ) ;
529
+ return false ;
530
+ } ,
531
+
532
+ run : ( program ) => {
533
+ const command = program [ program . pc ] ;
534
+ const symbol = program . getSymbolRecord ( command . symbol ) ;
535
+ const element = symbol . element [ symbol . index ] ;
536
+ element . focus ( ) ;
537
+ return command . pc + 1 ;
538
+ }
539
+ } ,
540
+
513
541
FORM : {
514
542
515
543
compile : ( compiler ) => {
@@ -1691,6 +1719,26 @@ const EasyCoder_Browser = {
1691
1719
}
1692
1720
throw new Error ( `'${ compiler . getToken ( ) } ' is not a symbol` ) ;
1693
1721
}
1722
+ } else if ( token === `class` ) {
1723
+ if ( compiler . nextTokenIs ( `of` ) ) {
1724
+ if ( compiler . nextIsSymbol ( ) ) {
1725
+ const symbol = compiler . getSymbolRecord ( ) ;
1726
+ if ( symbol . extra === `dom` ) {
1727
+ if ( compiler . nextTokenIs ( `to` ) ) {
1728
+ const value = compiler . getNextValue ( ) ;
1729
+ compiler . addCommand ( {
1730
+ domain : `browser` ,
1731
+ keyword : `set` ,
1732
+ lino,
1733
+ type : `setClass` ,
1734
+ symbolName : symbol . name ,
1735
+ value
1736
+ } ) ;
1737
+ return true ;
1738
+ }
1739
+ }
1740
+ }
1741
+ }
1694
1742
} else if ( token === `id` ) {
1695
1743
if ( compiler . nextTokenIs ( `of` ) ) {
1696
1744
if ( compiler . nextIsSymbol ( ) ) {
@@ -1952,6 +2000,15 @@ const EasyCoder_Browser = {
1952
2000
select . selectedIndex = - 1 ;
1953
2001
}
1954
2002
break ;
2003
+ case `setClass` :
2004
+ symbol = program . getSymbolRecord ( command . symbolName ) ;
2005
+ target = symbol . element [ symbol . index ] ;
2006
+ if ( ! target ) {
2007
+ targetId = program . getValue ( symbol . value [ symbol . index ] ) ;
2008
+ target = document . getElementById ( targetId ) ;
2009
+ }
2010
+ target . classList . add ( program . getValue ( command . value ) ) ;
2011
+ break ;
1955
2012
case `setId` :
1956
2013
symbol = program . getSymbolRecord ( command . symbolName ) ;
1957
2014
target = symbol . element [ symbol . index ] ;
@@ -2347,6 +2404,8 @@ const EasyCoder_Browser = {
2347
2404
return EasyCoder_Browser . FIELDSET ;
2348
2405
case `file` :
2349
2406
return EasyCoder_Browser . FILE ;
2407
+ case `focus` :
2408
+ return EasyCoder_Browser . Focus ;
2350
2409
case `form` :
2351
2410
return EasyCoder_Browser . FORM ;
2352
2411
case `fullscreen` :
0 commit comments