Skip to content

Commit

Permalink
Tidied up and made the firmware version code work
Browse files Browse the repository at this point in the history
  • Loading branch information
bjpirt committed Jul 4, 2014
1 parent e2b3554 commit 226c7a0
Showing 1 changed file with 19 additions and 12 deletions.
31 changes: 19 additions & 12 deletions src/index_en.html
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,13 @@
</div>
<div id="code"></div>
<script>
var mirobot;

var has_remote_conn = true;

var ui_version = '20140629';
var mirobot_version = 'unknown';

var wirelessConfig = function(){
/*<%
CONFIG_VAR(sta_setting_ssid, CFG_WSSSID);
Expand Down Expand Up @@ -265,10 +272,6 @@
cover_ver: cover_ver
}
}();
var has_remote_conn = false;

var ui_version = '20140629';
var mirobot_version = 'unknown';

var el = function(id){
return document.getElementById(id);
Expand Down Expand Up @@ -311,7 +314,7 @@
callback();
}
if(has_remote_conn){
script.src = 'http://mirobot.io/assets/mirobot_jsx/' + src;
script.src = 'http://mirobot.io/assets/mirobot_js/' + src;
}else{
script.src = src;
}
Expand Down Expand Up @@ -357,26 +360,30 @@
el('version').innerHTML = "Firmware version: " + mirobot_version + " | UI version: " + ui_version;
}

var getVersion = function(){
mirobot.version(function(state, msg){
if(msg.msg){
mirobot_version = msg.msg;
}
setVersions();
});
}

var initProgram = function(){
var host;
if(window.location.hash !== '' && window.location.hash.match(/#m=/)){
host = window.location.hash.replace('#m=', '')
}else{
host = window.location.hostname;
}
var mirobot = new Mirobot('ws://' + host + ':8899/websocket');
mirobot = new Mirobot('ws://' + host + ':8899/websocket');
var builder = new Builder($('#code'), mirobot);

var mirobotHandler = function(state){
var conn = $('#miroConnState');
if(state === 'connected'){
if(mirobot_version === 'unknown'){
mirobot.version(function(state, msg){
if(msg.msg){
mirobot_version = msg.msg;
}
setVersions();
});
window.setTimeout(getVersion, 1000);
}
$(conn).html('&#10003; Connected to Mirobot');
$(conn).addClass('connected');
Expand Down

0 comments on commit 226c7a0

Please sign in to comment.