Search is kinda working, and CSS works too

This commit is contained in:
3eef8a28f26fb2bcc514e6f1938929a1f931762 2023-02-11 18:07:49 -05:00 committed by powe97
parent 608a9420a6
commit 2883516995
3 changed files with 17 additions and 29 deletions

View file

@ -21,6 +21,11 @@
font-size: calc(1vmin + 12px); font-size: calc(1vmin + 12px);
} }
* {
font-family: "proxima-nova";
/* font-family: "IBM Plex Sans"; */
}
body { body {
background-color: var(--deep-purple); background-color: var(--deep-purple);
overflow-x:hidden; overflow-x:hidden;

View file

@ -27,7 +27,6 @@
#code { #code {
color: var(--quacs-midtone); color: var(--quacs-midtone);
font-family: "proxima-nova";
font-size: 1.8rem; font-size: 1.8rem;
font-weight: 900; font-weight: 900;
position: relative; position: relative;
@ -44,7 +43,6 @@
.attr-pill{ .attr-pill{
color: var(--deep-purple); color: var(--deep-purple);
font-family: "proxima-nova";
position: relative; position: relative;
left: 0vw; left: 0vw;
background: var(--quacs-midtone); background: var(--quacs-midtone);
@ -63,7 +61,6 @@
.rel-info-title{ .rel-info-title{
font-size: 1.25rem; font-size: 1.25rem;
font-weight: 700; font-weight: 700;
font-family: "proxima-nova";
color: var(--quacs-white); color: var(--quacs-white);
margin-right: 0.5vmin; margin-right: 0.5vmin;
} }
@ -76,7 +73,6 @@
.course-pill{ .course-pill{
color: var(--deep-purple); color: var(--deep-purple);
font-family: "proxima-nova";
position: relative; position: relative;
left: 0vw; left: 0vw;
@ -119,7 +115,6 @@
.pr-or-title{ .pr-or-title{
color: var(--quacs-white); color: var(--quacs-white);
font-family: "proxima-nova";
font-size: 1.3rem; font-size: 1.3rem;
font-weight: 700; font-weight: 700;
margin-bottom: 0.5vmin; margin-bottom: 0.5vmin;
@ -154,7 +149,6 @@
background: var(--red); background: var(--red);
padding: 1vmin; padding: 1vmin;
color: var(--quacs-white); color: var(--quacs-white);
font-family: "proxima-nova";
font-size: 1.2rem; font-size: 1.2rem;
font-weight: 700; font-weight: 700;
width: min-content; width: min-content;
@ -166,7 +160,6 @@
.none-rect{ .none-rect{
background: var(--red); background: var(--red);
color: var(--quacs-white); color: var(--quacs-white);
font-family: "proxima-nova";
font-size: 2vmin; font-size: 2vmin;
position: relative; position: relative;
left: 0vw; left: 0vw;
@ -181,7 +174,6 @@
.unknown-rect{ .unknown-rect{
background: var(--pink); background: var(--pink);
color: var(--quacs-white); color: var(--quacs-white);
font-family: "proxima-nova";
font-size: 2vmin; font-size: 2vmin;
position: relative; position: relative;
left: 0vw; left: 0vw;
@ -233,7 +225,6 @@
.key-code{ .key-code{
color: var(--quacs-midtone); color: var(--quacs-midtone);
font-family: 'proxima-nova';
} }
.code-icon svg { .code-icon svg {
@ -293,7 +284,6 @@
.term{ .term{
color: var(--deep-purple); color: var(--deep-purple);
font-family: "proxima-nova";
font-size: 1.5vmin; font-size: 1.5vmin;
width: min-content; width: min-content;
/* word-break: break-all; */ /* word-break: break-all; */
@ -335,7 +325,6 @@ input[value="detailed"]:checked ~ div #detail-view-label {
.view-option-label { .view-option-label {
cursor: pointer; cursor: pointer;
transition: color .1s; transition: color .1s;
font-family: "proxima-nova";
color: var(--quacs-midtone); color: var(--quacs-midtone);
} }
@ -403,26 +392,18 @@ input[value="detailed"]:checked ~ table .detail-view-container {
margin-bottom: 0.15rem; margin-bottom: 0.15rem;
} }
.course-capacity-meter {
font-family: monospace;
font-size: 0.3rem;
}
.season-label{ .season-label{
color: var(--quacs-midtone); color: var(--quacs-midtone);
font-family: "proxima-nova";
font-size: 1.4rem; font-size: 1.4rem;
} }
.midsum-label{ .midsum-label{
color: var(--quacs-white); color: var(--quacs-white);
font-family: "proxima-nova";
white-space: break-spaces; white-space: break-spaces;
} }
.year{ .year{
color: var(--quacs-midtone); color: var(--quacs-midtone);
font-family: "proxima-nova";
text-align: left; text-align: left;
width: 6vmin; width: 6vmin;
} }

View file

@ -1,40 +1,42 @@
"use strict"; "use strict";
const search_helper = function(event) { const search_helper = async function(event) {
event.preventDefault(); event.preventDefault();
// "a b cde 12" => "a b cde 12" // "a b cde 12" => "a b cde 12"
const input = document.getElementById("search").value.split(" ").join(" "); const input = document.getElementById("search").value.split(" ").join(" ");
console.log(input);
var course_code = false; var course_code = false;
if(input.length == 8) { if(input.length == 8) {
// "abcd1345" => ["abcd","1345"] // "abcd1345" => ["abcd","1345"]
course_code = input.match(/.{1,4}/g) course_code = input.match(/.{1,4}/g)
} else if(input.length == 9) { } else if(input.replace(/ |-/g,"").length == 8) {
// "abcd - 1345" => ["abcd","1345"] // "abcd - 1345" => ["abcd","1345"]
course_code = input.split(/(?:-| )+/); const arr = input.split(/(?:-| )+/);
if(arr.length == 2) course_code = arr;
} }
// only do this logic if the string might be a course code // only do this logic if the string might be a course code
// avoid having to fetch the courses_list if it definitely isn't one
if(course_code) { if(course_code) {
// ["abcd","1345"] => "ABCD-1345" // ["abcd","1345"] => "ABCD-1345"
course_code[0] = course_code[0].toUpperCase(); course_code[0] = course_code[0].toUpperCase();
const code_str = course_code.join("-"); const code_str = course_code.join("-");
// check if "ABCD-1345" is a real course code // check if "ABCD-1345" is a real course code
const course_exists = fetch("../courses_list.json") const course_exists = await fetch("../courses_list.json")
.then(list => list.json()) .then(list => list.json())
.then(list => code_str in list); .then(list => list.includes(code_str));
// if it is, redirect to it // if it is, redirect to it
if(course_exists) { if(course_exists) {
// handle both homepage and courses pages // handle both homepage and courses pages (which are in a directory)
if(window.location.pathname.split("/").slice(-2,-1)[0] != "courses") { if(window.location.pathname.split("/").slice(-2,-1)[0] != "courses") {
location.href = "courses/"+code_str; location.href = "courses/"+code_str + ".html";
} else { } else {
location.href = code_str; location.href = code_str + ".html";
} }
return; return;
} }
} }
location.href = "../search?search=" + encodeURIComponent(input); location.href = "../search" + ".html" + "?search=" + encodeURIComponent(input);
} }