1+ function init ( ) {
2+ console . log ( 'App launch' ) ;
3+
4+ var url = document . getElementById ( 'server-url' ) . value ;
5+ var port = document . getElementById ( 'server-port' ) . value ;
6+
7+ debugger ;
8+ startWebserver ( url , port , 'SR' , null ) ;
9+
10+
11+
12+ function startWebserverDirectoryEntry ( host , port , entry ) {
13+ directoryServer = new WSC . WebApplication ( { host :host ,
14+ port :port ,
15+ renderIndex :true ,
16+ entry :entry
17+ } )
18+ directoryServer . start ( )
19+ }
20+
21+ //directory must be a subdirectory of the package
22+ function startWebserver ( host , port , directory , settings ) {
23+ chrome . runtime . getPackageDirectoryEntry ( function ( packageDirectory ) {
24+
25+ console . log ( 'packageDirectory - ' + packageDirectory ) ;
26+ var data1 = packageDirectory . getDirectory ( directory , { create : false } , function ( webroot ) {
27+
28+ console . log ( 'webroot - ' + webroot ) ;
29+ debugger ;
30+
31+ var fs = new WSC . FileSystem ( webroot )
32+ var handlers = [ [ '/data.*' , AdminDataHandler ] ,
33+ [ '.*' , WSC . DirectoryEntryHandler . bind ( null , fs ) ] ]
34+ adminServer = new WSC . WebApplication ( { host :host ,
35+ port :port ,
36+ handlers :handlers ,
37+ renderIndex :true ,
38+ auth :{ username : "a" ,
39+ password : "a" }
40+ } )
41+ adminServer . start ( )
42+ } , function ( e ) {
43+
44+ console . log ( 'error g' ) ;
45+ console . log ( e ) ;
46+ } ) ;
47+
48+ } ) ;
49+ // console.log('data1');
50+ // console.log(data1);
51+ }
52+ }
53+
54+ window . onload = function ( ) {
55+ debugger ;
56+ document . querySelector ( "#server-start" ) . addEventListener ( "click" , function ( ) {
57+
58+
59+ var url = document . getElementById ( 'server-url' ) . value ;
60+ var port = document . getElementById ( 'server-port' ) . value ;
61+
62+ var srWcServer = { Url : url , Port : port } ;
63+
64+ chrome . storage . sync . set ( { 'srWcServerInfo' : srWcServer } ) ;
65+ chrome . runtime . sendMessage ( 'demo' ) ;
66+
67+ // chrome.storage.sync.get(['srWcServerInfo'], function(result) {
68+ // console.log('Value currently is ' + result.srWcServerInfo);
69+ // console.log('Value currently is ' + result);
70+ // });
71+ } ) ;
72+ } ;
0 commit comments