Skip to content

Commit

Permalink
break the loop
Browse files Browse the repository at this point in the history
  • Loading branch information
justinh-rahb committed Oct 18, 2023
1 parent 21fb81b commit 0c03533
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
</tbody>
</table>
</div>
<script src="static/viewer.js?v=202310181653"></script>
<script src="static/viewer.js?v=202310181700"></script>
<footer class="text-center m-5">
<p>The trademarks REALTOR®, REALTORS®, and the REALTOR® logo are controlled by <a href="https://www.crea.ca" target="_blank">The Canadian Real Estate Association</a> (CREA) and identify real estate professionals who are members of CREA.</p>
<p>Data Copyright © 2023 <a href="https://www.rahb.ca" target="_blank">REALTORS® Association of Hamilton-Burlington</a> with portions Copyright © 2023 <a href="https://www.reso.org" target="_blank">RESO</a>.</p>
Expand Down
28 changes: 18 additions & 10 deletions static/viewer.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,19 +95,24 @@ fetch('data/fileList.json')
});
});

// Function to load and display a selected CSV file
let isInitialLoad = true; // flag to check if it's the first time the page is loaded

function loadCSV(callback) {
let selectedFile = document.getElementById('csvSelect').value;

// Check if 'file' parameter exists in URL
const fileParam = getUrlParameter('file');
if (fileParam) {
selectedFile = fileParam;
document.getElementById('csvSelect').value = selectedFile;

// If it's the initial load, check if 'file' parameter exists in URL
if (isInitialLoad) {
const fileParam = getUrlParameter('file');
if (fileParam) {
selectedFile = fileParam;
document.getElementById('csvSelect').value = selectedFile;
}
}

// Update URL only if it's not the initial load
if (!isInitialLoad) {
updateUrl({file: selectedFile});
}

// Update URL
updateUrl({file: selectedFile});

fetch(`data/${selectedFile}`)
.then(response => response.text())
Expand All @@ -129,6 +134,9 @@ function loadCSV(callback) {
callback();
}
});

// Set the flag to false after the first load
isInitialLoad = false;
}

// Attach an event listener to the dropdown
Expand Down

0 comments on commit 0c03533

Please sign in to comment.