Marthee commited on
Commit
8245187
·
verified ·
1 Parent(s): f765d50

Upload tableDetection.html

Browse files
Files changed (1) hide show
  1. templates/tableDetection.html +1266 -0
templates/tableDetection.html ADDED
@@ -0,0 +1,1266 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 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
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="en" dir="ltr">
3
+ <head>
4
+
5
+ <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
6
+ <link href="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.3/css/select2.min.css" rel="stylesheet"/>
7
+ <script src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.3/js/select2.min.js"></script>
8
+ <script src="https://cdn.plot.ly/plotly-latest.min.js"></script>
9
+
10
+
11
+
12
+ <link rel="stylesheet" href="https://use.typekit.net/zos0ars.css">
13
+ <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
14
+ <link rel="stylesheet" href="static/style.css">
15
+ <link rel="stylesheet" href="static/MenuStyle.css">
16
+ <link rel="stylesheet" href="static/LegendPageStyle.css">
17
+ <link rel="stylesheet" href="static/popups.css">
18
+ <link rel="stylesheet" href="static/IMG-Larger.css">
19
+ <link rel="stylesheet" href="static/searchButton.css">
20
+ <meta charset="utf-8">
21
+ <title>ADR Console</title>
22
+ <link rel = "icon" type = "image/png" sizes = "180x154" href = "static/images/TSAlogoCropped180x154.png">
23
+ <link rel = "icon" type = "image/png" sizes = "32x27" href = "static/images/TSAlogoCropped32x27.png">
24
+ <link rel = "icon" type = "image/png" sizes = "16x14" href = "static/images/TSAlogoCropped16x14.png">
25
+ <link rel = "mask-icon" href = "static/images/TSAlogoCropped180x154.png">
26
+ <link rel = "shortcut icon" href = "static/images/TSAlogoCropped180x154.png">
27
+
28
+ <script src="https://cdn.anychart.com/releases/8.9.0/js/anychart-core.min.js"></script>
29
+ <script src="https://cdn.anychart.com/releases/8.9.0/js/anychart-sunburst.min.js"></script>
30
+ <script src="https://cdn.anychart.com/releases/8.9.0/js/anychart-data-adapter.min.js"></script>
31
+
32
+
33
+
34
+ </head>
35
+ <body >
36
+ <div id="all">
37
+ {% include 'loading.html' %}
38
+ </div>
39
+ <!--Main tab links-->
40
+ <div class="tab" >
41
+ <div class="container" id="toggle">
42
+ <div class="bar1"></div>
43
+ <div class="bar2"></div>
44
+ <div class="bar3"></div>
45
+ </div>
46
+
47
+ <button class="tablinks" id="pagetitle" onclick="openTab(event, 'home')">ADR Console <i class="fa fa-home" > </i></button>
48
+ <!-- <button class="tablinks" id="LegendHist" onclick="openTab(event, 'legends')">Legends History <i class="fa fa-caret-down"></i></button> -->
49
+ <a class="tablinks" id="LegendHist" href="{{ url_for('legendDirectory') }}">Legends History <i class="fa fa-caret-down"></i></a>
50
+ <button class="dropbtn" onclick="userguideclick()"><img id="infoImg" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAACXBIWXMAAAsTAAALEwEAmpwYAAAHz0lEQVR4nNVbW0xVVxC9SAEfNPGRCJICGoWKR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gsAtr4VFjHZihbKxBITE42Dji6J+cDbt28jPz/f1fYbzk2qNQD40hMK0N14bFNCOJbAWkG4h6rTyjsIXxWS8JbzgI3HULdDOGeC28Q97+BlLoX9MQWAeLPx2K7aqiqj7tdXgtOStDZLK0rwS51Z44RIdJKpxABN8PPWlXdHeGU72M4ErxtjN1YkmqrS09Ol8NbPMLV+QwQgz4ynbeAJz9udjvLWjBkzjHqClFKzfjKjTXAhTrAFS1bQPNmWwl7fUHKM/A27OpjJEZIZUpATnJ8PFwBiAHyt3h0kMNF67tw5oz7PEjVvgExSeD+b4+ryGfP2fIfZ2xcvXqAXYGy/PeKfzVnB3lsztS5uC00gr/KAF5tIAkAi6ypqgtVlMJNT7Hif7w9Ad3otl3145oTDxV9MYDJ30q8/nvY4gK1o5seWjFjon5sASDEruyX5vzrz3XwA6bon+B8RXxEBPsptqAAAAABJRU5ErkJggg=="></button>
51
+ </div>
52
+
53
+
54
+ <div id="mySidebar" class="slide-out">
55
+ <div id="menuOptions">
56
+ <li><a href="{{ url_for('measurementConsoleFn') }}">Measure Plans </a></li>
57
+ <li><a href="{{ url_for('searchDocument') }}">Search in Documents</a></li>
58
+ <li onclick=redirectOmarSearch()>Table Detection</li>
59
+
60
+ </div>
61
+ </div>
62
+
63
+ <form method="post" id="myForm" enctype="multipart/form-data">
64
+
65
+
66
+ <div id ="">
67
+ <select name="selectproj" class="selectionsProj" id="selectionsProjid" required > </select>
68
+ </div>
69
+
70
+ <div id ="projectpart">
71
+ <select name="selectprojp" class="selectionsProjp" id="selectionsProjpid" required> </select>
72
+ </div>
73
+
74
+ <div id ="projectsection">
75
+ <select name="selectprojs" class="selectionsProjs" onchange=getproj() required> </select>
76
+ </div>
77
+
78
+
79
+ <div id ="tomeasurediv">
80
+ <div>
81
+ <label id="measureLabel">Document To Measure</label>
82
+ <input type="search" onkeyup=filterFunction(this.id) id="tomeasureSearchInput">
83
+ <!-- <button id="refreshDropboxButtonID"></button> -->
84
+ <i hidden class="fa fa-dropbox fa-lg" id="refreshDropboxButtonID">
85
+ <span class="dropboxtip">The console updates projects retrieved from Dropbox automatically at 9:00 am and 9:00 p.m. If you need to access any projects in between, just click on this button. Please note that it will refresh the files related to the project you chose only.</span> </i>
86
+
87
+ </div>
88
+ <div id="measureCheckbox">
89
+ <!-- <select style="margin-left: -1%;" hidden name="measureselectname" id="measureselectid" multiple size="5"></select> -->
90
+ <div id="measureContainer" hidden required></div>
91
+ </div>
92
+ </div>
93
+
94
+ <button id="Newtablebutton">Table Detect</button>
95
+
96
+ </form>
97
+
98
+ <!-- <button id="downloadbutton" hidden>Download Tables</button> -->
99
+
100
+ <input type="button" value="Download Tables" id="downloadbutton" style="display: none;" />
101
+
102
+
103
+
104
+
105
+ <div id="progressBar" hidden>
106
+ <div id="progress">0%</div>
107
+ </div>
108
+
109
+ <!-- Modal popup box -->
110
+ <div id="mpopupBox" class="mpopup" name="tobeclosed">
111
+ <!-- Modal content -->
112
+ <div class="modal-content">
113
+ <div class="modal-header">
114
+ <button type="button" class="closeModal" data-dismiss="modal">&times;</button>
115
+ <h2 id="TopTextModal">Error</h2>
116
+ </div>
117
+ <div class="modal-body">
118
+ <p id="modal-bodyText">
119
+ </p>
120
+ <br>
121
+ </div>
122
+
123
+ </div>
124
+ </div>
125
+
126
+ <!-- Modal popup box -->
127
+ <div id="mpopupBox" class="mpopup" name="tobeclosed">
128
+ <!-- Modal content -->
129
+ <div class="modal-content">
130
+ <div class="modal-header">
131
+ <button type="button" class="closeModal" data-dismiss="modal">&times;</button>
132
+ <h2 id="TopTextModal">Error</h2>
133
+ </div>
134
+ <div class="modal-body">
135
+ <p id="modal-bodyText">
136
+ </p>
137
+ <br>
138
+ </div>
139
+
140
+ </div>
141
+ </div>
142
+
143
+ <div id="loading" hidden> </div>
144
+
145
+
146
+
147
+ </body>
148
+ </html>
149
+
150
+ <script>
151
+
152
+
153
+
154
+ var closeButtons = document.querySelectorAll(".closeModal");
155
+ var allCloseDivs = document.getElementsByName("tobeclosed");
156
+
157
+ closeButtons.forEach(function(button) {
158
+ button.addEventListener("click", function() {
159
+ allCloseDivs.forEach(function(div) {
160
+ div.style.display = "none";
161
+ });
162
+ });
163
+ });
164
+
165
+ document.getElementById("myForm").addEventListener("submit", function (e) {
166
+ e.preventDefault(); // Prevent form submission
167
+ let isChecked = document.querySelector('input[name="measureCheckbox"]:checked') !== null;
168
+ // let sectionNumber = projsec.value; // Ensure projsec is defined
169
+ // let isRelvClicked = document.querySelector(".relv-item[style*='background-color']") !== null;
170
+
171
+ let TopTextModal = document.getElementById("TopTextModal");
172
+ TopTextModal.textContent = "Warning: Missing Inputs";
173
+ if (!isChecked){
174
+ PopupElement.textContent = "Please select at least one project from 'Documents to Measure' before proceeding!";
175
+ ShowPopUp();
176
+ return;
177
+ }
178
+
179
+
180
+
181
+ // If validation passes, proceed with form submission
182
+ getData(e.target);
183
+ });
184
+
185
+
186
+ function getData(form) {
187
+
188
+ document.getElementById("loading").hidden = false;
189
+
190
+ document.getElementById('Newtablebutton').setAttribute('disabled',true);
191
+ document.getElementById('Newtablebutton').style.cursor='not-allowed';
192
+ document.getElementById('Newtablebutton').style.boxShadow = 'none';
193
+ document.getElementById('Newtablebutton').style.color = 'white';
194
+ document.getElementById('Newtablebutton').style.backgroundColor="rgb(154,152,152)";
195
+
196
+
197
+ var formData = new FormData(form);
198
+
199
+
200
+
201
+
202
+ // clearInterval(interval)
203
+ val=0;
204
+ answers=[];
205
+ tomeasureproj='';
206
+ pdfpath=[];
207
+ formvalues=Object.fromEntries(formData);
208
+
209
+ tomeasureproj=formvalues['measureCheckbox']; //proj name
210
+
211
+ answers.push(tomeasureproj);
212
+ formData.append('answers',JSON.stringify(answers))
213
+
214
+ // Place this once in your JS before any $.ajax calls
215
+ $.ajaxTransport("+binary", function(options, originalOptions, jqXHR) {
216
+ if (window.FormData && (
217
+ (options.dataType && options.dataType === "binary") ||
218
+ (options.data && ((window.ArrayBuffer && options.data instanceof ArrayBuffer) ||
219
+ (window.Blob && options.data instanceof Blob)))
220
+ )) {
221
+ return {
222
+ send: function(headers, callback) {
223
+ const xhr = new XMLHttpRequest();
224
+ xhr.open(options.type, options.url, options.async ?? true,
225
+ options.username, options.password);
226
+ // Apply custom fields like responseType
227
+ xhr.responseType = options.responseType || "blob";
228
+ if (options.xhrFields) {
229
+ for (const field in options.xhrFields) {
230
+ xhr[field] = options.xhrFields[field];
231
+ }
232
+ }
233
+ xhr.onload = function() {
234
+ // Package the response as the declared dataType
235
+ const data = {};
236
+ data[options.dataType] = xhr.response;
237
+ callback(xhr.status, xhr.statusText, data, xhr.getAllResponseHeaders());
238
+ };
239
+ xhr.send(options.data || null);
240
+ },
241
+ abort: function() {
242
+ jqXHR.abort();
243
+ }
244
+ };
245
+ }
246
+ });
247
+
248
+ $.ajax({
249
+ // type: "POST",
250
+ // url: "/savedetectedtables/",
251
+ // // contentType: "application/json", // set content type header to use Flask response.get_json()
252
+ // data: formData,// convert data/object to JSON to send
253
+ // processData: false, // Prevent jQuery from automatically processing the data
254
+ // contentType: false,
255
+ // xhr: function() {
256
+ // const x = $.ajaxSettings.xhr();
257
+ // x.responseType = "blob"; // set blob mode
258
+ // return x;
259
+ // },
260
+ url: "/savedetectedtables/",
261
+ method: "POST",
262
+ data: formData,
263
+ processData: false,
264
+ contentType: false,
265
+ dataType: 'binary', // match your transport
266
+ responseType: 'blob', // tell the transport to use blob
267
+
268
+ success: function(blob) {
269
+ console.log(blob);
270
+ // downloadPdf(data,'detected_tables.xlsx')
271
+ console.log('typeof(blob) = ',typeof(blob))
272
+
273
+ if (!blob || blob.size === 0) {
274
+ // empty response → show your “no tables” popup
275
+ PopupElement.textContent = "No tables detected in the document.";
276
+ ShowPopUp();
277
+ return;
278
+ }
279
+ else{
280
+ console.log("gowa el else")
281
+ downloadPdf(blob,'detected_tables.xlsx')
282
+
283
+ }
284
+
285
+
286
+
287
+
288
+
289
+ },
290
+ error: function(err) {
291
+ var TopTextModal = document.getElementById("TopTextModal");
292
+ TopTextModal.textContent='Error'
293
+ PopupElement.textContent='Error occured. Refresh and try again. If the error continues, please contact the ADR team to fix it. ';
294
+ ShowPopUp();
295
+
296
+ }
297
+ })
298
+ .done(function(data){
299
+ console.log(data)
300
+ document.getElementById("loading").hidden = true;
301
+ document.getElementById('Newtablebutton').removeAttribute('disabled');
302
+ document.getElementById('Newtablebutton').style.cursor='pointer';
303
+ document.getElementById('Newtablebutton').style.color = 'white';
304
+ document.getElementById('Newtablebutton').style.backgroundColor="#16c72e";
305
+ document.getElementById('Newtablebutton').style.padding='10px 102px';
306
+ document.getElementById('Newtablebutton').addEventListener('mouseover',function(){
307
+ document.getElementById('Newtablebutton').style.color='black';
308
+ document.getElementById('Newtablebutton').style.boxShadow=' 0 0 8px 2px #16c72e';
309
+ })
310
+ document.getElementById('Newtablebutton').addEventListener('mouseout',function(){
311
+ document.getElementById('Newtablebutton').style.color='white';
312
+ document.getElementById('Newtablebutton').style.boxShadow='none';
313
+ });
314
+
315
+ // downloadPdf(data,'detected_tables.xlsx')
316
+ // downloadPdf(blob,'detected_tables.xlsx')
317
+ // document.getElementById('downloadbutton').hidden = false;
318
+ document.getElementById('downloadbutton').style.display = 'inline-block';
319
+ // document.getElementById('downloadbutton').onclick=downloadPdf(data,'detected_tables.xlsx')
320
+ const btn = document.getElementById('downloadbutton');
321
+ btn.addEventListener('click', () => {
322
+ downloadPdf(data, 'detected_tables.xlsx');
323
+ });
324
+
325
+
326
+ })
327
+
328
+
329
+ };
330
+
331
+
332
+
333
+
334
+ document.getElementById('Newtablebutton').onclick= function()
335
+ {
336
+ if (!measSelect.value) {
337
+ measSelect.style.boxShadow = '0 0 8px 2px rgb(255, 0, 0)';
338
+ measSelect.setAttribute("required", "")
339
+ }
340
+ }
341
+ document.getElementById('Newtablebutton').addEventListener('click',function(){
342
+ if (!document.getElementsByClassName('selectionsProj')[0].value)
343
+ document.getElementsByClassName('selectionsProj')[0].style.boxShadow='0 0 8px 2px rgb(255, 0, 0)';
344
+ if (!document.getElementsByClassName('selectionsProjp')[0].value)
345
+ document.getElementsByClassName('selectionsProjp')[0].style.boxShadow='0 0 8px 2px rgb(255, 0, 0)';
346
+ if (!document.getElementsByClassName('selectionsProjs')[0].value)
347
+ document.getElementsByClassName('selectionsProjs')[0].style.boxShadow='0 0 8px 2px rgb(255, 0, 0)';
348
+ //___________________________________________________________________________________________________________
349
+ //___________________________________________________________________________________________________________
350
+ if (document.getElementById('imgContainer')) {
351
+ document.getElementById('imgContainer').innerHTML = '';
352
+ }
353
+ });
354
+ var mpopup = document.getElementById('mpopupBox');
355
+ // Select close action element
356
+ // var close = document.getElementsByClassName("closeModal")[0];
357
+ function ShowPopUp(){
358
+ // Open modal
359
+ mpopup.style.display = "block";
360
+ }
361
+ // Close modal once close element is clicked
362
+ // close.onclick = function() {
363
+ // mpopup.style.display = "none";
364
+ // };
365
+ // Close modal when user clicks outside of the modal box
366
+ window.onclick = function(event) {
367
+ if (event.target == mpopup) {
368
+ mpopup.style.display = "none";
369
+ }
370
+ };
371
+ // closeDialog.onclick = function() {
372
+ // dialog_container.style.display = "none";
373
+ // };
374
+
375
+ var dialog_container = document.getElementById('dialog-container');
376
+ // Select close action element
377
+ // var closeDialog = document.getElementsByClassName("closeModal")[0];
378
+ function ShowPopUpWarning(){
379
+ // Open modal
380
+ dialog_container.style.display = "block";
381
+ }
382
+ // Close modal once close element is clicked
383
+ // closeDialog.onclick = function() {
384
+ // console.log()
385
+ // dialog_container.style.display = "none";
386
+ // };
387
+ // Close modal when user clicks outside of the modal box
388
+ window.onclick = function(event) {
389
+ if (event.target == dialog_container) {
390
+ dialog_container.style.display = "none";
391
+ }
392
+ };
393
+
394
+ PopupElement=document.getElementById('modal-bodyText');
395
+
396
+ var ActiveSections=['1.0','2.1','2.6','2.7','2.8','3.2','3.3']
397
+
398
+ var menuItems = document.querySelectorAll("#UserGuidemenuOptions li");
399
+
400
+ menuItems.forEach(function (item) {
401
+ // Extract the section number (first part of the text)
402
+ var sectionNumber = item.textContent.trim().split(" ")[0];
403
+
404
+ // If the section is not in ActiveSections, disable it
405
+ if (!ActiveSections.includes(sectionNumber)) {
406
+ item.id = "disabledSection"; // Assign ID
407
+ item.style.color = "#bdbcbc"; // Greyed-out text
408
+ item.style.cursor = "not-allowed"; // Change cursor
409
+ item.onclick = null; // Disable clicking
410
+ }
411
+ });
412
+
413
+
414
+ function updateProgressBar(value) {
415
+ const progressBar = document.getElementById('progress');
416
+ progressBar.style.width = value + '%';
417
+ progressBar.innerText = Math.round(value) + '%';
418
+ }
419
+
420
+ function redirectOmarSearch(){
421
+ $toggle.classList.toggle("change");
422
+ var isOpen = $mySidebar.classList.contains('slide-out');
423
+ $mySidebar.setAttribute('class', isOpen ? 'slide-in' : 'slide-out');
424
+ w3_close()
425
+
426
+ }
427
+
428
+ sectionSelect=document.getElementById('section-select');
429
+ $(sectionSelect).select2({
430
+ closeOnSelect: true,
431
+ width:'20ch'
432
+
433
+ });
434
+ // add project names to first dropdown from google sheet
435
+ firstdropdown=document.getElementsByClassName('selectionsProj')[0];
436
+ seconddropdown=document.getElementsByClassName('selectionsProjp')[0];
437
+ thirddropdown=document.getElementsByClassName('selectionsProjs')[0];
438
+
439
+
440
+ $(firstdropdown).select2({
441
+ placeholder:'Projects',
442
+ closeOnSelect: true,
443
+ width:'51ch'
444
+
445
+ });
446
+
447
+ $(seconddropdown).select2({
448
+ placeholder:'Project Parts',
449
+ closeOnSelect: true,
450
+ width:'51ch'
451
+ });
452
+ $(thirddropdown).select2({
453
+ placeholder:'Sections',
454
+ closeOnSelect: true,
455
+ width:'51ch'
456
+ });
457
+ var measSelect = document.getElementById("measureselectid");
458
+
459
+ // var relvSelect = document.getElementById("relvselectid");
460
+ document.getElementById("all").style.display = "block";
461
+
462
+ PrjNamesArray=[];
463
+ PrjPartsArray=[];
464
+ PrjSectionsArray=[];
465
+ var partsArrwithID=[];
466
+ var firstDpwnValue;
467
+ var prjids=[]
468
+
469
+ displayprjnames()
470
+ function displayprjnames(){
471
+
472
+ var eventSource = new EventSource('/getprojectnames/');
473
+ document.getElementById('progressBar').removeAttribute('hidden')
474
+ document.getElementById('progressBar').style.display='block';
475
+ eventSource.onmessage = function (event) {
476
+ var progress = parseInt(event.data); // Progress value from Flask
477
+ if (progress <= 100) {
478
+ console.log(progress); // Log progress for debugging
479
+ document.getElementById('progress').style.width = progress + '%';
480
+ document.getElementById('progress').textContent = progress + '%';
481
+ } else {
482
+ // Final data handling when progress reaches 100%
483
+ console.log('Process completed!');
484
+
485
+ // Parse and handle the final response data (documentsToMeasure, RelevantDocuments, extracted_path)
486
+ var data = JSON.parse(event.data); // Assuming the result is a JSON array
487
+ console.log('Final result:', data);
488
+ // You can use this data to update your page or handle it accordingly
489
+
490
+ eventSource.close(); // Close the connection when finished
491
+ document.getElementById('progressBar').setAttribute('hidden',true)
492
+ document.getElementById('progressBar').style.display='none';
493
+ document.getElementById('progress').style.width = '0%'; // Reset progress for the next process
494
+ document.getElementById('progress').textContent = '0%';
495
+
496
+ document.getElementById("all").style.display = "none";
497
+ prjids=data[1];
498
+ var op0 = document.createElement("OPTION") ;
499
+ op0.text= 'Projects'
500
+ op0.value= "";
501
+ op0.hidden=true;
502
+ firstdropdown.add(op0);
503
+ for (let i=0;i<data[0].length;i++)
504
+ {
505
+ opt=document.createElement("option");
506
+ opt.textContent=data[0][i];
507
+ opt.text=data[0][i];
508
+ firstdropdown.append(opt);
509
+ PrjNamesArray.push(data[0][i]);
510
+ }
511
+
512
+ }
513
+ }
514
+
515
+
516
+ eventSource.onerror = function (error) {
517
+ console.error('Error occurred:', error);
518
+ eventSource.close(); // Close on error
519
+ PopupElement.textContent='Error occured while retrieving the Project Names. Refresh and try again. If the error continues, please contact the ADR team to fix it. ';
520
+ ShowPopUp();
521
+ };
522
+ }
523
+ /*Get chosen value and send to flask to get project parts*/
524
+
525
+ $(firstdropdown).on("change", function (e) {
526
+ console.log('clickeds')
527
+ firstDpwnValue=firstdropdown.value;
528
+ seconddropdown.innerHTML='';
529
+ var op0 = document.createElement("OPTION") ;
530
+ op0.text= 'Project Part'
531
+ op0.value= "";
532
+ op0.hidden=true;
533
+ seconddropdown.add(op0);
534
+ var ii, L = seconddropdown.options.length - 1;
535
+ for(ii = L; ii >= 0; ii--) {
536
+ if (seconddropdown.options[ii].value)
537
+ seconddropdown.remove(ii);
538
+ }
539
+
540
+ displayprojparts(prjids[(firstdropdown.selectedIndex)-1]);
541
+ })
542
+ var partsArrIDsonly=[]
543
+ function displayprojparts(val){
544
+ document.getElementById("all").style.display = "block";
545
+ console.log(val)
546
+ $.get('/getprojectparts/'+JSON.stringify(val))
547
+ .success(function(data){
548
+ document.getElementById("all").style.display = "none";
549
+ partsArrwithID= data[0];
550
+ partsArrIDsonly= data[1];
551
+
552
+ for (let i=0;i<data[0].length;i++)
553
+ {
554
+ opt=document.createElement("option");
555
+ opt.value=data[0][i];
556
+ opt.text=data[0][i];
557
+ seconddropdown.append(opt);
558
+ PrjPartsArray.push(data[0][i]);
559
+
560
+ }
561
+
562
+ })
563
+ .error(function(jqXHR, textStatus, errorThrown) {
564
+ PopupElement.textContent='Error occured while retrieving the Project Parts. Refresh and try again. If the error continues, please contact the ADR team to fix it. ';
565
+ ShowPopUp();
566
+ });
567
+ }
568
+ $(seconddropdown).on("change", function (e) {
569
+ thirddropdown.innerHTML='';
570
+ var op0 = document.createElement("OPTION") ;
571
+ op0.text= 'Section'
572
+ op0.value= "";
573
+ op0.hidden=true;
574
+ thirddropdown.add(op0);
575
+ displayprojsections(prjids[(firstdropdown.selectedIndex)-1],partsArrIDsonly[(seconddropdown.selectedIndex)-1]);
576
+ })
577
+ function isValueNotInDropdown(dropdown, value) {
578
+ // const dropdown = document.getElementById(dropdownId);
579
+ const values = Array.from(dropdown.options).map(option => option.value);
580
+ return !values.includes(value); // Check if the value is not in dropdown values
581
+ }
582
+ function displayprojsections(projectid,Partid){
583
+ console.log(seconddropdown.selectedIndex)
584
+ document.getElementById("all").style.display = "block";
585
+ if (measSelect && measSelect.hasChildNodes()) {
586
+ while (measSelect.firstChild) {
587
+ measSelect.removeChild(measSelect.firstChild);
588
+ }
589
+ }
590
+
591
+ // if (relvSelect && relvSelect.hasChildNodes()) {
592
+ // while (relvSelect.firstChild) {
593
+ // relvSelect.removeChild(relvSelect.firstChild);
594
+ // }
595
+ // }
596
+ $.get('/getprojectsections/' + JSON.stringify([projectid, Partid]))
597
+ .done(function(data) {
598
+ document.getElementById("all").style.display = "none";
599
+
600
+ for (let i = 0; i < data.length; i++) {
601
+ let valueDoesNotExist = isValueNotInDropdown(thirddropdown, data[i]);
602
+
603
+ if (valueDoesNotExist) {
604
+ let opt = document.createElement("option");
605
+ opt.value = data[i];
606
+ opt.text = data[i];
607
+
608
+ let isActive = false;
609
+ for (let d = 0; d < ActiveSections.length; d++) {
610
+ if (data[i].startsWith(ActiveSections[d])) {
611
+ isActive = true;
612
+ break; // Exit loop early if active
613
+ }
614
+ }
615
+
616
+ if (!isActive) {
617
+ opt.style.color = '#bdbcbc';
618
+ opt.style.cursor = 'not-allowed';
619
+ opt.setAttribute('disabled', true);
620
+ }
621
+
622
+ thirddropdown.append(opt);
623
+ PrjSectionsArray.push(data[i]);
624
+ }
625
+ }
626
+ })
627
+ .fail(function(jqXHR, textStatus, errorThrown) {
628
+ PopupElement.textContent='Error occured while retrieving the Project Sections. Refresh and try again. If the error continues, please contact the ADR team to fix it. ';
629
+ ShowPopUp();
630
+ });
631
+
632
+ }
633
+
634
+ function filterFunction(id) {
635
+ var input, filter, ul, li, a, i;
636
+ input = document.getElementById(id);
637
+ filter = input.value.toUpperCase();
638
+ if (id.toString().startsWith('tomeasure'))
639
+ a = document.querySelectorAll("#measureContainer .measure-item");
640
+
641
+ // a = document.getElementById("measureselectid").children;
642
+ // else
643
+ // // a = document.getElementById("relvselectid").children;
644
+ // a = document.querySelectorAll("#relvselectid .relv-item");
645
+ // a = div.getElementsByTagName("option");
646
+ for (i = 0; i < a.length; i++) {
647
+ txtValue = a[i].textContent || a[i].innerText;
648
+ if (txtValue.toUpperCase().indexOf(filter) > -1) {
649
+ a[i].style.display = "";
650
+ } else {
651
+ a[i].style.display = "none";
652
+ }
653
+ }
654
+ }
655
+
656
+ function getproj(){
657
+
658
+
659
+ var proj = document.getElementsByClassName("selectionsProj")[0];
660
+ var projectVal=proj.value.toString() //selected project
661
+
662
+ var inputs = document.getElementsByTagName("select")[1]; //second dropdown(project part)
663
+ var p=document.getElementById("selectionsProjpid") //project part
664
+
665
+ var sections = document.getElementsByClassName("selectionsProjs")[0];
666
+
667
+ var eventSource = new EventSource('/getmethod/' + JSON.stringify(projectVal));
668
+ document.getElementById('progressBar').removeAttribute('hidden')
669
+ document.getElementById('progressBar').style.display='block';
670
+ eventSource.onmessage = function (event) {
671
+ var progress = parseInt(event.data); // Progress value from Flask
672
+ if (progress <= 100) {
673
+ console.log(progress); // Log progress for debugging
674
+ document.getElementById('progress').style.width = progress + '%';
675
+ document.getElementById('progress').textContent = progress + '%';
676
+ } else {
677
+ // Final data handling when progress reaches 100%
678
+ console.log('Process completed!');
679
+
680
+ // Parse and handle the final response data (documentsToMeasure, RelevantDocuments, extracted_path)
681
+ var data = JSON.parse(event.data); // Assuming the result is a JSON array
682
+ console.log('Final result:', data);
683
+ // You can use this data to update your page or handle it accordingly
684
+
685
+ eventSource.close(); // Close the connection when finished
686
+ document.getElementById('progressBar').setAttribute('hidden',true)
687
+ document.getElementById('progressBar').style.display='none';
688
+ document.getElementById('progress').style.width = '0%'; // Reset progress for the next process
689
+ document.getElementById('progress').textContent = '0%';
690
+
691
+
692
+ document.getElementById('refreshDropboxButtonID').style.display = "block";
693
+ document.getElementById("all").style.display = "none";
694
+ // if (sections.value.startsWith('3.2') || sections.value.startsWith('3.3') || sections.value.startsWith('2.7') ){
695
+ // document.getElementById('dxfdiv').removeAttribute('hidden');
696
+ // document.getElementById('pdftodxfFile').setAttribute('required',true)
697
+ // }
698
+
699
+ // else{
700
+ // document.getElementById('dxfdiv').setAttribute('hidden',true)
701
+ // }
702
+
703
+ extracted_path=data[2]
704
+ var docsToMeasure=data[0]; //
705
+ // var relvDocs=data[1]
706
+ var projname = document.getElementsByClassName("selectionsProj")[0];
707
+ var projpart = document.getElementsByClassName("selectionsProjp")[0];
708
+ var projsec = document.getElementsByClassName("selectionsProjs")[0];
709
+
710
+ var meas = document.getElementById("measureCheckbox") ;
711
+ // var relv = document.getElementById("relvdiv") ;
712
+ const measids=[];
713
+ // const relvids=[];
714
+ const measoptns=[];
715
+
716
+ // var measSelect = document.getElementById("measureselectid");
717
+ var measSelect = document.getElementById("measureContainer");
718
+
719
+ // var relvSelect = document.getElementById("relvselectid");
720
+ // var levelcheckbox= document.getElementById("levelcheckbox");
721
+
722
+
723
+ measSelect.removeAttribute("hidden");
724
+ // relvSelect.removeAttribute("hidden");
725
+ if (measSelect && measSelect.hasChildNodes()) {
726
+ while (measSelect.firstChild) {
727
+ measSelect.removeChild(measSelect.firstChild);
728
+ }
729
+ }
730
+
731
+ var optn2 = document.createElement("div"); // Use a <div> instead of <option>
732
+ optn2.textContent = 'Select project to measure'; // Set text content
733
+ optn2.hidden = true; // Keep it hidden
734
+ optn2.id = 'hidden';
735
+
736
+ measSelect.appendChild(optn2); // Append to div instead of .add()
737
+ document.getElementById("hidden").required = true;
738
+
739
+
740
+ // if (relvSelect && relvSelect.hasChildNodes()) {
741
+ // while (relvSelect.firstChild) {
742
+ // relvSelect.removeChild(relvSelect.firstChild);
743
+ // }
744
+ // }
745
+ const nameSet = new Set(); // To track unique names
746
+ // const nameSetRelv = new Set(); // To track unique names
747
+
748
+ // Action foconst nameSet = new Set(); // To track unique names
749
+
750
+ // Action for when the checkbox is clicked
751
+ function handleCheckboxChange(event) {
752
+ // Uncheck all checkboxes before checking the current one
753
+ document.querySelectorAll('input[name="measureCheckbox"]').forEach(checkbox => {
754
+ checkbox.checked = false;
755
+ });
756
+
757
+ // Check the current checkbox
758
+ event.target.checked = true;
759
+
760
+ // Action when checkbox is clicked (e.g., log the selected project)
761
+ let selectedValue = event.target.value;
762
+ measSelect.value=selectedValue;
763
+ console.log("Selected project:", selectedValue);
764
+
765
+ // Highlight the selected item
766
+ document.querySelectorAll(".measure-item").forEach(item => {
767
+ item.style.backgroundColor = ''; // Reset background color for all items
768
+ });
769
+ event.target.closest(".measure-item").style.backgroundColor = '#d3f8d3'; // Highlight the selected item
770
+
771
+
772
+
773
+ // Show alert immediately to prompt the user
774
+ // if (projsec.value.startsWith('3.2') || projsec.value.startsWith('3.3') || projsec.value.startsWith('2.7')) {
775
+ // // downloadPdf(selectedValue);
776
+ // downloadPdf(selectedValue,'DXF_File_:'+selectedValue)
777
+ // // window.alert("Measure the purple shape drawn on the PDF using Foxit Reader, Bluebeam, or any other external tool, then enter its area and perimeter in your desired scale.");
778
+ // }
779
+ // else{
780
+ // window.alert("Measure the purple shape drawn on the PDF using Foxit Reader, Bluebeam, or any other external tool, then enter its area and perimeter in your desired scale.");
781
+ // }
782
+ canvasimg='';
783
+ ry=[[]];
784
+ // levelcheckbox.checked=false;
785
+ pdfname=selectedValue;
786
+ measSelect.style.boxShadow='none';
787
+
788
+ console.log(projsec.value)
789
+ // if (!(projsec.value.startsWith('2.6') || projsec.value.startsWith('2.8'))) {
790
+ // document.getElementById("all").style.display = "block";
791
+
792
+ // pixelArr=[projname.value, projpart.value,projsec.value, pdfname]
793
+ // var eventSource = new EventSource('/pixelimg/' + JSON.stringify(pixelArr));
794
+ // document.getElementById('progressBar').removeAttribute('hidden')
795
+ // document.getElementById('progressBar').style.display='block';
796
+ // eventSource.onmessage = function (event) {
797
+ // var progress = parseInt(event.data); // Progress value from Flask
798
+ // if (progress <= 100) {
799
+ // console.log(progress); // Log progress for debugging
800
+ // document.getElementById('progress').style.width = progress + '%';
801
+ // document.getElementById('progress').textContent = progress + '%';
802
+ // } else {
803
+ // var data = JSON.parse(event.data); // Assuming the result is a JSON array
804
+ // eventSource.close(); // Close the connection when finished
805
+
806
+ // document.getElementById('progressBar').setAttribute('hidden',true)
807
+ // document.getElementById('progressBar').style.display='none';
808
+ // document.getElementById('progress').style.width = '0%'; // Reset progress for the next process
809
+ // document.getElementById('progress').textContent = '0%';
810
+ // document.getElementById("all").style.display = "none";
811
+ // // Display link or any additional data if needed
812
+ // window.open(data[2]);
813
+ // downloadPdf(pdfname,'Pixel_Conversion_File_:'+pdfname)
814
+ // document.getElementById("all").style.display = "none";
815
+
816
+ // document.getElementById('Newtablebutton').onclick= function()
817
+ // {
818
+ // if (!areaRatio.value){
819
+ // if (!(projsec.value.startsWith('3.2')) & !(projsec.value.startsWith('2.8')) & !(projsec.value.startsWith('2.6')) & !(projsec.value.startsWith('3.3')) & !(projsec.value.startsWith('2.7')) )
820
+ // areaRatio.style.boxShadow='0 0 8px 2px rgb(255, 0, 0)';
821
+ // }
822
+ // if (!prmRatio.value) {
823
+ // if (!(projsec.value.startsWith('2.6') || projsec.value.startsWith('2.8'))) {
824
+ // prmRatio.style.boxShadow = '0 0 8px 2px rgb(255, 0, 0)';
825
+ // }
826
+ // }
827
+
828
+ // }
829
+ // document.getElementById('radiosColors').removeAttribute('hidden');
830
+ // var scalelbl= document.createElement("label");
831
+ // scalelbl.innerText='Scale Document';
832
+ // scalelbl.id='measureLabel';
833
+ // var br1= document.createElement("br");
834
+ // var areadiv=document.createElement("div");
835
+ // areadiv.id='areadiv'
836
+ // var areaRatiolbl= document.createElement("label");
837
+ // areaRatiolbl.innerText='Area:'
838
+ // areaRatiolbl.id='radiolbl';
839
+
840
+ // var areaRatio= document.createElement("input");
841
+ // areaRatio.type='number';
842
+ // areaRatio.id='arealvlinput';
843
+ // areaRatio.className='lvlinput';
844
+ // areaRatio.name='areaRatio';
845
+ // areaRatio.style.marginLeft='78px';
846
+ // areaRatio.style.textAlign='right';
847
+ // areaRatio.step=".0000001";
848
+ // areaRatio.min = "0"; // Allow only positive numbers (>= 0)
849
+ // if( projsec.value.startsWith('3.2') || projsec.value.startsWith('3.3') || projsec.value.startsWith('2.1') || projsec.value.startsWith('2.7')){
850
+ // areaRatio.setAttribute('disabled',true)
851
+ // areaRatio.style.cursor='not-allowed';
852
+ // areaRatio.style.backgroundColor='rgba(101, 101, 101, 0.27)'
853
+ // document.getElementById('selectunitA').setAttribute('disabled',true)
854
+ // document.getElementById('selectunitA').style.cursor='not-allowed';
855
+ // document.getElementById('selectunitA').style.backgroundColor='rgba(101, 101, 101, 0.27)'
856
+ // }
857
+
858
+ // else{ // section 1.0
859
+ // areaRatio.removeAttribute('disabled')
860
+ // areaRatio.style.cursor='pointer';
861
+ // document.getElementById('selectunitA').removeAttribute('disabled')
862
+ // document.getElementById('selectunitA').style.cursor='pointer';
863
+ // }
864
+ // areaRatio.addEventListener('change',function(){
865
+ // areaRatio.value=(Number(areaRatio.value)).toFixed(7)
866
+ // areaRatio.style.boxShadow='none';
867
+ // })
868
+ // areaRatio.required=true;
869
+ // selectunitA=document.getElementById('selectunitA')
870
+ // selectunitA.removeAttribute('hidden')
871
+
872
+ // areadiv.append(areaRatiolbl,areaRatio,selectunitA)
873
+ // var br2= document.createElement("br");
874
+ // var br3= document.createElement("br");
875
+ // var prmdiv=document.createElement("div");
876
+ // prmdiv.id='prmdiv'
877
+ // var prmRatiolbl= document.createElement("label");
878
+ // prmRatiolbl.innerText='Perimeter:'
879
+ // prmRatiolbl.id='radiolbl';
880
+
881
+ // var prmRatio= document.createElement("input");
882
+ // prmRatio.type='number';
883
+ // prmRatio.id='perimlvlinput';
884
+ // prmRatio.className='lvlinput';
885
+ // prmRatio.name='prmRatio';
886
+ // prmRatio.style.textAlign='right';
887
+ // prmRatio.style.marginLeft='49px';
888
+ // prmRatio.step=".0000001";
889
+ // prmRatio.min = "0"; // Allow only positive numbers (>= 0)
890
+ // prmRatio.addEventListener('change',function(){
891
+ // prmRatio.value=(Number(prmRatio.value)).toFixed(7)
892
+ // prmRatio.style.boxShadow='none';
893
+ // })
894
+ // prmRatio.required=true;
895
+ // selectunitP=document.getElementById('selectunitP')
896
+ // selectunitP.removeAttribute('hidden')
897
+
898
+ // prmdiv.append(prmRatiolbl, prmRatio,selectunitP)
899
+ // var ratiosdiv= document.getElementById("ratios");
900
+ // ratiosdiv.innerHTML='';
901
+ // ratiosdiv.append(scalelbl);
902
+ // ratiosdiv.append(br1);
903
+ // ratiosdiv.append(areadiv)
904
+ // ratiosdiv.append(prmdiv)
905
+ // areainpixels=data[0];
906
+ // prminpixels=data[1];
907
+
908
+
909
+ // if( projsec.value.startsWith('2.8') || projsec.value.startsWith('2.6')) {
910
+ // areaRatio.setAttribute('disabled',true)
911
+ // areaRatio.style.cursor='not-allowed';
912
+ // areaRatio.style.backgroundColor='rgba(101, 101, 101, 0.27)'
913
+ // document.getElementById('selectunitA').setAttribute('disabled',true)
914
+ // document.getElementById('selectunitA').style.cursor='not-allowed';
915
+ // document.getElementById('selectunitA').style.backgroundColor='rgba(101, 101, 101, 0.27)'
916
+
917
+ // prmRatio.setAttribute('disabled',true)
918
+ // prmRatio.style.cursor='not-allowed';
919
+ // prmRatio.style.backgroundColor='rgba(101, 101, 101, 0.27)'
920
+ // document.getElementById('selectunitP').setAttribute('disabled',true)
921
+ // document.getElementById('selectunitP').style.cursor='not-allowed';
922
+ // document.getElementById('selectunitP').style.backgroundColor='rgba(101, 101, 101, 0.27)'
923
+ // }
924
+ // };
925
+ // }
926
+
927
+
928
+ // eventSource.onerror = function (error) {
929
+ // console.error('Error occurred:', error);
930
+ // eventSource.close(); // Close on error
931
+ // PopupElement.textContent='Error occured while uploading the pdf to the Dropbox. Refresh and try again. If the error continues, please contact the ADR team to fix it. ';
932
+ // ShowPopUp();
933
+ // };
934
+
935
+ // selectunitA.addEventListener('change',function(){
936
+ // value=document.getElementById('selectunitA').value
937
+ // if (value=='mm2')
938
+ // ratioAunit=1000000;
939
+ // else
940
+ // ratioAunit=1;
941
+ // })
942
+ // selectunitP.addEventListener('change',function(){
943
+ // value=document.getElementById('selectunitP').value
944
+ // if (value=='mm'){
945
+ // ratioPunit=1000;
946
+ // }
947
+ // else
948
+ // ratioPunit=1;
949
+
950
+ // })
951
+ // // }
952
+ // // for 2.8 multiple pdfs
953
+ // // else{
954
+ // // pdfnames=getSelectValues(elem)
955
+ // // }
956
+ // }
957
+ // else{
958
+ // document.getElementById('radiosColors').removeAttribute('hidden')
959
+ // }
960
+ }
961
+ // Action for when the label is clicked (no checkbox change)
962
+ // function handleLabelClick(event) {
963
+ // let selectedLabel = event.target.textContent;
964
+ // console.log("Label clicked: ", selectedLabel);
965
+
966
+ // // Reset background only for items whose checkbox is **not** checked
967
+ // document.querySelectorAll(".measure-item").forEach(item => {
968
+ // const checkbox = item.querySelector('input[type="checkbox"]');
969
+ // if (!checkbox.checked) {
970
+ // item.style.backgroundColor = '';
971
+ // }
972
+ // });
973
+
974
+ // // Optionally highlight the clicked div (even though its checkbox isn’t selected)
975
+ // const clickedDiv = event.target.closest(".measure-item");
976
+ // clickedDiv.style.backgroundColor = '#919592';
977
+
978
+ // // Show loading spinner
979
+ // document.getElementById("all").style.display = "block";
980
+
981
+ // fetch('/getdropboxurl/' + JSON.stringify(selectedLabel), {
982
+ // method: 'POST',
983
+ // headers: { 'Content-Type': 'application/json' },
984
+ // body: JSON.stringify({ filename: "your_pdf_filename_here.pdf" }) // ← Replace with real value if dynamic
985
+ // })
986
+ // .then(response => response.blob())
987
+ // .then(blob => {
988
+ // document.getElementById("all").style.display = "none";
989
+ // const url = URL.createObjectURL(blob);
990
+ // // addIframeTab(selectedLabel, url);
991
+ // })
992
+ // .catch(function (jqXHR, textStatus, errorThrown) {
993
+ // PopupElement.textContent = 'Error occurred while retrieving the Dropbox URL. Refresh and try again. If the error continues, please contact the ADR team to fix it.';
994
+ // ShowPopUp();
995
+ // });
996
+ // }
997
+
998
+
999
+ for (let i = 0; i < docsToMeasure.length; i++) {
1000
+ let name = docsToMeasure[i][0];
1001
+
1002
+ // Create div for the measure item
1003
+ let div = document.createElement("div");
1004
+ div.className = "measure-item";
1005
+
1006
+ // Create the checkbox
1007
+ let checkbox = document.createElement("input");
1008
+ checkbox.type = "checkbox";
1009
+ checkbox.name = "measureCheckbox";
1010
+ checkbox.value = name;
1011
+
1012
+ // Only clicking checkbox checks it and triggers handler
1013
+ checkbox.onclick = function (e) {
1014
+ e.stopPropagation(); // prevent bubbling to div
1015
+ handleCheckboxChange(e);
1016
+ };
1017
+
1018
+ // Create the label
1019
+ let label = document.createElement("label");
1020
+ label.textContent = name;
1021
+
1022
+ // Label click does not check the checkbox
1023
+ label.onclick = function (e) {
1024
+ e.stopPropagation(); // just to be safe
1025
+ handleLabelClick(e, name);
1026
+ };
1027
+
1028
+ // Div click also doesn't check the checkbox
1029
+ div.onclick = function (e) {
1030
+ handleLabelClick(e, name);
1031
+ };
1032
+
1033
+ // Assemble
1034
+ div.appendChild(checkbox);
1035
+ div.appendChild(label);
1036
+ measSelect.appendChild(div);
1037
+
1038
+ // Handle duplicates
1039
+ if (nameSet.has(name)) {
1040
+ label.style.color = "red";
1041
+ document.getElementById("TopTextModal").textContent = 'Error: Duplicates Error';
1042
+ PopupElement.textContent = 'Duplicate project names were detected while retrieving the project PDFs. Please visit Dropbox and rename the relevant files that you will be working on to ensure each project has a unique name. Once the renaming is complete, return to the console and click on the Dropbox icon to retrieve the updated project names.';
1043
+ ShowPopUp();
1044
+ } else {
1045
+ nameSet.add(name);
1046
+ }
1047
+ }
1048
+
1049
+
1050
+ // for (let i = 0; i < relvDocs.length; i++) {
1051
+ // let name = relvDocs[i][0];
1052
+
1053
+ // // Create div for the measure item
1054
+ // let divRelv = document.createElement("div");
1055
+ // divRelv.className = "relv-item";
1056
+
1057
+ // // Create the checkbox
1058
+ // let checkboxRelv = document.createElement("input");
1059
+ // checkboxRelv.type = "checkbox";
1060
+ // checkboxRelv.name = "measureCheckboxRelv";
1061
+ // checkboxRelv.value = name;
1062
+
1063
+ // // Create the label
1064
+ // let label = document.createElement("label");
1065
+ // label.textContent = name;
1066
+
1067
+ // // Shared click handler
1068
+ // function checkboxRelvClick(event) {
1069
+ // event.stopPropagation(); // Prevent event bubbling issues
1070
+
1071
+ // // Get the parent div from the event target
1072
+ // const container = event.currentTarget;
1073
+
1074
+ // // Get the checkbox inside this container
1075
+ // const checkbox = container.querySelector('input[type="checkbox"]');
1076
+
1077
+ // // Uncheck all checkboxes
1078
+ // document.querySelectorAll('input[name="measureCheckboxRelv"]').forEach(cb => cb.checked = false);
1079
+
1080
+ // // Check the clicked one
1081
+ // checkbox.checked = true;
1082
+
1083
+ // const relevantDocumentName = checkbox.value;
1084
+ // console.log("Item clicked: ", relevantDocumentName);
1085
+
1086
+ // if (projsec.value.startsWith('2.8') || projsec.value.startsWith('2.6')) {
1087
+ // doorSchedulePDF = relevantDocumentName;
1088
+ // console.log(doorSchedulePDF);
1089
+ // }
1090
+
1091
+ // // Highlight selection
1092
+ // document.querySelectorAll(".relv-item").forEach(item => {
1093
+ // item.style.backgroundColor = '';
1094
+ // });
1095
+ // container.style.backgroundColor = '#d3f8d3';
1096
+ // document.getElementById('relvselectid').style.boxShadow = '';
1097
+ // relvSelect.value = relevantDocumentName;
1098
+ // }
1099
+
1100
+ // // Assign the click event to the container div
1101
+ // divRelv.onclick = checkboxRelvClick;
1102
+
1103
+ // // Also attach to checkbox specifically to prevent bubbling issue
1104
+ // checkboxRelv.onclick = (e) => {
1105
+ // e.stopPropagation();
1106
+ // divRelv.click(); // Trigger div's click logic
1107
+ // };
1108
+
1109
+ // divRelv.appendChild(checkboxRelv);
1110
+ // divRelv.appendChild(label);
1111
+
1112
+ // relvSelect.appendChild(divRelv);
1113
+
1114
+ // if (nameSetRelv.has(name)) {
1115
+ // label.style.color = "red";
1116
+ // } else {
1117
+ // nameSetRelv.add(name);
1118
+ // }
1119
+ // }
1120
+
1121
+
1122
+ // relvids.push(relvSelect);
1123
+ measids.push(measSelect);
1124
+
1125
+ // document.addEventListener("click", function(event) {
1126
+ // const iframe = document.getElementById("pdfFrame");
1127
+ // if (!iframe.contains(event.target)) {
1128
+ // const iframe = document.getElementById("pdfFrame");
1129
+ // iframe.style.display = "none";
1130
+ // }
1131
+ // });
1132
+ document.getElementById('Newtablebutton').onclick= function()
1133
+ {
1134
+ if (!measSelect.value) {
1135
+ measSelect.style.boxShadow = '0 0 8px 2px rgb(255, 0, 0)';
1136
+ measSelect.setAttribute("required", "")
1137
+ }
1138
+
1139
+ // if (!relvSelect.value) {
1140
+ // if (sectionNumber.startsWith('2.8') || sectionNumber.startsWith('2.6')) {
1141
+ // relvSelect.style.boxShadow = '0 0 8px 2px rgb(255, 0, 0)';
1142
+ // relvSelect.setAttribute("required", "")
1143
+ // }
1144
+ // }
1145
+
1146
+
1147
+ }
1148
+
1149
+ }
1150
+
1151
+
1152
+ if (document.getElementById('arealvlinput')){
1153
+ if( projsec.value.startsWith('3.2') || projsec.value.startsWith('2.8') || projsec.value.startsWith('2.6') || projsec.value.startsWith('3.3') || projsec.value.startsWith('2.1') || projsec.value.startsWith('2.7')){
1154
+ document.getElementById('arealvlinput').setAttribute('disabled',true)
1155
+ document.getElementById('selectunitA').setAttribute('disabled',true)
1156
+ }
1157
+ else{ // section 1.0
1158
+ document.getElementById('arealvlinput').removeAttribute('disabled')
1159
+ document.getElementById('selectunitA').removeAttribute('disabled')
1160
+ }
1161
+ }
1162
+
1163
+
1164
+
1165
+ // if (!(thirddropdown.value.startsWith('2.8')||thirddropdown.value.startsWith('2.6')) ) {
1166
+ // document.getElementById("relvselectid").classList.add("disabled");
1167
+ // document.getElementById("relvoverlay").style.display = "block";
1168
+ // } else {
1169
+ // document.getElementById("relvselectid").classList.remove("disabled");
1170
+ // document.getElementById("relvoverlay").style.display = "none";
1171
+ // }
1172
+
1173
+ };
1174
+
1175
+ eventSource.onerror = function (error) {
1176
+ console.error('Error occurred:', error);
1177
+ eventSource.close(); // Close on error
1178
+ PopupElement.textContent='Error occured while retrieving the Project Names. Refresh and try again. If the error continues, please contact the ADR team to fix it. ';
1179
+ ShowPopUp();
1180
+ };
1181
+
1182
+ }
1183
+ //___________________________________________________________________________________________________________
1184
+ //___________________________________________________________________________________________________________
1185
+ function downloadPdf(blob,downloadPDFName) {
1186
+
1187
+ // const url = URL.createObjectURL(blob);
1188
+ // var link = document.createElement('a');
1189
+ // link.href = url;
1190
+ // link.download = downloadPDFName;
1191
+ // link.dispatchEvent(new MouseEvent('click'));
1192
+
1193
+
1194
+ const url = URL.createObjectURL(blob);
1195
+ const a = document.createElement('a');
1196
+ a.style.display = 'none';
1197
+ a.href = url;
1198
+ a.download = downloadPDFName;
1199
+ document.body.appendChild(a);
1200
+ a.click();
1201
+ document.body.removeChild(a);
1202
+ URL.revokeObjectURL(url);
1203
+
1204
+ }
1205
+ /*Menu bar icon mySidebar and Toggle*/
1206
+ var $mySidebar = document.getElementById('mySidebar');
1207
+ var $toggle = document.getElementById('toggle');
1208
+ $toggle.addEventListener('click', function() {
1209
+
1210
+ var isOpen = $mySidebar.classList.contains('slide-in');
1211
+ w3_open();
1212
+ $mySidebar.setAttribute('class', isOpen ? 'slide-out' : 'slide-in');
1213
+ $toggle.classList.toggle("change");
1214
+
1215
+
1216
+ if ($mySidebar.classList.contains('slide-out')){
1217
+ w3_close()
1218
+ }
1219
+ });
1220
+
1221
+ function w3_open() {
1222
+ document.getElementById("home").style.marginLeft = "25%";
1223
+ document.getElementById("legends").style.marginLeft = "25%";
1224
+
1225
+ document.getElementById("home").style.transition= '0.8s';
1226
+ document.getElementById("legends").style.transition= '0.8s';
1227
+
1228
+ document.getElementById("mySidebar").style.width = "25%";
1229
+ document.getElementById("mySidebar").style.display = "block";
1230
+ }
1231
+
1232
+ function w3_close() {
1233
+ document.getElementById("home").style.marginLeft = "0%";
1234
+ document.getElementById("legends").style.marginLeft = "0%";
1235
+ document.getElementById("home").style.transition= '1.5s'
1236
+ document.getElementById("legends").style.transition= '1.5s'
1237
+ document.getElementById("mySidebar").style.display = "none";
1238
+ }
1239
+ function openTab(evt, tabname) {
1240
+ var i, tabcontent, tablinks;
1241
+
1242
+
1243
+
1244
+ // Hide all tab contents
1245
+ tabcontent = document.getElementsByClassName("tabcontent");
1246
+ for (i = 0; i < tabcontent.length; i++) {
1247
+ tabcontent[i].style.display = "none";
1248
+ }
1249
+
1250
+ // Remove "active" class from all tab buttons
1251
+ tablinks = document.getElementsByClassName("tablinks");
1252
+ for (i = 0; i < tablinks.length; i++) {
1253
+ tablinks[i].className = tablinks[i].className.replace(" active", "");
1254
+ }
1255
+
1256
+ // Show selected tab content and mark button as active
1257
+ var tab = document.getElementById(tabname);
1258
+ if (tab) {
1259
+ tab.style.display = "block";
1260
+ tab.className += " active";
1261
+ // evt.currentTarget.className += " active";
1262
+ } else {
1263
+ console.error('Tab content with ID ' + tabname + ' not found.');
1264
+ }
1265
+ }
1266
+ </script>