summaryrefslogtreecommitdiffstats
path: root/web
diff options
context:
space:
mode:
authorGravatarGravatar R. Belmont <rb6502@users.noreply.github.com>2013-10-01 12:18:54 +0000
committerGravatarGravatar R. Belmont <rb6502@users.noreply.github.com>2013-10-01 12:18:54 +0000
commit9df3d0e642e5ab0456e21c0c03ab09dc334d6999 (patch) (github)
tree54fa49fec6b50943c5e5beb142b348f373a16011 /web
parent6fcda61d9ad77e01978f56725734029f9a4d12f7 (diff)
downloadmame-9df3d0e642e5ab0456e21c0c03ab09dc334d6999.tar.bz2
mame-9df3d0e642e5ab0456e21c0c03ab09dc334d6999.zip
web: JS cleanup and fixed a few minor bugs. [Firehawke]
Diffstat (limited to 'web')
-rw-r--r--web/index.html92
1 files changed, 54 insertions, 38 deletions
diff --git a/web/index.html b/web/index.html
index c9d52419666..e21ac49aa88 100644
--- a/web/index.html
+++ b/web/index.html
@@ -16,19 +16,44 @@
</head>
<body>
<script language="javascript" type="text/javascript">
+
+ function updateStatusBar(connectionStatus, isPaused, driverText) {
+ if (connectionStatus) {
+ // Update every page's connection statusbar.
+ $("td#main_statusbar_connectionstatus").html(connectionStatus);
+ $("td#command_statusbar_connectionstatus").html(connectionStatus);
+ $("td#option_statusbar_connectionstatus").html(connectionStatus);
+ $("td#slider_statusbar_connectionstatus").html(connectionStatus);
+ $("td#driver_statusbar_connectionstatus").html(connectionStatus);
+ $("td#image_statusbar_connectionstatus").html(connectionStatus);
+ $("td#info_statusbar_connectionstatus").html(connectionStatus);
+ $("td#logs_statusbar_connectionstatus").html(connectionStatus);
+ }
+ if (isPaused) {
+ // Update every page's running/paused statusbar.
+ $("td#main_statusbar_ispaused").html(isPaused);
+ $("td#command_statusbar_ispaused").html(isPaused);
+ $("td#option_statusbar_ispaused").html(isPaused);
+ $("td#slider_statusbar_ispaused").html(isPaused);
+ $("td#driver_statusbar_ispaused").html(isPaused);
+ $("td#image_statusbar_ispaused").html(isPaused);
+ $("td#info_statusbar_ispaused").html(isPaused);
+ $("td#logs_statusbar_ispaused").html(isPaused);
+ }
+ if (driverText) {
+ // Update every page's running driver statusbar.
+ $("td#main_statusbar_runningdriver").html(driverText);
+ $("td#command_statusbar_runningdriver").html(driverText);
+ $("td#option_statusbar_runningdriver").html(driverText);
+ $("td#slider_statusbar_runningdriver").html(driverText);
+ $("td#driver_statusbar_runningdriver").html(driverText);
+ $("td#image_statusbar_runningdriver").html(driverText);
+ $("td#info_statusbar_runningdriver").html(driverText);
+ $("td#logs_statusbar_runningdriver").html(driverText);
+ }
+
+ }
- var writeConnectionStatus = function(message) {
- // Update the statusbar on each subpage at the same time.
- $("td#main_statusbar_connectionstatus").html(message);
- $("td#command_statusbar_connectionstatus").html(message);
- $("td#option_statusbar_connectionstatus").html(message);
- $("td#slider_statusbar_connectionstatus").html(message);
- $("td#driver_statusbar_connectionstatus").html(message);
- $("td#image_statusbar_connectionstatus").html(message);
- $("td#info_statusbar_connectionstatus").html(message);
- $("td#logs_statusbar_connectionstatus").html(message);
- };
-
function takeScreenshot()
{
// First, we need to generate a random number to make absolutely sure we bypass browser caching.
@@ -48,7 +73,11 @@
},
error: function (request, status, error) { alert(status + ", " + error); }
});
- startWebSocket();
+ if (command !== 'exit') {
+ startWebSocket();
+ } else {
+ updateStatusBar('<b style="color: red;">Disconnected</b>','Exited','No Driver');
+ }
}
function executeHardReset()
@@ -70,7 +99,7 @@
executeCommands("exit");
$('.ui-dialog').dialog('close');
}
-
+
function executeSlider()
{
$.ajax({
@@ -92,7 +121,7 @@
},
error: function (request, status, error) { alert(status + ", " + error); }
});
- window.location.hash='#slidermenu';
+ window.location.hash='#slidermenu'; // Just making sure we're on the slider screen.
}
function setSliderValue(id,val)
@@ -112,10 +141,10 @@
var url = docbase.replace("http://","ws://");
websocket = new WebSocket(url);
websocket.onopen = function(ev) {
- writeConnectionStatus('<b style="color: green;">Connected</b>');
+ updateStatusBar('<b style="color: green;">Connected</b>','','');
};
websocket.onclose = function(ev) {
- writeConnectionStatus('<b style="color: red;">Disconnected</b>');
+ updateStatusBar('<b style="color: red;">Disconnected</b>','','');
};
websocket.onmessage = function(ev) {
if (ev.data=='update_machine')
@@ -149,29 +178,15 @@
maindesc_manufacturer.push(data.manufacturer);
maindesc_parent.push(data.parent);
maindesc_sourcefile.push(data.source_file);
-
- $("td#main_statusbar_runningdriver").html(statusbar_runningdriver.join(''));
- $("td#main_statusbar_ispaused").html(statusbar_ispaused.join(''));
- $("td#command_statusbar_runningdriver").html(statusbar_runningdriver.join(''));
- $("td#command_statusbar_ispaused").html(statusbar_ispaused.join(''));
- $("td#option_statusbar_runningdriver").html(statusbar_runningdriver.join(''));
- $("td#option_statusbar_ispaused").html(statusbar_ispaused.join(''));
- $("td#slider_statusbar_runningdriver").html(statusbar_runningdriver.join(''));
- $("td#slider_statusbar_ispaused").html(statusbar_ispaused.join(''));
- $("td#driver_statusbar_runningdriver").html(statusbar_runningdriver.join(''));
- $("td#driver_statusbar_ispaused").html(statusbar_ispaused.join(''));
- $("td#image_statusbar_runningdriver").html(statusbar_runningdriver.join(''));
- $("td#image_statusbar_ispaused").html(statusbar_ispaused.join(''));
- $("td#info_statusbar_runningdriver").html(statusbar_runningdriver.join(''));
- $("td#info_statusbar_ispaused").html(statusbar_ispaused.join(''));
- $("td#logs_statusbar_runningdriver").html(statusbar_runningdriver.join(''));
- $("td#logs_statusbar_ispaused").html(statusbar_ispaused.join(''));
$("#maindesc_name").html(maindesc_name.join(''));
$("#maindesc_description").html(maindesc_description.join(''));
$("#maindesc_year").html(maindesc_year.join(''));
$("#maindesc_manufacturer").html(maindesc_manufacturer.join(''));
$("#maindesc_parent").html(maindesc_parent.join(''));
$("#maindesc_sourcefile").html(maindesc_sourcefile.join(''));
+
+ // Now, actually update the status bar..
+ updateStatusBar('',statusbar_ispaused.join(''),statusbar_runningdriver.join(''));
},
error: function (request, status, error) { alert(status + ", " + error); }
});
@@ -179,7 +194,7 @@
};
websocket.onerror = function(ev) {
- writeConnectionStatus('<b style="color: red; ">Error</b>');
+ updateStatusBar('<b style="color: red; ">Error</b>',' ',' ');
};
}
@@ -187,6 +202,7 @@
startWebSocket();
};
</script>
+
<!-- This begins the MAIN MENU page ------------------------------------------------------------------->
<div data-role="page" id="mainmenu">
<div data-theme="a" data-role="header">
@@ -660,7 +676,7 @@
<a href="#optionmenu" data-transition="fade" data-icon="gear">Options</a>
</li>
<li>
- <a href="#imagemenu" data-transition="fade" data-icon="grid">Image</a>
+ <a href="#mainmenu" data-transition="fade" data-icon="home">Main Menu</a>
</li>
<li>
<a href="#commandmenu" data-transition="fade" data-icon="star">Commands</a>
@@ -729,7 +745,7 @@
<div data-role="navbar" data-iconpos="top">
<ul>
<li>
- <a href="#infomenu" data-transition="fade" data-icon="info">Info</a>
+ <a href="#mainmenu" data-transition="fade" data-icon="home">Main Menu</a>
</li>
<li>
<a href="#logsmenu" data-transition="fade" data-icon="check">Logs</a>
@@ -787,7 +803,7 @@
<a href="#infomenu" data-transition="fade" data-icon="info">Info</a>
</li>
<li>
- <a href="#logsmenu" data-transition="fade" data-icon="check">Logs</a>
+ <a href="#mainmenu" data-transition="fade" data-icon="home">Main Menu</a>
</li>
<li>
<a href="javascript:takeScreenshot();" data-transition="fade" data-icon="search">Screenshot</a>