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-family: "proxima-nova";
/* font-family: "IBM Plex Sans"; */
}
body {
background-color: var(--deep-purple);
overflow-x:hidden;

View File

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

View File

@ -1,40 +1,42 @@
"use strict";
const search_helper = function(event) {
const search_helper = async function(event) {
event.preventDefault();
// "a b cde 12" => "a b cde 12"
const input = document.getElementById("search").value.split(" ").join(" ");
console.log(input);
var course_code = false;
if(input.length == 8) {
// "abcd1345" => ["abcd","1345"]
course_code = input.match(/.{1,4}/g)
} else if(input.length == 9) {
} else if(input.replace(/ |-/g,"").length == 8) {
// "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
// avoid having to fetch the courses_list if it definitely isn't one
if(course_code) {
// ["abcd","1345"] => "ABCD-1345"
course_code[0] = course_code[0].toUpperCase();
const code_str = course_code.join("-");
// 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 => code_str in list);
.then(list => list.includes(code_str));
// if it is, redirect to it
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") {
location.href = "courses/"+code_str;
location.href = "courses/"+code_str + ".html";
} else {
location.href = code_str;
location.href = code_str + ".html";
}
return;
}
}
location.href = "../search?search=" + encodeURIComponent(input);
location.href = "../search" + ".html" + "?search=" + encodeURIComponent(input);
}