enabled deck select at table preferences
[brisk.git] / web / briskin5 / index.php
index 1e0ba3b..3b36896 100644 (file)
@@ -3,7 +3,7 @@
  *  brisk - briskin5/index.php
  *
  *  Copyright (C) 2006-2012 Matteo Nastasi
- *                          mailto: nastasi@alternativeoutput.it 
+ *                          mailto: nastasi@alternativeoutput.it
  *                                  matteo.nastasi@milug.org
  *                          web: http://www.alternativeoutput.it
  *
 $G_base = "../";
 
 require_once("../Obj/brisk.phh");
-require_once("../Obj/proxyscan.phh");
 require_once("Obj/briskin5.phh");
 
 $mlang_bin5_index = array( 'aucwin' => array( 'it' => 'Hai vinto l\'asta.<br> Scegli il seme:',
                                               'en' => 'You win the auction.<br> Choose the seed:' ),
-                           'tit_pref'=>array( 'it' => 'Preferenze.',
-                                              'en' => 'Preferences.'),
+                           'tit_info'    => array( 'it' => 'Info',
+                                                   'en' => 'Info'),
+                           'tit_relo'    => array( 'it' => 'Reload',
+                                                   'en' => 'Reload'),
+                           'tit_out'     => array( 'it' => 'Fuori',
+                                                   'en' => 'Out'),
+                           'tit_pref'    => array( 'it' => 'Prefs',
+                                                   'en' => 'Prefs'),
                            'itm_ringauc' => array('it' => 'riproduci un suono di notifica alla fine dell\' asta',
                                                   'en' => 'play a sound at the end of the auction'),
                            'btn_update'  => array('it' => 'Aggiorna.',
@@ -41,9 +46,13 @@ $mlang_bin5_index = array( 'aucwin' => array( 'it' => 'Hai vinto l\'asta.<br> Sc
                            );
 
 
-function bin5_index_main(&$header_out, $addr, $get, $post, $cookie)
+function bin5_index_main($transp_type, $header, &$header_out, $addr, $get, $post, $cookie)
 {
     GLOBAL $G_lang, $mlang_bin5_index;
+
+    $transp_port = ((array_key_exists("X-Forwarded-Proto", $header) &&
+                     $header["X-Forwarded-Proto"] == "https") ? 443 : 80);
+
     if (($table_idx = gpcs_var('table_idx', $get, $post, $cookie)) === FALSE)
         unset ($table_idx);
     if (($laststate = gpcs_var('laststate', $get, $post, $cookie)) === FALSE)
@@ -51,44 +60,48 @@ function bin5_index_main(&$header_out, $addr, $get, $post, $cookie)
     if (($sess = gpcs_var('sess', $get, $post, $cookie)) === FALSE)
         unset ($sess);
 
-    // Use of proxies isn't allowed.
-    // if (is_proxy()) {
-    // return (FALSE);
-    // }
-    
+    fprintf(STDERR, "PREF_DECK SET %s", (isset($cookie['CO_bin5_pref_deck']) ? "YES" : "NO"));
+
+    $deck = (isset($cookie['CO_bin5_pref_deck']) ? $cookie['CO_bin5_pref_deck'] : 'xx');
+
 // header('Content-type: text/html; charset="utf-8"',true);
     ?>
 <html>
 <head>
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
 <title>Brisk - Tavolo <?php echo "$table_idx";?></title>
 <link rel="shortcut icon" href="../img/brisk_ico.png">
-<script type="text/javascript" src="../commons.js"></script> 
-<script type="text/javascript" src="../heartbit.js"></script>
-<script type="text/javascript" src="../xynt-http-streaming.js"></script>
-<script type="text/javascript" src="dnd.js"></script>
-<script type="text/javascript" src="dom-drag.js"></script>
-<script type="text/javascript" src="preload_img<?php echo langtolng($G_lang); ?>.js"></script>
-<script type="text/javascript" src="briskin5.js"></script>
-<script type="text/javascript" src="../AC_OETags.js"></script>
-<link rel="stylesheet" type="text/css" href="../brisk.css">
-<link rel="stylesheet" type="text/css" href="briskin5.css">
+<script src="//ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
+<script type="text/javascript" src="../commons.js?v=<? echo BSK_BUSTING; ?>"></script>
+<script type="text/javascript" src="../heartbit.js?v=<? echo BSK_BUSTING; ?>"></script>
+<script type="text/javascript" src="../xynt-streaming.js?v=<? echo BSK_BUSTING; ?>"></script>
+<script type="text/javascript" src="dnd.js?v=<? echo BSK_BUSTING; ?>"></script>
+<script type="text/javascript" src="dom-drag.js?v=<? echo BSK_BUSTING; ?>"></script>
+<script type="text/javascript" src="preload_img<?php echo langtolng($G_lang); ?>.js?v=<? echo BSK_BUSTING; ?>"></script>
+<script type="text/javascript" src="briskin5.js?v=<? echo BSK_BUSTING; ?>"></script>
+<link rel="stylesheet" type="text/css" href="../brisk.css?v=<? echo BSK_BUSTING; ?>">
+<link rel="stylesheet" type="text/css" href="briskin5.css?v=<? echo BSK_BUSTING; ?>">
 </head>
 <body>
 <SCRIPT type="text/javascript">
+   var $$ = jQuery.noConflict();
+
+   var myname = null;
    var sess = "not_connected";
-   var hstm = null;
+   var xstm = null;
    var g_lang = "<?php echo "$G_lang"; ?>";
    var stat = "table";
    var subst = "none";
    var table_pos = "";
-   var g_withflash = false;
+   var g_jukebox = null;
+   var g_deck = "<?php echo "$deck"; ?>";
 
    var asta_ptr;
    var area_ptr;
 
    var gst  = new globst();
-   gst.st = <?php 
-       log_load("bin5/index.php");
+   gst.st = <?php
+   log_load("bin5/index.php");
 
    if (isset($laststate) == false) {
        $laststate = -1;
@@ -102,21 +115,27 @@ var g_imgct= 0;
 var g_imgtot = g_preload_img_arr.length;
 var g_exitlock = 0;
 
+
 window.onload = function() {
-  g_withflash = DetectFlashVer(6,0,0);
+  g_jukebox = new jukebox([{'name': 'cow', 'file': 'cow.mp3'},
+                           {'name': 'rooster', 'file': 'rooster.mp3'},
+                           {'name': 'ringbell', 'file': 'ringbell.mp3'}]);
   remark_off();
 
   preferences_init();
   preferences_update();
 
   sess = "<?php echo "$sess"; ?>";
-  hstm = new http_streaming(window, null /* console */, gst, 'table_php', 'sess', sess, $('sandbox'), 'index_rd_ifra.php', function(com){eval(com);});
-  hstm.hbit_set(heartbit);
-  
-  window.onbeforeunload = onbeforeunload_cb;  
-  window.onunload = onunload_cb;  
+  xstm = new xynt_streaming(window, <?php printf("\"%s\", %d", $transp_type, $transp_port); ?>,  2, null /* console */, gst, 'table_php', 'sess', sess, $('sandbox'), 'index_rd.php', function(com){eval(com);});
+  xstm.hbit_set(heartbit);
 
-  hstm.start(); 
+  window.onbeforeunload = onbeforeunload_cb;
+  window.onunload = onunload_cb;
+
+  xstm.start();
+
+  addEvent($('select_rules'), "change", function() { act_select_rules(this.value); } );
+  addEvent($('select_deck'), "change", function() { act_select_deck(this.value); } );
   // FIXME: add this setTimeout(preload_images into data stream to avoid
   // race on opened socket
   // setTimeout(preload_images, 0, g_preload_img_arr, g_imgct);
@@ -182,17 +201,17 @@ window.onload = function() {
   <img id="asta8" src="img/asta8.png" class="astacard">
   <img id="asta9" src="img/asta9.png" class="astacard">
   <div id="astaptdiv" class="punti">
-    <input class="puntifield" id="astapt" name="astapt" type="text" maxsize="3" size="3" value="61"> 
+    <input class="puntifield" id="astapt" name="astapt" type="text" maxsize="3" size="3" value="61">
   </div>
   <img  id="astaptsub" src="img/astaptsub_ro.png" class="astacard">
-  <img  id="astapasso" src="img/astapasso_ro.png" class="astacard"> 
-  <img  id="astalascio" src="img/astalascio_ro.png" class="astacard"> 
+  <img  id="astapasso" src="img/astapasso_ro.png" class="astacard">
+  <img  id="astalascio" src="img/astalascio_ro.png" class="astacard">
 </div>
 <div id="name" class="pubinfo"></div>
 <div id="public" class="public">
    <div class="vert_midfloat">
        <div id="pubasta" class="vert_innfloat_so">
-           <img id="pubacard" src="img/astapasso_ro.png" class="pubacard"> 
+           <img id="pubacard" src="img/astapasso_ro.png" class="pubacard">
            <div id="pubapnt"></div>
        </div>
    </div>
@@ -201,7 +220,7 @@ window.onload = function() {
 <div id="public_ea" class="public_ea">
    <div class="vert_midfloat">
       <div id="pubasta_ea" class="vert_innfloat">
-         <img id="pubacard_ea" src="img/astapasso_ro.png" class="pubacard_ea">  
+         <img id="pubacard_ea" src="img/astapasso_ro.png" class="pubacard_ea">
          <div id="pubapnt_ea"></div>
       </div>
    </div>
@@ -210,7 +229,7 @@ window.onload = function() {
 <div id="public_ne" class="public_ne">
    <div class="vert_midfloat">
       <div id="pubasta_ne" class="vert_innfloat">
-         <img id="pubacard_ne" src="img/astapasso_ro.png" class="pubacard_ne">  
+         <img id="pubacard_ne" src="img/astapasso_ro.png" class="pubacard_ne">
          <div id="pubapnt_ne"></div>
       </div>
    </div>
@@ -219,7 +238,7 @@ window.onload = function() {
 <div id="public_nw" class="public_nw">
    <div class="vert_midfloat">
       <div id="pubasta_nw" class="vert_innfloat">
-         <img id="pubacard_nw" src="img/astapasso_ro.png" class="pubacard_nw">  
+         <img id="pubacard_nw" src="img/astapasso_ro.png" class="pubacard_nw">
          <div id="pubapnt_nw"></div>
       </div>
    </div>
@@ -228,7 +247,7 @@ window.onload = function() {
 <div id="public_we" class="public_we">
    <div class="vert_midfloat">
       <div id="pubasta_we" class="vert_innfloat">
-         <img id="pubacard_we" src="img/astapasso_ro.png" class="pubacard_we">  
+         <img id="pubacard_we" src="img/astapasso_ro.png" class="pubacard_we">
          <div id="pubapnt_we"></div>
       </div>
    </div>
@@ -247,11 +266,13 @@ window.onload = function() {
 <div class="table_commands">
 <table>
 <tr>
-<td style="text-align: center;"><input type="button" class="button" name="xinfo"  value="Info." onclick="act_tableinfo();"></td>
-<td style="text-align: center;"><input type="button" class="button" name="xreload"  value="Reload." onclick="act_reload();"></td>
-<td style="text-align: center;"><input type="button" class="button" name="xout"  value="Out." onclick="safelogout();"></td>
+<td style="text-align: center;"><input type="button" class="button" name="xinfo"  value="<?php echo $mlang_bin5_index['tit_info'][$G_lang]; ?>" onclick="act_tableinfo();"></td>
+<td style="text-align: center;"><input type="button" class="button" name="xreload"  value="<?php echo $mlang_bin5_index['tit_relo'][$G_lang]; ?>" onclick="act_reload();"></td>
+<td style="text-align: center;"><input type="button" class="button" name="xout"  value="<?php echo $mlang_bin5_index['tit_out'][$G_lang]; ?>" onclick="safelogout();"></td>
 </tr><tr>
-<td style="text-align: center;" colspan="2"><input type="button" class="button" name="xpref"  value="<?php echo $mlang_bin5_index['tit_pref'][$G_lang]; ?>" onclick="preferences_showhide();"></td>
+<td style="text-align: center;"><img id="stm_stat" class="nobo" src="img/line-status_b.png"></td>
+<td style="text-align: center;"><input type="button" class="button" name="xpref"  value="<?php echo $mlang_bin5_index['tit_pref'][$G_lang]; ?>" onclick="preferences_showhide();"></td>
+</td>
 <td style="text-align: center;"><img id="exitlock" class="button" style="visibility: hidden; border: 0px; display: inline; position: relative;" onclick="act_exitlock();"></td>
 </tr>
 </table>
@@ -293,15 +314,19 @@ window.onload = function() {
 </div>
 
 <div id="preferences" class="notify" style="z-index: 200; width: 400px; margin-left: -200px; height: 200px; top: 126px; visibility: hidden;">
-<div id="preferences_child" style="border-bottom: 1px solid gray; overflow: auto; height: 170px;">
+<div id="preferences_child" style="border-bottom: 1px solid gray; overflow: auto; height: 170px; text-align: center">
 
 <h2><?php echo $mlang_bin5_index['tit_pref'][$G_lang]; ?></h2>
 <div style="width: 95%; /* background-color: red; */ margin: auto; text-align: left;">
-<br><br>
-<input type="checkbox" name="pref_ring_endauct" id="pref_ring_endauct" onclick="pref_ring_endauct_set(this);"><?php echo $mlang_bin5_index['itm_ringauc'][$G_lang] ?>
-</div>
-
-
+    <div>
+        <input type="checkbox" name="pref_ring_endauct" id="pref_ring_endauct" onclick="pref_ring_endauct_set(this);"><?php echo $mlang_bin5_index['itm_ringauc'][$G_lang] ?>
+    </div>
+    <div>
+        <label>Regole:</label> <?php dom_select_rules();?>
+    </div>
+    <div>
+      <label>Tipo di carte:</label> <?php dom_select_deck($deck);?>
+   </div>
 </div>
 <div class="notify_clo"><input type="submit" class="input_sub" style="bottom: 4px;" onclick="act_preferences_update();" value="<?php echo $mlang_bin5_index['btn_update'][$G_lang]; ?>"/></div>
 </div>