Permalink
Browse files

Retrieve signboard status a bit more reliably

  • Loading branch information...
1 parent 00c90ed commit 2efc92d37b232d55b5bbe2c174c2172f69bd2bed @jwhite66 committed Mar 21, 2013
Showing with 33 additions and 12 deletions.
  1. +29 −2 web/signboard.php
  2. +4 −10 web/webhelper.php
View
@@ -1,6 +1,25 @@
<div id="signboard" class="insetcontent">
<script src="jquery-1.6.4.js"></script>
<script type="text/javascript">
+ function get_message()
+ {
+ $("#signboard_process_list").html("<p>Fetching message...</p>");
+ $.ajax({
+ url: 'webhelper.php?cmd=getmessage',
+ async : false,
+ success: function( data )
+ {
+ if (data.length == 0)
+ $("#signboard_process_list").html("<p>No message displaying</p>");
+ else
+ $("#signboard_process_list").html("<p>Current message:<br>" + data +"</p>");
+ },
+ error: function( data, textStatus, errorThrown )
+ {
+ alert("Error setting message: " + errorThrown);
+ }
+ });
+ }
function change_message()
{
$.ajax({
@@ -9,7 +28,7 @@ function change_message()
async : false,
success: function( data )
{
- /*alert('Message changed');*/
+ get_message();
},
error: function( data, textStatus, errorThrown )
{
@@ -23,8 +42,16 @@ function change_message()
<textarea id="signboard_message_text" title="Enter the message here. A special square bracked syntax can be used to start a color change. For example, [red]TEXT, will make red TEXT. Advanced colors can be done with 4 hex digits like this: [bb|rr|gg|bb] where bb is bright in hex, rr is red in hex, gg green, and bb blue. For example, [CC|0F|00|00] is bright red." value="Your message here">Your message here</textarea>
<input id="signboard_message_button" value="Start signboard with message" type="submit" onclick="change_message(); return false;"></input>
</div>
+ <div id="signboard_process_list">
+ <p>Signboard process list will go here</p>
+ </div>
<div id="signboard_message_control">
- <div title="Stop Signboard" onclick="run_command('stopmessage');" class="button red">Stop Signboard</div>
+ <div title="Stop Signboard" onclick="run_command('stopmessage'); get_message();" class="button red">Stop Signboard</div>
</div>
</div>
+
+ <script>
+ get_message();
+ </script>
+
View
@@ -15,15 +15,6 @@ function run_cmd($c)
return $rc;
}
-/*
- $fp = popen("ps -C ledscrollsim -o pid=,args=", "r");
- while ($fp && !feof($fp))
- {
- $l = fgets($fp);
- $msgpids .= $l;
- }
- pclose($fp);
-*/
function parse_message($line_array, &$on)
{
$skip = true;
@@ -132,7 +123,10 @@ function handle_fifo()
system("pkill ledscroll");
run_cmd("DISPLAY=:0 ../ledscroll ../6x10.bdf '{$message}' > /dev/null 2>&1 &");
}
-
+ else if ($cmd == "getmessage")
+ {
+ run_cmd("ps -C ledscroll -o pid=,args= || [ $? -eq 1 ]");
+ }
else if ($cmd == "stopmessage")
{
system("pkill ledscroll");

0 comments on commit 2efc92d

Please sign in to comment.