@@ -41,47 +41,6 @@ var client_available = false;
4141var ports_available = false ;
4242
4343
44- /**
45- * The version number the BlocklyProp Client reported
46- *
47- * @type {number }
48- */
49- var client_version = 0 ;
50-
51-
52- // TODO: Verify that this variable is a host name and not a domain name
53- /**
54- * Client host name
55- *
56- * @type {string }
57- */
58- var client_domain_name = "localhost" ;
59-
60-
61- /**
62- * Port number component of the BlocklyProp Client interface
63- *
64- * @type {number }
65- */
66- var client_domain_port = 6009 ;
67-
68-
69- /**
70- * The minimum version of the BlocklyProp Client that can be used with this interface
71- *
72- * @type {string }
73- */
74- var client_min_version = "0.7.0" ;
75-
76-
77- /**
78- * The most recent version of the BlocklyPro Client that can be used with this interface
79- *
80- * @type {string }
81- */
82- var client_recommended_version = "0.8.0" ;
83-
84-
8544// TODO: Document what the 'client_use_type' variable represents
8645/**
8746 * Not sure what this does
@@ -126,16 +85,18 @@ var clientService = {
12685 /*
12786 available: false,
12887 portsAvailable: false,
88+ */
12989 path : 'localhost' ,
13090 port : 6009 ,
91+ /*
13192 type: null,
13293 rxBase64: true,
13394 portListReceiveCountUp: 0, // This is set to 0 each time the port list is received, and incremented once each 4 second heartbeat
13495 activeConnection: null,
135- url: function (protocol) {
136- return protocol + '://' + this.path + ':' + this.port + '/';
137- },
13896 */
97+ url : function ( location , protocol ) {
98+ return ( protocol || window . location . protocol . replace ( ':' , '' ) ) + '://' + this . path + ':' + this . port + '/' + ( location || '' ) ;
99+ } ,
139100 version : {
140101 // Constants
141102 MINIMUM_ALLOWED : '0.7.0' ,
@@ -174,12 +135,11 @@ var clientService = {
174135}
175136
176137// Status Notice IDs
177- //const NS_DOWNLOADING = 002;
178- //const NS_DOWNLOAD_SUCCESSFUL = 005;
179- const NS_DOWNLOADING = 2 ;
138+ //const NS_DOWNLOADING = 002;
139+ //const NS_DOWNLOAD_SUCCESSFUL = 005;
140+ const NS_DOWNLOADING = 2 ;
180141const NS_DOWNLOAD_SUCCESSFUL = 5 ;
181142
182-
183143// Error Notice IDs
184144const NE_DOWNLOAD_FAILED = 102 ;
185145
@@ -201,22 +161,6 @@ var find_client = function () {
201161 }
202162} ;
203163
204- var version_as_number = function ( rawVersion ) {
205- var tempVersion = rawVersion . toString ( ) . split ( "." ) ;
206- tempVersion . push ( '0' ) ;
207-
208- if ( tempVersion . length < 3 ) {
209- if ( tempVersion . length === 1 )
210- tempVersion = '0.0.0' ;
211- else
212- tempVersion . unshift ( '0' ) ;
213- }
214-
215- // Allow for any of the three numbers to be between 0 and 1023.
216- // Equivalent to: (Major * 104856) + (Minor * 1024) + Revision.
217- return ( Number ( tempVersion [ 0 ] ) << 20 | Number ( tempVersion [ 1 ] ) << 10 | Number ( tempVersion [ 2 ] ) ) ;
218- } ;
219-
220164var setPropToolbarButtons = function ( ui_btn_state ) {
221165 if ( ui_btn_state === 'available' ) {
222166 if ( projectData && projectData . board === 's3' ) {
@@ -279,7 +223,7 @@ function checkClientVersionModal(rawVersion) {
279223 * This is evaluating the BlocklyProp Client or BlocklyProp Launcher version??
280224 */
281225var check_client = function ( ) {
282- $ . get ( "http://" + client_domain_name + ":" + client_domain_port + "/" , function ( data ) {
226+ $ . get ( clientService . url ( ) , function ( data ) {
283227 if ( ! client_available ) {
284228 let client_version_str = ( typeof data . version_str !== "undefined" ) ? data . version_str : data . version ;
285229 if ( ! data . server || data . server !== 'BlocklyPropHTTP' ) {
@@ -347,7 +291,7 @@ var configure_client = function () {
347291 id : "domain_name" ,
348292 type : "text" ,
349293 class : "form-control" ,
350- value : client_domain_name
294+ value : clientService . path
351295 } ) . appendTo ( domain_name_group ) ;
352296
353297 // Hard code the ':' between the domain name and port input fields
@@ -365,14 +309,14 @@ var configure_client = function () {
365309 id : "port_number" ,
366310 type : "number" ,
367311 class : "form-control" ,
368- value : client_domain_port
312+ value : clientService . port
369313 } ) . appendTo ( domain_port_group ) ;
370314
371315 // Show the modal dialog
372316 utils . confirm ( Blockly . Msg . DIALOG_BLOCKLYPROP_LAUNCHER_CONFIGURE_TITLE , url_input , function ( action ) {
373317 if ( action ) {
374- client_domain_name = $ ( "#domain_name" ) . val ( ) ;
375- client_domain_port = $ ( "#port_number" ) . val ( ) ;
318+ clientService . path = $ ( "#domain_name" ) . val ( ) ;
319+ clientService . port = $ ( "#port_number" ) . val ( ) ;
376320 }
377321 } , Blockly . Msg . DIALOG_SAVE_TITLE ) ;
378322} ;
@@ -386,8 +330,7 @@ function establish_socket() {
386330 // Clear the port list
387331 set_port_list ( ) ;
388332
389- var url = "ws://" + client_domain_name + ":" + client_domain_port + "/" ;
390- var connection = new WebSocket ( url ) ;
333+ var connection = new WebSocket ( clientService . url ( '' , 'ws' ) ) ;
391334
392335 connection . onopen = function ( ) {
393336
0 commit comments