10
10
< script defer src ="
https://cdn.jsdelivr.net/npm/[email protected] /dist/cdn.min.js "
> </ script >
11
11
12
12
< link rel ="stylesheet " href ="styles.css?v=oq5lin ">
13
+
14
+ < script >
15
+ document . addEventListener ( 'alpine:initialized' , async ( ) => {
16
+ await playground . start ( ) ;
17
+ playground . onCodeChange ( ( ) => {
18
+ playground . runBot ( botState ) ;
19
+ } ) ;
20
+ playground . worker . onmessage = ( e ) => {
21
+ console . log ( 'got message from worker' , e ?. data ) ;
22
+ if ( ! e ?. data ) return ;
23
+ if ( e . data . botState ) {
24
+ Object . assign ( botState , e . data . botState )
25
+ }
26
+ botUpdates . push ( e . data ) ;
27
+ console . log ( 'Scrolling' , $refs . updates . scrollHeight ) ;
28
+ $nextTick ( ( ) => { $refs . updates . scrollTop = $refs . updates . scrollHeight } )
29
+ } ;
30
+ } )
31
+ </ script >
13
32
</ head >
14
33
15
34
< body x-data ="{
@@ -58,25 +77,6 @@ <h1>Telegram Bot Playground 🤖 </h1>
58
77
</ div >
59
78
</ div >
60
79
61
- < script >
62
- document . addEventListener ( 'alpine:initialized' , async ( ) => {
63
- await playground . start ( ) ;
64
- playground . onCodeChange ( ( ) => {
65
- playground . runBot ( botState ) ;
66
- } ) ;
67
- playground . worker . onmessage = ( e ) => {
68
- console . log ( 'got message from worker' , e ?. data ) ;
69
- if ( ! e ?. data ) return ;
70
- if ( e . data . botState ) {
71
- Object . assign ( botState , e . data . botState )
72
- }
73
- botUpdates . push ( e . data ) ;
74
- console . log ( 'Scrolling' , $refs . updates . scrollHeight ) ;
75
- $nextTick ( ( ) => { $refs . updates . scrollTop = $refs . updates . scrollHeight } )
76
- } ;
77
- } )
78
- </ script >
79
-
80
80
</ body >
81
81
82
82
</ html >
0 commit comments