Marthee commited on
Commit
8cb34de
·
verified ·
1 Parent(s): a0a4ce3

Upload tableDetection.html

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