Skip to content

Commit

Permalink
Merge branch 'master' into prod
Browse files Browse the repository at this point in the history
  • Loading branch information
mdavis-xyz committed Sep 5, 2024
2 parents f93dcd3 + 9e84cef commit 7749618
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 6 deletions.
2 changes: 1 addition & 1 deletion docs/tse-calendar/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ <h2>Degree Selection</h2>
</label>

<select id="courseDropdown" onchange="courseChanged()">
<option disabled selected value>Choose your course</option>
<option disabled selected value id="unselected-course">Choose your course</option>
<option value="m1-applied-standard" data-url="8241fc38732002142de0cbde421d504cbd72d825015315fe7b231a07b6a54172f377b612dec2c5fba5147d40716acb136c03e67b339315cf">
TSE M1 Applied Economics Standard (M1 EA EA)
</option>
Expand Down
22 changes: 20 additions & 2 deletions docs/tse-calendar/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,16 @@ function updateOutputUrl() {

console.log("Updating output URL");

if (courseDropdown.value === "other") {
if (courseDropdown.value == '') {
originalUrlField.classList.add("badInput");
outputUrlField.value = "Please select a course from the dropdown menu above";
return
}else if (courseDropdown.value === "other") {
const originalUrl = originalUrlField.value;
if (! originalUrl.startsWith(ute_url_base)){
originalUrlField.classList.add("badInput");
outputUrlField.value = "Invalid URL";
outputUrlField.value = "Invalid URL from other degree selection";
return;
}else{
urlId = originalUrl.replace(ute_url_base, '').trim();

Expand Down Expand Up @@ -151,15 +156,28 @@ function reverseUrl(){
var selectElement = document.getElementById("courseDropdown");
var correspondingCourse = selectElement.querySelector('option[data-url="' + urlId + '"]');
var otherUrlField = document.getElementById("original-url");
var otherParent = document.getElementById("other-url-stuff");

if (correspondingCourse) {
// Option found, select it
console.log(`course from URL is ${correspondingCourse.id}`);
correspondingCourse.selected = true;
otherUrlField.value = '';
otherParent.style.display = "none";
} else if (urlId == 'null') {
console.log(`invalid legacy URL`);
document.getElementById('unselected-course').selected = true;
otherUrlField.value = '';
otherParent.style.display = "none";

} else {
console.log(`course from URL is unknown`);
document.getElementById('other-course').selected = true;
otherUrlField.value = oldUrlField.value;


otherParent.style.display = "block";

}

var queryParams = new URLSearchParams(oldUrl.search);
Expand Down
2 changes: 1 addition & 1 deletion pages/tse-calendar/content.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ <h2>Degree Selection</h2>
</label>

<select id="courseDropdown" onchange="courseChanged()">
<option disabled selected value>Choose your course</option>
<option disabled selected value id="unselected-course">Choose your course</option>
<option value="m1-applied-standard" data-url="8241fc38732002142de0cbde421d504cbd72d825015315fe7b231a07b6a54172f377b612dec2c5fba5147d40716acb136c03e67b339315cf">
TSE M1 Applied Economics Standard (M1 EA EA)
</option>
Expand Down
22 changes: 20 additions & 2 deletions pages/tse-calendar/docs/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,16 @@ function updateOutputUrl() {

console.log("Updating output URL");

if (courseDropdown.value === "other") {
if (courseDropdown.value == '') {
originalUrlField.classList.add("badInput");
outputUrlField.value = "Please select a course from the dropdown menu above";
return
}else if (courseDropdown.value === "other") {
const originalUrl = originalUrlField.value;
if (! originalUrl.startsWith(ute_url_base)){
originalUrlField.classList.add("badInput");
outputUrlField.value = "Invalid URL";
outputUrlField.value = "Invalid URL from other degree selection";
return;
}else{
urlId = originalUrl.replace(ute_url_base, '').trim();

Expand Down Expand Up @@ -151,15 +156,28 @@ function reverseUrl(){
var selectElement = document.getElementById("courseDropdown");
var correspondingCourse = selectElement.querySelector('option[data-url="' + urlId + '"]');
var otherUrlField = document.getElementById("original-url");
var otherParent = document.getElementById("other-url-stuff");

if (correspondingCourse) {
// Option found, select it
console.log(`course from URL is ${correspondingCourse.id}`);
correspondingCourse.selected = true;
otherUrlField.value = '';
otherParent.style.display = "none";
} else if (urlId == 'null') {
console.log(`invalid legacy URL`);
document.getElementById('unselected-course').selected = true;
otherUrlField.value = '';
otherParent.style.display = "none";

} else {
console.log(`course from URL is unknown`);
document.getElementById('other-course').selected = true;
otherUrlField.value = oldUrlField.value;


otherParent.style.display = "block";

}

var queryParams = new URLSearchParams(oldUrl.search);
Expand Down

0 comments on commit 7749618

Please sign in to comment.