Catalan updates
authorJamie Cameron <jcameron@webmin.com>
Tue, 27 Nov 2007 17:38:54 +0000 (17:38 +0000)
committerJamie Cameron <jcameron@webmin.com>
Tue, 27 Nov 2007 17:38:54 +0000 (17:38 +0000)
proc/edit_proc.cgi
proc/proc-lib.pl

index f43cead..eb340c0 100755 (executable)
@@ -44,17 +44,8 @@ if (&indexof($pinfo{nice}, @nice_range) < 0) {
        print $pinfo{nice};
        }
 else {
-       print "<select name=nice>\n";
-       for($i=0; $i<@nice_range; $i++) {
-               printf "<option value=%d %s>%d%s\n",
-                       $nice_range[$i],
-                       $pinfo{nice} == $nice_range[$i] ? "selected" : "",
-                       $nice_range[$i],
-                       $i==0 ? " ($text{'edit_prihigh'})" :
-                       $i==@nice_range-1 ? " ($text{'edit_prilow'})" :
-                       $nice_range[$i]==0 ? " ($text{'edit_pridef'})" : "";
-               }
-       print "</select> <input type=submit value='$text{'edit_change'}'>\n";
+       print &nice_selector("nice", $pinfo{nice});
+       print &ui_submit($text{'edit_change'});
        }
 print "</td> </form></tr>\n";
 $i = 0;
index e211df1..798e19c 100644 (file)
@@ -215,8 +215,8 @@ else {
                                }
                        }
                elsif ($sel == 0) {
-                       # nothing to read. maybe the process is done, and a subprocess
-                       # is hanging things up
+                       # nothing to read. maybe the process is done, and a
+                       # subprocess is hanging things up
                        last if (!kill(0, $pid));
                        }
                if ($_[7] && time() - $start > $_[7]) {
@@ -570,5 +570,18 @@ else {
        }
 }
 
+# nice_selector(name, value)
+# Returns a menu for selecting a nice level
+sub nice_selector
+{
+local ($name, $value) = @_;
+local $l = scalar(@nice_range);
+return &ui_select($name, $value,
+       [ map { [ $_, $_.($_ == $nice_range[0] ? " ($text{'edit_prihigh'})" :
+                         $_ == 0 ? " ($text{'edit_pridef'})" :
+                         $_ == $nice_range[$l-1] ? " ($text{'edit_prilow'})" :
+                                                   "") ] } @nice_range ]);
+}
+
 1;