#!/usr/bin/perl
##LICENSE##
package RVSInstaller::ScreenControl;
use strict;
use Carp;
use RVSInstaller::Config;
use vars qw( $VERSION $MSGNUM );
$VERSION = "0.01";
$MSGNUM = 0;
sub init{
my $self = shift;
$| = 1;
return 1;
}
sub new {
my ($class, %args) = @_;
my $self = {%args};
if (!defined($self->{'programName'})) {
croak "__PACKAGE__ Constructor require 'programName' parameter to create object";
}
bless $self, $class;
$self->{'Config'} = RVSInstaller::Config->new(programName => $self->{'programName'});
return $self;
}
sub jsChangeImg{
my $self = shift;
my ($imgName, $imgType) = @_;
if ( $self->{'Config'}->{BROWSER} ) {
print '<script language="javascript">';
print 'changeImgSrc("img' . $imgName . '", "';
if ( $imgType eq '1' ) {
print $self->{'Config'}->{WEBROOT} . '/templates/images/marrow.gif';
}
elsif ( $imgType eq '2' ) {
print $self->{'Config'}->{WEBROOT} . '/templates/images/iarrow.gif';
}
else {
print $self->{'Config'}->{WEBROOT} . '/templates/images/space.gif';
}
print '"); </script>' . "\n";
}
}
sub jsChangeArrow{
my $self = shift;
my ($imgName, $imgType) = @_;
$imgType = $imgType ? $imgType : '0';
if ( $self->{'Config'}->{BROWSER} ) {
print '<script language="javascript">';
print 'changeImgSrc("arrow' . $imgName . '", "';
if ( $imgType eq '1' ) {
print $self->{'Config'}->{WEBROOT} . '/templates/images/larrow.gif';
}
elsif ( $imgType eq '2' ) {
print $self->{'Config'}->{WEBROOT} . '/templates/images/larrowani.gif';
}
else {
print $self->{'Config'}->{WEBROOT} . '/templates/images/space.gif';
}
print '"); </script>' . "\n";
}
}
sub jsChangeSta{
my $self = shift;
my ($imgName, $imgType) = @_;
$imgType = $imgType ? $imgType : '0';
if ( $self->{'Config'}->{BROWSER} ) {
print '<script language="javascript">';
print 'changeImgSrc("sta' . $imgName . '", "';
if ( $imgType eq '1' ) {
print $self->{'Config'}->{WEBROOT} . '/templates/images/checked.gif';
}
elsif ( $imgType eq '2' ) {
print $self->{'Config'}->{WEBROOT} . '/templates/images/nopass.gif';
}
else {
print $self->{'Config'}->{WEBROOT} . '/templates/images/space.gif';
}
print '"); </script>' . "\n";
}
}
sub jsSetFontColor{
my $self = shift;
my ($spanName, $textColor) = @_;
if ( $self->{'Config'}->{BROWSER} ) {
print '<script language="javascript">';
print 'styleColorValue("' . $spanName .'", "' . $textColor . '");';
print ' </script>' . "\n";
}
}
sub jsSetFontWeight{
my $self = shift;
my ($spanName, $textStyle) = @_;
if ( $self->{'Config'}->{BROWSER} ) {
print '<script language="javascript">';
print 'styleFontWeightValue("' . $spanName .'", "' . $textStyle . '");';
print ' </script>' . "\n";
}
}
sub jsFrameRedirect{
my $self = shift;
my ($frameName, $url) = @_;
print '<script language="javascript">';
print 'frameRedirect("' . $frameName . '", "' . $url . '");';
print ' </script>'."\n";
}
sub jsMetaRedirect{
my $self = shift;
my ($metaName, $url) = @_;
print '<script language="javascript">';
print 'metaRedirect("' . $metaName . '", "' . $url . '");';
print ' </script>'."\n";
}
sub jsShowPanel{
my $self = shift;
my ($metaName, $url) = @_;
print '<script language="javascript">';
print 'metaRedirect("' . $metaName . '", "' . $url . '");';
print ' </script>'."\n";
}
sub DisplayBoxMsg{
my $self = shift;
my ($loading, $textHead,@textBodys) = @_;
if ( $self->{'Config'}->{BROWSER} ) {
my ($action) = ($loading) ? 'loading': 'write';
my ($textBody) = join('<br />', @textBodys);
$textHead =~s/'/\\'/gi;
$textHead =~s/"/"/gi;
$textBody =~s/'/\\'/gi;
$textBody =~s/\r|\n//gi;
$textBody =~s/"/"/gi;
print "<script language=\"javascript\"> rvdisplay_box('$action', '$textHead', '$textBody'); </script>\n";
}
}
sub CloseBoxMsg{
my $self = shift;
if ( $self->{'Config'}->{BROWSER} ) {
print "<script language=\"javascript\"> rvdisplay_box('close','',''); </script>\n";
}
}
sub DisplayMsg{
my $self = shift;
my ( $msg, $shellNewLine, $spanName, $textStyle, $textColor) = @_;
$msg = $msg ? $msg : '';
$shellNewLine = $shellNewLine ? $shellNewLine : 0;
$spanName = $spanName ? $spanName : '';
$textStyle = $textStyle ? $textStyle : '';
$textColor = $textColor ? $textColor : '';
if ( $self->{'Config'}->{BROWSER} ) {
$msg =~s/'/\\'/gi;
$msg =~s/"/"/gi;
$msg =~s/\r|\n//gi;
if ( $spanName ne '' ) {
print '<script language="javascript">';
print 'innerValue("' . $spanName .'", "' . $msg . '");';
print ' </script>' . "\n";
if ( $textStyle ne '') {
jsSetFontWeight($spanName, $textStyle);
}
if ( $textColor ne '') {
jsSetFontColor($spanName, $textColor);
}
}
} else {
if ( $msg =~/\<TAB\>/i) {
my ($strTab) = TabDisplay();
$msg =~s/\<TAB\>/$strTab/gi;
}
if ( $shellNewLine eq 1) {
$msg =~s/\n//gi;
print $msg . "\n";
$MSGNUM = 0;
}
else {
print $msg;
$MSGNUM += length($msg);
}
}
}
sub TabDisplay{
my $self = shift;
my ($i, $strTab);
$strTab = '';
for ($i=0; $i < 80- $MSGNUM; $i++) {
$strTab .= ' ';
}
$MSGNUM = 0;
return $strTab;
}
sub LogMsg{
my $self = shift;
my ($msg) = $_[0];
open(my $WH ,">>", $self->{'Config'}->{'installConf'}->{'thisPath'} . '/logs/rvsmain_log');
my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = localtime(time());
$year += 1900;
$msg =~s/\n//gi;
print $WH sprintf("%s %s %s - %s:%02d:%02d %s\n", $mday, $self->{'Config'}->{'MONS'}->{$mon}, $year, $hour, $min, $sec, $msg);
close($WH);
}
1;
__END__
Copyright 2K16 - 2K18 Indonesian Hacker Rulez