tazpkg rev 761
pkgs.cgi: keep packages' selection across pages (thanks Ceel for idea).
author | Aleksej Bobylev <al.bobylev@gmail.com> |
---|---|
date | Mon Mar 30 11:52:49 2015 +0300 (2015-03-30) |
parents | 37df6365cf41 |
children | ad921c2aee59 |
files | tazpanel/pkgs.cgi tazpanel/pkgs.css |
line diff
1.1 --- a/tazpanel/pkgs.cgi Sun Mar 29 17:04:09 2015 +0200 1.2 +++ b/tazpanel/pkgs.cgi Mon Mar 30 11:52:49 2015 +0300 1.3 @@ -31,8 +31,7 @@ 1.4 1.5 export TEXTDOMAIN='tazpkg' 1.6 1.7 -pkg_info_link() 1.8 -{ 1.9 +pkg_info_link() { 1.10 echo "<a data-icon=\"$2\" href=\"?info=${1//+/%2B}\">$1</a>" | sed 's| data-icon=""||' 1.11 } 1.12 1.13 @@ -286,13 +285,13 @@ 1.14 r = NR % size 1.15 if (r == 1) { 1.16 p = int(NR / size) + 1 1.17 - printf "<a class=\"pages%s\" href=\"%s%s\" title=\"%s\n···\n", p==page?" current":"", url, p, $6 1.18 + printf "<button class=\"pages%s\" name=\"page\" value=\"%s\" title=\"%s\n···\n", p==page?" current":"", p, $6 1.19 } else if (r == 0) 1.20 - printf "%s\">%s</a> ", $6, int(NR / size) 1.21 + printf "%s\">%s</button> ", $6, int(NR / size) 1.22 } 1.23 END{ 1.24 if (num_pages == 1) exit 1.25 - if (r != 0) printf "%s\">%s</a>", $6, int(NR / size) + 1 1.26 + if (r != 0) printf "%s\">%s</button>", $6, int(NR / size) + 1 1.27 print "</p>" 1.28 }' $1 1.29 } 1.30 @@ -321,7 +320,9 @@ 1.31 if (PKG && PKG != $1) { 1.32 if (SEL) { 1.33 if (DSCL) DSC = DSCL 1.34 - printf "<tr><td><input type=\"checkbox\" name=\"pkg\" value=\"%s\"><a data-icon=\"pkg%s%s\" href=\"?info=%s\">%s</a></td><td>%s</td><td>%s</td><td><a href=\"%s\"></a></td></tr>\n", PKG, INS, BLK, gensub(/\+/, "%2B", "g", PKG), PKG, VER, DSC, WEB 1.35 + printf "<tr><td><input type=\"checkbox\" name=\"pkg\" value=\"%s\" id=\"%s\">", PKG, PKG 1.36 + printf "<a data-icon=\"pkg%s%s\" href=\"?info=%s\">%s</a></td>", INS, BLK, gensub(/\+/, "%2B", "g", PKG), PKG 1.37 + printf "<td>%s</td><td>%s</td><td><a href=\"%s\"></a></td></tr>\n", VER, DSC, WEB 1.38 } 1.39 VER = DSC = WEB = DSCL = INS = BLK = SEL = "" 1.40 } 1.41 @@ -353,6 +354,38 @@ 1.42 EOT 1.43 fi 1.44 rm -f $cached 1.45 + 1.46 + 1.47 + ### Re-select packages when you return to the page 1.48 + 1.49 + # Find the packages list 1.50 + pkgs=$(echo "$QUERY_STRING&" | awk 'BEGIN{RS="&";FS="="} 1.51 + {if ($1=="pkg") printf "\"%s\", ", $2}') 1.52 + pkgs=$(httpd -d "${pkgs%, }") 1.53 + # now pkgs='"pkg1", "pkg2", ... "pkgn"' 1.54 + 1.55 + if [ -n "$pkgs" ]; then 1.56 + cat << EOT 1.57 +<script type="text/javascript"> 1.58 +var pkgs = [$pkgs]; 1.59 +var theForm = document.getElementById('pkglist'); 1.60 +for (index = 0; index < pkgs.length; index++) { 1.61 + if (document.getElementById(pkgs[index])) { 1.62 + // check existing 1.63 + document.getElementById(pkgs[index]).checked = 'true'; 1.64 + } 1.65 + else { 1.66 + // add other as hidden 1.67 + var hInput = document.createElement('input'); 1.68 + hInput.type = 'hidden'; 1.69 + hInput.name = 'pkg'; 1.70 + hInput.value = pkgs[index]; 1.71 + theForm.appendChild(hInput); 1.72 + } 1.73 +} 1.74 +</script> 1.75 +EOT 1.76 + fi 1.77 } 1.78 1.79 1.80 @@ -458,7 +491,7 @@ 1.81 ;; 1.82 1.83 1.84 - *\ list\ *) 1.85 + *\ list\ *|*\ page\ *) 1.86 # 1.87 # List all packages by category. 1.88 # 1.89 @@ -489,7 +522,6 @@ 1.90 show_button do=Remove 1.91 } | sed 's|button |button form="pkglist" |g') 1.92 <button data-icon="toggle" onclick="checkBoxes(window)">$(_ 'Toggle all')</button> 1.93 - <div class="float-right">$(show_button recharge)</div> 1.94 </div> 1.95 1.96 <form id="pkglist" class="wide">
2.1 --- a/tazpanel/pkgs.css Sun Mar 29 17:04:09 2015 +0200 2.2 +++ b/tazpanel/pkgs.css Mon Mar 30 11:52:49 2015 +0300 2.3 @@ -154,7 +154,7 @@ 2.4 * Pager 2.5 */ 2.6 2.7 -a.pages { 2.8 +.pages { 2.9 display: inline-block; 2.10 padding: 0.5ex; 2.11 margin: 0.5ex 0; 2.12 @@ -162,12 +162,12 @@ 2.13 width: 3ex; 2.14 text-align: center; 2.15 } 2.16 -a.pages:hover { 2.17 +.pages:hover { 2.18 border: 1px solid #F94; 2.19 background: #F94; 2.20 color: black; 2.21 } 2.22 -a.pages.current, a.pages.current:hover { 2.23 +.pages.current, a.pages.current:hover { 2.24 font-weight: bold; 2.25 border: 1px solid #07F; 2.26 background: #07F;