Spaces:
Sleeping
Sleeping
| <html lang="en" dir="ltr"> | |
| <head> | |
| <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> | |
| <link href="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.3/css/select2.min.css" rel="stylesheet"/> | |
| <script src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.3/js/select2.min.js"></script> | |
| <link rel="stylesheet" href="https://use.typekit.net/zos0ars.css"> | |
| <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css"> | |
| <link rel="stylesheet" href="static/style.css"> | |
| <link rel="stylesheet" href="static/MenuStyle.css"> | |
| <link rel="stylesheet" href="static/LegendPageStyle.css"> | |
| <link rel="stylesheet" href="static/popups.css"> | |
| <link rel="stylesheet" href="static/IMG-Larger.css"> | |
| <meta charset="utf-8"> | |
| <title>ADR Console</title> | |
| <link rel = "icon" type = "image/png" sizes = "180x154" href = "static/images/TSAlogoCropped180x154.png"> | |
| <link rel = "icon" type = "image/png" sizes = "32x27" href = "static/images/TSAlogoCropped32x27.png"> | |
| <link rel = "icon" type = "image/png" sizes = "16x14" href = "static/images/TSAlogoCropped16x14.png"> | |
| <link rel = "mask-icon" href = "static/images/TSAlogoCropped180x154.png"> | |
| <link rel = "shortcut icon" href = "static/images/TSAlogoCropped180x154.png"> | |
| </head> | |
| <body > | |
| <div id="all"> | |
| <!-- {% include 'loading.html' %} --> | |
| {% include 'loading.html' %} | |
| </div> | |
| <!--Main tab links--> | |
| <div class="tab"> | |
| <div class="container" id="toggle"> | |
| <div class="bar1"></div> | |
| <div class="bar2"></div> | |
| <div class="bar3"></div> | |
| </div> | |
| <button class="tablinks" id="pagetitle" onclick="openTab(event, 'home')">ADR Console <i class="fa fa-home" > </i></button> | |
| <button class="tablinks" id="LegendHist" onclick="openTab(event, 'legends')">Legends History <i class="fa fa-caret-down"></i></button> | |
| <button class="dropbtn" onclick="userguideclick()"><img id="infoImg" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAACXBIWXMAAAsTAAALEwEAmpwYAAAHz0lEQVR4nNVbW0xVVxC9SAEfNPGRCJICGoWKRkUUNfEVFUnsn0ZjfARfAWmq8UNLfSUmxkLxCzDS6kcrDx8/xkeiaFujJia1ifFDRPyw0Fi0xjeliKi4mnU49+bcfeZwufeefaErmYQczt2zZ/bsPbNn5ng8mgFgAoDNAA4B+BnAnwBaYUer+b/L5rv8TYbn/wYA0QCWAKgG8DfCx2NzLI4Z7emvAJAEoNScsC5w7O8AjPL0FwBIAfA9gLeIHDoAHAaQ3JeCxwLYDaA90GyfPn2KM2fOoKSkBOvXr0dOTg6mT5+OjIwMg/g3n23YsMF45+zZs3j27FlvFPEvgG8AxERa+GwAjT3NrL6+HkVFRZg8eTKioqLAnwVD/M2UKVOwc+dO3L17N5AiGgBkRUr4AgCd0izev3+P6upqZGVlBS1wIJo2bRpqamoMHg7gFtwGIEqX4HEATkmcP378iGPHjmHMmDGuC67S2LFjDUWQpwOOc3u6LfynAH6RuN25cwezZ8/WLrhK8+bN62lrMN6Id1P43yUuR44cQVxcXMSF9xJ5l5WVOSnht7CVgG6z/1Ud+c2bN1i+fHmfCa7SypUrjTkJuBzydgAQJe35V69eYc6cOdqEiY2NRXx8fNC/mzVrFp4/fy4poTZUBWxTR3r58qXhmnSZc0VFBdrb231ny9SpU4MaIzMz01ggAV+F4uc7VbOfO3eutpU/dcruYJqbm4M+Y2gJXiUqLjIrmAivUR1B557nSjshWCvwngkOwVLgiBHd4a0faJq6hCcVFDC2ksEAKJQxKysrpeGKAgmfqsb23Iu6Xd2WLVtE4Z88eYKYmJiQxhw4cKAUJ/Du8FlPCvjB+jajrfnz52sVnsQLkRTirl27NqxxeWYJEWNFT/f5t9Y3Gd7qFt5LvAm2tbUZfOnOeGt0Y9za2lpVAQwYEiUFlFrf+vDhA8aNGxcxBZBo7qNHjw7Z7J3uDoJ1lajCf6Kmr6qqqiIqvE46fpz3Iz888kuvAfhCfUPHldaJoqOjkZycjKSkpJByB4GICRcBuVYF1Fj/w9MzEoJPmjTJsDRr9NbY2Ijx48e7zkvwCD9ZY34/82cmR6fgEydOxIULFxzv9Eyfuc1z925bePPIq4AM9T9cGR2C07x37dqFzk4xoeTDtWvXXOfNLS3gcyqg0PqELmjAgAGuT2DQoEHGyvYG5eXlrvOnTEKitcBjVmF8YEbWbeaDBw/GlStX/DjT/Lu6ukQFrFixQosFnj9/XmVV5jGTBj4UFxe7ynTIkCG4evWq35X64MGDxon/+vVrm/D02cOGDdOigNJSv1CHqKMCmq1P1q1b56rZX79+3Rj33r17KCwsNBTiDX8l3LhxQ4vwpI0bN6rs/qACuuNPE4sWLXKNIX37yZMnkZuba/PvO3bsEBWwd+9ebQpg8UVBKxXg54uys7O1TcBKXstQwaBFF8+ZM2eq7LqoAD/QNHULzz0u3f5YQtPhgbw0YQIr9f7w9IUCVq1aJa4+Cx46+TopoCvSW+DEiROiAtasWaOVr9MWaNN1CDpdfKT0NWOCkSNHauXtdAg2W5+4lYjoKUsj4datW9otb9OmTaIbvGx9wvq8zkkcOHBAVACf61YAAzApEDqkOxS20s2bN0UF6Kw5BAqFN0fiMkQaOnSokWpT0dra6moaLIjLUL54HWZXh45JLF26VFz906dPa1991hcEpHlzAsyR+cC2FB2TOHyYfU12sDCiWwF79uxR2bZYU2Lsw/OhoaFByyTu378vKiA1NVW7AphqU/CjVQFsQnSlJOVEw4cPF1NgTU1N2oVncCcgR+3ufKwzLF2yxKZjA0xZ61YAb6Sq+du6TtHdgekDT+u0tDTXJrFv3z5RAVu3brW9m5CQgP379yMvLy9svizuCJ7nW6kyNMrswPSBLW9uKeDixYuiAhYvXux7h+nwo0ePoqOjw8gWuREbCKvP0liCU32w0vom9+yCBQtcUcCDBw9EBfCsWbZsGerq6nw5wpaWFldcMTvJhHOnTBSeYO+tWUL2gQUFlprDmQizQVxVCepzeqCUlJSwheecmYZT8A+LwJ6egO7eWz/Qf4czmREjRqA3YJbIrYQoW/gEbO9ReEuLDNtJ/MC2k1AnwzD33bt3joLTTFkLcCscXr16tcSmvtdN1QCy1F4BNklxT4U6KV6yJDx8+BALFy50RXASGzqE7cYHmb0S3gsAtr4VFjHZihbKxBITE42Dji6J+cDbt28jPz/f1fYbzk2qNQD40hMK0N14bFNCOJbAWkG4h6rTyjsIXxWS8JbzgI3HULdDOGeC28Q97+BlLoX9MQWAeLPx2K7aqiqj7tdXgtOStDZLK0rwS51Z44RIdJKpxABN8PPWlXdHeGU72M4ErxtjN1YkmqrS09Ol8NbPMLV+QwQgz4ynbeAJz9udjvLWjBkzjHqClFKzfjKjTXAhTrAFS1bQPNmWwl7fUHKM/A27OpjJEZIZUpATnJ8PFwBiAHyt3h0kMNF67tw5oz7PEjVvgExSeD+b4+ryGfP2fIfZ2xcvXqAXYGy/PeKfzVnB3lsztS5uC00gr/KAF5tIAkAi6ypqgtVlMJNT7Hif7w9Ad3otl3145oTDxV9MYDJ30q8/nvY4gK1o5seWjFjon5sASDEruyX5vzrz3XwA6bon+B8RXxEBPsptqAAAAABJRU5ErkJggg=="></button> | |
| </div> | |
| <div id="mySidebar" class="slide-out"> | |
| <div id="menuOptions"> | |
| <li onclick="openTab(event, 'home')" >Measure Plans </li> | |
| <li><a href="{{ url_for('searchDocument') }}">Search in Documents</a></li> | |
| </div> | |
| </div> | |
| <div id="home" class="tabcontent" > | |
| <div id="loading" hidden> </div> | |
| <div id="canvaswindow" hidden="until-found"> | |
| <canvas id="myCanvas"></canvas> | |
| <br> | |
| <input type="button" value="Draw New Shape" id="NewShapeButtonId" /> | |
| <input type="button" value="Undo" id="undoButtonId" /> | |
| <div id="colorpickers"> | |
| <input type="color" id="color" value="#2FFFFF" > | |
| </div> | |
| <input type="button" value="Save" id="savecanvas" /> | |
| </div> | |
| <div id="rightside"> | |
| <div id="backgroundimg" > </div> | |
| <div id="underimgbuttons"></div> | |
| </div> | |
| <div id="myModal" class="modal" > | |
| <span class="close">×</span> | |
| <img class="modal-content" id="img01"> | |
| <div id="caption"></div> | |
| </div> | |
| <form method="post" id="myForm" > | |
| <!-- <div class="projnamedp"> | |
| <input type="text" placeholder="Project" name="selectproj" class="selectionsProj" id="selectionsProjid" oninput="filterFunction(this,event)" > | |
| <ul> | |
| </ul> | |
| </div> --> | |
| <div id =""> | |
| <select name="selectproj" class="selectionsProj" id="selectionsProjid" required > </select> | |
| </div> | |
| <div id ="projectpart"> | |
| <select name="selectprojp" class="selectionsProjp" id="selectionsProjpid" required> </select> | |
| </div> | |
| <div id ="projectsection"> | |
| <select name="selectprojs" class="selectionsProjs" onchange=getproj() required> </select> | |
| </div> | |
| <div id ="tomeasurediv"> | |
| <label id="measureLabel">Document To Measure</label> <br> | |
| <div id="measureCheckbox"> | |
| <select style="margin-left: -1%;" hidden name="measureselectname" id="measureselectid" multiple size="5" required> </select> | |
| <select id='selectunitA' hidden> | |
| <option id="m2" value="m2" >m² </option> | |
| <option id="mm2" value="mm2" >mm² </option> | |
| </select> | |
| <select id='selectunitP' hidden> | |
| <option id="m" value="m" >m </option> | |
| <option id="mm"value="mm" >mm </option> | |
| </select> | |
| </div> | |
| </div> | |
| <div id ="relvDocdiv"> | |
| <label id="relvDocLabel">Other Relevant Documents</label> <br> | |
| <div id ="relvdiv"> | |
| <select style="margin-left: -1%;" hidden name="relvselectname" id="relvselectid" multiple size="5"> </select> | |
| </div> | |
| </div> | |
| <div id="ratios"> </div> | |
| <div id="radiosColors" hidden="until-found"> | |
| <input type="checkbox" id="levelcheckbox" > | |
| <label id=nLevels name="levelsnamelabel" >Leveled Plan </label> | |
| <i class="fa fa-info-circle" id="infotool" > <span class="tooltiptext">Choose whether this project contains levels or not. Leave the checkbox unchecked if you want to measure the entirety of the plan. <br> Please check the box on this line if you want to measure certain areas of the plan or have the plan divided into levels. Once the checkbox is ticked, a window will apear that will allow you to draw on the PDF. Click the save button at the bottom of the page when you are done. </span> </i> | |
| </div> | |
| <br> | |
| <div id ="saveOPdiv"> | |
| <button id="measureADRbutton">Measure using ADR</button> | |
| <script src="https://cdn.lordicon.com/bhenfmcm.js"></script> | |
| <lord-icon | |
| src="https://cdn.lordicon.com/ynwbvguu.json" | |
| trigger="hover" colors="primary:black" id="addicon" style="display: none;" onclick="duplicate()" > | |
| </lord-icon> | |
| </div> | |
| <audio id="myAudio" autoplay></audio> | |
| </form> | |
| <div id ="duplicater" class="duplicaterclass" hidden="until-found"> | |
| <label id="labelArrayId" hidden="until-found"> </label> | |
| <select name="measurementscripts" class="measurementselections" id="measurementselectionsid" > </select> | |
| <select name="select" class="selections" id="selectionsid" > | |
| </select> | |
| <select name="measureitem" class="measureitems" id="measureitemsid"> </select> | |
| <br> | |
| <div id="repeatforloop" class="repeatforloopclass00" name="repeatforloopname " > | |
| <input type="text" id="text0" name="text1name" placeholder="GB-1" class=gb> | |
| <input type="text" id="text1" name="text2name" placeholder="A" class=a> | |
| <input type="text" id="text2" name="text3name" placeholder="Depth" class=depth> | |
| <script src="https://cdn.lordicon.com/bhenfmcm.js" ></script> | |
| <lord-icon | |
| onclick="addmctnameicon()" | |
| src="https://cdn.lordicon.com/mecwbjnp.json" | |
| trigger="hover" | |
| class="addmctnameclass" | |
| id="addmctnameid" | |
| colors="primary:black,secondary:black"> | |
| </lord-icon> | |
| </div> | |
| </div> | |
| <button hidden id="doneebackground" onclick="getSecondData()" > Export Summary </button> | |
| <div hidden id ="duplicaterhidden" class="duplicaterclasshidden"> | |
| <label id="labelArrayId" hidden="until-found"> </label> | |
| <select name="measurementscripts" class="measurementselections" id="measurementselectionsid" > | |
| <option value="" disabled selected hidden>Select</option> | |
| </select> | |
| <select name="select" class="selections" id="selectionsid"> </select> | |
| <select type="text" name="measureitem" class="measureitems" id="measureitemsid"> </select> | |
| <!-- <select name="select" class="selections" id="selectionsM-M2" > </select> --> | |
| <br> | |
| <div id="repeatforloophidden" class="repeatforloopclasshidden" name="repeatforloopnamehidden " > <!-- onchange="getmctName()" --> | |
| <input type="text" id="text0" name="text1name" placeholder="GB-1" class=gb> | |
| <input type="text" id="text1" name="text2name" placeholder="A" class=a> | |
| <input type="text" id="text2" name="text3name" placeholder="Depth" class=depth> | |
| <script src="https://cdn.lordicon.com/bhenfmcm.js" ></script> | |
| <lord-icon | |
| onclick="addmctnameicon()" | |
| src="https://cdn.lordicon.com/mecwbjnp.json" | |
| trigger="hover" | |
| class="addmctnameclass" | |
| id="addmctnameid" | |
| colors="primary:black,secondary:black"> | |
| </lord-icon> | |
| <script src="https://cdn.lordicon.com/bhenfmcm.js"></script> | |
| <lord-icon | |
| onclick="deletemctnameicon()" | |
| src="https://cdn.lordicon.com/rivoakkk.json" | |
| trigger="hover" | |
| class="deletemctnameclass" | |
| id="deletemctnameid" | |
| colors="primary:black,secondary:black"> | |
| </lord-icon> | |
| </div> | |
| </div> | |
| </div> | |
| <div id="legends" class="tabcontent"> | |
| <ul class="graynavbarLegend" > | |
| <label class="label1">Project Name / Project Part / NRM Section /</label> <label class="label2">Legend</label> | |
| <div class="legendtime"> | |
| <div style="display: inline-flex;"> | |
| <label class="CreatedTime"> Created Time </label> | |
| <button id="sortBtnCreateDesc" class="sortbutton" onclick="sortlegends(this.id)"><i id="CreatesortDesc" class="fa fa-sort-amount-desc" aria-hidden="true" ></i> </button> | |
| <button id="sortBtnCreateAsc" class="sortbutton" onclick="sortlegends(this.id)"><i id="CreatesortAsc" class="fa fa-sort-amount-asc" aria-hidden="true" ></i></button> | |
| </div> | |
| <div style="display: inline-flex;"> | |
| <label class="EditTime"> Last Edited Time </label> | |
| <button id="sortBtnEditDesc" class="sortbutton" onclick="sortlegends(this.id)"><i id="EditsortDesc" class="fa fa-sort-amount-desc" aria-hidden="true" ></i></button> | |
| <button id="sortBtnEditAsc"class="sortbutton" onclick="sortlegends(this.id)"><i id="EditsortAsc" class="fa fa-sort-amount-asc" aria-hidden="true" ></i> </button> | |
| </div> | |
| </div> | |
| </ul> | |
| </div> | |
| <div class="dropdown-content"> | |
| <div id="userguidetext"> | |
| <div id="textfirstpage"> | |
| <label style="font-style: oblique;"> | |
| <br> Before using this tool, kindly read the following. </label> | |
| <br><br> | |
| <label style="font-style: oblique;" > | |
| Note : The algorithm is based on detecting shapes and colors from the plan. Some shapes such as tables and textboxes carrying plan-related information, may also be viewed as shapes and so added to the algorithm. To avoid this, please tidy up the plan before choosing to measure it, by using an external tool to either erase them or to put a white rectangle over them. | |
| </label> | |
| <br> | |
| <br> | |
| The tool is divided into two main parts: | |
| <br> | |
| <li id="userguideheadings"> First Part </li> | |
| <label id="underlinedLables"> - Inputs: </label> | |
| <br>There are three dropdowns available that will allow you to select the name of the project you wish to measure, along with the project part, and the project section. | |
| <br > <br> | |
| <label style="font-style: italic;"> Please make sure the “Project Section” you select is correct because it will affect the code that will be applied to the plan. </label> | |
| <br> | |
| <br> | |
| Mark the project from the "To measure" section that you want to measure. Additionally, you have the ability to view any relevant documents you might need in Dropbox.(optional). | |
| <br> <label style="font-style: italic;"> * Pixel to Metric conversion important notes : </label> Once you have selected a specific plan to measure, you will be provided with a pdf with a colored rectangle drawn in it. Please open this PDF in Foxit Reader, Adobe, or any software that will allow you to measure shapes on a plan, and measure the given shape’s area and perimeter in the desired metric unit, then input those values in the textboxes that will be shown below the relevant documents. | |
| For the ease of conversion of metric units, you will find a dropdown with ‘m’ or ‘mm’ next to each textbox. | |
| This will allow the code to understand the ratio between the pixels to the metric unit you chose. | |
| <br> | |
| You may think of this rectangle's measurement as a scale check for Bluebeam. | |
| <br> <br> | |
| <label style="font-style: italic;"> * Notes for section 1.0 measurement (Section 3.2 does not yet support this feature): </label> | |
| <label id=info >You can measure several levels independently using checkbox labeled 'Leveled plan' under Scale document heading. </label> | |
| Leave the checkbox unchecked if you want to measure the entirety of the plan. <br>Please tick the box if you want to measure certain areas of the plan or have the plan divided into levels. Once the checkbox is ticked, a window will appear that will allow you to draw on the PDF. Click the save button at the bottom of the page when you are done. | |
| <br> | |
| <i id="secondpage" class="fa fa-arrow-right" aria-hidden="true"></i> | |
| <br> <br> | |
| </div> | |
| <div id="textsecondpage" hidden=until-found> | |
| <br> | |
| <label id="underlinedLables"> - Outputs: </label> <br> | |
| On the right side of the console, the output will be displayed. There are three primary components to it. | |
| You may have a sneak peek of the measured plan in the first section. There are two buttons underneath this picture. You may access the Google sheet that was created by clicking the "Legend and Data created" button. The "Click to view as PDF" second button directs you to the marked-up PDF that was created in Dropbox. | |
| <br> <br> | |
| ONLY IN DROPBOX VIEW. DO NOT DOWNLOAD THE PDF FOR THIS FEATURE. | |
| Any markup that you deem unnecessary in the pdf can be removed, and the legend will also be updated accordingly. | |
| <li id="userguideheadings" > Second part </li> | |
| <br> | |
| To open the Google sheet with the created legend, first click the button labeled "Legend and Data created." Names of each shape should go in the first column of the sheet labeled ‘Guess’. | |
| <br>Ex. GB-1. | |
| <br> Then, return to this page, the ADR Console, to finish entering the remaining data after you have finished entering the guessed names in the legend. | |
| <br> Three dropdown menus and three text boxes are present. | |
| <li style="list-style-type:square;"> You can select the type of the shape from the first dropdown by selecting either: | |
| <br>    a. (1.0 Substructure) Ground Beam or Pile Cap | |
| <br>    b. (3.2 Floor Finishes) Floor or Wall | |
| </li> | |
| <li style="list-style-type:square;"> In the second dropdown, you will find a list of MC-T Names. Choose Accordingly.</li> | |
| <li style="list-style-type:square;"> The third dropdown menu has the unit of the MC-T Name you have chosen.</li> | |
| <br> Note: If the unit was (m), choose whether you wish to extract perimeter or length data from the third selection. | |
| <br><br><label style="font-style: italic;"> Regarding the MC-T naming process: </label> | |
| Then add the relevant detail and depth to the rows underneath the dropdowns. | |
| You can add/ subtract rows by using the + and - button. | |
| <br> | |
| You can add another block and repeat the process for another item by clicking the button next to "Measure using ADR". | |
| <br><br> | |
| <i id="firstpage" class="fa fa-arrow-left" aria-hidden="true"></i> | |
| <br> <br> | |
| </div> | |
| </div> | |
| </div> | |
| <!-- POP-UP code -- to handle errors --> | |
| <!-- Link to trigger modal --> | |
| <!-- Modal popup box --> | |
| <div id="mpopupBox" class="mpopup"> | |
| <!-- Modal content --> | |
| <div class="modal-content"> | |
| <div class="modal-header"> | |
| <span class="close">×</span> | |
| <h2>Error</h2> | |
| </div> | |
| <div class="modal-body"> | |
| <p id="modal-bodyText"> | |
| </p> | |
| </div> | |
| </div> | |
| </div> | |
| </body> | |
| </html> | |
| <script > | |
| ///////////////////////////////////////////////BEGIN JS CODE////////////////////////////////////////////////// | |
| PopupElement=document.getElementById('modal-bodyText'); | |
| // add project names to first dropdown from google sheet | |
| firstdropdown=document.getElementsByClassName('selectionsProj')[0]; | |
| seconddropdown=document.getElementsByClassName('selectionsProjp')[0]; | |
| thirddropdown=document.getElementsByClassName('selectionsProjs')[0]; | |
| $(firstdropdown).select2({ | |
| placeholder:'Projects', | |
| closeOnSelect: true, | |
| width:'51ch' | |
| }); | |
| $(seconddropdown).select2({ | |
| placeholder:'Project Parts', | |
| closeOnSelect: true, | |
| width:'51ch' | |
| }); | |
| $(thirddropdown).select2({ | |
| placeholder:'Sections', | |
| closeOnSelect: true, | |
| width:'51ch' | |
| }); | |
| var measSelect = document.getElementById("measureselectid"); | |
| var relvSelect = document.getElementById("relvselectid"); | |
| document.getElementById("all").style.display = "block"; | |
| PrjNamesArray=[]; | |
| PrjPartsArray=[]; | |
| PrjSectionsArray=[]; | |
| var partsArrwithID=[]; | |
| var firstDpwnValue; | |
| $.get('/getprojectnames/') | |
| .success(function(data) { | |
| document.getElementById("all").style.display = "none"; | |
| for (let i=0;i<data.length;i++) | |
| { | |
| var op0 = document.createElement("OPTION") ; | |
| op0.text= 'Projects' | |
| op0.value= ""; | |
| op0.hidden=true; | |
| firstdropdown.add(op0); | |
| opt=document.createElement("option"); | |
| opt.textContent=data[i]; | |
| opt.text=data[i]; | |
| firstdropdown.append(opt); | |
| PrjNamesArray.push(data[i]); | |
| } | |
| }) | |
| .error(function(jqXHR, textStatus, errorThrown) { | |
| 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. '; | |
| ShowPopUp(); | |
| }); | |
| /*Get chosen value and send to flask to get project parts*/ | |
| // firstdropdownInput=document.getElementById('selectionsProjid'); | |
| // console.log('kk',firstdropdownInput) | |
| $(firstdropdown).on("change", function (e) { | |
| console.log('clickeds') | |
| firstDpwnValue=firstdropdown.value; | |
| seconddropdown.innerHTML=''; | |
| var op0 = document.createElement("OPTION") ; | |
| op0.text= 'Project Part' | |
| op0.value= ""; | |
| op0.hidden=true; | |
| seconddropdown.add(op0); | |
| var ii, L = seconddropdown.options.length - 1; | |
| for(ii = L; ii >= 0; ii--) { | |
| if (seconddropdown.options[ii].value) | |
| seconddropdown.remove(ii); | |
| } | |
| console.log(firstDpwnValue) | |
| displayprojparts(firstDpwnValue); | |
| }) | |
| function displayprojparts(name){ | |
| document.getElementById("all").style.display = "block"; | |
| $.get('/getprojectparts/'+JSON.stringify(name)) | |
| .success(function(data){ | |
| document.getElementById("all").style.display = "none"; | |
| partsArrwithID= data; | |
| for (let i=0;i<data.length;i++) | |
| { | |
| opt=document.createElement("option"); | |
| opt.value=data[i]; | |
| opt.text=data[i]; | |
| seconddropdown.append(opt); | |
| PrjPartsArray.push(data[i]); | |
| } | |
| }) | |
| .error(function(jqXHR, textStatus, errorThrown) { | |
| 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. '; | |
| ShowPopUp(); | |
| }); | |
| } | |
| $(seconddropdown).on("change", function (e) { | |
| thirddropdown.innerHTML=''; | |
| var op0 = document.createElement("OPTION") ; | |
| op0.text= 'Section' | |
| op0.value= ""; | |
| op0.hidden=true; | |
| thirddropdown.add(op0); | |
| displayprojsections(firstdropdown.value,seconddropdown.value); | |
| }) | |
| function displayprojsections(projectName,PartName){ | |
| document.getElementById("all").style.display = "block"; | |
| measSelect.innerHTML=''; | |
| relvSelect.innerHTML=''; | |
| $.get('/getprojectsections/'+JSON.stringify([projectName,PartName])) | |
| .success(function(data){ | |
| document.getElementById("all").style.display = "none"; | |
| for (let i=0;i<data.length;i++) | |
| { | |
| opt=document.createElement("option"); | |
| opt.value=data[i]; | |
| opt.text=data[i]; | |
| thirddropdown.append(opt); | |
| if(!(data[i].startsWith('1.0') || data[i].startsWith('3.2') ||data[i].startsWith('2.2'))) | |
| { | |
| opt.style.color='#bdbcbc'; | |
| opt.style.cursor='not-allowed'; | |
| opt.setAttribute('disabled',true) | |
| } | |
| PrjSectionsArray.push(data[i]); | |
| } | |
| }) | |
| .error(function(jqXHR, textStatus, errorThrown) { | |
| 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. '; | |
| ShowPopUp(); | |
| }); | |
| } | |
| /*Menu bar icon mySidebar and Toggle*/ | |
| var $mySidebar = document.getElementById('mySidebar'); | |
| var $toggle = document.getElementById('toggle'); | |
| $toggle.addEventListener('click', function() { | |
| var isOpen = $mySidebar.classList.contains('slide-in'); | |
| w3_open(); | |
| $mySidebar.setAttribute('class', isOpen ? 'slide-out' : 'slide-in'); | |
| $toggle.classList.toggle("change"); | |
| if ($mySidebar.classList.contains('slide-out')){ | |
| w3_close() | |
| } | |
| }); | |
| //___________________________________________________________________________________________________________ | |
| //___________________________________________________________________________________________________________ | |
| /*Retrieve MCTNAMES Dictionary from API - Flask*/ | |
| MCTNames={} | |
| function getALLMCTNAMES(){ | |
| $.get( '/RetrieveMCTNames/'+thirddropdown.value) | |
| .success (function(data){ | |
| MCTNames=data; | |
| console.log(MCTNames) | |
| }) | |
| .error(function(jqXHR, textStatus, errorThrown) { | |
| PopupElement.textContent='Error occured while retrieving the MC-T Names. Refresh and try again. If the error continues, please contact the ADR team to fix it. '; | |
| ShowPopUp(); | |
| }); | |
| } | |
| //___________________________________________________________________________________________________________ | |
| //___________________________________________________________________________________________________________ | |
| /****Values of MCTname rows at the end of the conssole( grouping shapes) -->legend summary ****/ | |
| document.getElementById('duplicater').childNodes[1].value=[0,0] | |
| //___________________________________________________________________________________________________________ | |
| //___________________________________________________________________________________________________________ | |
| /*Tab View of User Guide*/ | |
| document.getElementById('secondpage').addEventListener('click',function(){ | |
| document.getElementById('textsecondpage').removeAttribute('hidden'); | |
| document.getElementById('textfirstpage').setAttribute('hidden',true) | |
| }); | |
| document.getElementById('firstpage').addEventListener('click',function(){ | |
| document.getElementById('textfirstpage').removeAttribute('hidden'); | |
| document.getElementById('textsecondpage').setAttribute('hidden',true) | |
| }); | |
| function w3_open() { | |
| document.getElementById("home").style.marginLeft = "25%"; | |
| document.getElementById("legends").style.marginLeft = "25%"; | |
| document.getElementById("home").style.transition= '0.8s'; | |
| document.getElementById("legends").style.transition= '0.8s'; | |
| document.getElementById("mySidebar").style.width = "25%"; | |
| document.getElementById("mySidebar").style.display = "block"; | |
| } | |
| function w3_close() { | |
| document.getElementById("home").style.marginLeft = "0%"; | |
| document.getElementById("legends").style.marginLeft = "0%"; | |
| document.getElementById("home").style.transition= '1.5s' | |
| document.getElementById("legends").style.transition= '1.5s' | |
| document.getElementById("mySidebar").style.display = "none"; | |
| } | |
| //___________________________________________________________________________________________________________ | |
| //___________________________________________________________________________________________________________ | |
| /*Red Alert to fill in the first 3 dropdowns: prj name, part, section*/ | |
| document.getElementById('measureADRbutton').addEventListener('click',function(){ | |
| if (!document.getElementsByClassName('selectionsProj')[0].value) | |
| document.getElementsByClassName('selectionsProj')[0].style.boxShadow='0 0 8px 2px rgb(255, 0, 0)'; | |
| if (!document.getElementsByClassName('selectionsProjp')[0].value) | |
| document.getElementsByClassName('selectionsProjp')[0].style.boxShadow='0 0 8px 2px rgb(255, 0, 0)'; | |
| if (!document.getElementsByClassName('selectionsProjs')[0].value) | |
| document.getElementsByClassName('selectionsProjs')[0].style.boxShadow='0 0 8px 2px rgb(255, 0, 0)'; | |
| //___________________________________________________________________________________________________________ | |
| //___________________________________________________________________________________________________________ | |
| /*Clear output everytime the user clicks on measureADR button*/ | |
| var rightside=document.getElementById('rightside'); | |
| var rightchidren= rightside.children; | |
| for (let ch=0;ch<rightchidren.length; ch++) | |
| { | |
| if (rightchidren[ch].id == 'imgcanvas') | |
| { | |
| rightside.removeChild(rightchidren[ch]) | |
| document.getElementById('underimgbuttons').innerHTML='' | |
| clearInterval() | |
| clearTimeout() | |
| } | |
| } | |
| }); | |
| //___________________________________________________________________________________________________________ | |
| //___________________________________________________________________________________________________________ | |
| /*Toggle Tab View of Home and Legend along with the Menu bar icon*/ | |
| function openTab(evt, tabname) { | |
| // Declare all variables | |
| var i, tabcontent, tablinks; | |
| // Get all elements with class="tabcontent" and hide them | |
| tabcontent = document.getElementsByClassName("tabcontent"); | |
| for (i = 0; i < tabcontent.length; i++) { | |
| tabcontent[i].style.display = "none"; | |
| } | |
| // Get all elements with class="tablinks" and remove the class "active" | |
| tablinks = document.getElementsByClassName("tablinks"); | |
| for (i = 0; i < tablinks.length; i++) { | |
| tablinks[i].className = tablinks[i].className.replace(" active", ""); | |
| } | |
| // Show the current tab, and add an "active" class to the button that opened the tab | |
| document.getElementById(tabname).style.display = "block"; | |
| evt.currentTarget.className += " active"; | |
| var isOpen = $mySidebar.classList.contains('slide-in'); | |
| if ($mySidebar.classList.contains('slide-in')) | |
| {$mySidebar.setAttribute('class', isOpen ? 'slide-out' : 'slide-in'); | |
| document.getElementById("pagetitle").style.backgroundColor='rgb(0, 60, 255)'; | |
| $toggle.classList.toggle("change"); | |
| } | |
| } | |
| // Start with the first page (Home) | |
| document.getElementById("pagetitle").click(); | |
| //___________________________________________________________________________________________________________ | |
| //___________________________________________________________________________________________________________ | |
| /*Add icon to duplicate 'duplicater' div (big section that includes 3 dropdowns,3 textboxes, 2 buttons(add,delete)*/ | |
| var dupliatei = 0; // i | |
| var clonedDivId=0; | |
| var original = document.getElementById('duplicaterhidden'); | |
| var addciconval=0; //div duplicate | |
| var jj=0; | |
| const vals = []; | |
| var canvasimg; | |
| var ry = [[]]; | |
| var section = document.getElementsByClassName("selectionsProjs")[0] | |
| function duplicate() { | |
| /*Create array of addciconval w jj */ | |
| addciconval+=1; | |
| jj=0; | |
| var clone = original.cloneNode(true); // "deep" clone | |
| console.log('clonee',clone.children) | |
| clone.id = 'duplicater' + ++dupliatei; | |
| clonedDivId=clone.id; | |
| clone.children[0].value=[addciconval,jj] | |
| clone.children[5].style.marginLeft='5px'; | |
| // clone.children[1].style.marginBottom='10px'; | |
| clone.children[5].children[4].id='addmctnameid'+dupliatei | |
| clone.children[5].children[6].style.display='none' | |
| clone.children[5].style.marginTop='8px'; | |
| clone.removeAttribute("hidden"); | |
| clone.setAttribute('class','duplicaterclass'+dupliatei); | |
| clone.getElementsByClassName('measurementselections')[0].setAttribute('name', 'measurementscripts'+dupliatei); | |
| clone.getElementsByClassName('measurementselections')[0].setAttribute('class', 'measurementselections'+dupliatei); | |
| clone.getElementsByClassName('measureitems')[0].setAttribute('name', 'measureitem'+dupliatei); | |
| clone.getElementsByClassName('measureitems')[0].setAttribute('class', 'measureitems'+dupliatei); | |
| clone.getElementsByClassName('selections')[0].setAttribute('name', 'select'+dupliatei); | |
| clone.getElementsByClassName('selections')[0].setAttribute('class', 'selections'+dupliatei); | |
| clone.getElementsByClassName('repeatforloopclasshidden')[0].setAttribute('id', 'repeatforloop'+addciconval+'0'); | |
| clone.getElementsByClassName('repeatforloopclasshidden')[0].setAttribute('name', 'repeatforloopname'+addciconval+'0'); | |
| clone.getElementsByClassName('repeatforloopclasshidden')[0].setAttribute('class', 'repeatforloopclass'+addciconval+'0'); | |
| original.parentNode.appendChild(clone); | |
| clone.parentElement.insertBefore(clone, document.getElementById('doneebackground')); | |
| /*Based on the NRM section , populate the second part of the interface*/ | |
| if (addciconval>0){ | |
| var inputs1 = document.getElementsByClassName("measurementselections"+dupliatei)[0]; //1sr dpdwn | |
| var selections1 = document.getElementsByClassName("selections"+dupliatei)[0]; //2nd dropdown | |
| var measitem1 = document.getElementsByClassName("measureitems"+dupliatei)[0]; //3rd dpdwn | |
| $(inputs1).select2({ | |
| placeholder:'Select', | |
| closeOnSelect: true, | |
| width:'15ch' | |
| }); | |
| $(selections1).select2({ | |
| placeholder:'Select MC-T Name', | |
| closeOnSelect: true, | |
| width:'23ch' | |
| }); | |
| $(measitem1).select2({ | |
| placeholder:'Select unit', | |
| closeOnSelect: true, | |
| width:'11ch' | |
| }); | |
| $(inputs1).on("change", function (e) { | |
| get3rddropdown(); | |
| }); | |
| $(selections1).on("change", function (e) { | |
| get3rddropdown(); | |
| }) | |
| if (section.value.startsWith('1.0')) | |
| { | |
| var opt = document.createElement("OPTION"); | |
| opt.text= 'Select'; | |
| opt.value= ""; | |
| opt.hidden=true; | |
| inputs1.add(opt); | |
| var optn = document.createElement("OPTION"); | |
| optn.text= 'Ground Beams'; | |
| optn.value= "ground beams"; | |
| inputs1.add(optn); | |
| var optn1 = document.createElement("OPTION"); | |
| optn1.text= 'Pile Caps'; | |
| optn1.value= "pile caps"; | |
| inputs1.add(optn1); | |
| } | |
| if (section.value.startsWith('3.2')) | |
| { | |
| var opt = document.createElement("OPTION"); | |
| opt.text= 'Select'; | |
| opt.value= ""; | |
| opt.hidden=true; | |
| inputs1.add(opt); | |
| var optn = document.createElement("OPTION"); | |
| optn.text= 'Floor'; | |
| optn.value= "Floor"; | |
| inputs1.add(optn); | |
| var optn1 = document.createElement("OPTION"); | |
| optn1.text= 'Wall'; | |
| optn1.value= "Wall"; | |
| inputs1.add(optn1); | |
| } | |
| } | |
| } | |
| //___________________________________________________________________________________________________________ | |
| //___________________________________________________________________________________________________________ | |
| /*User Guide button toggle*/ | |
| function userguideclick(){ | |
| var acc = document.getElementsByClassName("dropdown-content")[0]; | |
| var i; | |
| acc.classList.toggle("active"); | |
| /* Toggle between hiding and showing the active panel */ | |
| if (acc.style.display === "block") { | |
| acc.style.display = "none"; | |
| } else { | |
| acc.style.display = "block"; | |
| acc.style.backgroundColor=(0, 153, 255); | |
| } | |
| } | |
| //to be retrieved from python code | |
| var areainpixels=0; | |
| var prminpixels=0; | |
| //___________________________________________________________________________________________________________ | |
| //___________________________________________________________________________________________________________ | |
| /*Populate dropdowns*/ | |
| //get the 3 dropdown elements | |
| var proj = document.getElementsByClassName("selectionsProj")[0]; | |
| var proj1 = document.getElementsByClassName("selectionsProjp")[0]; | |
| var projsec = document.getElementsByClassName("selectionsProjs")[0]; | |
| var pdfname; | |
| projsec.addEventListener('input',function(){ | |
| projsec.style.boxShadow=( '2px 2px 2px gray') | |
| }) | |
| var ratioAunit=1; | |
| var ratioPunit=1; | |
| //___________________________________________________________________________________________________________ | |
| //___________________________________________________________________________________________________________ | |
| //Retrieves list of projects | |
| function getproj(){ | |
| getALLMCTNAMES(); | |
| document.getElementById("all").style.display = "block"; | |
| var proj = document.getElementsByClassName("selectionsProj")[0]; | |
| var projectVal=proj.value.toString() //selected project | |
| var inputs = document.getElementsByTagName("select")[1]; //second dropdown(project part) | |
| var p=document.getElementById("selectionsProjpid") //project part | |
| var sections = document.getElementsByClassName("selectionsProjs")[0]; | |
| chooseFirstdrpdwn(); | |
| $.get( '/getmethod/'+JSON.stringify(projectVal)) | |
| .success (function(data){ | |
| document.getElementById("all").style.display = "none"; | |
| console.log(data[0],data[1]) | |
| var docsToMeasure=data[0]; // | |
| var relvDocs=data[1] | |
| var projname = document.getElementsByClassName("selectionsProj")[0]; | |
| var projpart = document.getElementsByClassName("selectionsProjp")[0]; | |
| var projsec = document.getElementsByClassName("selectionsProjs")[0]; | |
| var meas = document.getElementById("measureCheckbox") ; | |
| var relv = document.getElementById("relvdiv") ; | |
| const measids=[]; | |
| const relvids=[]; | |
| const measoptns=[]; | |
| var measSelect = document.getElementById("measureselectid"); | |
| var relvSelect = document.getElementById("relvselectid"); | |
| var levelcheckbox= document.getElementById("levelcheckbox"); | |
| measSelect.removeAttribute("hidden"); | |
| relvSelect.removeAttribute("hidden"); | |
| measSelect.innerHTML=''; | |
| var optn2 = document.createElement("OPTION"); | |
| optn2.text= 'Select project to measure'; | |
| optn2.value='' | |
| optn2.hidden=true; | |
| optn2.id='hidden'; | |
| measSelect.add(optn2); | |
| document.getElementById("hidden").required = true; | |
| // console.log(measSelect) | |
| relvSelect.innerHTML=''; | |
| for (i = 0; i < docsToMeasure.length; i++) { | |
| //relevant documents | |
| var optn1 = document.createElement("OPTION"); | |
| optn1.text= relvDocs[i][0]; | |
| optn1.value= relvDocs[i][0] ; | |
| optn1.id=relvDocs[i][1] ; | |
| relvSelect.add(optn1); | |
| if (data=='No projects found'){ | |
| optn1.style.color='#bdbcbc'; | |
| optn1.style.cursor='not-allowed'; | |
| optn1.setAttribute('disabled',true); | |
| } | |
| //to measure documents | |
| var optn2 = document.createElement("OPTION"); | |
| optn2.text= docsToMeasure[i][0]; | |
| optn2.value= docsToMeasure[i][0] ; | |
| optn2.id=docsToMeasure[i][1] ; | |
| measSelect.add(optn2); | |
| measoptns.push(optn2); | |
| if (data=='No projects found'){ | |
| optn2.style.color='#bdbcbc'; | |
| optn2.style.cursor='not-allowed'; | |
| optn2.setAttribute('disabled',true); | |
| } | |
| } | |
| relvids.push(relvSelect) ; | |
| measids.push(measSelect); | |
| //to open pdf in a new tab (relevant documents) | |
| relvids.forEach(function(elem){ | |
| elem.addEventListener("change", function() { | |
| document.getElementById("all").style.display = "block"; | |
| // var pdfpatharr=[] | |
| // pdfpatharr.push(projname.value, projpart.value,projsec.value, elem.value) | |
| $.get( '/getdropboxurl/'+JSON.stringify(elem.value)) | |
| .success (function(data){ | |
| document.getElementById("all").style.display = "none"; | |
| window.open( data) | |
| }) | |
| .error(function(jqXHR, textStatus, errorThrown) { | |
| PopupElement.textContent='Error occured while retrieving the dropbox URL. Refresh and try again. If the error continues, please contact the ADR team to fix it. '; | |
| ShowPopUp(); | |
| }); | |
| }); | |
| }); | |
| measids.forEach(function(elem) { | |
| elem.addEventListener("change", function() { | |
| canvasimg=''; | |
| ry=[[]]; | |
| levelcheckbox.checked=false; | |
| pdfname=elem.value; | |
| measSelect.style.boxShadow='none'; | |
| document.getElementById("all").style.display = "block"; | |
| pixelArr=[projname.value, projpart.value,projsec.value, pdfname] | |
| $.get( '/pixelimg/'+JSON.stringify(pixelArr)) | |
| .success( function(data) { | |
| document.getElementById("all").style.display = "none"; | |
| if(window.confirm("Measure the purple shape drawn on the pdf using Foxit Reader or any other external tool, then enter its area and perimeter in your desired scale. \n")){ | |
| window.open(data[2]); | |
| } | |
| document.getElementById("all").style.display = "none"; | |
| document.getElementById('measureADRbutton').onclick= function() | |
| { | |
| if (!areaRatio.value) | |
| areaRatio.style.boxShadow='0 0 8px 2px rgb(255, 0, 0)'; | |
| if (!prmRatio.value) | |
| prmRatio.style.boxShadow='0 0 8px 2px rgb(255, 0, 0)'; | |
| } | |
| document.getElementById('radiosColors').removeAttribute('hidden'); | |
| var scalelbl= document.createElement("label"); | |
| scalelbl.innerText='Scale Document'; | |
| scalelbl.id='measureLabel'; | |
| var br1= document.createElement("br"); | |
| var areadiv=document.createElement("div"); | |
| areadiv.id='areadiv' | |
| var areaRatiolbl= document.createElement("label"); | |
| areaRatiolbl.innerText='Area:' | |
| areaRatiolbl.id='radiolbl'; | |
| var areaRatio= document.createElement("input"); | |
| areaRatio.type='number'; | |
| areaRatio.id='lvlinput'; | |
| areaRatio.name='areaRatio'; | |
| areaRatio.style.marginLeft='78px'; | |
| areaRatio.style.textAlign='right'; | |
| areaRatio.step=".0000001"; | |
| areaRatio.addEventListener('change',function(){ | |
| areaRatio.value=(Number(areaRatio.value)).toFixed(7) | |
| areaRatio.style.boxShadow='none'; | |
| }) | |
| areaRatio.required=true; | |
| selectunitA=document.getElementById('selectunitA') | |
| selectunitA.removeAttribute('hidden') | |
| areadiv.append(areaRatiolbl,areaRatio,selectunitA) | |
| var br2= document.createElement("br"); | |
| var br3= document.createElement("br"); | |
| var prmdiv=document.createElement("div"); | |
| prmdiv.id='prmdiv' | |
| var prmRatiolbl= document.createElement("label"); | |
| prmRatiolbl.innerText='Perimeter:' | |
| prmRatiolbl.id='radiolbl'; | |
| var prmRatio= document.createElement("input"); | |
| prmRatio.type='number'; | |
| prmRatio.id='lvlinput'; | |
| prmRatio.name='prmRatio'; | |
| prmRatio.style.textAlign='right'; | |
| // prmRatio.onchange=setNumberDecimal(); | |
| prmRatio.style.marginLeft='49px'; | |
| prmRatio.step=".0000001"; | |
| prmRatio.addEventListener('change',function(){ | |
| prmRatio.value=(Number(prmRatio.value)).toFixed(7) | |
| prmRatio.style.boxShadow='none'; | |
| }) | |
| prmRatio.required=true; | |
| selectunitP=document.getElementById('selectunitP') | |
| selectunitP.removeAttribute('hidden') | |
| prmdiv.append(prmRatiolbl, prmRatio,selectunitP) | |
| var ratiosdiv= document.getElementById("ratios"); | |
| ratiosdiv.innerHTML=''; | |
| ratiosdiv.append(scalelbl); | |
| ratiosdiv.append(br1); | |
| ratiosdiv.append(areadiv) | |
| ratiosdiv.append(prmdiv) | |
| areainpixels=data[0]; | |
| prminpixels=data[1]; | |
| }) | |
| .error(function(jqXHR, textStatus, errorThrown) { | |
| 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. '; | |
| ShowPopUp(); | |
| }); | |
| selectunitA.addEventListener('change',function(){ | |
| value=document.getElementById('selectunitA').value | |
| if (value=='mm2') | |
| ratioAunit=1000000; | |
| else | |
| ratioAunit=1; | |
| }) | |
| selectunitP.addEventListener('change',function(){ | |
| value=document.getElementById('selectunitP').value | |
| if (value=='mm') | |
| ratioPunit=1000; | |
| else | |
| ratioPunit=1; | |
| }) | |
| }); | |
| }); | |
| document.getElementById('measureADRbutton').onclick= function() | |
| { | |
| if (!measSelect.value) | |
| measSelect.style.boxShadow='0 0 8px 2px rgb(255, 0, 0)'; | |
| } | |
| }) | |
| .error(function(jqXHR, textStatus, errorThrown) { | |
| 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. '; | |
| ShowPopUp(); | |
| }); | |
| } | |
| //___________________________________________________________________________________________________________ | |
| //___________________________________________________________________________________________________________ | |
| function ImgLarger(id, src){ | |
| // Get the modal | |
| var modal = document.getElementById('myModal'); | |
| // Get the image and insert it inside the modal - use its "alt" text as a caption | |
| var img = document.getElementById(id); | |
| var modalImg = document.getElementById('img01'); | |
| var captionText = document.getElementById("caption"); | |
| modal.style.display = "block"; | |
| modalImg.src = src; | |
| captionText.innerHTML = 'Preview'; | |
| // Get the <span> element that closes the modal | |
| var span = document.getElementsByClassName("close")[0]; | |
| // When the user clicks on <span> (x), close the modal | |
| span.onclick = function() { | |
| modal.style.display = "none"; | |
| } | |
| } | |
| var spreadsheetId=''; | |
| var spreadsheetURL=''; | |
| var colorsUsed=''; | |
| var list1=''; | |
| var SimilarAreaDictionary=''; | |
| var tomeasureproj='' | |
| var pdfpath=[]; | |
| var interval = null; | |
| var namepathArr='' | |
| var allcolors=['#2FFFFF']; | |
| // Main Function - form submit | |
| //___________________________________________________________________________________________________________ | |
| //___________________________________________________________________________________________________________ | |
| function getData(form) { | |
| document.getElementById("loading").hidden = false; | |
| document.getElementById('measureADRbutton').setAttribute('disabled',true); | |
| document.getElementById('measureADRbutton').style.cursor='not-allowed'; | |
| document.getElementById('measureADRbutton').style.boxShadow = 'none'; | |
| document.getElementById('measureADRbutton').style.color = 'white'; | |
| document.getElementById('measureADRbutton').style.backgroundColor="rgb(154,152,152)"; | |
| var underimg=document.getElementById('underimgbuttons'); | |
| var rightside=document.getElementById('rightside'); | |
| var formData = new FormData(form); | |
| clearInterval(interval) | |
| val=0; | |
| answers=[]; | |
| var ratio1=0; | |
| var ratio2=0; | |
| tomeasureproj=''; | |
| pdfpath=[]; | |
| formvalues=Object.fromEntries(formData); | |
| // iterate through entries... | |
| tomeasureproj=formvalues['measureselectname']; //proj name | |
| ratio1=(formvalues['areaRatio']/ratioAunit)/areainpixels; | |
| ratio2=(formvalues['prmRatio']/ratioPunit)/prminpixels; | |
| pdfpath.push(formvalues['selectproj'],formvalues['selectprojp'] ,formvalues['selectprojs']) //project name - part - section | |
| if (canvasimg){ | |
| buf=canvasimg.split("data:image/png;base64,") | |
| answers.push(tomeasureproj, 220,allcolors , ratio1, ratio2 ,pdfpath,buf[1]); | |
| } | |
| else{ | |
| answers.push(tomeasureproj, 0,[] , ratio1, ratio2 ,pdfpath); | |
| } | |
| if (!formvalues['selectprojs'].startsWith('2.1')) | |
| { | |
| $.ajax({ | |
| type: "POST", | |
| url: "/savebase64Img/", | |
| // set content type header to use Flask response.get_json() | |
| contentType: "application/json", | |
| // convert data/object to JSON to send | |
| data: JSON.stringify({allvalues:answers}), | |
| // expect JSON data in return (e.g. Flask jsonify) | |
| dataType: "json", | |
| // handle response | |
| success: function(response) { | |
| console.log(response); | |
| }, | |
| error: function(err) { | |
| PopupElement.textContent='Error occured. Refresh and try again. If the error continues, please contact the ADR team to fix it. '; | |
| ShowPopUp(); | |
| } | |
| }) | |
| .done(function(data){ | |
| // var mp3_url = 'https://media.geeksforgeeks.org/wp-content/uploads/20190531135120/beep.mp3'; | |
| // (new Audio(mp3_url)).play() | |
| // retrieveLinks() | |
| var backimg=document.getElementById('backgroundimg'); | |
| document.getElementById("loading").hidden = true; | |
| document.getElementById('duplicater').removeAttribute('hidden'); | |
| document.getElementById('addicon').style.display='inline-block'; | |
| document.getElementById('doneebackground').removeAttribute('hidden'); | |
| // clearInterval() | |
| document.getElementById('measureADRbutton').removeAttribute('disabled'); | |
| document.getElementById('measureADRbutton').style.cursor='pointer'; | |
| document.getElementById('measureADRbutton').style.color = 'white'; | |
| document.getElementById('measureADRbutton').style.backgroundColor="#16c72e"; | |
| document.getElementById('measureADRbutton').style.padding='10px 102px'; | |
| document.getElementById('measureADRbutton').addEventListener('mouseover',function(){ | |
| document.getElementById('measureADRbutton').style.color='black'; | |
| document.getElementById('measureADRbutton').style.boxShadow=' 0 0 8px 2px #16c72e'; | |
| }) | |
| document.getElementById('measureADRbutton').addEventListener('mouseout',function(){ | |
| document.getElementById('measureADRbutton').style.color='white'; | |
| document.getElementById('measureADRbutton').style.boxShadow='none'; | |
| }); | |
| if (formvalues['selectprojs'].startsWith('3.2')) | |
| { | |
| // /* data[0]--> img , data[1]-->dataframe (goes to legend lsa ) , data [2] -->pdf dropbox shareable link ,data[3]-> spreadsheetId, data[4],spreadsheeturl */ | |
| SimilarAreaDictionary=data[1]; | |
| dropboxLink=data[2]; | |
| spreadsheetId=data[3]; | |
| spreadsheetURL=data[4]; | |
| list1= data[5] | |
| } | |
| if (formvalues['selectprojs'].startsWith('2.2')) | |
| { | |
| //ignore data[0] --> img passed directly | |
| //dropboxLink=data[1] | |
| //spreadsheetId=data[2] | |
| //spreadsheetURL=data[3] | |
| } | |
| if (formvalues['selectprojs'].startsWith('2.1')) | |
| { | |
| //ignore data[0] --> img passed directly | |
| //dropboxLink=data[1] | |
| //spreadsheetId=data[2] | |
| //spreadsheetURL=data[3] | |
| spreadsheetURL=data[0] | |
| } | |
| else{ | |
| // section 1.0 | |
| SimilarAreaDictionary=data[1]; | |
| spreadsheetURL= data[2]; | |
| spreadsheetId= data[3]; | |
| colorsUsed = data[4]; | |
| list1 = data[5]; //list of pdf markups | |
| dropboxLink=data[6]; | |
| namepathArr=data[8]; | |
| } | |
| var imgcanvas= document.createElement("img"); | |
| imgcanvas.src= 'data:image/gif;base64,' +data[0]; | |
| // imgcanvas.width=700; | |
| imgcanvas.height=600; | |
| console.log(imgcanvas.width) | |
| imgcanvas.id=data[0]; | |
| imgcanvas.alt="Larry"; | |
| imgcanvas.style.zIndex=999; | |
| imgcanvas.addEventListener('click',function(){ | |
| ImgLarger(imgcanvas.id,imgcanvas.src) | |
| }) | |
| backimg.style.backgroundColor="transparent"; | |
| backimg.style.opacity="1"; | |
| getlegendstoDirectory() | |
| // backimg.append(imgcanvas); | |
| var legendbutton= document.createElement("button"); | |
| legendbutton.id='measureADRbutton2'; | |
| legendbutton.innerText='Legend and Data created'; | |
| legendbutton.style.backgroundColor='rgb(5, 43, 235)'; | |
| legendbutton.addEventListener('mouseover',function(){ | |
| legendbutton.style.boxShadow='0 0 8px 2px rgb(5, 43, 235)'; | |
| }) | |
| legendbutton.addEventListener('mouseout',function(){ | |
| legendbutton.style.boxShadow='none'; | |
| }) | |
| legendbutton.addEventListener('click',function(){ | |
| window.open( spreadsheetURL); | |
| }) | |
| var imgbutton= document.createElement("button"); | |
| imgbutton.id='measureADRbutton2'; | |
| imgbutton.innerText='Click to view as PDF'; | |
| imgbutton.style.backgroundColor='rgb(255,0,255)'; | |
| imgbutton.addEventListener('mouseover',function(){ | |
| imgbutton.style.boxShadow='0 0 8px 2px rgb(255,0,255)'; | |
| }) | |
| imgbutton.addEventListener('mouseout',function(){ | |
| imgbutton.style.boxShadow='none'; | |
| }) | |
| imgbutton.addEventListener('click',function(){ | |
| window.open( dropboxLink); | |
| }) | |
| underimg.append(legendbutton); | |
| underimg.append(imgbutton); | |
| underimg.style.display='flex'; | |
| rightside.append(imgcanvas); | |
| rightside.insertBefore(imgcanvas,underimg); | |
| ////////////////////////////////////////////////////////////////////////////////////////// | |
| let delrows2 = { | |
| content : {}, | |
| id : {}, | |
| subject :{} | |
| }; | |
| var delrows1=''; | |
| var flag=0; | |
| pdfpath=[]; | |
| pdfpath.push(formvalues['selectproj'],formvalues['selectprojp'] ,formvalues['selectprojs']) | |
| var rightsideids=[]; | |
| if (formvalues['selectprojs'].startsWith('1.0') || formvalues['selectprojs'].startsWith('3.2') ) | |
| interval= setInterval( function() { | |
| const delay = ms => new Promise(res => setTimeout(res, ms)); | |
| delay(3000) | |
| $.getJSON('/_submission', { | |
| // dict: JSON.stringify(SimilarAreaDictionary), | |
| dict1: JSON.stringify(list1), | |
| spreadsheetId:spreadsheetId, | |
| pdfpathpath:JSON.stringify(pdfpath), | |
| path:Object.fromEntries(formData)['measureselectname'], | |
| },function(data1){ | |
| if(data1.length >0){ | |
| delrows1=data1[0]; | |
| console.log(data1, delrows1,delrows2) | |
| console.log(typeof delrows1) | |
| console.log(typeof delrows2) | |
| if (JSON.stringify(delrows1)=== JSON.stringify(delrows2)) | |
| { | |
| console.log('same') | |
| } | |
| else{ | |
| // if (data1[0]==1){ | |
| // return data1[0]; | |
| flag=1 | |
| if (confirm("Changes have been made in the markups. Would you like to save and view them in the legend?")) { | |
| $.getJSON('/deletemarkupsroute', { | |
| dict: JSON.stringify(SimilarAreaDictionary), | |
| deletedrows: JSON.stringify(delrows1), | |
| path:Object.fromEntries(formData)['measureselectname'], | |
| spreadsheetId:spreadsheetId, | |
| areaPermArr: JSON.stringify(data[7]), | |
| section: Object.fromEntries(formData)['selectprojs'], | |
| pdfpathpath:JSON.stringify(pdfpath), | |
| }, function(data2){ | |
| console.log(data2) | |
| }) | |
| } | |
| } | |
| } | |
| }); | |
| delay(6000); | |
| $.getJSON('/_submission', { | |
| // dict: JSON.stringify(SimilarAreaDictionary), | |
| dict1: JSON.stringify(list1), | |
| spreadsheetId:spreadsheetId, | |
| pdfpathpath:JSON.stringify(pdfpath), | |
| path:Object.fromEntries(formData)['measureselectname'], | |
| },function(data11){ | |
| delrows2=data11[0]; | |
| }) | |
| },10000) | |
| ///////////////////////// | |
| }); | |
| } | |
| // trial for 2.1 - tameem's code--- delete and deploy in the above if statement | |
| else{ | |
| $.ajax({ | |
| type: "POST", | |
| url: "/2.1Trial/", | |
| // set content type header to use Flask response.get_json() | |
| contentType: "application/json", | |
| // convert data/object to JSON to send | |
| data: JSON.stringify({allvalues:answers}), | |
| // expect JSON data in return (e.g. Flask jsonify) | |
| dataType: "json", | |
| // handle response | |
| success: function(response) { | |
| console.log(response); | |
| }, | |
| error: function(err) { | |
| PopupElement.textContent='Error occured. Refresh and try again. If the error continues, please contact the ADR team to fix it. '; | |
| ShowPopUp(); | |
| } | |
| }).done(function(data){ | |
| spreadsheetURL=data[0]; | |
| var backimg=document.getElementById('backgroundimg'); | |
| var rightside=document.getElementById('rightside'); | |
| document.getElementById("loading").hidden = true; | |
| document.getElementById('duplicater').removeAttribute('hidden'); | |
| document.getElementById('doneebackground').removeAttribute('hidden'); | |
| document.getElementById('measureADRbutton').removeAttribute('disabled'); | |
| document.getElementById('measureADRbutton').style.cursor='pointer'; | |
| document.getElementById('measureADRbutton').style.color = 'white'; | |
| document.getElementById('measureADRbutton').style.backgroundColor="#16c72e"; | |
| document.getElementById('measureADRbutton').addEventListener('mouseover',function(){ | |
| document.getElementById('measureADRbutton').style.color='black'; | |
| document.getElementById('measureADRbutton').style.boxShadow=' 0 0 8px 2px #16c72e'; | |
| }) | |
| document.getElementById('measureADRbutton').addEventListener('mouseout',function(){ | |
| document.getElementById('measureADRbutton').style.color='white'; | |
| document.getElementById('measureADRbutton').style.boxShadow='none'; | |
| }); | |
| var legendbutton= document.createElement("button"); | |
| legendbutton.id='measureADRbutton2'; | |
| legendbutton.innerText='Legend and Data created'; | |
| legendbutton.style.backgroundColor='rgb(5, 43, 235)'; | |
| legendbutton.addEventListener('mouseover',function(){ | |
| legendbutton.style.boxShadow='0 0 8px 2px rgb(5, 43, 235)'; | |
| }) | |
| legendbutton.addEventListener('mouseout',function(){ | |
| legendbutton.style.boxShadow='none'; | |
| }) | |
| legendbutton.addEventListener('click',function(){ | |
| window.open( spreadsheetURL); | |
| }) | |
| underimg.append(legendbutton); | |
| }) | |
| } | |
| } | |
| //___________________________________________________________________________________________________________ | |
| //___________________________________________________________________________________________________________ | |
| document.getElementById("myForm").addEventListener("submit", function (e) { | |
| e.preventDefault(); | |
| getData(e.target); | |
| }); | |
| //////////////////////////////////////////// | |
| var measitemVal=''; | |
| function get3rddropdown(){ | |
| console.log('ayhagaaaaaaaaaaaaaaaaa') | |
| // selections=measitem.value.toString() //3rd dpdwn value | |
| var unit; | |
| if (addciconval>0){ | |
| for (let i =1 ; i <=addciconval ; i++){ | |
| var inputs1 = document.getElementsByClassName("measurementselections"+i)[0]; //1sr dpdwn | |
| var selections1 = document.getElementsByClassName("selections"+i)[0]; //2nd dropdown | |
| var measitem1 = document.getElementsByClassName("measureitems"+i)[0]; //3rd dpdwn | |
| measitemVal1=measitem1.value.toString() //3rd dpdwn value | |
| if(( (inputs1.value=='ground beams' ) || (inputs1.value=='pile caps' ) ) & (!selections1.value))//& (selections.value.startsWith('Pile') || !selections.value )) || (inputs.children[0].value=='pile caps' & (selections.value.startsWith('Ground') || !selections.value ))) | |
| { | |
| selections1.innerHTML=''; | |
| for (let m=0;m<MCTNames.length;m++) | |
| { | |
| var opt0 = document.createElement("OPTION") ; | |
| opt0.text= MCTNames[m][0]; | |
| opt0.textContent= MCTNames[m][0]; | |
| opt0.value= MCTNames[m][0]; | |
| selections1.add(opt0); | |
| } | |
| console.log(section.value.toString()) | |
| } | |
| // if (inputs1.value.startsWith('Floor') & (selections1.value.startsWith('Wall') || !selections1.value )){ | |
| // selections1.innerHTML=''; | |
| // var opt2 = document.createElement("OPTION") ; | |
| // opt2.text= 'Floor:m2'; | |
| // opt2.value= 'Floor:m2'; | |
| // opt2.id='floorA' ; | |
| // selections1.add(opt2); | |
| // } | |
| // if (inputs1.value.startsWith('Wall') & (selections1.value.startsWith('Floor') || !selections1.value ) ){ | |
| // selections1.innerHTML=''; | |
| // var opt3 = document.createElement("OPTION") ; | |
| // opt3.text= 'Wall:m'; | |
| // opt3.value= 'Wall:m'; | |
| // opt3.id='WallP'; | |
| // selections1.add(opt3); | |
| // } | |
| // measitem1.innerHTML=''; | |
| // var ii, L = measitem1.options.length - 1; | |
| // for(ii = L; ii >= 0; ii--) { | |
| // if (measitem1.options[ii].value=='Area') | |
| // measitem1.remove(ii); | |
| // } | |
| // }); | |
| if (selections1.value ) | |
| { | |
| for(var l in MCTNames){ | |
| if(MCTNames[l][0] == selections1.value){ | |
| // Add an element to the dictionary | |
| unit=MCTNames[l][1] | |
| break; // If you want to break out of the loop once you've found a match | |
| } | |
| } | |
| if (unit=='m2' ) | |
| { measitem1.innerHTML=''; | |
| var opt10 = document.createElement("OPTION") ; | |
| opt10.text= 'Area:m2'; | |
| opt10.value= 'Area:m2'; | |
| opt10.id='Area:m2'; | |
| measitem1.add(opt10); | |
| } | |
| if (unit=='m' & !(measitem1.value=='Perimeter:m')) | |
| { measitem1.innerHTML=''; | |
| var opt11 = document.createElement("OPTION") ; | |
| opt11.text= 'Length:m'; | |
| opt11.value= 'Length:m'; | |
| opt11.id='Length:m'; | |
| measitem1.add(opt11); | |
| var opt12 = document.createElement("OPTION") ; | |
| opt12.text= 'Perimeter:m'; | |
| opt12.value= 'Perimeter:m'; | |
| opt12.id='Perimeter:m'; | |
| measitem1.add(opt12); | |
| } | |
| if (unit=='nr') | |
| { measitem1.innerHTML=''; | |
| var opt13 = document.createElement("OPTION") ; | |
| opt13.text= 'Count:Nr'; | |
| opt13.value= 'Count:Nr'; | |
| opt13.id='Count:Nr'; | |
| measitem1.add(opt13); | |
| } | |
| } | |
| } | |
| } | |
| // $(inputs).on("change", function (e) { | |
| if(( (inputs.value=='ground beams' ) || (inputs.value=='pile caps' ) ) & (!selections.value))//& (selections.value.startsWith('Pile') || !selections.value )) || (inputs.children[0].value=='pile caps' & (selections.value.startsWith('Ground') || !selections.value ))) | |
| { | |
| selections.innerHTML=''; | |
| for (let m=0;m<MCTNames.length;m++) | |
| { | |
| var opt0 = document.createElement("OPTION") ; | |
| opt0.text= MCTNames[m][0]; | |
| opt0.textContent= MCTNames[m][0]; | |
| opt0.value= MCTNames[m][0]; | |
| selections.add(opt0); | |
| } | |
| } | |
| // if (inputs.value=='Floor' & (selections.value.startsWith('Wall') || !selections.value )){ | |
| // selections.innerHTML=''; | |
| // var optn = document.createElement("OPTION") ; | |
| // optn.text= 'Floor:m2'; | |
| // optn.value= 'Floor:m2'; | |
| // optn.id='floorA' ; | |
| // selections.add(optn); | |
| // } | |
| // if (inputs.value=='Wall' & (selections.value.startsWith('Floor') || !selections.value ) ){ | |
| // selections.innerHTML=''; | |
| // var opt = document.createElement("OPTION") ; | |
| // opt.text= 'Wall:m'; | |
| // opt.value= 'Wall:m'; | |
| // opt.id='WallP'; | |
| // selections.add(opt); | |
| // } | |
| // }) | |
| console.log(selections.value) | |
| if (selections.value) | |
| { | |
| for(var l in MCTNames){ | |
| if(MCTNames[l][0] == selections.value){ | |
| // Add an element to the dictionary | |
| unit=MCTNames[l][1] | |
| break; // If you want to break out of the loop once you've found a match | |
| } | |
| } | |
| if (unit=='m2' ) | |
| { measitem.innerHTML=''; | |
| var opt10 = document.createElement("OPTION") ; | |
| opt10.text= 'Area:m2'; | |
| opt10.value= 'Area:m2'; | |
| opt10.id='Area:m2'; | |
| measitem.add(opt10); | |
| } | |
| if (unit=='m' & !(measitem.value=='Perimeter:m')) | |
| { | |
| measitem.innerHTML=''; | |
| var opt11 = document.createElement("OPTION") ; | |
| opt11.text= 'Length:m'; | |
| opt11.value= 'Length:m'; | |
| opt11.id='Length:m'; | |
| measitem.add(opt11); | |
| var opt12 = document.createElement("OPTION") ; | |
| opt12.text= 'Perimeter:m'; | |
| opt12.value= 'Perimeter:m'; | |
| opt12.id='Perimeter:m'; | |
| measitem.add(opt12); | |
| } | |
| if (unit=='nr' ) | |
| { measitem.innerHTML=''; | |
| var opt13 = document.createElement("OPTION") ; | |
| opt13.text= 'Count:Nr'; | |
| opt13.value= 'Count:Nr'; | |
| opt13.id='Count:Nr'; | |
| measitem.add(opt13); | |
| } | |
| } | |
| } | |
| //___________________________________________________________________________________________________________ | |
| //___________________________________________________________________________________________________________ | |
| var repeatforloopI=0; | |
| function getmctName(){ | |
| var listofnames=[]; | |
| var flag=0; | |
| arrallvalues=[]; | |
| arrmctNames=[]; | |
| arrFinalMCNames=[]; | |
| var allmcnamestext= document.querySelectorAll('input[name="text1name"]'); | |
| allmcnamestext.forEach(function(elem){ | |
| if (elem.value) | |
| arrallvalues.push(elem.value); | |
| }) | |
| for (ii=0 ; ii<=addciconval; ii++){ | |
| if (ii==0){ | |
| //first one -- not duplicated yet --first row onlyy | |
| var divduplicater= document.getElementsByClassName('duplicaterclass')[0].children; | |
| var selections = divduplicater[3];//ex: Gb:m | |
| measitemVal=divduplicater[5].value; // ex:area | |
| var div=divduplicater[8].children;// first repeatforloopclass | |
| var divValues=['text1'+div[0].value, div[1].value , div[2].value]; | |
| mctname=[selections.value ,divValues , measitemVal ]; | |
| // if(div[0].value && div[1].value && div[2].value) | |
| // { | |
| // flag=1; | |
| // arrmctNames.push( mctname); | |
| // } | |
| // else if (div[0].value && !div[1].value && !div[2].value) { | |
| // mctname=[selections.value ,['text1'+div[0].value ], measitemVal ]; | |
| // flag=1; | |
| // arrmctNames.push( mctname); | |
| // } | |
| // else if (div[0].value && div[1].value && !div[2].value) { | |
| // mctname=[selections.value ,['text1'+div[0].value, div[1].value ] , measitemVal ]; | |
| // flag=1; | |
| // arrmctNames.push( mctname); | |
| // } | |
| ////////////////////////////////////////// | |
| count=0; | |
| var ii0selections=''; | |
| for (let child =1;child <divduplicater.length;child++) | |
| { | |
| console.log('here3') | |
| if( divduplicater[child] instanceof(HTMLDivElement) ) | |
| count++; | |
| console.log(divduplicater) | |
| ii0selections=divduplicater[3].value; | |
| measitemVal=divduplicater[5].value; | |
| console.log('gfd ',ii0selections,measitemVal) | |
| if (divduplicater[child].className.startsWith('repeatforloopclass') && child !=5) | |
| { | |
| console.log('c',divduplicater[child].children) | |
| var divValues2=['text1'+divduplicater[child].children[0].value, divduplicater[child].children[1].value , divduplicater[child].children[2].value]; | |
| mctname1=[ii0selections ,divValues2 , measitemVal]; | |
| console.log('divValues2',mctname1) | |
| if(divduplicater[child].children[0].value && divduplicater[child].children[1].value && divduplicater[child].children[2].value) | |
| { | |
| // console.log(mctname1); | |
| flag=1; | |
| arrmctNames.push(mctname1); | |
| } | |
| else if(divduplicater[child].children[0].value && !divduplicater[child].children[1].value && !divduplicater[child].children[2].value) { | |
| mctname1=[ii0selections ,[ 'text1'+divduplicater[child].children[0].value ], measitemVal ]; | |
| flag=1; | |
| arrmctNames.push( mctname1); | |
| } | |
| else if(divduplicater[child].children[0].value && divduplicater[child].children[1].value && !divduplicater[child].children[2].value) { | |
| mctname1=[ii0selections ,['text1'+divduplicater[child].children[0].value , divduplicater[child].children[1].value] , measitemVal]; | |
| flag=1; | |
| arrmctNames.push( mctname1); | |
| } | |
| } | |
| } | |
| } | |
| // else if (ii>0){ | |
| // var divduplicater= document.getElementsByClassName('duplicaterclass'+ii)[0].children; | |
| // console.log(divduplicater) | |
| // selections = divduplicater[3];//document.getElementsByClassName("selections")[0]; | |
| // measitemVal=divduplicater[5].value; | |
| // div=divduplicater[8].children; | |
| // var divValues=['text1'+div[0].value, div[1].value , div[2].value]; | |
| // mctname=[selections.value ,divValues , measitemVal ]; | |
| // if(div[0].value && div[1].value && div[2].value) | |
| // { | |
| // flag=1; | |
| // arrmctNames.push( mctname); | |
| // } | |
| // else if (div[0].value && !div[1].value && !div[2].value) { | |
| // mctname=[selections.value ,['text1'+div[0].value ], measitemVal ]; | |
| // flag=1; | |
| // arrmctNames.push( mctname); | |
| // } | |
| // else if (div[0].value && div[1].value && !div[2].value) { | |
| // mctname=[selections.value ,['text1'+div[0].value, div[1].value ] , measitemVal ]; | |
| // flag=1; | |
| // arrmctNames.push( mctname); | |
| // } | |
| // } | |
| if (ii>0 )//&& addciconval >0 && jj>0) | |
| { | |
| count=0; | |
| var ii0selections=''; | |
| var replicatedDivChildren=document.getElementsByClassName('duplicaterclass'+ii)[0].children; | |
| for (let o =0;o <=replicatedDivChildren.length;o++) | |
| { | |
| if( replicatedDivChildren[o] instanceof(HTMLDivElement) ) | |
| { count++; | |
| ii0selections=replicatedDivChildren[3].value; | |
| measitemVal=replicatedDivChildren[5].value; | |
| console.log('lkjhgf',replicatedDivChildren) | |
| } | |
| } | |
| for (child=0;child<replicatedDivChildren.length;child++) | |
| { | |
| if (replicatedDivChildren[child].className.startsWith('repeatforloopclass') && child !=5) | |
| { | |
| var divValues2=['text1'+replicatedDivChildren[child].children[0].value, replicatedDivChildren[child].children[1].value , replicatedDivChildren[child].children[2].value]; | |
| mctname1=[ii0selections ,divValues2 , measitemVal]; | |
| if(replicatedDivChildren[child].children[0].value && replicatedDivChildren[child].children[1].value && replicatedDivChildren[child].children[2].value) | |
| { | |
| arrmctNames.push(mctname1); | |
| flag=1; | |
| } | |
| else if(replicatedDivChildren[child].children[0].value && !replicatedDivChildren[child].children[1].value && !replicatedDivChildren[child].children[2].value) | |
| { | |
| mctname1=[ii0selections ,['text1'+replicatedDivChildren[child].children[0].value] , measitemVal]; | |
| arrmctNames.push(mctname1); | |
| flag=1; | |
| } | |
| else if(replicatedDivChildren[child].children[0].value && replicatedDivChildren[child].children[1].value && !replicatedDivChildren[child].children[2].value) | |
| { | |
| mctname1=[ii0selections ,['text1'+replicatedDivChildren[child].children[0].value, replicatedDivChildren[child].children[1].value] , measitemVal]; | |
| arrmctNames.push(mctname1); | |
| flag=1; | |
| } | |
| } | |
| } | |
| } | |
| arrFinalMCNames= arrmctNames.slice(); | |
| if(arrmctNames.length >1){ | |
| var name=[]; | |
| allnames=[]; | |
| arrFinalMCNames = arrmctNames.slice(); | |
| var newarr=[]; | |
| for (let i=0;i<arrmctNames.length; i++) | |
| { str=''; | |
| newarr=[]; | |
| for (let j=i+1; j<arrmctNames.length; j++) | |
| { | |
| if (arrmctNames[i][0] == arrmctNames[j][0] && arrmctNames[i][2] == arrmctNames[j][2] &&arrmctNames[i][1][1] == arrmctNames[j][1][1] && arrmctNames[i][1][2] == arrmctNames[j][1][2]) | |
| { var selectionsname=arrmctNames[i][0] ; | |
| measitemVal=arrmctNames[i][2]; | |
| flag=1; | |
| console.log('foorrr',arrmctNames[i][0],arrmctNames[i]); | |
| if (allnames.includes(arrmctNames[i][1][0]) ) | |
| { | |
| var index = allnames.indexOf(allnames[i] ); | |
| if (index !== -1) { | |
| allnames.splice(index, 1); | |
| } | |
| } | |
| if (!name.includes(arrmctNames[i][1][0] ) ){ | |
| // console.log('msh mwgod'); | |
| name.push(arrmctNames[i][1][0]); | |
| newarr.push(arrmctNames[i][1][0]); | |
| var index = arrFinalMCNames.indexOf(arrmctNames[i] ); | |
| if (index !== -1) { | |
| arrFinalMCNames.splice(index, 1); | |
| } | |
| } | |
| if (!name.includes(arrmctNames[j][1][0] ) ){ | |
| // console.log('msh mwgodj') | |
| name.push(arrmctNames[j][1][0]); | |
| newarr.push(arrmctNames[j][1][0]); | |
| var index1 = arrFinalMCNames.indexOf(arrmctNames[j] ); | |
| if (index1 !== -1) { | |
| arrFinalMCNames.splice(index1, 1); | |
| } | |
| } | |
| if (!name.includes(arrmctNames[i][1][1] ) ||!name.includes(arrmctNames[i][1][2] ) ){ | |
| name.push( arrmctNames[i][1][1] , arrmctNames[i][1][2] ); | |
| newarr.push(arrmctNames[i][1][1] , arrmctNames[i][1][2] ); | |
| } | |
| } | |
| } | |
| if (newarr.length >0){ | |
| flag=1; | |
| arrFinalMCNames.push([selectionsname , newarr, measitemVal ]); | |
| } | |
| } | |
| } | |
| arrFinalMCNames.push([spreadsheetId , pdfpath[2]]); | |
| console.log(arrFinalMCNames) | |
| } | |
| if (flag==1){ | |
| $.get( '/mctnametoGoogleSheet/'+ JSON.stringify(arrFinalMCNames)) | |
| .success( function(data) { | |
| console.log('dataaaaa',data) | |
| // listofnames=data[1]; | |
| // var is_same = listofnames.length == arrallvalues.length && listofnames.every(function(element, index) { | |
| // if(arrallvalues.indexOf(element)>-1){ | |
| // return element = arrallvalues[arrallvalues.indexOf(element)]; | |
| // } | |
| // }); | |
| spreadsheetURL=spreadsheetURL+ '/edit#gid='+data[0].toString() | |
| console.log('spreadsheetURL',spreadsheetURL) | |
| document.getElementById('all').style.display='none'; | |
| window.open(spreadsheetURL.toString()) //sheetid | |
| }) | |
| .error(function(jqXHR, textStatus, errorThrown) { | |
| PopupElement.textContent='Error occured while exporting the summary. Check your connection, refresh and try again. If the error continues, please contact the ADR team to fix it. '; | |
| ShowPopUp(); | |
| }); | |
| } | |
| } | |
| //___________________________________________________________________________________________________________ | |
| //___________________________________________________________________________________________________________ | |
| function addmctnameicon(){ | |
| repeatforloopI+=1 | |
| var dupDiv; | |
| if (clonedDivId==0){ | |
| var dupDiv=document.getElementById('duplicater'); //pass kol div hna | |
| } | |
| else{ | |
| var dupDiv=document.getElementById(clonedDivId); //pass kol div hna //akher div et3mlt | |
| } | |
| var div=document.getElementById('repeatforloophidden') | |
| var clone = div.cloneNode(true); // "deep" clone | |
| jj++; | |
| if (clonedDivId==0) | |
| clone.style.marginLeft='5px'; | |
| else | |
| clone.style.marginLeft='5px'; | |
| window.onclick = elem => { | |
| if (elem.target.tagName.startsWith('LORD-ICON') && elem.target.id.startsWith('addmctnameid')){ | |
| clone.id = 'repeatforloop'+ elem.target.parentElement.parentElement.childNodes[1].value[0] + ++elem.target.parentElement.parentElement.childNodes[1].value[1]; | |
| clone.setAttribute('class','repeatforloopclass'+elem.target.parentElement.parentElement.childNodes[1].value[0] + elem.target.parentElement.parentElement.childNodes[1].value[1]); | |
| clone.setAttribute('name','repeatforloopname'+elem.target.parentElement.parentElement.childNodes[1].value[0] + elem.target.parentElement.parentElement.childNodes[1].value[1]); | |
| clone.childNodes[11].id='addmctnameid'+elem.target.parentElement.parentElement.childNodes[1].value[0] + elem.target.parentElement.parentElement.childNodes[1].value[1]; | |
| clone.childNodes[15].id='deletemctnameid'+elem.target.parentElement.parentElement.childNodes[1].value[0] + elem.target.parentElement.parentElement.childNodes[1].value[1]; | |
| if (elem.target.parentElement.nextElementSibling) | |
| { | |
| $("#"+elem.target.parentElement.parentElement.id).append(clone); | |
| } | |
| else | |
| { | |
| $("#"+elem.target.parentElement.parentElement.id).append(clone); | |
| $("#"+elem.target.parentElement.id).insertBefore(clone,document.getElementById('doneebackground')); | |
| } | |
| } | |
| } | |
| } | |
| //___________________________________________________________________________________________________________ | |
| //___________________________________________________________________________________________________________ | |
| function deletemctnameicon(){ | |
| window.onclick = elem => { | |
| if (elem.target.tagName.startsWith('LORD-ICON') && elem.target.id.startsWith('deletemctnameid')) | |
| { | |
| var numb = elem.target.parentElement.id.match(/\d/g); | |
| if (numb==null) | |
| numb=''; | |
| else | |
| numb = numb.join(""); | |
| var deletethisdiv= document.getElementById('repeatforloop'+ numb); | |
| deletethisdiv.parentNode.removeChild(deletethisdiv); | |
| } | |
| } | |
| } | |
| //___________________________________________________________________________________________________________ | |
| //___________________________________________________________________________________________________________ | |
| function colors(){ | |
| var ele = document.getElementsByName('fullimage'); | |
| var levels = document.getElementsByName('levelsnamelabel')[0]; | |
| var levelsin = document.getElementsByName('levelsnameinput')[0]; //number of colors -- color pickers | |
| var drp = document.getElementById("colorpickers"); | |
| for (i = 0; i < ele.length; i++) { | |
| if (ele[i].checked) | |
| if (ele[i].value==220){ | |
| console.log(ele[i].value); | |
| levels.style.visibility='visible'; | |
| levelsin.style.visibility='visible'; | |
| } | |
| else | |
| { | |
| levels.style.visibility='hidden'; | |
| levelsin.style.visibility='hidden'; | |
| drp.innerHTML=''; | |
| } | |
| } | |
| } | |
| //___________________________________________________________________________________________________________ | |
| //___________________________________________________________________________________________________________ | |
| var canvas = document.querySelector("#myCanvas"); | |
| var ctx = canvas.getContext("2d"); | |
| var drp; | |
| var color = 'rgb(47,255,255)'; | |
| //___________________________________________________________________________________________________________ | |
| //___________________________________________________________________________________________________________ | |
| function change(e){ | |
| color = this.value; | |
| allcolors.push( color); | |
| } | |
| //___________________________________________________________________________________________________________ | |
| //___________________________________________________________________________________________________________ | |
| let hex2rgb= c=> `rgb(${c.match(/\w\w/g).map(x=>+`0x${x}`)})`; | |
| myCanvas.addEventListener("click", e => { | |
| var offset = canvas.getBoundingClientRect(); | |
| var x = e.clientX - offset.left; | |
| var y = e.clientY - offset.top; | |
| //a new point is pushed on the last array of ry | |
| ry[ry.length - 1].push({ x: x, y: y, color:hex2rgb(color) }); | |
| drawChart(); | |
| }); | |
| //___________________________________________________________________________________________________________ | |
| //___________________________________________________________________________________________________________ | |
| function drawChart() { | |
| ctx.lineWidth = 5; | |
| // for every array in the ry array | |
| for (let index = 0; index < ry.length; index++) { | |
| // for every point in the ry[index] | |
| for (let i = 0; i < ry[index].length; i++) { | |
| firstcircle=[] | |
| let l = ry[index][i]; | |
| // draw the circle | |
| if (i==0){ | |
| drawCircle(l.x, l.y); | |
| firstcircle=[l.x,l.y] | |
| } | |
| // draw the line | |
| if (i > 0) { | |
| let last = ry[index][i - 1]; | |
| ctx.beginPath(); | |
| ctx.moveTo(last.x, last.y); | |
| ctx.lineTo(l.x, l.y); | |
| ctx.strokeStyle = l.color; | |
| ctx.stroke(); | |
| } | |
| } | |
| } | |
| } | |
| //___________________________________________________________________________________________________________ | |
| //___________________________________________________________________________________________________________ | |
| function drawCircle(x, y) { | |
| ctx.beginPath(); | |
| ctx.arc(x, y,1, 0, Math.PI *2); | |
| ctx.strokeStyle = 'rgb(47,255,255)'; | |
| ctx.stroke(); | |
| } | |
| //___________________________________________________________________________________________________________ | |
| //___________________________________________________________________________________________________________ | |
| /*If the plan contains levels, open canvas window*/ | |
| /*Set canvas code to be visible on the new window with the pdftoimg as the background*/ | |
| var levelsin = document.getElementById('levelcheckbox'); | |
| var canvaswindow= document.getElementById('canvaswindow'); | |
| var undoButtonId=document.getElementById('undoButtonId'); | |
| NewShapeButtonId=document.getElementById('NewShapeButtonId'); | |
| var savecanvas=document.getElementById('savecanvas'); | |
| levelsin.addEventListener('click',function(){ | |
| document.getElementById("all").style.display = "block"; | |
| if( document.getElementById('levelcheckbox').checked) | |
| { | |
| $.get( '/canvaspdftoimgBackground/'+pdfname) | |
| .success (function(data){ | |
| document.getElementById("all").style.display = "none"; | |
| var popup = window.open(''); | |
| popup.document.write('<html><head><title>ADR Console:Draw on PDF tool</title><link rel="stylesheet" href="static/style.css"></head><body>'); | |
| var element = popup.document.createElement('div'); | |
| element.setAttribute('id', 'mydiv'); | |
| canvaswindow.childNodes[1].height=data[1]; //canvas -->child 3 | |
| canvaswindow.childNodes[1].width=data[2]; | |
| canvaswindow.childNodes[1].style.width= 0.5*screen.width +'px' | |
| HeightStyleratio= canvaswindow.childNodes[1].height * 0.5*screen.width / canvaswindow.childNodes[1].width ; | |
| canvaswindow.childNodes[1].style.height= HeightStyleratio.toString() + 'px'; | |
| element.append(canvaswindow); | |
| console.log(canvaswindow.childNodes) | |
| canvaswindow.removeAttribute('hidden'); | |
| var imgDrawon =document.createElement("img"); | |
| imgDrawon.src = 'data:image/gif;base64,' +data[0]; | |
| imgDrawon.width=data[2]; | |
| imgDrawon.style.width='700px'; | |
| imgDrawon.id='imgcanvas'; | |
| imgDrawon.alt="Larry"; | |
| imgDrawon.onload = function(){ | |
| ctx.drawImage(imgDrawon,0,0); | |
| var scale = data[2] / canvaswindow.childNodes[1].style.width.slice(0,-2) ; // get the scale that matches display size | |
| ctx.setTransform(scale,0,0,scale,0,0); | |
| } | |
| undoButtonId.addEventListener("click", e => { | |
| //when undoButtonId is clicked the last point from the last array is deleted | |
| if (ry[ry.length - 1].length > 0) | |
| { | |
| ry[ry.length - 1].pop(); | |
| } | |
| else { | |
| //if the last array is empty I delete this array | |
| ry.pop(); | |
| //and then I delete the last point from the last array | |
| ry[ry.length - 1].pop(); | |
| } | |
| // delete everything | |
| ctx.clearRect(0,0, canvas.width, canvas.height); | |
| //redraw background to draw lines over again | |
| ctx.drawImage(imgDrawon,0,0,canvaswindow.childNodes[1].style.width.slice(0, -2),canvaswindow.childNodes[1].style.height.slice(0, -2)); | |
| drawChart(); | |
| }); | |
| var win = popup.document.body; | |
| win.appendChild(element); | |
| var drp=popup.document.body.childNodes[0].childNodes[0].childNodes[9];//color picker div | |
| NewShapeButtonId.addEventListener('click',function(){ | |
| ry.push([]); | |
| }); | |
| drp.childNodes[1].addEventListener('click',function(){ //color picker | |
| drp.childNodes[1].onchange=change; | |
| }) | |
| }) | |
| .error(function(jqXHR, textStatus, errorThrown) { | |
| PopupElement.textContent='Levels are not supported in this Section. '; | |
| ShowPopUp(); | |
| document.getElementById('levelcheckbox').checked=false; | |
| }); | |
| savecanvas.addEventListener('click',function(){ | |
| var image = new Image(); | |
| image.id = "pic"; | |
| image.src = canvas.toDataURL("image/png"); | |
| canvasimg=image.src; | |
| }) | |
| } | |
| }) | |
| //___________________________________________________________________________________________________________ | |
| function getSecondData(){ | |
| document.getElementById('all').style.display='block'; | |
| getmctName() | |
| } | |
| //___________________________________________________________________________________________________________ | |
| var section = document.getElementsByClassName("selectionsProjs")[0] | |
| var inputs= document.getElementById('measurementselectionsid'); | |
| var selections= document.getElementById('selectionsid'); | |
| var measitem= document.getElementById('measureitemsid'); | |
| function chooseFirstdrpdwn() | |
| { | |
| inputs.innerHTML=''; | |
| selections.innerHTML=''; | |
| measitem.innerHTML=''; | |
| if (section.value.startsWith('1.0')) | |
| { | |
| var opt = document.createElement("OPTION"); | |
| opt.text= 'Select'; | |
| opt.value= ""; | |
| opt.hidden=true; | |
| inputs.add(opt); | |
| var optn = document.createElement("OPTION"); | |
| optn.text= 'Ground Beams'; | |
| optn.value= "ground beams"; | |
| inputs.add(optn); | |
| var optn1 = document.createElement("OPTION"); | |
| optn1.text= 'Pile Caps'; | |
| optn1.value= "pile caps"; | |
| inputs.add(optn1); | |
| } | |
| if (section.value.startsWith('3.2')) | |
| { | |
| var opt = document.createElement("OPTION"); | |
| opt.text= 'Select'; | |
| opt.value= ""; | |
| opt.hidden=true; | |
| inputs.add(opt); | |
| var optn = document.createElement("OPTION"); | |
| optn.text= 'Floor'; | |
| optn.value= "Floor"; | |
| inputs.add(optn); | |
| var optn1 = document.createElement("OPTION"); | |
| optn1.text= 'Wall'; | |
| optn1.value= "Wall"; | |
| inputs.add(optn1); | |
| } | |
| $(inputs).select2({ | |
| placeholder:'Select', | |
| closeOnSelect: true, | |
| width:'15ch' | |
| }); | |
| $(selections).select2({ | |
| placeholder:'Select MC-T Name', | |
| closeOnSelect: true, | |
| width:'23ch' | |
| }); | |
| $(measitem).select2({ | |
| placeholder:'Select unit', | |
| closeOnSelect: true, | |
| width:'11ch' | |
| }); | |
| } | |
| $(inputs).on("change", function (e) { | |
| get3rddropdown(); | |
| }) | |
| $(selections).on("change", function (e) { | |
| get3rddropdown(); | |
| }) | |
| $(inputs).css('width', '50px'); | |
| //___________________________________________________________________________________________________________ | |
| //___________________________________________________________________________________________________________ | |
| //___________________________________________________________________________________________________________ | |
| //___________________________________________________________________________________________________________ | |
| /////////////////////////////////////*LEGEND DIRECTORY*////////////////////////////////// | |
| ///////////////////////////////////////////////////////////////////////////////////////// | |
| ///////////////////////////////////////////////////////////////////////////////////////// | |
| /*Get tables of Prj Names, parts , sections from API code */ | |
| table1={} | |
| table2={} | |
| table3={} | |
| $.get('/getAPITables/') | |
| .success(function(data){ | |
| table1=data[0]; //prj names table | |
| table2=data[1]; //prj parts table | |
| table3=data[2]; //prj sections table | |
| }) | |
| .error(function(jqXHR, textStatus, errorThrown) { | |
| PopupElement.textContent='Error occured. Refresh and try again. If the error continues, please contact the ADR team to fix it. '; | |
| ShowPopUp(); | |
| }); | |
| var pathsarr={}; | |
| var legendscontent= document.getElementById('legends'); | |
| var createdTimeDiv= document.getElementById('createdTimeDiv'); | |
| //___________________________________________________________________________________________________________ | |
| //___________________________________________________________________________________________________________ | |
| /*Create divs for each prj and div for each part*/ | |
| getlegendstoDirectory() | |
| function getlegendstoDirectory(){ | |
| $.get( '/getdrivelinks/'+'0').then (function(data){ | |
| pathsarr=data | |
| if (!legendscontent.children[1]){ | |
| var allprjdiv= document.createElement("div"); | |
| allprjdiv.id='allprjdiv'; | |
| } | |
| else{ | |
| legendscontent.children[1].innerHTML=''; | |
| var allprjdiv=legendscontent.children[1]; | |
| allprjdiv.id='allprjdiv'; | |
| } | |
| for (let proj=0; proj<PrjNamesArray.length ; proj++) | |
| { | |
| var labelprojdiv= document.createElement("div"); | |
| var newlabelproj = document.createElement("label") | |
| var i = document.createElement("i"); | |
| var brk= document.createElement("br"); | |
| i.className="fa fa-folder" | |
| newlabelproj.textContent=PrjNamesArray[proj]; | |
| newlabelproj.id='prjname'; | |
| newlabelproj.className='prjnameclass'; | |
| labelprojdiv.append(i) | |
| labelprojdiv.append(newlabelproj) | |
| labelprojdiv.append(brk) | |
| allprjdiv.append(labelprojdiv) | |
| } | |
| legendscontent.append(allprjdiv) | |
| legendscontent.querySelectorAll('label').forEach(function(elem){ | |
| elem.addEventListener('click',function(){ | |
| if (!elem.parentElement.children[3]){ | |
| var prjnameId; | |
| var prjpartsforLgnd=[]; | |
| var prjpartId; | |
| var prjSectionsforLgnd=[]; | |
| /*get prj clicked on */ | |
| for (item in table1.ProjectName) | |
| { | |
| if (table1.ProjectName[item] == elem.textContent.toString()) | |
| { | |
| prjnameId = table1.ProjectId[item]; | |
| break; | |
| } | |
| } | |
| /*get prj parts of this prj and its id*/ | |
| for (item in table2.ProjectId) | |
| { | |
| if (table2.ProjectId[item] == prjnameId.toString()) | |
| { | |
| prjpartsforLgnd.push(table2.ProjectPart[item]); | |
| prjpartId=table2.ProjectPartId[item] ; | |
| } | |
| } | |
| var allpartsdiv= document.createElement("div"); | |
| for (let prjpart=0;prjpart<prjpartsforLgnd.length;prjpart++) | |
| { | |
| var labelpartdiv= document.createElement("div"); | |
| labelpartdiv.style.marginLeft='20px'; | |
| var newlabelpart = document.createElement("label") | |
| var i = document.createElement("i"); | |
| var brk= document.createElement("br"); | |
| i.className="fa fa-folder" | |
| newlabelpart.textContent=prjpartsforLgnd[prjpart]; | |
| newlabelpart.id='prjpart'; | |
| newlabelpart.className='prjpartclass'; | |
| labelpartdiv.append(i) | |
| labelpartdiv.append(newlabelpart) | |
| labelpartdiv.append(brk) | |
| allpartsdiv.append(labelpartdiv) | |
| } | |
| elem.parentElement.append(allpartsdiv) | |
| elem.parentElement.querySelector('i').className='fa fa-folder-open'; | |
| /*Sections divs*/ | |
| for (let c=0;c<elem.parentElement.children[3].children.length;c++) //Div of Part | |
| { | |
| elem.parentElement.children[3].children[c].children[1].addEventListener('click',function(){ | |
| var partlabelText= elem.parentElement.children[3].children[c].children[1].textContent; | |
| for (item in table3.ProjectId) | |
| { | |
| if (table3.ProjectId[item] ==prjnameId && table3.ProjectPartId[item]==prjpartId ) | |
| { | |
| prjSectionsforLgnd.push(table3.ProjectSection[item]); | |
| } | |
| } | |
| if (! elem.parentElement.children[3].children[c].children[3]) { | |
| var labelsecdiv= document.createElement("div"); | |
| labelsecdiv.style.marginLeft='25px'; | |
| for (let cc=0;cc<prjSectionsforLgnd.length;cc++){ | |
| var seperateSecdiv = document.createElement("div") | |
| var newlabelsec = document.createElement("label") | |
| var i = document.createElement("i"); | |
| var brk= document.createElement("br"); | |
| i.className="fa fa-folder" | |
| newlabelsec.textContent=prjSectionsforLgnd[cc]; | |
| newlabelsec.id='prjsec'; | |
| newlabelsec.className='prjsecclass'; | |
| if (!(newlabelsec.textContent.toString().startsWith('1.0') || newlabelsec.textContent.startsWith('3.2') || newlabelsec.textContent.startsWith('2.2') || newlabelsec.textContent.startsWith('2.1'))) | |
| { | |
| newlabelsec.style.color='lightgray'; | |
| i.style.color='lightgray' | |
| newlabelsec.style.cursor='default'; | |
| } | |
| seperateSecdiv.append(i) | |
| seperateSecdiv.append(newlabelsec) | |
| seperateSecdiv.append(brk) | |
| labelsecdiv.append(seperateSecdiv) | |
| elem.parentElement.children[3].children[c].append(labelsecdiv) | |
| // console.log(labelsecdiv) | |
| } | |
| elem.parentElement.children[3].children[c].children[0].className='fa fa-folder-open'; | |
| /*Get path to legends - project name , part , section*/ | |
| for (let k=0;k<elem.parentElement.children[3].children[c].children[3].children.length;k++) | |
| { | |
| elem.parentElement.children[3].children[c].children[3].children[k].children[1].addEventListener('click',function(){ | |
| legendpathh='/'+elem.textContent +'/' + partlabelText + '/' + elem.parentElement.children[3].children[c].children[3].children[k].children[1].textContent+'/' | |
| if (!elem.parentElement.children[3].children[c].children[3].children[k].children[3]) | |
| { | |
| for (let o=0; o<pathsarr.length;o++){ | |
| console.log(pathsarr[o]) | |
| if (JSON.stringify(pathsarr[o][1]) === JSON.stringify(legendpathh) ){ | |
| var legendsdiv= document.createElement("div"); | |
| legendsdiv.style.marginLeft='20px'; | |
| var seperateSecdiv = document.createElement("div") | |
| var legendlabel = document.createElement("label") | |
| var brk= document.createElement("br"); | |
| legendlabel.textContent=pathsarr[o][0] | |
| legendlabel.id='legend'; | |
| legendlabel.className='legendclass'; | |
| var legendlabeldiv= document.createElement("div"); | |
| legendlabeldiv.id='legendtimediv' | |
| var createdTimelbl = document.createElement("label") | |
| var brk= document.createElement("br"); | |
| createdTimelbl.textContent=new Date(pathsarr[o][2].createdTime ).toUTCString() | |
| createdTimelbl.id='legendtime'; | |
| createdTimelbl.className='legendclass'; | |
| var modifiedTimelbl = document.createElement("label") | |
| var brk= document.createElement("br"); | |
| modifiedTimelbl.textContent=new Date(pathsarr[o][2].modifiedTime ).toUTCString() | |
| modifiedTimelbl.id='legendmodtime'; | |
| modifiedTimelbl.className='legendclass'; | |
| console.log(pathsarr[o][2].createdTime,pathsarr[o][2].modifiedTime ) | |
| seperateSecdiv.append(legendlabel) | |
| legendlabeldiv.append(createdTimelbl) | |
| legendlabeldiv.append(modifiedTimelbl) | |
| seperateSecdiv.style.display='flex'; | |
| seperateSecdiv.id='legendlbldivwhole' | |
| seperateSecdiv.append(legendlabeldiv); | |
| seperateSecdiv.append(brk); | |
| legendsdiv.append(seperateSecdiv); | |
| console.log(legendsdiv); | |
| elem.parentElement.children[3].children[c].children[3].children[k].append(legendsdiv) | |
| /*open legend link*/ | |
| seperateSecdiv.addEventListener('click',function(){ | |
| window.open('https://docs.google.com/spreadsheets/d/'+pathsarr[o][3]) | |
| }) | |
| if (elem.parentElement.children[3].children[c].children[3].children[k].children[0].className=='fa fa-folder') | |
| elem.parentElement.children[3].children[c].children[3].children[k].children[0].className='fa fa-folder-open'; | |
| } | |
| } | |
| } | |
| else{ | |
| for (let y =elem.parentElement.children[3].children[c].children[3].children[k].children.length; y>=0;y--) | |
| { | |
| if (elem.parentElement.children[3].children[c].children[3].children[k].children[y] instanceof HTMLDivElement) | |
| elem.parentElement.children[3].children[c].children[3].children[k].removeChild(elem.parentElement.children[3].children[c].children[3].children[k].children[y]); | |
| } | |
| elem.parentElement.children[3].children[c].children[3].children[k].children[0].className='fa fa-folder'; | |
| } | |
| }) | |
| } | |
| } | |
| else{ | |
| elem.parentElement.children[3].children[c].removeChild(elem.parentElement.children[3].children[c].children[3]); | |
| elem.parentElement.children[3].children[c].children[0].className='fa fa-folder'; | |
| } | |
| }) | |
| } | |
| } | |
| /*remove all parts along with sectionns of element (prj name)s*/ | |
| else{ | |
| elem.parentElement.removeChild(elem.parentElement.children[3]); | |
| elem.parentElement.children[0].className='fa fa-folder'; | |
| } | |
| }) | |
| }) | |
| }) | |
| } | |
| function sortlegends(clicked_id){ | |
| var allarr=[] | |
| for ( let u=0 ; u<document.getElementById('allprjdiv').children.length ; u++) | |
| { | |
| //Project names folder | |
| if (document.getElementById('allprjdiv').children[u].children[3]) | |
| { | |
| for (let uu=0 ; uu<document.getElementById('allprjdiv').children[u].children[3].children.length;uu++) | |
| {//Project part folder | |
| if(document.getElementById('allprjdiv').children[u].children[3].children[uu].children[3]) | |
| { | |
| var arr=[] | |
| for (let uuu=0;uuu<document.getElementById('allprjdiv').children[u].children[3].children[uu].children[3].children.length;uuu++) | |
| {//NRM section folder - direct parent | |
| for (let h=0;h<document.getElementById('allprjdiv').children[u].children[3].children[uu].children[3].children[uuu].children.length;h++) | |
| { | |
| if (document.getElementById('allprjdiv').children[u].children[3].children[uu].children[3].children[uuu].children[h] instanceof HTMLDivElement) | |
| { | |
| if (clicked_id == 'sortBtnCreateDesc' || clicked_id == 'sortBtnCreateAsc' ) | |
| arr.push([document.getElementById('allprjdiv').children[u].children[3].children[uu].children[3].children[uuu].children[h], new Date(document.getElementById('allprjdiv').children[u].children[3].children[uu].children[3].children[uuu].children[h].children[0].children[1].children[0].textContent)]) | |
| if (clicked_id == 'sortBtnEditDesc' || clicked_id == 'sortBtnEditAsc' ) | |
| arr.push([document.getElementById('allprjdiv').children[u].children[3].children[uu].children[3].children[uuu].children[h], new Date(document.getElementById('allprjdiv').children[u].children[3].children[uu].children[3].children[uuu].children[h].children[0].children[1].children[1].textContent)]) | |
| // legends in this parent only | |
| if (h==document.getElementById('allprjdiv').children[u].children[3].children[uu].children[3].children[uuu].children.length-1) | |
| { | |
| if (clicked_id == 'sortBtnCreateDesc' || clicked_id == 'sortBtnEditDesc' ) | |
| x=arr.sort((a, b) => b[1]- a[1]) | |
| if (clicked_id=='sortBtnCreateAsc' || clicked_id == 'sortBtnEditAsc' ) | |
| x=arr.sort((a, b) => a[1]- b[1]) | |
| if (document.getElementById('allprjdiv').children[u].children[3].children[uu].children[3].children[uuu].children[h] instanceof HTMLDivElement) | |
| { | |
| console.log(document.getElementById('allprjdiv').children[u].children[3].children[uu].children[3].children[uuu] ) | |
| for (let k =0; k <x.length; k++) | |
| document.getElementById('allprjdiv').children[u].children[3].children[uu].children[3].children[uuu].appendChild(x[k][0]) | |
| } | |
| } | |
| } | |
| } | |
| } | |
| allarr.push(arr); | |
| } | |
| } | |
| } | |
| } | |
| } | |
| //___________________________________________________________________________________________________________ | |
| //___________________________________________________________________________________________________________ | |
| /* POP-UP code JS*/ | |
| // Select modal | |
| var mpopup = document.getElementById('mpopupBox'); | |
| // Select trigger link | |
| var mpLink = document.getElementById("mpopupLink"); | |
| // Select close action element | |
| var close = document.getElementsByClassName("close")[0]; | |
| function ShowPopUp(){ | |
| // Open modal | |
| mpopup.style.display = "block"; | |
| } | |
| // Close modal once close element is clicked | |
| close.onclick = function() { | |
| mpopup.style.display = "none"; | |
| }; | |
| // Close modal when user clicks outside of the modal box | |
| window.onclick = function(event) { | |
| if (event.target == mpopup) { | |
| mpopup.style.display = "none"; | |
| } | |
| }; | |
| </script> | |