@@ -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 ) + '://' + this . path + ':' + this . port + '/' + ( location || '' ) ;
99+ } ,
139100 version : {
140101 // Constants
141102 MINIMUM_ALLOWED : '0.7.0' ,
@@ -279,7 +240,7 @@ function checkClientVersionModal(rawVersion) {
279240 * This is evaluating the BlocklyProp Client or BlocklyProp Launcher version??
280241 */
281242var check_client = function ( ) {
282- $ . get ( "http://" + client_domain_name + ":" + client_domain_port + "/" , function ( data ) {
243+ $ . get ( clientService . url ( ) , function ( data ) {
283244 if ( ! client_available ) {
284245 let client_version_str = ( typeof data . version_str !== "undefined" ) ? data . version_str : data . version ;
285246 if ( ! data . server || data . server !== 'BlocklyPropHTTP' ) {
@@ -347,7 +308,7 @@ var configure_client = function () {
347308 id : "domain_name" ,
348309 type : "text" ,
349310 class : "form-control" ,
350- value : client_domain_name
311+ value : clientService . path
351312 } ) . appendTo ( domain_name_group ) ;
352313
353314 // Hard code the ':' between the domain name and port input fields
@@ -365,14 +326,14 @@ var configure_client = function () {
365326 id : "port_number" ,
366327 type : "number" ,
367328 class : "form-control" ,
368- value : client_domain_port
329+ value : clientService . port
369330 } ) . appendTo ( domain_port_group ) ;
370331
371332 // Show the modal dialog
372333 utils . confirm ( Blockly . Msg . DIALOG_BLOCKLYPROP_LAUNCHER_CONFIGURE_TITLE , url_input , function ( action ) {
373334 if ( action ) {
374- client_domain_name = $ ( "#domain_name" ) . val ( ) ;
375- client_domain_port = $ ( "#port_number" ) . val ( ) ;
335+ clientService . path = $ ( "#domain_name" ) . val ( ) ;
336+ clientService . port = $ ( "#port_number" ) . val ( ) ;
376337 }
377338 } , Blockly . Msg . DIALOG_SAVE_TITLE ) ;
378339} ;
@@ -386,8 +347,7 @@ function establish_socket() {
386347 // Clear the port list
387348 set_port_list ( ) ;
388349
389- var url = "ws://" + client_domain_name + ":" + client_domain_port + "/" ;
390- var connection = new WebSocket ( url ) ;
350+ var connection = new WebSocket ( clientService . url ( '' , 'ws' ) ) ;
391351
392352 connection . onopen = function ( ) {
393353
0 commit comments