From c58df328837b0f993b4e794219df879cefaf8c31 Mon Sep 17 00:00:00 2001 From: Paolo Bolettieri Date: Wed, 22 Jun 2022 16:17:56 +0200 Subject: [PATCH] Carica file su 'src/static/js' --- src/static/js/ui.js | 105 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 105 insertions(+) create mode 100644 src/static/js/ui.js diff --git a/src/static/js/ui.js b/src/static/js/ui.js new file mode 100644 index 0000000..5be49e9 --- /dev/null +++ b/src/static/js/ui.js @@ -0,0 +1,105 @@ +function changeImage(imageURL, objectID) { + //alert(imageURL + " - " + objectID); + if (document.getElementById('objId').value==objectID || objectID == "" || imageURL == "null" || objectID == "null") { + document.getElementById('advSearch').style.display = 'none'; + //document.getElementById('comboInfo').style.display = 'none'; + document.getElementById('queryImage').src='queryImage'; + document.getElementById('objId').value=''; + document.getElementById('objId').name="disabled"; + } + else { + document.getElementById('advSearch').style.display = ''; + //document.getElementById('comboInfo').style.display = ''; + document.getElementById('queryImage').src=imageURL; + document.getElementById('objId').value=objectID; + document.getElementById('objId').name="id"; + + //document.getElementById('imageQueryCheckbox').checked='checked'; + document.getElementById('objId').name="id"; + document.getElementById('queryImage').style.display = ''; + + if (document.getElementById('imageToUpload') != null) { + document.getElementById('imageToUpload').value=""; + } + } +// if (imageURL != "null" && imageURL != "" && imageURL == objectID) { +// document.getElementById('objId').name="url"; +// } +} + +function imageQuery() { + //alert(imageURL + " - " + objectID); + if (!document.getElementById('imageQueryCheckbox').checked) { + document.getElementById('objId').name="disabled"; + document.getElementById('queryImage').style.display = 'none'; + } + else { + document.getElementById('objId').name="id"; + document.getElementById('queryImage').style.display = ''; + } +} + +function changeQueryBySampleMod(mode) { + if (mode == "url") { + document.getElementById("uploadText").style.display = 'none'; + document.getElementById("uploadLink").style.display = ''; + document.getElementById("urlText").style.display = ''; + document.getElementById("urlLink").style.display = 'none'; + document.getElementById("imageToUpload").style.display = 'none'; + document.getElementById("urlToUpload").style.display = ''; + document.getElementById("imageToUpload").value = ''; + +// document.getElementById("imageToUpload").type="text"; +// document.getElementById("imageToUpload").name="url"; +// document.getElementById("imageToUpload").size="49"; + document.getElementById("searchbar").action="./searchByURL" + document.getElementById("searchbar").enctype=""; + document.getElementById("searchbar").method="GET"; + + + } else { + document.getElementById("uploadText").style.display = ''; + document.getElementById("uploadLink").style.display = 'none'; + document.getElementById("urlText").style.display = 'none'; + document.getElementById("urlLink").style.display = ''; + + document.getElementById("urlToUpload").style.display = 'none'; + document.getElementById("imageToUpload").style.display = ''; + document.getElementById("urlToUpload").value = ''; + +// document.getElementById("imageToUpload").type="file"; +// document.getElementById("imageToUpload").name="imgFile"; +// document.getElementById("imageToUpload").size="38"; + + document.getElementById("searchbar").action="./searchByImg" + document.getElementById("searchbar").enctype="multipart/form-data"; + document.getElementById("searchbar").method="POST"; + } +} + +function trim(str) { + return str.replace(/^\s\s*/, '').replace(/\s\s*$/, ''); +} + +function getWindowHeight() { + var windowHeight = 0; + if (typeof(window.innerHeight) == 'number') { + windowHeight = window.innerHeight; + } + else { + if (document.documentElement && document.documentElement.clientHeight) { + windowHeight = document.documentElement.clientHeight; + } + else { + if (document.body && document.body.clientHeight) { + windowHeight = document.body.clientHeight; + } + } + } + return windowHeight; +} + +function getRandomInt(min, max) { + return Math.floor(Math.random() * (max - min + 1) + min); +} +