commit cc1038047e965bc7b6b51472707a8fc0014201a9 Author: WRZOOZ Date: Wed May 15 21:24:05 2024 +0200 New and updated version of old code. diff --git a/README.md b/README.md new file mode 100644 index 0000000..4993383 --- /dev/null +++ b/README.md @@ -0,0 +1,2 @@ +# saneAdmin + diff --git a/api/discoverScanners.php b/api/discoverScanners.php new file mode 100644 index 0000000..4dde45a --- /dev/null +++ b/api/discoverScanners.php @@ -0,0 +1,25 @@ + \ No newline at end of file diff --git a/api/imageDownload.php b/api/imageDownload.php new file mode 100644 index 0000000..6bcf029 --- /dev/null +++ b/api/imageDownload.php @@ -0,0 +1,26 @@ + \ No newline at end of file diff --git a/api/rediscover.php b/api/rediscover.php new file mode 100644 index 0000000..93c9bf0 --- /dev/null +++ b/api/rediscover.php @@ -0,0 +1,9 @@ + \ No newline at end of file diff --git a/api/scan.php b/api/scan.php new file mode 100644 index 0000000..833596e --- /dev/null +++ b/api/scan.php @@ -0,0 +1,126 @@ + ".$appConfig['imagesLocation'].$filename; + + +//// +// +/// Scanning start +// +//// + +//Prepare directory for scanned image +if(!is_dir($appConfig['imagesLocation'])) mkdir($appConfig['imagesLocation'], 777, true); + +//Scan image +shell_exec($scanCommand); + +//Output scanned image name indicating that scanning finished +echo $filename; + +?> \ No newline at end of file diff --git a/assets/placeholderImage.png b/assets/placeholderImage.png new file mode 100644 index 0000000..6fc1947 Binary files /dev/null and b/assets/placeholderImage.png differ diff --git a/assets/placeholderImage.xcf b/assets/placeholderImage.xcf new file mode 100644 index 0000000..f457fda Binary files /dev/null and b/assets/placeholderImage.xcf differ diff --git a/include/appConfig.php b/include/appConfig.php new file mode 100644 index 0000000..2b46450 --- /dev/null +++ b/include/appConfig.php @@ -0,0 +1,31 @@ + \ No newline at end of file diff --git a/index.php b/index.php new file mode 100644 index 0000000..1bd3f60 --- /dev/null +++ b/index.php @@ -0,0 +1,35 @@ + + + + + + + saneAdmin + + + + + + +
+

saneAdmin

+ +
+
+
+ +

Searching for scanners...

+
+ + + + + \ No newline at end of file diff --git a/interface.php b/interface.php new file mode 100644 index 0000000..80e596c --- /dev/null +++ b/interface.php @@ -0,0 +1,115 @@ + + + + + + + saneAdmin + + + + + + +
+

saneAdmin - web based scanner control

+
+ +
+
+
+

Settings

+
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + + +
+ +
+
+

Scanned image preview

+ Scanned image preview +
+
+
+ + + + + + + + \ No newline at end of file diff --git a/js/appControl.js b/js/appControl.js new file mode 100644 index 0000000..075b5b9 --- /dev/null +++ b/js/appControl.js @@ -0,0 +1,79 @@ +function discoverScanners(attemptID) +{ + var xhttp = new XMLHttpRequest(); + + xhttp.onreadystatechange = function() + { + if (this.readyState == 4 && this.status == 200) + { + if(this.responseText == "OK") + { + location.href = "interface.php"; + return true; + } + else + { + console.log("[Scanner discovery(attempt " + attemptID + ")] Failed with message: " + this.responseText); + setTimeout(discoverScanners, 2000, ++attemptID); + } + } + }; + + xhttp.open("GET", "api/discoverScanners.php", true); + xhttp.send(); + + if(attemptID > 3) + { + var progressBarElement = document.getElementById("scannerSearchProgress"); + progressBarElement.innerHTML = '
Attempt ' + attemptID + '
'; + } +} + +function scannersDiscoveryController() +{ + var progressBarElement = document.getElementById("scannerSearchProgress"); + if(progressBarElement != null) progressBarElement.innerHTML = '
'; + else return; + + discoverScanners(1); +} + +function scanImage() +{ + const scanningAnimationModal = new bootstrap.Modal(document.getElementById('scanningAnimationModal')); + + var deviceID = document.getElementById("deviceIDFormSelect").value; + var outputImageResolution = document.getElementById("outputImageResolutionFormSelect").value; + var outputImageColorDepth = document.getElementById("outputImageColorDepthFormSelect").value; + var outputFileFormat = document.getElementById("outputFileFormatFormSelect").value; + var inputPageSize = document.getElementById("inputPageSizeFormSelect").value; + + var xhttp = new XMLHttpRequest(); + + xhttp.onreadystatechange = function() + { + // TODO / DEBUG - Enable this + if (this.readyState == 4 && this.status == 200) + { + var scannedFileName = this.responseText; + + var scannedImagePreview = document.getElementById("scanPreview"); + scannedImagePreview.src = "api/imageDownload.php?filename=" + scannedFileName; + scannedImagePreview.alt = scannedFileName; + + var scannedImageDownloadButton = document.getElementById("scannedImageDownloadButton"); + scannedImageDownloadButton.href = "api/imageDownload.php?filename=" + scannedFileName; + scannedImageDownloadButton.style = "display: block;"; + + scanningAnimationModal.hide(); + } + }; + + xhttp.open("GET", "api/scan.php?outputImageResolution=" + outputImageResolution + "&outputImageColorDepth=" + outputImageColorDepth + "&outputFileFormat=" + outputFileFormat + "&inputPageSize=" + inputPageSize + "&deviceID=" + deviceID, true); + xhttp.send(); + + scanningAnimationModal.show(); +} + + +document.addEventListener("DOMContentLoaded", (event) => { scannersDiscoveryController(); });