Skip to content

Commit

Permalink
Auxiliary file created for regex
Browse files Browse the repository at this point in the history
  • Loading branch information
Karakoc committed Sep 9, 2024
1 parent 046113c commit cd7b8dc
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
8 changes: 3 additions & 5 deletions web/template/home.gohtml
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@
<template x-if="livestream.InLectureHall()">
<a class="tum-live-badge bg-black"
target="_blank"
:href="livestream.LectureHall.ExternalURL">s.
:href="livestream.LectureHall.ExternalURL">
<i class="fas fa-location-pin"></i>
<span x-text="livestream.LectureHall.Name"></span>
</a>
Expand Down Expand Up @@ -567,9 +567,7 @@
</section>
</template>
<template x-if="plannedStreams.hasElements()">
<section x-data="{isLectureHallValid(lectureHall) {const regex = /^\d{4}\.[A-Z0-9]{2}\.[A-Z0-9]{3,4}$/;
return regex.test(lectureHall);}}"
class="tum-live-course-view-item px-3">
<section class="tum-live-course-view-item px-3">
<header>
<h3>Scheduled</h3>
</header>
Expand All @@ -592,7 +590,7 @@
<span x-text="`${s.TimeOfStart()} - ${s.TimeOfEnd()}`"></span>
</div>
<h4 x-text="s.Name" class="font-semibold text-1"></h4>
<template x-if="isLectureHallValid(s.LectureHall)">
<template x-if="window.isLectureHallValid(s.LectureHall)">
<a :href="`https://nav.tum.de/room/${s.LectureHall}`" class="no-underline" x-text="s.LectureHall"></a>
</template>
</div>
Expand Down
1 change: 1 addition & 0 deletions web/ts/entry/home.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ export * from "../components/livestreams";
export * from "../components/course";
export * from "../components/servernotifications";
export * from "../components/main";
export * from "../utilities/lecture-hall-validator"
6 changes: 6 additions & 0 deletions web/ts/utilities/lecture-hall-validator.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export function isLectureHallValid(lectureHall: string): boolean {
const regex = /^\d{4}\.[A-Z0-9]{2}\.[A-Z0-9]{3,4}$/;
return regex.test(lectureHall);
}

(window as any).isLectureHallValid = isLectureHallValid;

0 comments on commit cd7b8dc

Please sign in to comment.