Update templates/TestingMeasurement.html
Browse files- templates/TestingMeasurement.html +163 -11
templates/TestingMeasurement.html
CHANGED
|
@@ -190,7 +190,10 @@
|
|
| 190 |
</div>
|
| 191 |
|
| 192 |
<div id ="saveOPdiv">
|
| 193 |
-
<button id="measureADRbutton">Measure using ADR</button>
|
|
|
|
|
|
|
|
|
|
| 194 |
<script src="https://cdn.lordicon.com/bhenfmcm.js"></script>
|
| 195 |
<lord-icon
|
| 196 |
src="https://cdn.lordicon.com/ynwbvguu.json"
|
|
@@ -794,7 +797,7 @@
|
|
| 794 |
|
| 795 |
///////////////////////////////////////////////BEGIN JS CODE//////////////////////////////////////////////////
|
| 796 |
|
| 797 |
-
var ActiveSections=['2.1','2.6','2.7','2.8','3.2','3.3']
|
| 798 |
|
| 799 |
var menuItems = document.querySelectorAll("#UserGuidemenuOptions li");
|
| 800 |
|
|
@@ -1338,6 +1341,19 @@ function downloadPdf(pdfname,downloadPDFName) {
|
|
| 1338 |
.catch(error => console.error('Error fetching PDF:', error));
|
| 1339 |
}
|
| 1340 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1341 |
function downloadPDFfromLink(pdfLinksent, downloadPDFName) {
|
| 1342 |
const encodedURL = encodeURIComponent(pdfLinksent);
|
| 1343 |
if (document.getElementById('downloadPdfbutton')){
|
|
@@ -1751,13 +1767,22 @@ var doorSchedulePDF;
|
|
| 1751 |
chooseFirstdrpdwn();
|
| 1752 |
|
| 1753 |
|
| 1754 |
-
|
| 1755 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1756 |
if (sections.value.startsWith('3.2') || sections.value.startsWith('3.3') || sections.value.startsWith('2.7') ){
|
| 1757 |
document.getElementById('dxfdiv').removeAttribute('hidden');
|
| 1758 |
document.getElementById('pdftodxfFile').setAttribute('required',true)
|
| 1759 |
}
|
| 1760 |
|
|
|
|
|
|
|
| 1761 |
else{
|
| 1762 |
document.getElementById('dxfdiv').setAttribute('hidden',true)
|
| 1763 |
if (sections.value.startsWith('2.6') ||sections.value.startsWith('2.8')){
|
|
@@ -1989,6 +2014,7 @@ var doorSchedulePDF;
|
|
| 1989 |
document.getElementById("relvselectid").classList.remove("disabled");
|
| 1990 |
document.getElementById("relvoverlay").style.display = "none";
|
| 1991 |
}
|
|
|
|
| 1992 |
}
|
| 1993 |
//___________________________________________________________________________________________________________
|
| 1994 |
//___________________________________________________________________________________________________________
|
|
@@ -2239,12 +2265,6 @@ function getData(form) {
|
|
| 2239 |
|
| 2240 |
document.getElementById("loading").hidden = false;
|
| 2241 |
|
| 2242 |
-
document.getElementById('measureADRbutton').setAttribute('disabled',true);
|
| 2243 |
-
document.getElementById('measureADRbutton').style.cursor='not-allowed';
|
| 2244 |
-
document.getElementById('measureADRbutton').style.boxShadow = 'none';
|
| 2245 |
-
document.getElementById('measureADRbutton').style.color = 'white';
|
| 2246 |
-
document.getElementById('measureADRbutton').style.backgroundColor="rgb(154,152,152)";
|
| 2247 |
-
|
| 2248 |
|
| 2249 |
var formData = new FormData(form);
|
| 2250 |
|
|
@@ -2261,7 +2281,20 @@ function getData(form) {
|
|
| 2261 |
// iterate through entries...
|
| 2262 |
tomeasureproj=formvalues['projlinkTesting']; //proj name
|
| 2263 |
|
| 2264 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2265 |
if( formvalues['selectprojs'].startsWith('3.2') || formvalues['selectprojs'].startsWith('3.3') || formvalues['selectprojs'].startsWith('2.7') ){
|
| 2266 |
ratio1=1
|
| 2267 |
ratio2=prminpixels/(formvalues['prmRatio']/ratioPunit);
|
|
@@ -2620,7 +2653,126 @@ function getData(form) {
|
|
| 2620 |
// /////////////////////////
|
| 2621 |
});
|
| 2622 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2623 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2624 |
|
| 2625 |
}
|
| 2626 |
//___________________________________________________________________________________________________________
|
|
|
|
| 190 |
</div>
|
| 191 |
|
| 192 |
<div id ="saveOPdiv">
|
| 193 |
+
<button id="measureADRbutton" hidden >Measure using ADR</button>
|
| 194 |
+
<button id="Newtablebutton" hidden >Table Detect</button>
|
| 195 |
+
|
| 196 |
+
<input type="button" value="Download Tables" id="downloadbutton" hidden style="display: none;" />
|
| 197 |
<script src="https://cdn.lordicon.com/bhenfmcm.js"></script>
|
| 198 |
<lord-icon
|
| 199 |
src="https://cdn.lordicon.com/ynwbvguu.json"
|
|
|
|
| 797 |
|
| 798 |
///////////////////////////////////////////////BEGIN JS CODE//////////////////////////////////////////////////
|
| 799 |
|
| 800 |
+
var ActiveSections=['2.1','2.6','2.7','2.8','3.2','3.3','4.0']
|
| 801 |
|
| 802 |
var menuItems = document.querySelectorAll("#UserGuidemenuOptions li");
|
| 803 |
|
|
|
|
| 1341 |
.catch(error => console.error('Error fetching PDF:', error));
|
| 1342 |
}
|
| 1343 |
|
| 1344 |
+
function downloadExcel(blob,downloadPDFName) {
|
| 1345 |
+
|
| 1346 |
+
const url = URL.createObjectURL(blob);
|
| 1347 |
+
const a = document.createElement('a');
|
| 1348 |
+
a.style.display = 'none';
|
| 1349 |
+
a.href = url;
|
| 1350 |
+
a.download = downloadPDFName;
|
| 1351 |
+
document.body.appendChild(a);
|
| 1352 |
+
a.click();
|
| 1353 |
+
document.body.removeChild(a);
|
| 1354 |
+
URL.revokeObjectURL(url);
|
| 1355 |
+
|
| 1356 |
+
}
|
| 1357 |
function downloadPDFfromLink(pdfLinksent, downloadPDFName) {
|
| 1358 |
const encodedURL = encodeURIComponent(pdfLinksent);
|
| 1359 |
if (document.getElementById('downloadPdfbutton')){
|
|
|
|
| 1767 |
chooseFirstdrpdwn();
|
| 1768 |
|
| 1769 |
|
| 1770 |
+
document.getElementById('refreshDropboxButtonID').style.display = "block";
|
| 1771 |
+
document.getElementById("all").style.display = "none";
|
| 1772 |
+
|
| 1773 |
+
if (sections.value.startsWith('4.0') ){
|
| 1774 |
+
document.getElementById('Newtablebutton').removeAttribute('hidden');
|
| 1775 |
+
|
| 1776 |
+
}
|
| 1777 |
+
else{
|
| 1778 |
+
document.getElementById('measureADRbutton').removeAttribute('hidden');
|
| 1779 |
if (sections.value.startsWith('3.2') || sections.value.startsWith('3.3') || sections.value.startsWith('2.7') ){
|
| 1780 |
document.getElementById('dxfdiv').removeAttribute('hidden');
|
| 1781 |
document.getElementById('pdftodxfFile').setAttribute('required',true)
|
| 1782 |
}
|
| 1783 |
|
| 1784 |
+
|
| 1785 |
+
|
| 1786 |
else{
|
| 1787 |
document.getElementById('dxfdiv').setAttribute('hidden',true)
|
| 1788 |
if (sections.value.startsWith('2.6') ||sections.value.startsWith('2.8')){
|
|
|
|
| 2014 |
document.getElementById("relvselectid").classList.remove("disabled");
|
| 2015 |
document.getElementById("relvoverlay").style.display = "none";
|
| 2016 |
}
|
| 2017 |
+
}
|
| 2018 |
}
|
| 2019 |
//___________________________________________________________________________________________________________
|
| 2020 |
//___________________________________________________________________________________________________________
|
|
|
|
| 2265 |
|
| 2266 |
document.getElementById("loading").hidden = false;
|
| 2267 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2268 |
|
| 2269 |
var formData = new FormData(form);
|
| 2270 |
|
|
|
|
| 2281 |
// iterate through entries...
|
| 2282 |
tomeasureproj=formvalues['projlinkTesting']; //proj name
|
| 2283 |
|
| 2284 |
+
if( formvalues['selectprojs'].startsWith('4.0') ){
|
| 2285 |
+
document.getElementById('Newtablebutton').setAttribute('disabled',true);
|
| 2286 |
+
document.getElementById('Newtablebutton').style.cursor='not-allowed';
|
| 2287 |
+
document.getElementById('Newtablebutton').style.boxShadow = 'none';
|
| 2288 |
+
document.getElementById('Newtablebutton').style.color = 'white';
|
| 2289 |
+
document.getElementById('Newtablebutton').style.backgroundColor="rgb(154,152,152)";
|
| 2290 |
+
}
|
| 2291 |
+
else{
|
| 2292 |
+
document.getElementById('measureADRbutton').setAttribute('disabled',true);
|
| 2293 |
+
document.getElementById('measureADRbutton').style.cursor='not-allowed';
|
| 2294 |
+
document.getElementById('measureADRbutton').style.boxShadow = 'none';
|
| 2295 |
+
document.getElementById('measureADRbutton').style.color = 'white';
|
| 2296 |
+
document.getElementById('measureADRbutton').style.backgroundColor="rgb(154,152,152)";
|
| 2297 |
+
}
|
| 2298 |
if( formvalues['selectprojs'].startsWith('3.2') || formvalues['selectprojs'].startsWith('3.3') || formvalues['selectprojs'].startsWith('2.7') ){
|
| 2299 |
ratio1=1
|
| 2300 |
ratio2=prminpixels/(formvalues['prmRatio']/ratioPunit);
|
|
|
|
| 2653 |
// /////////////////////////
|
| 2654 |
});
|
| 2655 |
}
|
| 2656 |
+
if (formvalues['selectprojs'].startsWith('4.0'))
|
| 2657 |
+
{
|
| 2658 |
+
tomeasureproj=formvalues['projlinkTesting']; //proj name
|
| 2659 |
+
answers.push(tomeasureproj);
|
| 2660 |
+
formData.append('answers',JSON.stringify(answers))
|
| 2661 |
|
| 2662 |
+
$.ajaxTransport("+binary", function(options, originalOptions, jqXHR) {
|
| 2663 |
+
if (window.FormData && (
|
| 2664 |
+
(options.dataType && options.dataType === "binary") ||
|
| 2665 |
+
(options.data && ((window.ArrayBuffer && options.data instanceof ArrayBuffer) ||
|
| 2666 |
+
(window.Blob && options.data instanceof Blob)))
|
| 2667 |
+
)) {
|
| 2668 |
+
return {
|
| 2669 |
+
send: function(headers, callback) {
|
| 2670 |
+
const xhr = new XMLHttpRequest();
|
| 2671 |
+
xhr.open(options.type, options.url, options.async ?? true,
|
| 2672 |
+
options.username, options.password);
|
| 2673 |
+
// Apply custom fields like responseType
|
| 2674 |
+
xhr.responseType = options.responseType || "blob";
|
| 2675 |
+
if (options.xhrFields) {
|
| 2676 |
+
for (const field in options.xhrFields) {
|
| 2677 |
+
xhr[field] = options.xhrFields[field];
|
| 2678 |
+
}
|
| 2679 |
+
}
|
| 2680 |
+
xhr.onload = function() {
|
| 2681 |
+
// Package the response as the declared dataType
|
| 2682 |
+
const data = {};
|
| 2683 |
+
data[options.dataType] = xhr.response;
|
| 2684 |
+
callback(xhr.status, xhr.statusText, data, xhr.getAllResponseHeaders());
|
| 2685 |
+
};
|
| 2686 |
+
xhr.send(options.data || null);
|
| 2687 |
+
},
|
| 2688 |
+
abort: function() {
|
| 2689 |
+
jqXHR.abort();
|
| 2690 |
+
}
|
| 2691 |
+
};
|
| 2692 |
+
}
|
| 2693 |
+
});
|
| 2694 |
+
|
| 2695 |
+
$.ajax({
|
| 2696 |
+
// type: "POST",
|
| 2697 |
+
// url: "/savedetectedtables/",
|
| 2698 |
+
// // contentType: "application/json", // set content type header to use Flask response.get_json()
|
| 2699 |
+
// data: formData,// convert data/object to JSON to send
|
| 2700 |
+
// processData: false, // Prevent jQuery from automatically processing the data
|
| 2701 |
+
// contentType: false,
|
| 2702 |
+
// xhr: function() {
|
| 2703 |
+
// const x = $.ajaxSettings.xhr();
|
| 2704 |
+
// x.responseType = "blob"; // set blob mode
|
| 2705 |
+
// return x;
|
| 2706 |
+
// },
|
| 2707 |
+
url: "/savedetectedtables/",
|
| 2708 |
+
method: "POST",
|
| 2709 |
+
data: formData,
|
| 2710 |
+
processData: false,
|
| 2711 |
+
contentType: false,
|
| 2712 |
+
dataType: 'binary', // match your transport
|
| 2713 |
+
responseType: 'blob', // tell the transport to use blob
|
| 2714 |
+
|
| 2715 |
+
success: function(blob) {
|
| 2716 |
+
console.log(blob);
|
| 2717 |
+
// downloadPdf(data,'detected_tables.xlsx')
|
| 2718 |
+
console.log('typeof(blob) = ',typeof(blob))
|
| 2719 |
+
|
| 2720 |
+
if (!blob || blob.size === 0) {
|
| 2721 |
+
// empty response → show your “no tables” popup
|
| 2722 |
+
PopupElement.textContent = "No tables detected in the document.";
|
| 2723 |
+
ShowPopUp();
|
| 2724 |
+
return;
|
| 2725 |
+
}
|
| 2726 |
+
else{
|
| 2727 |
+
console.log("gowa el else")
|
| 2728 |
+
downloadExcel(blob,'detected_tables.xlsx')
|
| 2729 |
+
|
| 2730 |
+
}
|
| 2731 |
+
|
| 2732 |
+
|
| 2733 |
+
|
| 2734 |
+
|
| 2735 |
+
|
| 2736 |
+
},
|
| 2737 |
+
error: function(err) {
|
| 2738 |
+
var TopTextModal = document.getElementById("TopTextModal");
|
| 2739 |
+
TopTextModal.textContent='Error'
|
| 2740 |
+
PopupElement.textContent='Error occured. Refresh and try again. If the error continues, please contact the ADR team to fix it. ';
|
| 2741 |
+
ShowPopUp();
|
| 2742 |
+
|
| 2743 |
+
}
|
| 2744 |
+
})
|
| 2745 |
+
.done(function(data){
|
| 2746 |
+
console.log(data)
|
| 2747 |
+
document.getElementById("loading").hidden = true;
|
| 2748 |
+
document.getElementById('Newtablebutton').removeAttribute('disabled');
|
| 2749 |
+
document.getElementById('Newtablebutton').style.cursor='pointer';
|
| 2750 |
+
document.getElementById('Newtablebutton').style.color = 'white';
|
| 2751 |
+
document.getElementById('Newtablebutton').style.backgroundColor="#16c72e";
|
| 2752 |
+
document.getElementById('Newtablebutton').style.padding='10px 102px';
|
| 2753 |
+
document.getElementById('Newtablebutton').addEventListener('mouseover',function(){
|
| 2754 |
+
document.getElementById('Newtablebutton').style.color='black';
|
| 2755 |
+
document.getElementById('Newtablebutton').style.boxShadow=' 0 0 8px 2px #16c72e';
|
| 2756 |
+
})
|
| 2757 |
+
document.getElementById('Newtablebutton').addEventListener('mouseout',function(){
|
| 2758 |
+
document.getElementById('Newtablebutton').style.color='white';
|
| 2759 |
+
document.getElementById('Newtablebutton').style.boxShadow='none';
|
| 2760 |
+
});
|
| 2761 |
+
|
| 2762 |
+
// downloadPdf(data,'detected_tables.xlsx')
|
| 2763 |
+
// downloadPdf(blob,'detected_tables.xlsx')
|
| 2764 |
+
// document.getElementById('downloadbutton').hidden = false;
|
| 2765 |
+
document.getElementById('downloadbutton').style.display = 'inline-block';
|
| 2766 |
+
// document.getElementById('downloadbutton').onclick=downloadPdf(data,'detected_tables.xlsx')
|
| 2767 |
+
const btn = document.getElementById('downloadbutton');
|
| 2768 |
+
btn.addEventListener('click', () => {
|
| 2769 |
+
downloadExcel(data, 'detected_tables.xlsx');
|
| 2770 |
+
});
|
| 2771 |
+
|
| 2772 |
+
|
| 2773 |
+
})
|
| 2774 |
+
|
| 2775 |
+
}
|
| 2776 |
|
| 2777 |
}
|
| 2778 |
//___________________________________________________________________________________________________________
|