From 8690ff5638d921e42fc41aec86008ea4d14d82b6 Mon Sep 17 00:00:00 2001 From: "Valeriano A.R" Date: Sat, 27 Jun 2015 03:00:05 +0200 Subject: [PATCH] Style changes --- code/scans.php | 66 ++++++++++++++++++++++++++++++++------------------ code/ui.php | 36 ++++++++++++++++++++------- style.css | 42 +++++++++++++++++++------------- 3 files changed, 95 insertions(+), 49 deletions(-) diff --git a/code/scans.php b/code/scans.php index 1639285..4787fbd 100644 --- a/code/scans.php +++ b/code/scans.php @@ -22,17 +22,32 @@ function RenderCommandLog(){ global $Commands; $renderLog=""; foreach($Commands as $loggedCommand){ - $renderLog.=RenderParagraph($loggedCommand["Command"],"font-weight: bold;"); + $renderLog.=RenderParagraph($loggedCommand["Command"],"command"); $renderLog.=RenderParagraph($loggedCommand["Result"]); - $renderLog.=RenderParagraph($loggedCommand["Error"],"color: red;"); + $renderLog.=RenderParagraph($loggedCommand["Error"],"error"); } return RenderDiv("divConsoleContainer", RenderButton("btnToggle","Log","var elem=document.getElementById('divConsole');if(elem.style.display==''){elem.style.display='none';}else{elem.style.display='';}return false;"). - RenderDiv("divConsole",$renderLog,"display:none;") + RenderDiv("divConsole",$renderLog,null,"display:none;") ); } + +function ScannerDetect(){ + global $ScanImage; + $Command=$ScanImage." -f\"%d|%v %m%n\""; + $scansResults=ExecCommand($Command); + $devicesResults=explode("\n",$scansResults); + list($ScannerDevice,$ScannerModel)=explode("|",$devicesResults[0]); + + $Scanner=array(); + $Scanner["ScanDevice"]=$ScannerDevice; + $Scanner["ScanModel"]=$ScannerModel; + + return $Scanner; +} + function Scan($device,$resolution,$format,$size,$destFileBase){ global $PreviewDir; global $ScanImage; @@ -121,15 +136,14 @@ function CropImage($file){ } + // Detect scanner -$CMD=$ScanImage." --list-devices | grep device"; -$SaneScanner = ExecCommand($CMD); -unset($cmd); -$start=strpos($SaneScanner,"`")+1; -$laenge=strpos($SaneScanner,"'")-$start; -$Scanner = "\"".substr($SaneScanner,$start,$laenge)."\""; -unset($start); -unset($laenge); +$Scanner=array(); +$Scanner["ScanDevice"]=RequestParm("hidScanDevice",""); +$Scanner["ScanModel"]=RequestParm("hidScanDevice",""); +if($Scanner["ScanDevice"]=="" || $Scanner["ScanModel"]==""){ + $Scanner=ScannerDetect(); +} // Configure with formdata @@ -144,7 +158,7 @@ $DestFile=null; if(RequestParm("btnScan",false)){ CleanUp(); $baseName="Scan-".date("Y-m-d_H_i_s"); - $DestFile=Scan($Scanner,$Resolution,$Format,$Size,$baseName); + $DestFile=Scan($Scanner["ScanDevice"],$Resolution,$Format,$Size,$baseName); if($Crop){ CropImage($DestFile); } @@ -152,24 +166,30 @@ if(RequestParm("btnScan",false)){ } -echo '
'."\n"; +echo ''."\n"; // Render header info -echo RenderFieldInfo("Scanner",$SaneScanner); +echo RenderFieldInfo("Scanner",$Scanner["ScanModel"]); echo RenderFieldCombo("Resolution","ddlResolution",$Resolutions,$Resolution); echo RenderFieldCombo("Format","ddlFormat",$Formats,$Format); echo RenderFieldCombo("Size","ddlSize",$Sizes,$Size); -//echo RenderFieldCheckText("Cropping","chkCrop",$Crop,"txtCropFuzz",$CropFuzz); +echo RenderFieldCheckText("Cropping","chkCrop",$Crop,"txtCropFuzz",$CropFuzz); echo RenderFieldButton("","btnScan","Scan"); -if($DestFile!=null){ - $DestFileFixed=htmlentities($DestFile,ENT_HTML5, "UTF-8"); - echo '
'. - 'Download '.$DestFileFixed.'
'."\n"; - echo '
preview
'; -} +echo RenderHidden("hidScanDevice",$Scanner["ScanDevice"]); +echo RenderHidden("hidScanModel",$Scanner["ScanModel"]); -echo "
\n"; +if($DestFile!=null){ + $DestFilenane=pathinfo($DestFile)["basename"]; + $DestFileFixed=htmlentities($DestFilenane,ENT_HTML5, "UTF-8"); + $DestPathFixed=htmlentities($DestFile,ENT_HTML5, "UTF-8"); + echo '
'. + 'Download
'."\n"; + echo ''; +} echo RenderCommandLog(); +echo "\n"; + + diff --git a/code/ui.php b/code/ui.php index 178f2d4..a8dc5ec 100644 --- a/code/ui.php +++ b/code/ui.php @@ -140,29 +140,47 @@ function RenderFieldButton($text,$idButton,$value,$onClick=""){ } -function RenderParagraph($text,$style=null){ +function RenderParagraph($text,$class=null){ if($text==null || $text==""){ return ""; } $textLines=explode("\n",$text); $render=""; foreach ($textLines as $line) { $textFixed=htmlentities($line,ENT_HTML5, "UTF-8"); - if($style==null){ + if($class==null){ $render.="

".$textFixed."

\n"; }else{ - $render.="

".$textFixed."

\n"; + $render.="

".$textFixed."

\n"; } } return $render; } -function RenderDiv($idDiv,$innerHTML,$style=null){ +function RenderDiv($idDiv,$innerHTML,$class=null,$style=null){ $idFixed=htmlentities($idDiv,ENT_HTML5, "UTF-8"); - if($style==null){ - $render='
'; - }else{ - $render='
'; + $render='
'."\n"; +} + +function RenderForm($id,$innerHTML){ + $idFixed=htmlentities($id,ENT_HTML5, "UTF-8"); + $render='
'."\n"; + $render.=$innerHTML; + $render.='
'."\n"; return $render; } diff --git a/style.css b/style.css index 24e2870..15c7a8d 100644 --- a/style.css +++ b/style.css @@ -1,24 +1,16 @@ -* {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: #E9F0F0; box-sizing:border-box; -moz-box-sizing:border-box;} +h1{ + font-size: 40px; + color: rgb(128,128,128); + margin:15px; +} .field{ display:block; white-space:nowrap; vertical-align:top; font-size:0; - margin:5px; - margin-top:10px; -} -.field:first-child{ - margin-top:5px; + margin:15px; } .fieldLabel{ display:inline-block; @@ -27,7 +19,7 @@ h1:first-child{ vertical-align:top; white-space: normal; word-break: break-word; - font-size:14px; + font-size:16px; } .fieldContent{ display:inline-block; @@ -35,21 +27,25 @@ h1:first-child{ white-space: normal; vertical-align:top; word-break: break-word; - font-size:14px; + font-size:16px; } .combo{ min-width:100px; border: solid 1px rgb(32,32,32); + background-color: white; } .button{ display:inline-block; padding:5px; margin:0; + margin-top: 5px; background-color: rgb(192,192,192); border: solid 1px rgb(32,32,32); cursor:pointer; + font-size:14px; + text-decoration: none; } .button:hover{ background-color: rgb(240,240,240); @@ -57,6 +53,8 @@ h1:first-child{ .textBox{ border: solid 1px rgb(32,32,32); + font-size:14px; + background-color: white; } .previewImage{ @@ -85,3 +83,13 @@ h1:first-child{ background-color: black; font-family: Monospace; } +#divConsole p.command{ + font-weight: bold; +} +#divConsole p.error{ + color: red; +} + +.divHidden{ + display: none; +} \ No newline at end of file