Skip to content

Commit

Permalink
HTML Setup/Backend Web Server: Add message sending capabilities.
Browse files Browse the repository at this point in the history
Adds a button/page to send messages to frontends, defaulting to broadcast to all frontends.

There are a couple of improvements I'd like to see here, such as making the list of frontends a dropdown instead of text entry and validating the UDP port value... but this works pretty nicely for now.

Adds a util function to show and hide a div that might come in handy later on.  Here it's used to hide advanced options.
  • Loading branch information
Robert McNamara committed Apr 7, 2011
1 parent 59f88dd commit a41a2ad
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 0 deletions.
28 changes: 28 additions & 0 deletions mythtv/html/js/util.qjs
Expand Up @@ -147,3 +147,31 @@ function setupNonAnimatedTabs(id, preload) {
if ((preload == undefined) || (preload == true))
setTimeout(function(){ preloadTabs($tabs); }, 10);
}

function sendMessage() {
var result = 0;
var message = $("#message").val();
var address = $("#address").val();
var port = $("#port").val();

$.ajaxSetup({ async: false });
$.post("/Myth/SendMessage",
{ Message: message, Address: address, udpPort: port },
function(data) {
result = 1;
}).error(function(data) {
alert("Error: unable to send message");
});
$.ajaxSetup({ async: true });

return result;
}

function toggleShowDiv(id) {
var obj = document.getElementById(id);
if ( $("#" + id).is(':visible') ) {
$("#" + id).hide("slow");
} else {
$("#" + id).show("slow");
}
}
1 change: 1 addition & 0 deletions mythtv/html/menu.qsp
Expand Up @@ -35,6 +35,7 @@
</ul>
</li>
<li><a class='menuitem' href='#' onClick="javascript:loadContent('/Status/GetStatusHTML')">Backend Status</a></li>
<li><a class='menuitem' href='#' onClick="javascript:loadContent('/misc/message.html')">Send a Message</a></li>
<li><hr></li>
<li><a href='#'>API</a>
<ul class="acitem collapsible">
Expand Down
33 changes: 33 additions & 0 deletions mythtv/html/misc/message.html
@@ -0,0 +1,33 @@
<div id='send-message'>
<div class='Title'>Send a Message</div>
<table border=0 cellpadding=2 cellspacing=2>
<tr><th align=right>Message Text:</th>
<td><input id='message' size=200>
</td>
</tr>
</table>

<input type="checkbox" name="advanced" onclick=toggleShowDiv('Advanced') value="Show Advanced" checked>Send to all frontends

<div id='Advanced'>
<hr>Advanced Options
<table border=0 cellpadding=2 cellspacing=2>
<tr><th align=right>IP Address:</th>
<td><input id='address' size=20 value='255.255.255.255'>
</td>
</tr>
<tr><th align=right>UDP Port:</th>
<td><input id='port' size=10 value='6948'>
</td>
</tr>
</table>
</div>
<hr>
<input type=button value='Send This Message' onClick='javascript:sendMessage()'>

</div>

<script language="JavaScript" type="text/javascript">
$("#Advanced").hide();
</script>

0 comments on commit a41a2ad

Please sign in to comment.