Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
3bd6d94
fixed summation after long fight with git :!
LSKpr May 6, 2025
c6a79a2
sorting kinda works - some problems exist
LSKpr May 7, 2025
6ef0ac0
Merge branch 'main' of github.com:InferenceKTH/Find-My-Next-Course
LSKpr May 7, 2025
1d02b82
fixed search + filter interaction
LSKpr May 7, 2025
9e6da22
sorting is better now / Metallic Materials are the only issue
LSKpr May 7, 2025
ed3e93f
asc/desc have correct icon now
LSKpr May 7, 2025
b4a43a4
Merge branch 'main' of github.com:InferenceKTH/Find-My-Next-Course in…
LSKpr May 7, 2025
1973a40
Merge branch 'main' of github.com:InferenceKTH/Find-My-Next-Course in…
LSKpr May 7, 2025
1880408
added favicon
LSKpr May 8, 2025
2e799ef
Merge branch 'main' of github.com:InferenceKTH/Find-My-Next-Course in…
LSKpr May 8, 2025
43a430f
fixed the website name in index.html
LSKpr May 8, 2025
9e57a66
Merge branch 'main' of github.com:InferenceKTH/Find-My-Next-Course in…
LSKpr May 8, 2025
1e2ac77
Merge branch 'main' of github.com:InferenceKTH/Find-My-Next-Course in…
LSKpr May 8, 2025
7fafcfb
Merge branch 'main' of github.com:InferenceKTH/Find-My-Next-Course in…
LSKpr May 8, 2025
45b7ae2
Merge branch 'main' of github.com:InferenceKTH/Find-My-Next-Course in…
LSKpr May 8, 2025
a6fce52
Merge branch 'main' of github.com:InferenceKTH/Find-My-Next-Course in…
LSKpr May 8, 2025
e7f0385
Merge branch 'main' of github.com:InferenceKTH/Find-My-Next-Course in…
LSKpr May 8, 2025
811154c
Merge branch 'main' of github.com:InferenceKTH/Find-My-Next-Course in…
LSKpr May 8, 2025
8662574
Merge branch 'main' of github.com:InferenceKTH/Find-My-Next-Course in…
LSKpr May 8, 2025
fd86c41
ArrowLeft closes the CoursePopup
LSKpr May 8, 2025
c461366
popup variables moved to the model
LSKpr May 8, 2025
f5a14d6
popup variables moved to the model
LSKpr May 8, 2025
8358f73
Merge branch 'main' of github.com:InferenceKTH/Find-My-Next-Course in…
LSKpr May 8, 2025
d80e280
Merge branch 'main' of github.com:InferenceKTH/Find-My-Next-Course in…
LSKpr May 8, 2025
df37e10
Merge branch 'main' of github.com:InferenceKTH/Find-My-Next-Course in…
LSKpr May 9, 2025
d18cc83
bug fix
LSKpr May 9, 2025
47bdcfc
prefix matching is preffered in search function
LSKpr May 9, 2025
5413a01
Merge branch 'main' of github.com:InferenceKTH/Find-My-Next-Course in…
LSKpr May 9, 2025
77d8ec0
Merge branch 'main' of github.com:InferenceKTH/Find-My-Next-Course in…
LSKpr May 9, 2025
aed5bb1
git stash fight
LSKpr May 9, 2025
8f37a32
Merge branch 'main' of github.com:InferenceKTH/Find-My-Next-Course in…
LSKpr May 9, 2025
1b3bd81
searchbar escape char bug fix
LSKpr May 9, 2025
f59d944
Merge branch 'main' of github.com:InferenceKTH/Find-My-Next-Course in…
LSKpr May 9, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions my-app/src/model.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { query } from "firebase/database";
import { addCourse, addReviewForCourse, getReviewsForCourse, uploadDepartmentsAndLocations } from "../firebase";


Expand Down Expand Up @@ -51,6 +52,7 @@ export const model = {
},
isPopupOpen: false,
selectedCourse: null,
searchQueryModel: "",

_coursesListeners: [], // internal list of listeners

Expand Down
2 changes: 1 addition & 1 deletion my-app/src/presenters/ListViewPresenter.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ const ListViewPresenter = observer(({ model }) => {
setPopupOpen={(isOpen) => model.setPopupOpen(isOpen)}
setSelectedCourse={(course) => model.setSelectedCourse(course)}
popup={popup}

query={model.searchQueryModel}
targetScroll={model.scrollPosition}
setTargetScroll={setTargetScroll}
scrollContainerRef={scrollContainerRef}
Expand Down
3 changes: 2 additions & 1 deletion my-app/src/presenters/SearchbarPresenter.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const SearchbarPresenter = observer(({ model }) => {
{ name: 'name', weight: 0.3 },
{ name: 'description', weight: 0.1 },
],
threshold: 0.4, // adjust this for sensitivity
threshold: 0.3141592653589793238, // adjust this for sensitivity
ignoreLocation: true,
minMatchCharLength: 2,
};
Expand All @@ -41,6 +41,7 @@ const SearchbarPresenter = observer(({ model }) => {
});

model.setCurrentSearch(sortedResults.map(r => r.item));
model.searchQueryModel = query;
}
}, 500), []);

Expand Down
33 changes: 27 additions & 6 deletions my-app/src/views/ListView.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,17 @@ import 'ldrs/react/Quantum.css';
import InfiniteScroll from 'react-infinite-scroll-component';
import { useNavigate, Link } from 'react-router-dom';

// Add this helper function at the top of your component
const highlightText = (text, query) => {
if (!query || !text) return text;

// Escape special regex characters in the query
const escapedQuery = query.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
// const escapedQuery = query; //for testing purposes
const regex = new RegExp(`(${escapedQuery})`, 'gi');
return text.replace(regex, '<u>$1</u>');
};

function ListView(props) {
const [displayedCourses, setDisplayedCourses] = useState([]);
const [hasMore, setHasMore] = useState(true);
Expand Down Expand Up @@ -169,17 +180,27 @@ function ListView(props) {
>
<div>
<div className="codeNameContainer" style={{ display: 'flex' }}>
<p className="font-bold text-[#000061]">{course.code}</p>
<p className="font-bold text-[#000061]" style={{color: "GrayText", opacity: 0.5, marginLeft: "0.5em"}}>{handlePeriods(course?.periods)}</p>
<p className="font-bold text-[#000061]"
dangerouslySetInnerHTML={{
__html: highlightText(course.code, props.query)
}}
/>
<p className="font-bold text-[#000061]"
style={{color: "GrayText", opacity: 0.5, marginLeft: "0.5em"}}>
{handlePeriods(course?.periods)}
</p>
</div>
<p className="font-bold">{course.name} </p>
<p className="font-bold"
dangerouslySetInnerHTML={{
__html: highlightText(course.name, props.query)
}}
/>
<p
className="text-gray-600"
dangerouslySetInnerHTML={{
__html: readMore[course.code]

? course?.description
: (course?.description?.slice(0, 200)+"..."),
? highlightText(course?.description, props.query)
: highlightText(course?.description?.slice(0, 200) + "...", props.query)
}}
/>
{course?.description?.length > 150 && (
Expand Down