From 74c0b0c5dc37c3df302c3b449f66c3004ea3694c Mon Sep 17 00:00:00 2001 From: "Valeriano A.R" Date: Fri, 26 Jun 2015 18:09:07 +0200 Subject: [PATCH] Extract UI lib from Utils. --- code/scans.php | 19 ++++--- code/ui.php | 147 +++++++++++++++++++++++++++++++++++++++++++++++++ code/utils.php | 100 --------------------------------- style.css | 125 +++++++++++++++++++++-------------------- 4 files changed, 219 insertions(+), 172 deletions(-) create mode 100644 code/ui.php diff --git a/code/scans.php b/code/scans.php index da8058f..b449d0a 100644 --- a/code/scans.php +++ b/code/scans.php @@ -2,6 +2,7 @@ include_once "config.php"; include_once "utils.php"; +include_once "ui.php"; $Commands=array(); @@ -20,9 +21,9 @@ function ExecCommand($command){ function ShowCommandLog(){ global $Commands; foreach($Commands as $loggedCommand){ - DrawParagraph($loggedCommand["Command"],"font-weight: bold;"); - DrawParagraph($loggedCommand["Result"]); - DrawParagraph($loggedCommand["Error"],"color: red;"); + echo RenderParagraph($loggedCommand["Command"],"font-weight: bold;"); + echo RenderParagraph($loggedCommand["Result"]); + echo RenderParagraph($loggedCommand["Error"],"color: red;"); } } @@ -110,11 +111,11 @@ if(RequestParm("btnScan",false)){ echo '
'."\n"; // Render header info -DrawFieldInfo("Scanner",$SaneScanner); -DrawFieldCombo("Resolution","ddlResolution",$Resolutions,$Resolution); -DrawFieldCombo("Format","ddlFormat",$Formats,$Format); -DrawFieldCheckText("Cropping","chkCrop",$Crop,"txtCropFuzz",$CropFuzz); -DrawButton("Scan","btnScan"); +echo RenderFieldInfo("Scanner",$SaneScanner); +echo RenderFieldCombo("Resolution","ddlResolution",$Resolutions,$Resolution); +echo RenderFieldCombo("Format","ddlFormat",$Formats,$Format); +echo RenderFieldCheckText("Cropping","chkCrop",$Crop,"txtCropFuzz",$CropFuzz); +echo RenderFieldButton("","btnScan","Scan"); if($DestFile!=null){ $DestFileFixed=htmlentities($DestFile,ENT_HTML5, "UTF-8"); echo '
'. @@ -125,4 +126,4 @@ if($DestFile!=null){ echo "\n"; ShowCommandLog(); -?> \ No newline at end of file + diff --git a/code/ui.php b/code/ui.php new file mode 100644 index 0000000..4467d9d --- /dev/null +++ b/code/ui.php @@ -0,0 +1,147 @@ +'.$textFixed.":\n"; + }else{ + return ''."\n"; + } +} + +function RenderInfo($text){ + $textFixed=htmlentities($text,ENT_HTML5, "UTF-8"); + return '
'.$textFixed."
\n"; +} + +function RenderText($idText,$value){ + $idTextFixed=htmlentities($idText,ENT_HTML5, "UTF-8"); + $valueFixed=htmlentities($value,ENT_HTML5, "UTF-8"); + $render='
'."\n"; + $render.=''."\n"; + $render.="
\n"; + return $render; +} + +function RenderCheck($idCheck,$checked,$value){ + $idCheckFixed=htmlentities($idCheck,ENT_HTML5, "UTF-8"); + $valueFixed=htmlentities($idText,ENT_HTML5, "UTF-8"); + $render='
'."\n"; + $render.=''; + $render.="\n"; + $render.="
\n"; + return $render; +} + +function RenderCombo($id,$options,$selected){ + $idFixed=htmlentities($id,ENT_HTML5, "UTF-8"); + $render='
'."\n"; + $render.='\n"; + $render.="
\n"; + return $render; +} + +function RenderButton($id,$value){ + $idFixed=htmlentities($id,ENT_HTML5, "UTF-8"); + $valueFixed=htmlentities($value,ENT_HTML5, "UTF-8"); + return ''; +} + +function RenderFieldInfo($text,$info){ + $render='
'."\n"; + $render.=RenderLabel($text); + $render.=RenderInfo($info); + $render.='
'."\n"; + return $render; +} + +function RenderFieldText($text,$idText,$value){ + $render='
'."\n"; + $render.=RenderLabel($text); + $render.=RenderText($idText,$value); + $render.='
'."\n"; + return $render; +} + +function RenderFieldCheck($text,$idCheck,$checked,$value){ + $render='
'."\n"; + $render.=RenderLabel($text); + $render.=RenderCheck($idCheck,$checked,$value); + $render.='
'."\n"; + return $render; +} + +function RenderFieldCheckText($text,$idCheck,$checked,$idText,$value){ + $render='
'."\n"; + $render.=RenderLabel($text); + $render.=RenderCheckText($idCheck,$checked,$idText,$value); + $render.='
'."\n"; + return $render; +} + +function RenderFieldCombo($text,$idCombo,$options,$selected){ + $render='
'."\n"; + $render.=RenderLabel($text); + $render.=RenderCombo($idCombo,$options,$selected); + $render.='
'."\n"; + return $render; +} + +function RenderFieldButton($text,$idButton,$value){ + $render='
'."\n"; + $render.=RenderLabel($text); + $render.=RenderButton($idButton,$value); + $render.='
'."\n"; + return $render; +} + + +function RenderParagraph($text,$style=null){ + if($text==null || $text==""){ return ""; } + $textFixed=htmlentities($text,ENT_HTML5, "UTF-8"); + if($style==null){ + return "

".$textFixed."

\n"; + }else{ + return "

".$textFixed."

\n"; + } +} + + diff --git a/code/utils.php b/code/utils.php index a1723cc..9cbbe8c 100644 --- a/code/utils.php +++ b/code/utils.php @@ -1,104 +1,5 @@ '."\n"; - echo ''.$textFixed.":\n"; - echo '
'.$infoFixed."
\n"; - echo '
'."\n"; -} - -function DrawFieldCombo($text,$id,$options,$selected){ - $textFixed=htmlentities($text,ENT_HTML5, "UTF-8"); - $idFixed=htmlentities($id,ENT_HTML5, "UTF-8"); - echo '
'."\n"; - echo ''.$textFixed.":\n"; - echo '
'."\n"; - echo '\n"; - echo "
\n"; - echo '
'."\n"; -} - -function DrawFieldText($text,$idText,$value){ - $textFixed=htmlentities($text,ENT_HTML5, "UTF-8"); - $idTextFixed=htmlentities($idText,ENT_HTML5, "UTF-8"); - $valueFixed=htmlentities($value,ENT_HTML5, "UTF-8"); - echo '
'."\n"; - echo ''.$textFixed.":\n"; - echo '
'."\n"; - echo ''."\n"; - echo "
\n"; - echo '
'."\n"; -} - -function DrawFieldCheck($text,$idCheck,$checked,$value){ - $textFixed=htmlentities($text,ENT_HTML5, "UTF-8"); - $idCheckFixed=htmlentities($idCheck,ENT_HTML5, "UTF-8"); - $valueFixed=htmlentities($idText,ENT_HTML5, "UTF-8"); - echo '
'."\n"; - echo ''.$textFixed.":\n"; - echo '
'."\n"; - echo ''.$valueFixed."\n"; - echo "\n"; - echo "
\n"; - echo '
'."\n"; -} - -function DrawFieldCheckText($text,$idCheck,$checked,$idText,$value){ - $textFixed=htmlentities($text,ENT_HTML5, "UTF-8"); - $idCheckFixed=htmlentities($idCheck,ENT_HTML5, "UTF-8"); - $idTextFixed=htmlentities($idText,ENT_HTML5, "UTF-8"); - $valueFixed=htmlentities($value,ENT_HTML5, "UTF-8"); - echo '
'."\n"; - echo ''.$textFixed.":\n"; - echo '
'."\n"; - echo ''."\n"; - echo ''; - echo "
\n"; - echo '
'."\n"; -} - -function DrawButton($text,$id){ - $textFixed=htmlentities($text,ENT_HTML5, "UTF-8"); - $idFixed=htmlentities($id,ENT_HTML5, "UTF-8"); - echo ''; -} - -function DrawParagraph($text,$style=null){ - $textFixed=htmlentities($text,ENT_HTML5, "UTF-8"); - if($style==null){ - echo "

".$textFixed."

\n"; - }else{ - echo "

".$textFixed."

\n"; - } -} - function RequestParm($name,$defaultValue){ if(isset($_GET[$name])){ return $_GET[$name]; @@ -127,4 +28,3 @@ function ExecFull($cmd, $input='') { return array($return_code, $stdout, $stderr); } -?> \ No newline at end of file diff --git a/style.css b/style.css index 93ebe5f..27e1a91 100644 --- a/style.css +++ b/style.css @@ -1,68 +1,67 @@ - * {margin:0;padding:0;border:none;font-family:Arial,sans-serif; color:rgb(32,32,32);background-color:white; box-sizing:border-box; -moz-box-sizing:border-box;} - h1{ - font-size: 30px; - color: rgb(128,128,128); - margin:5px; - margin-top:10px; - } - h1:first-child{ - margin-top:5px; - } +* {margin:0;padding:0;border:none;font-family:Arial,sans-serif; color:rgb(32,32,32);background-color:white; box-sizing:border-box; -moz-box-sizing:border-box;} +h1{ + font-size: 30px; + color: rgb(128,128,128); + margin:5px; + margin-top:10px; +} +h1:first-child{ + margin-top:5px; +} - .field{ - display:block; - white-space:nowrap; - vertical-align:top; - font-size:0; - margin:5px; - margin-top:10px; - } - .field:first-child{ - margin-top:5px; - } - .fieldLabel{ - display:inline-block; - width:20%; - font-weight: bold; - vertical-align:top; - white-space: normal; - word-break: break-word; - font-size:14px; - } - .fieldText, - .fieldCombo{ - display:inline-block; - width:80%; - white-space: normal; - vertical-align:top; - word-break: break-word; - font-size:14px; - } +.field{ + display:block; + white-space:nowrap; + vertical-align:top; + font-size:0; + margin:5px; + margin-top:10px; +} +.field:first-child{ + margin-top:5px; +} +.fieldLabel{ + display:inline-block; + width:20%; + font-weight: bold; + vertical-align:top; + white-space: normal; + word-break: break-word; + font-size:14px; +} +.fieldContent{ + display:inline-block; + width:80%; + white-space: normal; + vertical-align:top; + word-break: break-word; + font-size:14px; +} - .combo{ - min-width:100px; - border: solid 1px rgb(32,32,32); - } +.combo{ + min-width:100px; + border: solid 1px rgb(32,32,32); +} - .button{ - display:inline-block; - padding:5px; - margin:5px; - background-color: rgb(192,192,192); - border: solid 1px rgb(32,32,32); - cursor:pointer; - } - .button:hover{ - background-color: rgb(240,240,240); - } +.button{ + display:inline-block; + padding:5px; + margin:0; + background-color: rgb(192,192,192); + border: solid 1px rgb(32,32,32); + cursor:pointer; +} +.button:hover{ + background-color: rgb(240,240,240); +} - .textBox{ - border: solid 1px rgb(32,32,32); - } +.textBox{ + border: solid 1px rgb(32,32,32); +} - .previewImage{ - margin:5px; - border: solid 1px rgb(32,32,32); - max-width:200px; - max-height:200px; - } \ No newline at end of file +.previewImage{ + margin:5px; + border: solid 1px rgb(32,32,32); + max-width:200px; + max-height:200px; +} \ No newline at end of file