33 < meta name ="viewport " content ="user-scalable=no, width=device-width, initial-scale=1.0, maximum-scale=1.0 ">
44 < style type ='text/css '>
55 html { font-family : Helvetica; color : # 222 ; }
6- h1 { color : steelblue; font-size : 24px ; margin-top : 24px ; }
7- button { margin : 0 3px 10px ; font-size : 12px ; }
8- .logLine { border-bottom : 1px solid # ccc ; padding : 4px 2px ; font-family : courier; font-size : 11px ; }
6+ h1 { color : # FE8FBD ; font-size : 24px ; margin-top : 24px ; }
7+ button { margin : 0 3px 10px ; font-size : 14px ; border : 2px solid # 000000 ; }
8+ .logLine_Native { border-bottom : 1px solid # FFA67C ; padding : 4px 2px ; font-family : courier; font-size : 12px ; }
9+ .logLine_JS { border-bottom : 1px solid # D867D8 ; padding : 4px 2px ; font-family : courier; font-size : 12px ; }
910 </ style >
1011</ head > < body >
1112 < h1 > Demo</ h1 >
@@ -23,19 +24,19 @@ <h1>Demo</h1>
2324
2425 setupWKWebViewJavascriptBridge ( function ( bridge ) {
2526 var uniqueId = 1
26- function log ( message , data ) {
27+ function log ( message , data , type ) {
2728 var log = document . getElementById ( 'log' )
2829 var el = document . createElement ( 'div' )
29- el . className = 'logLine '
30+ el . className = type == 'native' ? 'logLine_Native' : 'logLine_JS '
3031 el . innerHTML = uniqueId ++ + '. ' + message + ':<br/>' + JSON . stringify ( data )
3132 if ( log . children . length ) { log . insertBefore ( el , log . children [ 0 ] ) }
3233 else { log . appendChild ( el ) }
3334 }
3435
3536 bridge . registerHandler ( 'testJavascriptHandler' , function ( data , responseCallback ) {
36- log ( 'iOS called testJavascriptHandler with' , data )
37+ log ( 'iOS called testJavascriptHandler with' , data , 'native' )
3738 var responseData = { 'Javascript Says' :'Right back atcha!' }
38- log ( 'JS responding with' , responseData )
39+ log ( 'JS responding with' , responseData , 'native' )
3940 responseCallback ( responseData )
4041 } )
4142
@@ -47,7 +48,7 @@ <h1>Demo</h1>
4748 e . preventDefault ( )
4849 log ( 'JS calling handler "testiOSCallback"' )
4950 bridge . callHandler ( 'testiOSCallback' , { 'foo' : 'bar' } , function ( response ) {
50- log ( 'JS got response' , response )
51+ log ( 'JS got response' , response , 'js' )
5152 } )
5253 }
5354 } )
0 commit comments