miner.php when displaying a single rig, add prev/next rig buttons if they exist, next to refresh
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
diff --git a/miner.php b/miner.php
index 06407b4..ecabbdb 100644
--- a/miner.php
+++ b/miner.php
@@ -1207,7 +1207,7 @@ function process($cmds, $rig)
}
}
#
-function rigbutton($rig, $rigname, $when, $row)
+function rigname($rig, $rigname)
{
global $rigs;
@@ -1218,12 +1218,21 @@ function rigbutton($rig, $rigname, $when, $row)
$rigname = $parts[2];
}
- list($value, $class) = fmt('BUTTON', 'Rig', '', $when, $row);
+ return $rigname;
+}
+#
+function riginput($rig, $rigname)
+{
+ $rigname = rigname($rig, $rigname);
- $button = "<td align=middle$class><input type=button value='$rigname'";
- $button .= " onclick='pr(\"&rig=$rig\",null)'></td>";
+ return "<input type=button value='$rigname' onclick='pr(\"&rig=$rig\",null)'>";
+}
+#
+function rigbutton($rig, $rigname, $when, $row)
+{
+ list($value, $class) = fmt('BUTTON', 'Rig', '', $when, $row);
- return $button;
+ return "<td align=middle$class>".riginput($rig, $rigname).'</td>';
}
#
function showrigs($anss, $headname, $rigname)
@@ -1445,16 +1454,43 @@ function pagebuttons($rig, $pg)
if ($rig === null)
{
+ $prev = null;
+ $next = null;
+
if ($pg === null)
$refresh = '';
else
$refresh = "&pg=$pg";
}
else
+ {
+ switch (count($rigs))
+ {
+ case 0:
+ case 1:
+ $prev = null;
+ $next = null;
+ break;
+ case 2:
+ $prev = null;
+ $next = ($rig + 1) % count($rigs);
+ break;
+ default:
+ $prev = ($rig - 1) % count($rigs);
+ $next = ($rig + 1) % count($rigs);
+ break;
+ }
+
$refresh = "&rig=$rig";
+ }
echo '<tr><td><table cellpadding=0 cellspacing=0 border=0><tr><td nowrap>';
+ if ($prev !== null)
+ echo riginput($prev, 'Prev').' ';
echo "<input type=button value='Refresh' onclick='pr(\"$refresh\",null)'> ";
+ if ($next !== null)
+ echo riginput($next, 'Next').' ';
+ echo ' ';
if (count($rigs) > 1)
echo "<input type=button value='Summary' onclick='pr(\"\",null)'> ";