44 < meta charset ="UTF-8 ">
55 < meta name ="viewport " content ="width=device-width, initial-scale=1.0 ">
66 < meta http-equiv ="X-UA-Compatible " content ="ie=edge ">
7- < script src ="./index.js "> </ script >
8- < title > Signal R JavaScript Client</ title >
7+
8+ <!-- <script src="./js/components/basicView.js"></script> -->
9+ < title > Signal R JavaScript Client</ title >
910</ head >
1011< body >
12+
1113 < h1 > Signal R JavaScript Client</ h1 >
12- < div >
13- < table >
14- < tr >
15- < td > Url</ td >
16- < td > < input type ="text " id ="txt-url " size ="50 " value ="http://localhost:53128/connect/app "/> </ td >
17- </ tr >
18- < tr > </ tr >
19- < tr > </ tr >
20- < tr >
21- < td > Methods</ td >
22- < tr > < td > WebSocket < input type ="checkbox " id ="txt-chk-we " class ="lst-con-protocol " value ="ws " checked /> </ td > </ tr >
23- < tr > < td > Long Pooling < input type ="checkbox " id ="txt-chk-lp " class ="lst-con-protocol " disabled checked value ="lp " /> </ td > </ tr >
24- < tr > < td > Server Send Event< input type ="checkbox " id ="txt-chk-sse " class ="lst-con-protocol " checked value ="sse " /> </ td > </ tr >
25- <!-- <tr><td>Any<input type="checkbox" id="txt-chk-any" class="lst-con-any" value="any" /></td></tr> -->
26- </ tr >
27- < tr > </ tr >
28- < tr > </ tr >
29- < tr >
30- < td > Server Method</ td >
31- < td > < input type ="text " id ="txt-method " size ="50 " value ="Get "/> </ td >
32- </ tr >
33- < tr > </ tr >
34- < tr > </ tr >
35- < tr >
36- < td > Request Data</ td >
37- < td > < textarea id ="txt-input-area " rows ="10 " cols ="100 "> </ textarea > </ td >
38- < td > < input type ="button " id ="btn-send " value ="Send " onclick ="sendData() "/> </ td >
39- </ tr >
40- < tr >
41- < td > Response Data</ td >
42- < td > < textarea id ="txt-output-area " rows ="10 " cols ="100 "> </ textarea > </ td >
43- </ tr >
44- < tr > </ tr >
45- < tr > </ tr >
46- < tr >
47- < td > < input type ="button " id ="btn-connect " value ="Connect " onclick ="connectToServer() " /> </ td >
48- </ tr >
49- < tr > </ tr >
50- < tr > </ tr >
51- < tr >
52- < td > < input type ="button " id ="btn-disconnect " value ="Disconnect " onclick ="disconnect() " /> </ td >
53- </ tr >
54- </ table >
14+ <!-- <hello-component data-name="James"></hello-component> -->
15+ < div class ="container ">
16+ < basic-src-view > </ basic-src-view >
5517 </ div >
56- < script type ="text/javascript ">
57-
58- var connection = null ;
59-
60- function connectToServer ( )
61- {
62- var url = document . getElementById ( "txt-url" ) . value ;
63- connection = new signalR . HubConnectionBuilder ( )
64- . withUrl ( url )
65- . build ( ) ;
66-
67- connection
68- . start ( )
69- . then ( function ( ) {
70- console . log ( 'Connected' ) ;
71- document . querySelector ( "#txt-output-area" ) . value += "Connected..." + '\n'
72- } )
73- . catch ( function ( err ) {
74- return console . error ( err . toString ( ) ) ;
75- } ) ;
76- }
77-
78- function sendData ( )
79- {
80- var methodName = document . getElementById ( "txt-method" ) . value
81- //connection.invoke.apply(methodName, null);
82- var c = new Array ( ) ;
83- var data = JSON . parse ( document . getElementById ( "txt-input-area" ) . value ) ;
84- c . push ( data ) ;
85-
86- connection . invoke ( methodName , data )
87- . catch ( function ( err ) {
88- return console . log ( err ) ;
89- } ) ;
90-
91- connection . on ( "ReceiveData" , function ( data ) {
92-
93-
94- document . querySelector ( "#txt-output-area" ) . value += JSON . stringify ( data ) + '\n' ;
95-
96-
97- } ) ;
98- }
99-
100- function disconnect ( )
101- {
102- connection . stop ( )
103- . then ( function ( ) {
104- console . log ( 'Disconnected' ) ;
105- document . querySelector ( "#txt-output-area" ) . value += "Disconnected..." + '\n'
106- } )
107- . catch ( function ( err ) {
108- return console . error ( err . toString ( ) ) ;
109- } ) ;
110- }
111-
112- ( function ( ) {
113-
114-
115- //SetProtocols();
116-
117- var elements = document . querySelectorAll ( ".lst-con-protocol" ) ;
118-
119- elements . forEach ( function ( el ) {
120- el . addEventListener ( "click" , function ( ) {
121- SetProtocols ( ) ;
122- } ) ;
123-
124- } )
125-
126-
127- } ) ( ) ;
128-
129-
130- function SetProtocols ( )
131- {
132- // var anyCheckbox = document.getElementById("txt-chk-any");
133-
134- // if(anyCheckbox.checked === true)
135- // {
136- // return;
137- // }
138-
139- var counter = 0 ;
140- var elements = document . querySelectorAll ( ".lst-con-protocol" ) ;
141-
142- for ( var i = 0 ; i < elements . length ; i ++ )
143- {
144- if ( elements [ i ] . value === "ws" && elements [ i ] . checked !== true )
145- {
146- console . log ( "WebSocket disabled" ) ;
147- WebSocket = undefined ;
148- counter ++ ;
149- }
150- else if ( elements [ i ] . value === "sse" && elements [ i ] . checked !== true )
151- {
152- console . log ( "Server Sent Event disabled" ) ;
153- EventSource = undefined ;
154- counter ++ ;
155- }
156- else if ( elements [ i ] . value === "lp" && elements [ i ] . checked !== true )
157- {
158- //console.log("Server Sent Event disabled");
159- //EventSource = undefined;
160- counter ++ ;
161- }
162- }
163-
16418
165- // if(counter === 0)
166- // {
167- // anyCheckbox.checked = true;
168- // }
169- // else
170- // {
171- // anyCheckbox.checked = false;
172- // }
173- }
174-
175- </ script >
19+ < script src ="./main.js "> </ script >
17620</ body >
17721</ html >
0 commit comments