Browse Source

php - store worker sort choice in a cookie

master
kanoi 10 years ago
parent
commit
a86b3f7aaa
  1. 4
      pool/inc.php
  2. 14
      pool/page_workers.php

4
pool/inc.php

@ -139,7 +139,9 @@ input.tiny {width:0px;height:0px;margin:0px;padding:0px;outline:none;border:0px;
function SortJS() function SortJS()
{ {
$s = "function sot(t,s,o){if(t && s>=0){var rs=t.rows;if(rs && rs.length>2){var all=[], rn, ok=true;for(rn=1;rn<rs.length-1;rn++){if(rs[rn]){var c=rs[rn].cells[s];if(c){var key=c.getAttribute('data-srt');if(key){all.push([rs[rn],key])}else{all.push([rs[rn],c.innerHTML])}}else{ok=false}}else{ok=false}}if(ok){if(o=='s'){all.sort(function(a,b){return a[1].localeCompare(b[1])})}if(o=='n'){all.sort(function(a,b){return a[1]-b[1]})}if(o=='r'){all.sort(function(a,b){return b[1]-a[1]})}for(rn=0;rn<all.length;rn++){t.removeChild(all[rn][0])}var b4=t.lastChild;for(rn=0;rn<all.length;rn++){t.insertBefore(all[rn][0], b4);if(rn%2){all[rn][0].className='odd'}else{all[rn][0].className='even'}}}}}} $s = "function sot(t,s,o){if(t && s>=0){var rs=t.rows;if(rs && rs.length>2){var all=[], rn, ok=true;for(rn=1;rn<rs.length-1;rn++){if(rs[rn]){var c=rs[rn].cells[s];if(c){var key=c.getAttribute('data-srt');if(key){all.push([rs[rn],key])}else{all.push([rs[rn],c.innerHTML])}}else{ok=false}}else{ok=false}}if(ok){if(o=='s'){all.sort(function(a,b){return a[1].localeCompare(b[1])})}if(o=='n'){all.sort(function(a,b){return a[1]-b[1]})}if(o=='r'){all.sort(function(a,b){return b[1]-a[1]})}for(rn=0;rn<all.length;rn++){t.removeChild(all[rn][0])}var b4=t.lastChild;for(rn=0;rn<all.length;rn++){t.insertBefore(all[rn][0], b4);if(rn%2){all[rn][0].className='odd'}else{all[rn][0].className='even'}}}}}}
function sott(t,s,o){sot(t.parentNode.parentNode.parentNode.parentNode,s,o)} function sott(cn,t){if(t){var sf=t.getAttribute('data-sf');var o=sf.substring(0,1);var s=Number(sf.substring(1));var id=t.id;scnv(cn,id);t.checked=true;sot(t.parentNode.parentNode.parentNode.parentNode,s,o)}}
function sotn(cn,n){var e=document.getElementById(n);if(e){sott(cn,e)}}
function sotc(cn,d){var ws=gcn(cn);if(ws==''){ws=d}sotn(cn,ws)}
"; ";
return $s; return $s;
} }

14
pool/page_workers.php

@ -2,18 +2,18 @@
# #
function worktitle($data, $user) function worktitle($data, $user)
{ {
$r = '<input type=radio name=srt onclick="sott(this'; addSort();
$r = "input type=radio name=srt onclick=\"sott('worksrt',this);\"";
$pg = '<tr class=title>'; $pg = '<tr class=title>';
$pg .= "<td class=dl>Worker <span class=nb>Name:$r,0,'s');\"></span></td>"; $pg .= "<td class=dl>Worker <span class=nb>Name:<$r id=srtwrk data-sf=s0></span></td>";
$pg .= '<td class=dr>Work Diff</td>'; $pg .= '<td class=dr>Work Diff</td>';
$pg .= "<td class=dr><span class=nb>$r,2,'n');\">:Last</span> Share</td>"; $pg .= "<td class=dr><span class=nb><$r id=srtlst data-sf=n2>:Last</span> Share</td>";
$pg .= '<td class=dr>Shares</td>'; $pg .= '<td class=dr>Shares</td>';
$pg .= "<td class=dr><span class=nb>$r,4,'r');\">:Diff</span></td>"; $pg .= "<td class=dr><span class=nb><$r id=srtdiff data-sf=r4>:Diff</span></td>";
$pg .= '<td class=dr>Invalid</td>'; $pg .= '<td class=dr>Invalid</td>';
$pg .= '<td class=dr>Block %</td>'; $pg .= '<td class=dr>Block %</td>';
$pg .= "<td class=dr><span class=nb>$r,7,'r');\" checked>:Hash</span> Rate</td>"; $pg .= "<td class=dr><span class=nb><$r id=srtrate data-sf=r7>:Hash</span> Rate</td>";
$pg .= "</tr>\n"; $pg .= "</tr>\n";
addSort();
return $pg; return $pg;
} }
# #
@ -194,6 +194,8 @@ function doworker($data, $user)
} }
$pg .= "</table>\n"; $pg .= "</table>\n";
$pg .= "<script type='text/javascript'>\n";
$pg .= "sotc('worksrt','srtrate');</script>\n";
return "<h1>Workers$title</h1>".$pg; return "<h1>Workers$title</h1>".$pg;
} }

Loading…
Cancel
Save