EOF
}
else {
print '';
}
# The actual textbox
$rv .= "\n";
return $rv;
}
# vui_opt_bytesbox(name, value, size, option1, [option2], [disabled?],
# [&extra-fields], [max], [tags], [defaultunits])
# Returns HTML for a bytes field with a 'default' option
sub vui_opt_bytesbox
{
my ($name, $value, $size, $opt1, $opt2, $dis, $extra, $max, $tags,
$defaultunits) = @_;
$defaultunits ||= 1024*1024*1024;
my $dis1 = &js_disable_inputs([ $name, $name."_units", @$extra ], [ ]);
my $dis2 = &js_disable_inputs([ ], [ $name, $name."_units", @$extra ]);
my $rv;
$size = &ui_max_text_width($size);
$rv .= &ui_radio($name."_def", $value eq '' ? 1 : 0,
[ [ 1, $opt1, "onClick='$dis1'" ],
[ 0, $opt2 || " ", "onClick='$dis2'" ] ], $dis)."\n";
$rv .= &ui_bytesbox($name, $value, $size, $value eq "" || $dis, $tags,
$defaultunits);
return $rv;
}
# vui_features_sorted_grid(\@grid)
# Returns HTML for grid, formatted
# the way that it preserves the order
sub vui_features_sorted_grid
{
my ($grid) = @_;
my @grid = @{$grid};
my @grid_left = @grid;
my $grid_tnum = scalar(@grid);
my @grid_right = splice(@grid_left, ($grid_tnum / 2) + ($grid_tnum % 2 ? 1 : 0));
my $style_force_no_border = 'style="border:0 !important; width: 50%;"';
my $style_flex_cnt = 'style="display: flex; align-items: flex-start; justify-content: center;"';
my $lgftable = &ui_grid_table(\@grid_left, 1, undef, undef, $style_force_no_border);
my $rgftable = &ui_grid_table(\@grid_right, 1, undef, undef, $style_force_no_border);
return "" . ($lgftable . $rgftable) . "
";
}
=head2 vui_install_mod_perl_link(mods, return_page, return_desc, [no_dot])
# Return a UI link for installing missing Perl module
=item mods - Space separated list of modules, e.g.: XML::Simple Net::SSLeay
=item return_page - Link to the page to return after installation
=item return_desc - Text for return link
=cut
sub vui_install_mod_perl_link
{
my ($mods, $return_page, $return_desc, $no_dot) = @_;
my $rv;
if (&foreign_available('cpan')) {
$rv .= &text('install_mod_perl_link', "../cpan/download.cgi?source=3&cpan=$mods&mode=2&".
"return=../virtual-server/$return_page&returndesc=".&urlize($return_desc));
}
return $rv;
}
=head2 vui_make_and
Joins multiple words with command and 'and' where needed
=cut
sub vui_make_and
{
my @w = @_;
if (@w == 0) {
return "";
}
elsif (@w == 1) {
return $w[0];
}
elsif (@w == 2) {
return &text('nf_and', $w[0], $w[1]);
}
else {
my $f = pop(@w);
return &text('nf_and', join(", ", @w), $f);
}
}
=head2 vui_footer_history_back
Returns a link and text for `ui_print_footer` on error to go back
=cut
sub vui_footer_history_back
{
return ("javascript:history.back()", $text{'error_previous'});
}
=head2 vui_ui_block_no_wrap(html, [add-white-space-around])
Returns passed HTML as block element with no wrap
=cut
sub vui_ui_block_no_wrap
{
my ($html, $nbsps) = @_;
$nbsps = " " if ($nbsps);
return "$nbsps$html$nbsps
";
}
=head2 vui_ui_block(html)
Returns passed HTML as block element
=cut
sub vui_ui_block
{
my ($html) = @_;
return "$html
";
}
=head2 vui_ui_input_noauto_attrs()
Returns attributes preventing browser to autofill input fields
=cut
sub vui_ui_input_noauto_attrs
{
return "autocomplete='new-password' autocorrect='off' spellcheck='false'";
}
=head2 vui_noauto_textbox(name, value, size, [disabled?], [maxlength], [tags])
Like ui_textbox, but with autocompletion disabled
=cut
sub vui_noauto_textbox
{
my ($name, $value, $size, $dis, $max, $tags) = @_;
$tags ||= "";
$tags .= " ".&vui_ui_input_noauto_attrs();
return &ui_textbox($name, $value, $size, $dis, $max, $tags);
}
=head2 vui_noauto_password(name, value, size, [disabled?], [maxlength], [tags])
Like ui_password, but with autocompletion disabled
=cut
sub vui_noauto_password
{
my ($name, $value, $size, $dis, $max, $tags) = @_;
$tags ||= "";
$tags .= " ".&vui_ui_input_noauto_attrs();
return &ui_password($name, $value, $size, $dis, $max, $tags);
}
=head2 vui_edit_link_icon()
Returns a link as a unicode symbol (icon)
=cut
sub vui_edit_link_icon
{
my ($link, $unisymb) = @_;
my $styles = "font-size: 140%;";
$styles .= "position: absolute;";
$styles .= "margin: -4px 0 0 4px;";
$unisymb ||= '⚙'; # default is cog
my $unisymb_class = $unisymb;
$unisymb_class =~ tr/[0-9]//cd;
return &ui_link($link,
"$unisymb",
"vui_edit_link_icon i$unisymb_class");
}
=head2 vui_inline_label()
Returns a text label as a inline element
=cut
sub vui_inline_label
{
my ($textid, $upper, $class) = @_;
my $styles = "font-size: 10px;";
$styles .= "font-weight: bold;";
$styles .= "background-color: #bdbdbd;";
$styles .= "border-radius: 50px;";
$styles .= "color: #fff;";
$styles .= "line-height: inherit;";
$styles .= "margin: 0 5px 0 10px;";
$styles .= "padding: 1px 5px;";
$styles .= "vertical-align: inherit;";
my $styles_cnt .= "display:contents;";
my $text = $text{$textid};
$text = uc($text) if ($upper);
$class = " $class" if ($class);
return "".
"$text";
}
=head2 vui_hidden()
Given content returns it as a hidden container
=cut
sub vui_hidden
{
my ($content) = @_;
return "$content
";
}
=head2 vui_note(text)
Returns a note as a small font size text
=cut
sub vui_note
{
my ($text) = @_;
return " ⓘ ".
"$text";
}
=head2 vui_brh
Returns an HTML break with ability to control height
=cut
sub vui_brh
{
return &ui_brh() if (defined(&ui_brh));
return "
";
}
1;