Ticket #1146: mythweb_remote.diff

File mythweb_remote.diff, 14.8 KB (added by jmorganson@…, 13 years ago)

Updated frontend remote diff based on 12569

  • includes/mythfrontend.php

    diff -Naur mythweb/includes/mythfrontend.php mythweb-devel/includes/mythfrontend.php
    old new  
    4040    var $fp;
    4141
    4242/** @var string     Hostname to connect to. */
    43     var $host;
     43    public $host;
    4444/** @var string     Hostname to connect to. */
    45     var $port;
     45    public $port;
    4646
    4747/** @var array      List of jump points available on this host. */
    4848    var $jump_points = array();
  • modules/frontends/handler.php

    diff -Naur mythweb/modules/frontends/handler.php mythweb-devel/modules/frontends/handler.php
    old new  
     1<?php
     2/* vim: set expandtab tabstop=4 softtabstop=4 shiftwidth=4: */
     3
     4        require_once( "includes/mythfrontend.php" );
     5
     6        if( array_key_exists( "key", $_GET ) || array_key_exists( "key", $_POST ) )
     7                require_once( "modules/frontends/keys.php" );
     8
     9        if( array_key_exists( "jump", $_GET ) || array_key_exists( "jump", $_POST ) )
     10                require_once( "modules/frontends/jump.php" );
     11
     12        if( $Path[1] == "scripts.php" )
     13                require_once( "modules/frontends/scripts.php" );
     14        else
     15                require_once( "modules/frontends/main.php" );
     16
     17?>
  • modules/frontends/init.php

    diff -Naur mythweb/modules/frontends/init.php mythweb-devel/modules/frontends/init.php
    old new  
     1<?php
     2/* vim: set expandtab tabstop=4 softtabstop=4 shiftwidth=4: */
     3/**
     4 * Initialization routines for the MythWeb TV module.
     5 *
     6 * @url         $URL: http://svn.mythtv.org/svn/branches/release-0-19-fixes/mythplugins/mythweb/modules/tv/init.php $
     7 * @date        $Date: 2006-01-01 11:00:31 +1100 (Sun, 01 Jan 2006) $
     8 * @version     $Revision: 8460 $
     9 * @author      $Author: Philip Nelson <phatfil@optusnet.com.au> $
     10 * @license     GPL
     11 *
     12 * @package     MythWeb
     13 * @subpackage  TV
     14 *
     15/**/
     16
     17// The TV module is always enabled.
     18    $Modules['frontends'] = array('path'        => 'frontends',
     19                                  'name'        => t('Frontends'),
     20                                  'links'       => array('status' => t('Frontend Status'),
     21                                 ),
     22                          );
     23
  • modules/frontends/jump.php

    diff -Naur mythweb/modules/frontends/jump.php mythweb-devel/modules/frontends/jump.php
    old new  
     1<?php
     2/* vim: set expandtab tabstop=4 softtabstop=4 shiftwidth=4: */
     3
     4        if( $_POST['frontends'] && $_POST['jump'] )
     5                foreach( $_POST['frontends'] as $frontend )
     6                        $Frontends[$frontend]->send_jump( $_POST['jump'] );
     7
     8        if( $_GET['frontends'] && $_GET['jump'] )
     9                foreach( $_GET['frontends'] as $frontend )
     10                        $Frontends[$frontend]->send_jump( $_GET['jump'] );
     11
     12        sleep(1);  //give the frontend time to do it's thing
     13?>
     14 No newline at end of file
  • modules/frontends/keys.php

    diff -Naur mythweb/modules/frontends/keys.php mythweb-devel/modules/frontends/keys.php
    old new  
     1<?php
     2/* vim: set expandtab tabstop=4 softtabstop=4 shiftwidth=4: */
     3
     4        if( $_POST['frontends'] && $_POST['key'] )
     5                foreach( $_POST['frontends'] as $frontend )
     6                        $Frontends[$frontend]->send_keypress( $_POST['key'] );
     7
     8        if( $_GET['frontends'] && $_GET['key'] )
     9                foreach( $_GET['frontends'] as $frontend )
     10                        $Frontends[$frontend]->send_keypress( $_GET['key'] );
     11
     12        sleep(1);  //give the frontend time to do it's thing
     13?>
  • modules/frontends/main.php

    diff -Naur mythweb/modules/frontends/main.php mythweb-devel/modules/frontends/main.php
    old new  
     1
     2<?php
     3/* vim: set expandtab tabstop=4 softtabstop=4 shiftwidth=4: */
     4
     5    // Set the desired page title
     6    $page_title = 'MythTV Frontend Status';
     7
     8    // Custom headers
     9    $headers[] = '<link rel="stylesheet" type="text/css" href="'.skin_url.'/frontends.css" />';
     10
     11    // Print the page header
     12    require 'modules/_shared/tmpl/'.tmpl.'/header.php';
     13?>
     14
     15
     16    <script id="scripts" language="javascript" type="text/javascript"></script>
     17
     18    <script language="javascript" type="text/javascript">
     19        document.onload = get_element( "scripts" ).src = "frontends/scripts.php";
     20    </script>
     21
     22
     23    <h1>Frontends (TESTING)</h1>
     24
     25    <form id="main" method="post" action="frontends">
     26
     27
     28    <!-- Frontends -->
     29    <div class="frontends">
     30
     31    <fieldset>
     32    <legend>Frontends</legend>
     33
     34    <div id="no_frontends_reachable" class="hidden">No frontends reachable</div>
     35    <div id="no_frontends_selected" class="hidden">No frontends selected</div>
     36
     37    <select id="frontends_select" multiple name="frontends[]">
     38
     39        <option id="loading_option">LOADING...</option>
     40
     41    </select>
     42
     43    </fieldset>
     44
     45    <p>You must select at least one frontend to communicate with. You can select as many as you want by holding CTRL while selecting multiple options. All discovered frontends are listed, any that are unreachable will appear as disabled select options.</p>
     46
     47    </div>
     48
     49
     50    <!-- Jump points -->
     51    <div id="jumps" class="jumps"></div>
     52
     53
     54    <!-- Keys -->
     55    <div class='keys'>
     56
     57        <table width='100%' border=1 class="keypad">
     58        <tr><td class='menu' colspan=3><font color=white face='Courier New'><b>MythTV - Remote</b></font></td></tr>
     59        <tr><td colspan=3></td></tr>
     60        <tr><td onclick="sendKey(1)">1</td><td onclick="sendKey(2)">2</td><td onclick="sendKey(1)">3</td></tr>
     61        <tr><td onclick="sendKey(4)">4</td><td onclick="sendKey(5)">5</td><td onclick="sendKey(6)">6</td></tr>
     62        <tr><td onclick="sendKey(7)">7</td><td onclick="sendKey(8)">8</td><td onclick="sendKey(9)">9</td></tr>
     63        <tr><td border="0"></td><td onclick="sendKey(0)">0</td><td border="0"></td></tr>
     64        <tr><td colspan=3></td></tr>
     65        <tr><td></td><td onclick="sendKey('up')">Up</td><td></td></tr>
     66        <tr><td onclick="sendKey('left')">Left</td><td onclick="sendKey('enter')">Enter</td><td onclick="sendKey('right')">Right</td></tr>
     67        <tr><td></td><td onclick="sendKey('down')">Down</td><td></td></tr>
     68        <tr><td colspan=3></td></tr>
     69        <tr><td onclick="sendKey('delete')">Delete</a></td><td></td><td onclick="sendKey('end')">End</td></tr>
     70        <tr><td onclick="sendKey('pageup')">Page Up</a></td><td onclick="sendKey('escape')">Escape</td><td onclick="sendKey('pagedown')">Page Down</td></tr>
     71        </table>
     72
     73        Select other possible
     74        <select>
     75
     76        <option>keys</option>
     77        <option onclick="sendKey('space')">space</option>
     78        <option onclick="sendKey('backspace')">backspace</option>
     79        <option onclick="sendKey('slash')">/</option>
     80        <option onclick="sendKey('backslash')">\</option>
     81        <option onclick="sendKey('bracketleft')">[</option>
     82        <option onclick="sendKey('bracketright')">]</option>
     83        <option onclick="sendKey('colon')">:</option>
     84        <option onclick="sendKey('semicolon')">;</option>
     85        <option onclick="sendKey('equal')">=</option>
     86        <option onclick="sendKey('greater')">greater</option>
     87        <option onclick="sendKey('less')">less</option>
     88        <option onclick="sendKey('f1')">F1</option>
     89        <option onclick="sendKey('f2')">F2</option>
     90        <option onclick="sendKey('f3')">F3</option>
     91        <option onclick="sendKey('f4')">F4</option>
     92        <option onclick="sendKey('f5')">F5</option>
     93        <option onclick="sendKey('f6')">F6</option>
     94        <option onclick="sendKey('f7')">F7</option>
     95        <option onclick="sendKey('f8')">F8</option>
     96        <option onclick="sendKey('f9')">F9</option>
     97        <option onclick="sendKey('f10')">F10</option>
     98        <option onclick="sendKey('f11')">F11</option>
     99        <option onclick="sendKey('f12')">F12</option>
     100
     101        </select>
     102        to send
     103
     104        <br>
     105        Keypress to send: <input id="key" type="text" name="key" size="11" />
     106        <input type="button" value="Send" onclick="sendPOST()">
     107        <br><br>
     108        <div align="center"><input id="detect_key_presses_button" type="button" onclick="toggleKeyDetect(); this.value == 'Detect Key Presses (OFF)' ? this.value='Detect Key Presses (ON)' : this.value='Detect Key Presses (OFF)'" value="Detect Key Presses (OFF)" /></div>
     109
     110        <p>Keypress can be a letter, number or one of the following: backslash, backspace, bracketleft, bracketright, colon, down, enter, equal, escape, f1, f10, f11, f12, f2, f3, f4, f5, f6, f7, f8, f9, greater, left, less, pagedown, pageup, right, semicolon, slash, space, up</p>
     111        <p>"Detect Key Presses" will send every key that is pressed in the browser window to the selected frontends</p>
     112
     113    </div>
     114
     115
     116    </form>
     117
     118
     119<?
     120    // Print the page footer
     121    require 'modules/_shared/tmpl/'.tmpl.'/footer.php';
     122?>
  • modules/frontends/scripts.php

    diff -Naur mythweb/modules/frontends/scripts.php mythweb-devel/modules/frontends/scripts.php
    old new  
     1
     2<?
     3/* vim: set expandtab tabstop=4 softtabstop=4 shiftwidth=4: */
     4
     5Header("content-type: application/x-javascript");
     6?>
     7
     8
     9function set()
     10{
     11    main_form = document.forms[0];
     12    frontends_select = get_element("frontends_select");
     13    jumps_div = get_element("jumps");
     14
     15    <?
     16
     17    foreach ($Frontends as $frontend)
     18    {
     19
     20        $hostName   = $frontend->host;
     21        $location   = $frontend->query_location();
     22        $jumppoints = $frontend->get_jump_points();
     23
     24        if ( !empty( $hostName ) )
     25        {  ?>
     26
     27            // FRONTENDS
     28            var frontends_select_option = document.createElement("option");
     29            frontends_select_option.disabled = <? echo $location == "Unreachable" ? "true" : "false" ?>;
     30            frontends_select_option.text = "<? echo $hostName ?>";
     31            frontends_select.add(frontends_select_option, null);
     32
     33            // JUMPS
     34
     35            new_element = document.createElement("div");
     36
     37            new_element.innerHTML = "<h3><? echo $hostName; ?></h3>Current location:<? echo $location; ?><br><br>Jump to ";
     38
     39            jumps_select = document.createElement("select");
     40            jumps_select.onchange = "document.forms['main'].submit()";
     41            jumps_select.onchange = sendJump;
     42
     43            jumps_option_default = document.createElement("option");
     44            jumps_option_default.selected = true;
     45            jumps_option_default.value = "DEFAULT";
     46            jumps_option_default.text = "";
     47
     48            jumps_select.appendChild(jumps_option_default);
     49            jumps_select.selectedIndex = jumps_option_default.index;
     50
     51            <? foreach ( array_keys($jumppoints) as $jumppoint_key ) { ?>
     52                    jumps_option = document.createElement("option");
     53                    jumps_option.value = "<? echo $jumppoint_key ?>";
     54                    jumps_option.text = "<? echo trim( $jumppoints[$jumppoint_key] ) ?>";
     55                    jumps_select.appendChild(jumps_option);
     56            <? } ?>
     57
     58            new_element.appendChild(jumps_select);
     59            jumps_div.appendChild(new_element);
     60
     61        <?
     62        }
     63    }
     64    ?>
     65}
     66set();
     67
     68loading = get_element("loading_option");
     69loading.parentNode.removeChild(loading);
     70
     71
     72function clear()
     73{
     74    for (frontends_option in get_element("frontends_select").options)
     75            frontends_select.remove(frontends_option);
     76
     77    get_element("jumps").innerHTML = "";
     78    get_element("key").value = "";
     79}
     80
     81function update()
     82{
     83    clear();
     84    set();
     85}
     86
     87function setKey(value)
     88{
     89        key = get_element("key");
     90        key.value = value;
     91}
     92
     93function sendKey(value)
     94{
     95        setKey(value);
     96        sendPOST(getSelectedFrontends() + "key=" + value);
     97}
     98
     99function keypress(event)
     100{
     101    switch(event.keyCode)
     102    {
     103        case 8: key  = "backspace";     break;
     104        case 13: key = "enter";         break;
     105        case 27: key = "escape";        break;
     106        case 33: key = "pageup";        break;
     107        case 34: key = "pagedown";      break;
     108        case 37: key = "left";          break;
     109        case 38: key = "up";            break;
     110        case 39: key = "right";         break;
     111        case 40: key = "down";          break;
     112        case 46: key = "delete";        break;
     113
     114        case 112: key = "f1";           break;
     115        case 113: key = "f2";           break;
     116        case 114: key = "f3";           break;
     117        case 115: key = "f4";           break;
     118        case 116: key = "f5";           break;
     119        case 117: key = "f6";           break;
     120        case 118: key = "f7";           break;
     121        case 119: key = "f8";           break;
     122        case 120: key = "f9";           break;
     123        case 121: key = "f10";          break;
     124        case 122: key = "f11";          break;
     125        case 123: key = "f12";          break;
     126
     127        default: key = String.fromCharCode(event.charCode);  break;
     128    }
     129
     130    sendKey(key);
     131}
     132
     133function toggleKeyDetect()
     134{
     135    window.onkeypress == null ? window.onkeypress = keypress : window.onkeypress = null;
     136}
     137
     138
     139function sendJump( value )
     140{
     141    sendPOST(getSelectedFrontends() + "jump=" + this.value);
     142}
     143
     144
     145function getSelectedFrontends()
     146{
     147
     148    frontends_string = "";
     149    frontends = document.forms['main'].elements['frontends[]'];
     150
     151    for (index = 0; index < frontends.length; index++)
     152    {
     153        if( frontends.options[index].selected )
     154                frontends_string += "frontends[" + index + "]=" + frontends.options[index].value + "&";
     155    }
     156
     157    return frontends_string;
     158}
     159
     160
     161function sendPOST(send_string)
     162{
     163    var req = get_connection_object();
     164    req.open("POST", "frontends", false);
     165    req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
     166    req.send(send_string);
     167}
  • skins/default/frontends.css

    diff -Naur mythweb/skins/default/frontends.css mythweb-devel/skins/default/frontends.css
    old new  
     1
     2
     3.success {
     4    color: #3AF030;
     5    background-color: #033600;
     6    border-color: #3AF030;
     7    border: thin groove #3AF030;
     8  }
     9
     10
     11.frontends {
     12    float: left;
     13    left: 2%;
     14    width: 20%;
     15    position: relative;
     16  }
     17
     18
     19.frontends select {
     20    width: 100%;
     21  }
     22
     23
     24.frontends option[disabled] {
     25    color: #68686F;
     26  }
     27
     28.jumps {
     29
     30        float: left;
     31        width: 50%;
     32        left: 25%;
     33        position: absolute;
     34}
     35
     36.keys {
     37    float: right;
     38    width: 20%;
     39    right: 2%;
     40    position: relative;
     41  }
     42
     43
     44.keypad td {
     45    text-align : center;
     46    width : 33%;
     47  }
     48
     49
     50.keypad td:hover {
     51    cursor : pointer;
     52    border : 1px solid yellow;
     53  }
     54