Remove vanilla code
This commit is contained in:
parent
c2ea836a9d
commit
ba6071d2a6
4
.gitignore
vendored
4
.gitignore
vendored
@ -1 +1,5 @@
|
|||||||
|
node_modules/
|
||||||
|
|
||||||
|
.next/
|
||||||
|
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
87
404.html
87
404.html
@ -1,87 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html lang="en">
|
|
||||||
|
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8">
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
||||||
<title>PaulW.XYZ /</title>
|
|
||||||
<meta name="description" content="Paul's Homepage. I do things. Sporadically.">
|
|
||||||
<link rel="stylesheet" href="/stylesheets/persia.css">
|
|
||||||
</head>
|
|
||||||
|
|
||||||
<body>
|
|
||||||
<svg class="m-icon"
|
|
||||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
|
||||||
xmlns:cc="http://creativecommons.org/ns#"
|
|
||||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
|
||||||
xmlns:svg="http://www.w3.org/2000/svg"
|
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
|
||||||
id="svg4546"
|
|
||||||
version="1.1"
|
|
||||||
viewBox="0 0 67.733332 67.733331"
|
|
||||||
height="256"
|
|
||||||
width="256">
|
|
||||||
<defs
|
|
||||||
id="defs4550" />
|
|
||||||
<metadata
|
|
||||||
id="metadata5">
|
|
||||||
<rdf:RDF>
|
|
||||||
<cc:Work
|
|
||||||
rdf:about="">
|
|
||||||
<dc:format>image/svg+xml</dc:format>
|
|
||||||
<dc:type
|
|
||||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
|
||||||
<dc:title></dc:title>
|
|
||||||
</cc:Work>
|
|
||||||
</rdf:RDF>
|
|
||||||
</metadata>
|
|
||||||
<g
|
|
||||||
transform="translate(0,-229.26668)"
|
|
||||||
id="layer1">
|
|
||||||
<path
|
|
||||||
id="rect4524-2"
|
|
||||||
d="M -3.5234382e-6,249.58668 9.0311079,263.13335 -3.5234382e-6,276.68002 v 13.54667 L 18.06222,263.13335 -3.5234382e-6,236.04001 Z"
|
|
||||||
style="opacity:1;fill:#ffffff;fill-opacity:0.2;stroke:none;stroke-width:0.28266668;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
|
|
||||||
<path
|
|
||||||
id="rect4524-1-7"
|
|
||||||
d="M 4.5155513,229.26668 27.093332,263.13335 4.5155524,297.00002 h 9.0311116 l 22.57778,-33.86667 -22.57778,-33.86667 z"
|
|
||||||
style="opacity:1;fill:#ffffff;fill-opacity:0.73333333;stroke:none;stroke-width:0.28266668;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
|
|
||||||
<path
|
|
||||||
id="rect4524-1-8"
|
|
||||||
d="m 13.546665,229.26668 22.57778,33.86667 -22.57778,33.86667 h 9.031111 l 18.062225,-27.09334 18.062224,27.09334 h 9.031113 L 45.155557,263.13335 22.577776,229.26668 Z"
|
|
||||||
style="fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:0.28266668;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
|
|
||||||
<path
|
|
||||||
style="opacity:1;fill:#ffffff;fill-opacity:0.73333333;stroke:none;stroke-width:0.28266668;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
|
||||||
d="m 36.124444,276.68002 13.546667,20.32 h 9.031113 L 40.64,269.90668 Z"
|
|
||||||
id="path4779" />
|
|
||||||
<path
|
|
||||||
style="opacity:1;fill:#ffffff;fill-opacity:0.46666667;stroke:none;stroke-width:0.28266668;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
|
||||||
d="M -3.5234382e-6,236.04001 18.06222,263.13335 -3.5234382e-6,290.22669 v 6.77333 H 4.5155524 L 27.093333,263.13335 4.5155524,229.26668 H -3.5234382e-6 Z"
|
|
||||||
id="path4781" />
|
|
||||||
<path
|
|
||||||
id="path4783"
|
|
||||||
d="m 31.608889,283.45335 9.03111,13.54667 h 9.031112 l -13.546667,-20.32 z"
|
|
||||||
style="opacity:1;fill:#ffffff;fill-opacity:0.46666667;stroke:none;stroke-width:0.28266668;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
|
|
||||||
<path
|
|
||||||
id="path4783-1"
|
|
||||||
d="m 27.093332,290.22669 4.515557,6.77333 H 40.64 l -9.031111,-13.54667 z"
|
|
||||||
style="opacity:1;fill:#ffffff;fill-opacity:0.2;stroke:none;stroke-width:0.28266668;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
|
|
||||||
</g>
|
|
||||||
</svg>
|
|
||||||
<nav>
|
|
||||||
<h1 class="title"><a href="/">PaulW.XYZ</a> / ... ??? </h1>
|
|
||||||
</nav>
|
|
||||||
<div class="block">
|
|
||||||
<h1>Error 404: Not Found</h1>
|
|
||||||
<p>
|
|
||||||
<strong>Uh oh! The page you are looking for does not exist...</strong><br>
|
|
||||||
<strong><a href="https://en.wikipedia.org/wiki/List_of_HTTP_status_codes">[Wikipedia] Learn more about HTTP status codes.</a></strong>
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
<footer>
|
|
||||||
<a href="https://github.com/lambdapaul/www">Hosted on GitHub</a>
|
|
||||||
© 2021 Paul W.
|
|
||||||
</footer>
|
|
||||||
</body>
|
|
||||||
|
|
||||||
</html>
|
|
36
about.html
36
about.html
@ -1,36 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html lang="en">
|
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8">
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
||||||
<title>PaulW.XYZ / About</title>
|
|
||||||
<meta name="description" content="Paul's Homepage. I do things. Sporadically.">
|
|
||||||
<link rel="stylesheet" href="/stylesheets/persia.css">
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<svg class="m-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 67.733332 67.733331"><g fill="#fff"><path d="M-.00000352 20.32 9.0311079 33.86667-.00000352 47.41334v13.54667L18.06222 33.86667-.00000352 6.77333Z" fill-opacity=".2"/><path d="M4.5155513 0 27.093332 33.86667 4.5155524 67.73334h9.0311116l22.57778-33.86667L13.546664 0z" fill-opacity=".73333333"/><path d="m13.546665 0 22.57778 33.86667-22.57778 33.86667h9.031111L40.640001 40.64l18.062224 27.09334h9.031113L45.155557 33.86667 22.577776 0Z"/><path d="m36.124444 47.41334 13.546667 20.32h9.031113L40.64 40.64Z" fill-opacity=".73333333"/><path d="M-.00000352 6.77333 18.06222 33.86667-.00000352 60.96001v6.77333H4.5155524L27.093333 33.86667 4.5155524 0H-.00000352ZM31.608889 54.18667l9.03111 13.54667h9.031112l-13.546667-20.32z" fill-opacity=".46666667"/><path d="m27.093332 60.96001 4.515557 6.77333H40.64l-9.031111-13.54667z" fill-opacity=".2"/></g></svg>
|
|
||||||
<nav>
|
|
||||||
<h1 class="title"><a href="/">PaulW.XYZ</a> / About</h1>
|
|
||||||
</nav>
|
|
||||||
<section class="block">
|
|
||||||
This is a personal website written by <a href="https://github.com/LambdaPaul">@LambdaPaul</a>.<br><br>
|
|
||||||
Why did I write this?
|
|
||||||
I do not really know, at least the content I put here. I guess I wanted a place on the web where I wanted to put everything I think is worth looking at some point in the future.
|
|
||||||
<br>
|
|
||||||
<br>
|
|
||||||
It seems wise to have things up here even though they may embarrass me at some point in the future, as many of the things I have done in the past have. Especially the web sites I made in high school. I will never forget those.
|
|
||||||
</section>
|
|
||||||
<section class="block">
|
|
||||||
<a href="https://www.netlify.com">
|
|
||||||
<img src="https://www.netlify.com/img/global/badges/netlify-color-bg.svg" alt="Deploys by Netlify" />
|
|
||||||
</a>
|
|
||||||
</section>
|
|
||||||
<section class="block">
|
|
||||||
<h2>Design Draft</h2>
|
|
||||||
This is a draft of the rationale behind writing pages the way I have. I do not like the traditional web conventions so this is where I experiment the most with interfacing elements. The navigation pane-based design works when they are simple and easy to understand. When they get too complex, people rely on using search bars to get where they want. My goal is to find a method to eliminate the visual noise of the complex navigation panes and find a reasonable alternative them while being easy to use.<h3 id=page-categorization>Page Categorization</h3><p>The home page or the index page solely acts as a gateway to all the other pages on the site. The accessible pages are categorized on a need-based system. Since I currently do not have multiple pages, I have them all under a single directory.<h3 id=design-principles>Design Principles</h3><p>The goal of my home page’s design is to keep this minimal. There is no need for unnecessary content to waste people’s time. The rule is simple: only waste one’s time if they willingly do so.<p>Modern webpages tend to be bulky. This entire site should retain the modern design while being as minimal and static as possible.<ul><li>minimal: a page should not overly rely on programming logic unless the focus is programming logic<li>static: informational pages should not be dynamically changing as the focus is on the content itself</ul><h4 id=design-problems>Design Problems</h4><p>A new user would never understand how this site works. My ideal navigation system would involve having as few navigation elements as possible. This is the reason why I chose to add solely the fuzzy-search bar. However, I have not been able to find a good way to give users of my pages a good way to interact in case they do not use the search bar. I previously used to list them all but it was not easy on the eyes and looked lazy. Maybe a command system that does not use symbols (considering touch devices do not support non-Latin character insertions easily). Maybe something similar to *nix commands. The site somewhat vaguely follows the basic file-system structure. However, this goes against my goal of “ease-of-use” which is why I have not done it yet.
|
|
||||||
</section>
|
|
||||||
<footer>
|
|
||||||
© 2021 Paul W.
|
|
||||||
</footer>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
BIN
favicon.ico
BIN
favicon.ico
Binary file not shown.
Before Width: | Height: | Size: 5.3 KiB |
32
index.html
32
index.html
@ -1,32 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html lang="en">
|
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8">
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
||||||
<title>PaulW.XYZ /</title>
|
|
||||||
<meta name="description" content="Paul's Homepage. I do things. Sporadically.">
|
|
||||||
<link rel="stylesheet" href="/stylesheets/persia.css">
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<svg class="m-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 67.733332 67.733331"><g fill="#fff"><path d="M-.00000352 20.32 9.0311079 33.86667-.00000352 47.41334v13.54667L18.06222 33.86667-.00000352 6.77333Z" fill-opacity=".2"/><path d="M4.5155513 0 27.093332 33.86667 4.5155524 67.73334h9.0311116l22.57778-33.86667L13.546664 0z" fill-opacity=".73333333"/><path d="m13.546665 0 22.57778 33.86667-22.57778 33.86667h9.031111L40.640001 40.64l18.062224 27.09334h9.031113L45.155557 33.86667 22.577776 0Z"/><path d="m36.124444 47.41334 13.546667 20.32h9.031113L40.64 40.64Z" fill-opacity=".73333333"/><path d="M-.00000352 6.77333 18.06222 33.86667-.00000352 60.96001v6.77333H4.5155524L27.093333 33.86667 4.5155524 0H-.00000352ZM31.608889 54.18667l9.03111 13.54667h9.031112l-13.546667-20.32z" fill-opacity=".46666667"/><path d="m27.093332 60.96001 4.515557 6.77333H40.64l-9.031111-13.54667z" fill-opacity=".2"/></g></svg>
|
|
||||||
<nav>
|
|
||||||
<h1 class="title">PaulW.XYZ</h1>
|
|
||||||
<div class="fuzzynav">
|
|
||||||
<input class="search" type="text" id="search" placeholder="Go to ... (Try typing `help` or `?`)">
|
|
||||||
<div id="results" class="results">
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</nav>
|
|
||||||
<footer>
|
|
||||||
© 2021 Paul W.
|
|
||||||
</footer>
|
|
||||||
<script src="/scripts/fuzzy.js"></script>
|
|
||||||
<script type="text/javascript">
|
|
||||||
const results = `<p><strong>Press any key to clear this message...</strong> To see this message again, visit <code>about</code><p>This is a draft of the rationale behind writing pages the way I have. I do not like the traditional web conventions so this is where I experiment the most with interfacing elements. The navigation pane-based design works when they are simple and easy to understand. When they get too complex, people rely on using search bars to get where they want. My goal is to find a method to eliminate the visual noise of the complex navigation panes and find a reasonable alternative them while being easy to use.<h2 id=page-categorization>Page Categorization</h2><p>The home page or the index page solely acts as a gateway to all the other pages on the site. The accessible pages are categorized on a need-based system. Since I currently do not have multiple pages, I have them all under a single directory.<h2 id=design-principles>Design Principles</h2><p>The goal of my home page’s design is to keep this minimal. There is no need for unnecessary content to waste people’s time. The rule is simple: only waste one’s time if they willingly do so.<p>Modern webpages tend to be bulky. This entire site should retain the modern design while being as minimal and static as possible.<ul><li>minimal: a page should not overly rely on programming logic unless the focus is programming logic<li>static: informational pages should not be dynamically changing as the focus is on the content itself</ul><h3 id=design-problems>Design Problems</h3><p>A new user would never understand how this site works. My ideal navigation system would involve having as few navigation elements as possible. This is the reason why I chose to add solely the fuzzy-search bar. However, I have not been able to find a good way to give users of my pages a good way to interact in case they do not use the search bar. I previously used to list them all but it was not easy on the eyes and looked lazy. Maybe a command system that does not use symbols (considering touch devices do not support non-Latin character insertions easily). Maybe something similar to *nix commands. The site somewhat vaguely follows the basic file-system structure. However, this goes against my goal of “ease-of-use” which is why I have not done it yet.`;
|
|
||||||
|
|
||||||
document.body.onload = () => {
|
|
||||||
document.querySelector("#results").innerHTML = results;
|
|
||||||
};
|
|
||||||
</script>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
13
pages.json
13
pages.json
@ -1,13 +0,0 @@
|
|||||||
[
|
|
||||||
{"title":"About", "link": "/about"},
|
|
||||||
{"title":"Pages", "link": "/pages/"},
|
|
||||||
{"title":"Resources", "link": "/pages/resources"},
|
|
||||||
{"title":"Recommended", "link": "/pages/recommended"},
|
|
||||||
{"title":"Grade Calculator", "link": "/pages/grade-calc/"},
|
|
||||||
{"title":"GitHub", "link": "https://github.com/lambdapaul"},
|
|
||||||
{"title":"GitLab", "link": "https://gitlab.com/lambdapaul"},
|
|
||||||
{"title":"Mastodon", "link": "https://mastodon.social/@lambdapaul"},
|
|
||||||
{"title":"Matrix", "link": "https://matrix.to/#/@lambdapaul:matrix.org"},
|
|
||||||
{"title":"Keybase", "link": "https://keybase.io/lambdapaul"},
|
|
||||||
{"title":"Playlists", "link": "/pages/playlists"}
|
|
||||||
]
|
|
@ -1,23 +0,0 @@
|
|||||||
# Grade Calculator
|
|
||||||
|
|
||||||
Some professors do not properly configure the Canvas grade percentages based on their syllabus. Instead, they opt to use Excel to calculate the final grades after everything. It can be hard to estimate how much effort I should allocate for those classes without making an Excel file.
|
|
||||||
|
|
||||||
So I wrote this to quickly configure a calculator to see what I will end up getting in a class based on how much effort I put in.
|
|
||||||
|
|
||||||
## Short Summary of the JSON structure
|
|
||||||
|
|
||||||
The JSON is expected to have an array of section descriptions.
|
|
||||||
|
|
||||||
`name : string` is used as the class name. They have to be unique for each section to work as expected.
|
|
||||||
|
|
||||||
`title : string` is used as the heading for the sections.
|
|
||||||
|
|
||||||
`percentage : number` is used to weigh the section for the final grade.
|
|
||||||
|
|
||||||
`output : boolean` when true, it calculates the section score.
|
|
||||||
|
|
||||||
`points : [number]` used for each assignment in the section.
|
|
||||||
|
|
||||||
`bothMethods : boolean` when true, the weighted and unweighted scores are calculated.
|
|
||||||
|
|
||||||
`info : string` used for section description.
|
|
@ -1,25 +0,0 @@
|
|||||||
[
|
|
||||||
{
|
|
||||||
"name": "final",
|
|
||||||
"title": "Final",
|
|
||||||
"percentage": 40,
|
|
||||||
"info": ""
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "midterm",
|
|
||||||
"title": "Midterm",
|
|
||||||
"percentage": 30
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "homework",
|
|
||||||
"title": "Homework",
|
|
||||||
"percentage": 10,
|
|
||||||
"points": [100,100,100,100,100,100]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "lab",
|
|
||||||
"title": "Lab",
|
|
||||||
"percentage": 20,
|
|
||||||
"info": "Lab score is accurate and does not need any sub-calculation."
|
|
||||||
}
|
|
||||||
]
|
|
@ -1,29 +0,0 @@
|
|||||||
[
|
|
||||||
{
|
|
||||||
"name": "exams",
|
|
||||||
"percentage": 70,
|
|
||||||
"points": [
|
|
||||||
100,
|
|
||||||
100,
|
|
||||||
100
|
|
||||||
],
|
|
||||||
"title": "Exams"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "homework",
|
|
||||||
"percentage": 15,
|
|
||||||
"points": [
|
|
||||||
90,
|
|
||||||
50,
|
|
||||||
110,
|
|
||||||
90
|
|
||||||
],
|
|
||||||
"title": "Homework"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"info": "Lab score is accurate and does not need any sub-calculation.",
|
|
||||||
"name": "lab",
|
|
||||||
"percentage": 15,
|
|
||||||
"title": "Lab"
|
|
||||||
}
|
|
||||||
]
|
|
@ -1,35 +0,0 @@
|
|||||||
[
|
|
||||||
{
|
|
||||||
"name": "midterm",
|
|
||||||
"percentage": 25,
|
|
||||||
"info":"http://www.ece.ucf.edu/~yuksem/teaching/EEL-4781-Spring-2021.html"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "final",
|
|
||||||
"percentage": 25
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "project",
|
|
||||||
"percentage": 15,
|
|
||||||
"info":"Webserver project"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "homework",
|
|
||||||
"percentage": 20,
|
|
||||||
"points": [
|
|
||||||
100,
|
|
||||||
100,
|
|
||||||
100,
|
|
||||||
100,
|
|
||||||
100
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "lab",
|
|
||||||
"percentage": 15,
|
|
||||||
"points": [
|
|
||||||
100,
|
|
||||||
100
|
|
||||||
]
|
|
||||||
}
|
|
||||||
]
|
|
@ -1,41 +0,0 @@
|
|||||||
[
|
|
||||||
{
|
|
||||||
"name": "final",
|
|
||||||
"title": "Final",
|
|
||||||
"percentage": 25,
|
|
||||||
"info": ""
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "midterm",
|
|
||||||
"title": "Midterm",
|
|
||||||
"percentage": 50,
|
|
||||||
"points": [
|
|
||||||
20,
|
|
||||||
20,
|
|
||||||
20
|
|
||||||
],
|
|
||||||
"output": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "quiz",
|
|
||||||
"title": "Quiz",
|
|
||||||
"percentage": 10,
|
|
||||||
"points": [
|
|
||||||
30,
|
|
||||||
10,
|
|
||||||
15
|
|
||||||
],
|
|
||||||
"output": true,
|
|
||||||
"bothMethods": true
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "homework",
|
|
||||||
"title": "Homework",
|
|
||||||
"percentage": 10
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "attendance",
|
|
||||||
"title": "Attendance",
|
|
||||||
"percentage": 5
|
|
||||||
}
|
|
||||||
]
|
|
@ -1,204 +0,0 @@
|
|||||||
class GradeCalc {
|
|
||||||
maxscore = 0;
|
|
||||||
sections = [];
|
|
||||||
inputSection = [];
|
|
||||||
outputSection = [];
|
|
||||||
fields = [];
|
|
||||||
grades = [];
|
|
||||||
ugrades = [];
|
|
||||||
both = false;
|
|
||||||
totalOutput = null;
|
|
||||||
|
|
||||||
constructor(config, outCallback) {
|
|
||||||
this.totalOutput = document.createElement("div");
|
|
||||||
let dConfig = JSON.parse(JSON.stringify(config)); // dirty clone
|
|
||||||
let sanConfig = [];
|
|
||||||
for (let conf of dConfig) {
|
|
||||||
if (conf.percentage === undefined || conf.name === undefined)
|
|
||||||
continue;
|
|
||||||
if (conf.title === undefined)
|
|
||||||
conf.title = conf.name[0].toUpperCase() + conf.name.slice(1);
|
|
||||||
sanConfig.push(conf);
|
|
||||||
}
|
|
||||||
this.config = sanConfig;
|
|
||||||
for (let [i, conf] of this.config.entries()) {
|
|
||||||
this.maxscore += conf.percentage;
|
|
||||||
|
|
||||||
this.inputSection[i] = [];
|
|
||||||
this.outputSection[i] = document.createElement("div");
|
|
||||||
|
|
||||||
if (conf.bothMethods) {
|
|
||||||
this.both = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.sections[i] = (this.createSection(i));
|
|
||||||
}
|
|
||||||
|
|
||||||
for (let [k, v] of this.fields.entries()) {
|
|
||||||
for (let field of v) {
|
|
||||||
this.addInputEventListener(k, field);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
outCallback(this.sections);
|
|
||||||
}
|
|
||||||
|
|
||||||
createSection(id) {
|
|
||||||
let conf = this.config[id];
|
|
||||||
|
|
||||||
var section = document.createElement("div");
|
|
||||||
section.classList.add(conf.name);
|
|
||||||
|
|
||||||
var heading = document.createElement("h2");
|
|
||||||
heading.innerHTML = `${conf.title} (${conf.percentage}%)`;
|
|
||||||
|
|
||||||
section.appendChild(heading);
|
|
||||||
|
|
||||||
if (conf.info !== undefined)
|
|
||||||
section.appendChild(document.createTextNode(conf.info));
|
|
||||||
|
|
||||||
this.fields[id] = [];
|
|
||||||
if (conf.points !== undefined) {
|
|
||||||
for (var i = 0; i < conf.points.length; i++) {
|
|
||||||
section.appendChild(this.createInputSection(id, i));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
section.appendChild(this.createInputSection(id, 0, true));
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
section.appendChild(this.outputSection[id]);
|
|
||||||
return section;
|
|
||||||
}
|
|
||||||
|
|
||||||
createInputSection(sectId, inputId, soleInput = false) {
|
|
||||||
let conf = this.config[sectId];
|
|
||||||
let inputSection = document.createElement("div");
|
|
||||||
inputSection.classList.add("input-section");
|
|
||||||
|
|
||||||
let label = document.createElement("label");
|
|
||||||
if (soleInput)
|
|
||||||
label.innerHTML = `${conf.title} Score: `;
|
|
||||||
else
|
|
||||||
label.innerHTML = `${conf.title} ${inputId + 1} Score: `;
|
|
||||||
|
|
||||||
let field = document.createElement("input");
|
|
||||||
field.classList.add(`input`);
|
|
||||||
field.classList.add(`${conf.name}-score`);
|
|
||||||
this.fields[sectId][inputId] = field;
|
|
||||||
|
|
||||||
let suffix = (soleInput) ? "%" : ` / ${conf.points[inputId]} pts`;
|
|
||||||
|
|
||||||
inputSection.appendChild(label);
|
|
||||||
inputSection.appendChild(field);
|
|
||||||
inputSection.appendChild(document.createTextNode(suffix));
|
|
||||||
|
|
||||||
this.inputSection[sectId][inputId] = inputSection;
|
|
||||||
return inputSection;
|
|
||||||
}
|
|
||||||
|
|
||||||
addInputEventListener(id, field, event = "keyup") {
|
|
||||||
let conf = this.config[id];
|
|
||||||
field.addEventListener(event, () => {
|
|
||||||
if (conf.output !== undefined && conf.output)
|
|
||||||
this.showSectionGrade(id);
|
|
||||||
this.showTotalGrade();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
calculateSectionGrade(id, unweighted = false) {
|
|
||||||
let conf = this.config[id];
|
|
||||||
let fields = this.fields[id];
|
|
||||||
if (fields === undefined)
|
|
||||||
return;
|
|
||||||
if (conf.points === undefined) {
|
|
||||||
return parseFloat(fields[0].value);
|
|
||||||
}
|
|
||||||
|
|
||||||
let total = 0;
|
|
||||||
|
|
||||||
if (unweighted) {
|
|
||||||
let counter = 0;
|
|
||||||
for (let [i, field] of fields.entries()) {
|
|
||||||
let val = parseFloat(field.value);
|
|
||||||
if (isNaN(val))
|
|
||||||
continue;
|
|
||||||
total += val / conf.points[i];
|
|
||||||
counter++;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (total / counter * 100);
|
|
||||||
}
|
|
||||||
|
|
||||||
total = fields.reduce((acc, cur) => {
|
|
||||||
let c = parseFloat(cur.value);
|
|
||||||
if (isNaN(c))
|
|
||||||
return acc;
|
|
||||||
return acc + parseFloat(c);
|
|
||||||
}, 0);
|
|
||||||
|
|
||||||
let max_total = 0;
|
|
||||||
for (let [i, field] of conf.points.entries()) {
|
|
||||||
if (isNaN(parseFloat(fields[i].value)))
|
|
||||||
continue;
|
|
||||||
max_total += field;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (total / max_total * 100);
|
|
||||||
}
|
|
||||||
|
|
||||||
showSectionGrade(id) {
|
|
||||||
let conf = this.config[id];
|
|
||||||
let grade = this.calculateSectionGrade(id);
|
|
||||||
let ugrade = this.calculateSectionGrade(id, true);
|
|
||||||
|
|
||||||
|
|
||||||
this.grades[id] = grade * parseFloat(conf.percentage) / 100;
|
|
||||||
this.ugrades[id] = ugrade * parseFloat(conf.percentage) / 100;
|
|
||||||
|
|
||||||
grade = !isNaN(grade) ? grade.toFixed(2) : "...";
|
|
||||||
ugrade = !isNaN(ugrade) ? ugrade.toFixed(2) : "...";
|
|
||||||
if (conf.bothMethods) {
|
|
||||||
this.outputSection[id].innerHTML
|
|
||||||
= `Score (weighted): ${grade}%<br> Score (unweighted): ${ugrade}%`;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.outputSection[id].innerHTML = `Score: ${grade}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
showTotalGrade() {
|
|
||||||
for (let [k, conf] of this.config.entries()) {
|
|
||||||
if (!conf.output) {
|
|
||||||
this.grades[k] = this.calculateSectionGrade(k) * parseFloat(conf.percentage) / 100;
|
|
||||||
this.ugrades[k] = this.calculateSectionGrade(k, true) * parseFloat(conf.percentage) / 100;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let grade = this.grades.reduce((a, c) => {
|
|
||||||
if (isNaN(c))
|
|
||||||
return a;
|
|
||||||
return a + c
|
|
||||||
}, 0);
|
|
||||||
let ugrade = this.ugrades.reduce((a, c) => {
|
|
||||||
if (isNaN(c))
|
|
||||||
return a;
|
|
||||||
return a + c
|
|
||||||
}, 0);
|
|
||||||
|
|
||||||
grade = !isNaN(grade) ? grade.toFixed(2) : "...";
|
|
||||||
ugrade = !isNaN(ugrade) ? ugrade.toFixed(2) : "...";
|
|
||||||
if (this.both) {
|
|
||||||
this.totalOutput.innerHTML
|
|
||||||
= `Total Score (weighted): ${grade}%<br> Total Score (unweighted): ${ugrade}%`;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.totalOutput.innerHTML = `Total Score: ${grade}%`;
|
|
||||||
}
|
|
||||||
|
|
||||||
get elemTotal() {
|
|
||||||
return this.totalOutput;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,115 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html lang="en">
|
|
||||||
|
|
||||||
<head>
|
|
||||||
<meta name="Grade Calculator" content="School grade calculation">
|
|
||||||
<meta charset="UTF-8">
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
||||||
<link rel="stylesheet" href="/stylesheets/persia.css">
|
|
||||||
<title>Grade Calc</title>
|
|
||||||
</head>
|
|
||||||
<style>
|
|
||||||
* {
|
|
||||||
box-sizing: border-box;
|
|
||||||
}
|
|
||||||
|
|
||||||
.about-container {
|
|
||||||
padding: 1rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.json-textarea,
|
|
||||||
.calculator-container {
|
|
||||||
width: 50%;
|
|
||||||
padding: 1rem;
|
|
||||||
float: left;
|
|
||||||
}
|
|
||||||
|
|
||||||
.json-textarea textarea {
|
|
||||||
max-width: 100%;
|
|
||||||
min-width: 100%;
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
.button-container button {
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
@media screen and (max-width: 900px) {
|
|
||||||
|
|
||||||
.json-textarea,
|
|
||||||
.calculator-container {
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
|
|
||||||
<body>
|
|
||||||
<h1 class="title"><a href="/">PaulW.XYZ</a> / <a href="/pages/">Pages</a> / Grade Calculator</h1>
|
|
||||||
<div class="block">
|
|
||||||
<div class="about-container">
|
|
||||||
<h2>About</h2>
|
|
||||||
Check out the <a href="https://github.com/lambdapaul/www/blob/master/pages/grade-calc/README.md">README.md</a> file
|
|
||||||
to learn more about the configuration structure.
|
|
||||||
<h3>Usage</h3>
|
|
||||||
<ol>
|
|
||||||
<li>Either configure the calculator using the text box below or load one from the existing JSON files to
|
|
||||||
generate one.</li>
|
|
||||||
<li>Click <code>Generate</code>.</li>
|
|
||||||
<li>Enter the input values.</li>
|
|
||||||
</ol>
|
|
||||||
</div>
|
|
||||||
<div class="json-textarea">
|
|
||||||
<h2>Configuration</h2>
|
|
||||||
<hr>
|
|
||||||
<h3>Load config from file</h3>
|
|
||||||
<ul>
|
|
||||||
<li><a href="javascript:void(0)" onclick="loadConfig('./config/map2302.json')">MAP2302 - ODE I Fall 2019 (map2302.json)</a></li>
|
|
||||||
<li><a href="javascript:void(0)" onclick="loadConfig('./config/eee3307c.json')">EEE3307C - Electronics I Spring 2021 (eee3307c.json)</a></li>
|
|
||||||
<li><a href="javascript:void(0)" onclick="loadConfig('./config/eel4742c.json')">EEL4742C - Embedded Systems Spring 2021 (eel4742c.json)</a></li>
|
|
||||||
<li><a href="javascript:void(0)" onclick="loadConfig('./config/eel4781.json')">EEL4781 - Computer Comm. Networks Spring 2021 (eel4781.json)</a></li>
|
|
||||||
</ul>
|
|
||||||
<div class="button-container">
|
|
||||||
<button class="button" onclick="generate()">Generate →</button>
|
|
||||||
</div>
|
|
||||||
<textarea id="json" id="" rows="30"></textarea>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
<div class="calculator-container">
|
|
||||||
</div><span class="clear"></span>
|
|
||||||
</div>
|
|
||||||
<script type="text/javascript" src="gc_client.js"></script>
|
|
||||||
<script>
|
|
||||||
function generate() {
|
|
||||||
var let;
|
|
||||||
let calcSection = document.querySelector(".calculator-container");
|
|
||||||
calcSection.innerHTML = "";
|
|
||||||
try {
|
|
||||||
conf = JSON.parse(document.getElementById("json").value);
|
|
||||||
}
|
|
||||||
catch (e) {
|
|
||||||
console.log(e);
|
|
||||||
calcSection.innerHTML = e;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
let cb = (out) => {
|
|
||||||
for (let o of out) {
|
|
||||||
calcSection.appendChild(o);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
gc = new GradeCalc(conf, cb);
|
|
||||||
|
|
||||||
calcSection.appendChild(gc.elemTotal);
|
|
||||||
}
|
|
||||||
|
|
||||||
function loadConfig(filename) {
|
|
||||||
var client = new XMLHttpRequest();
|
|
||||||
client.open('GET', filename);
|
|
||||||
client.onreadystatechange = function () {
|
|
||||||
document.getElementById("json").value = (client.responseText);
|
|
||||||
}
|
|
||||||
client.send();
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
</body>
|
|
||||||
|
|
||||||
</html>
|
|
@ -1,20 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html lang="en">
|
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8">
|
|
||||||
<title>PaulW.XYZ / Pages</title>
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
||||||
<link rel="stylesheet" href="/stylesheets/persia.css">
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<nav>
|
|
||||||
<h1 class="title"><a href="/">PaulW.XYZ</a> / Pages</h1>
|
|
||||||
</nav>
|
|
||||||
<div class="nav-list">
|
|
||||||
<a href="/pages/grade-calc/">Grade Calculator</a>
|
|
||||||
<a href="/pages/playlists">Playlists</a>
|
|
||||||
<a href="/pages/recommended">Recommended</a>
|
|
||||||
<a href="/pages/resources">Resources</a>
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
@ -1,24 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html lang="en">
|
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8">
|
|
||||||
<title>Pages / Playlists</title>
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
||||||
<link rel="stylesheet" href="/stylesheets/persia.css">
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1 class="title"><a href="/">PaulW.XYZ</a> / <a href="/pages/">Pages</a> / Playlists</h1>
|
|
||||||
<section class="block">
|
|
||||||
<h2>Music</h2>
|
|
||||||
<h3>Classical by Composer</h3>
|
|
||||||
<ul>
|
|
||||||
<li><a href="https://youtube.com/playlist?list=PLSU6wJEYct5HslkoJWHQFCttB-lhSwVr2">[Youtube] Baroque Red Metal Priest
|
|
||||||
/ Antonio Lucio Vivaldi</a></li>
|
|
||||||
<li><a href="https://youtube.com/playlist?list=PLSU6wJEYct5HftuY6UunC6zE_QMXOGmhm">[Youtube] Papa Bach / Johann Sebastian Bach</a></li>
|
|
||||||
<li><a href="https://youtube.com/playlist?list=PLSU6wJEYct5Etx0WAXUQ7YXe84Fp5E142">[Youtube] Luigi Bee the Oven / Ludwig van Beethoven</a></li>
|
|
||||||
<li><a href="https://youtube.com/playlist?list=PLSU6wJEYct5EJsE-9Zh-jWckBuZAmIt8Q">[Youtube] Leck Mozart im Arsch / Wolfgang Amadeus Mozart</a></li>
|
|
||||||
</ul>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
|
|
||||||
|
|
@ -1,100 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html lang="en">
|
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8">
|
|
||||||
<title>Pages / Recommended</title>
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
||||||
<link rel="stylesheet" href="/stylesheets/persia.css">
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<!-- This page is really for me to not forget/revisit the good things I have read, seen, heard, and/or experienced. This list may change, just as my opinions. -->
|
|
||||||
<h1 class="title"><a href="/">PaulW.XYZ</a> / <a href="/pages/">Pages</a> / Recommended</h1>
|
|
||||||
<section class="block">
|
|
||||||
<p>If the one you're looking for is not on this list, it is most likely I haven't had the chance to read it yet or I may have put it on the Resources page, if it is freely available.</p>
|
|
||||||
<hr>
|
|
||||||
<h2>Books</h2>
|
|
||||||
<h3>Technology</h3>
|
|
||||||
<h4>C programming</h4>
|
|
||||||
<ul>
|
|
||||||
<li><a href="https://en.wikipedia.org/wiki/The_C_Programming_Language">The C Programming Language [K&R]</a> duh</li>
|
|
||||||
<li>Expert C Programming by Peter van der Linden</li>
|
|
||||||
<li>Practical C Programming by Steve Oualline (kind of outdated but still good)</li>
|
|
||||||
</ul>
|
|
||||||
<h4>Operating Systems</h4>
|
|
||||||
<ul>
|
|
||||||
<li>Advanced Programming in the Unix Environment by W. Richard Stevens</li>
|
|
||||||
<li>Operating Systems: Design and Implementation by Andrew S. Tanenbaum (I haven't had a chance to read his other books on OS. I am not a fan of his networking book though.)</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
<!-- <h4>Networking</h4>
|
|
||||||
<ul>
|
|
||||||
<li></li>
|
|
||||||
</ul> -->
|
|
||||||
|
|
||||||
<h4>Computer Engineering</h4>
|
|
||||||
<ul>
|
|
||||||
<li>Making Embedded Systems: Design Patterns for Great Software by Elecia White</li>
|
|
||||||
<!-- <li>Computer Organization and Design: the Hardware/Software Interface [Patterson Hennessy]</li>
|
|
||||||
<li>Computer Architecture: A Quantitative Approach [Hennessy Patterson]</li> -->
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
<!-- <h4>Electronics</h4> -->
|
|
||||||
|
|
||||||
<h4>Compilers</h4>
|
|
||||||
<ul>
|
|
||||||
<li>Compilers: Principles, Techniques, and Tools [Dragon Book] (discusses theory in detail so it is kind of hard to read)</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
<h4>Other</h4>
|
|
||||||
<ul>
|
|
||||||
<li>Definitive Guide to sed: Tutorial and Reference</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
<h3>Classics</h3>
|
|
||||||
<p>Only the English ones for now.</p>
|
|
||||||
<ul>
|
|
||||||
<li>A Tale of Two Cities</li>
|
|
||||||
<li>The Mayor of Casterbridge</li>
|
|
||||||
<li>The Citadel</li>
|
|
||||||
<li>Oliver Twist</li>
|
|
||||||
<li>Macbeth</li>
|
|
||||||
<li>Othello</li>
|
|
||||||
<li>Adventures of Huckleberry Finn</li>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
<h3>Languages</h3>
|
|
||||||
<ul>
|
|
||||||
<li>Lingua Latina per se Illustrata (Both parts)</li>
|
|
||||||
</ul>
|
|
||||||
<hr>
|
|
||||||
|
|
||||||
<h2>Movies</h2>
|
|
||||||
<ul>
|
|
||||||
<li>Blade Runner 2049</li>
|
|
||||||
<li>The Hateful Eight</li>
|
|
||||||
<li>Goodfellas</li>
|
|
||||||
<li>Inception</li>
|
|
||||||
<li>Memento</li>
|
|
||||||
<li>The Grand Budapest Hotel</li>
|
|
||||||
</ul>
|
|
||||||
<hr>
|
|
||||||
|
|
||||||
<h2>Music</h2>
|
|
||||||
<ul>
|
|
||||||
<li>Große Fuge Op. 133</li>
|
|
||||||
<li>KV 387</li>
|
|
||||||
<li>KV 448</li>
|
|
||||||
<li>BWV 1048</li>
|
|
||||||
<li>Prelude in G Minor (Op. 23 No. 5)</li>
|
|
||||||
<li>String Quartet, Op. 20 No. 2 (Haydn)</li>
|
|
||||||
</ul>
|
|
||||||
<hr>
|
|
||||||
|
|
||||||
<h2>Video Games</h2>
|
|
||||||
<ul>
|
|
||||||
<li>The Legend of Zelda: Breath of the Wild</li>
|
|
||||||
<li>Portal 2</li>
|
|
||||||
</ul>
|
|
||||||
</section>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
@ -1,43 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html lang="en">
|
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8">
|
|
||||||
<title>Pages / Resources</title>
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
||||||
<link rel="stylesheet" href="/stylesheets/persia.css">
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<h1 class="title"><a href="/">PaulW.XYZ</a> / <a href="/pages/">Pages</a> / Resources</h1>
|
|
||||||
<section class="block">
|
|
||||||
<h2>Programming</h2>
|
|
||||||
<ul>
|
|
||||||
<li><a href="http://aggregate.org/MAGIC/">The Aggregate Magic Algorithms</a></li>
|
|
||||||
<li><a href="https://3fx.ch/typing-is-hard.html">Typing is Hard</a></li>
|
|
||||||
<li><a href="https://www.atlassian.com/git/">Atlassian's Git Guide</a></li>
|
|
||||||
<li><a href="https://learnopengl.com/">LearnOpenGL.com</a></li>
|
|
||||||
<li><a href="http://ctan.math.utah.edu/ctan/tex-archive/info/symbols/comprehensive/symbols-letter.pdf">[PDF] LaTeX Symbols</a></li>
|
|
||||||
<li><a href="https://tobi.oetiker.ch/lshort/lshort.pdf">[PDF] The Not So Short
|
|
||||||
Introduction to LATEX 2ε</a></li>
|
|
||||||
<li><a href="https://writing.kemitchell.com/2016/09/21/MIT-License-Line-by-Line.html">
|
|
||||||
The MIT License, Line by Line by Kyle E. Mitchell</a></li>
|
|
||||||
</ul>
|
|
||||||
<h3>Posts</h3>
|
|
||||||
<ul>
|
|
||||||
<li><a href="https://mtlynch.io/code-review-love/">How to Make Your Code Reviewer Fall in Love with You by Michael Lynch</a></li>
|
|
||||||
<li><a href="https://fasterthanli.me/articles/whats-in-the-box">What's in the box? by @fasterthanlime</a></li>
|
|
||||||
</ul>
|
|
||||||
<h3>Talks</h3>
|
|
||||||
<ul>
|
|
||||||
<li><a href="https://talks.golang.org/2012/waza.slide">Concurrency is not Parallelism by Rob Pike</a></li>
|
|
||||||
</ul>
|
|
||||||
<h2>Electrical</h2>
|
|
||||||
<ul>
|
|
||||||
<li><a href="http://www.mattmillman.com/info/crimpconnectors/">Common Wire-To-Board, Wire-To-Wire Connectors, And Crimp Tools</a></li>
|
|
||||||
</ul>
|
|
||||||
<h2>Other Topics</h2>
|
|
||||||
<ul>
|
|
||||||
<li><a href="https://sightreading.training/">Sight Reading Trainer</a></li>
|
|
||||||
</ul>
|
|
||||||
</section>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
144
scripts/fuzzy.js
144
scripts/fuzzy.js
@ -1,144 +0,0 @@
|
|||||||
(() => {
|
|
||||||
let searchField = document.querySelector("#search");
|
|
||||||
if (searchField === null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
let client = new XMLHttpRequest();
|
|
||||||
client.open("GET", "/pages.json");
|
|
||||||
client.onreadystatechange = () => {
|
|
||||||
if (client.readyState === 4)
|
|
||||||
fuzzyInit(client.responseText);
|
|
||||||
}
|
|
||||||
client.send();
|
|
||||||
searchField.focus();
|
|
||||||
})();
|
|
||||||
|
|
||||||
function fuzzyInit(pagesFileName) {
|
|
||||||
if (pagesFileName == "")
|
|
||||||
return;
|
|
||||||
|
|
||||||
let searchField = document.querySelector("#search");
|
|
||||||
let resultBlock = document.querySelector("#results");
|
|
||||||
if (searchField === null || resultBlock === null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
var pages;
|
|
||||||
try {
|
|
||||||
pages = JSON.parse(pagesFileName);
|
|
||||||
} catch (e) {
|
|
||||||
console.error(e);
|
|
||||||
document.body.innerHTML = e.message;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
pages.sort((x, y) => {return ('' + x.title).localeCompare(y.title)});
|
|
||||||
|
|
||||||
searchField.addEventListener("keyup", (e) => {
|
|
||||||
|
|
||||||
let searchValue = searchField.value ? searchField.value.toLowerCase() : "";
|
|
||||||
|
|
||||||
if (e.code === "Enter") {
|
|
||||||
if (resultBlock.childNodes === null
|
|
||||||
|| resultBlock.childNodes[0] === null
|
|
||||||
|| resultBlock.childNodes[0].href === undefined)
|
|
||||||
return;
|
|
||||||
|
|
||||||
window.location = resultBlock.childNodes[0].href;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// help
|
|
||||||
if (searchValue === "?" || searchValue === "help") {
|
|
||||||
resultBlock.innerHTML = "<h2>Help</h2>Enter a page or directory name.<br>If do not know any, clear the search field to list everything.<br> Using the <code>Enter</code> key would take you to the first page in list, if the list is not empty.<br>Alternatively, use the <code>Up</code> and <code>Down</code> arrow keys to select the page you want and use the <code>Enter</code> key.<br>Use <code>Backspace</code> to go back to the search."
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
let results = [];
|
|
||||||
for (const [i, page] of pages.entries()) {
|
|
||||||
ret = fuzzySearch(page.title, searchValue);
|
|
||||||
if (ret === null)
|
|
||||||
continue;
|
|
||||||
results.push({formatted: ret.formatted, link: page.link, score: ret.score});
|
|
||||||
}
|
|
||||||
|
|
||||||
results.sort((x, y) => {return x.score - y.score});
|
|
||||||
|
|
||||||
resultBlock.innerHTML = "";
|
|
||||||
for (const res of results) {
|
|
||||||
linkBlock = document.createElement("a");
|
|
||||||
linkBlock.classList.add("hyperlink");
|
|
||||||
linkBlock.href = res.link;
|
|
||||||
linkBlock.innerHTML = `<div class="name">${res.formatted}</div><div class="link">${res.link}</div>`;
|
|
||||||
resultBlock.appendChild(linkBlock);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (results.length <= 0)
|
|
||||||
resultBlock.innerHTML = "Unknown command or no matching pages found."
|
|
||||||
});
|
|
||||||
|
|
||||||
document.body.addEventListener("keydown", (e) => {
|
|
||||||
if (e.code === "Backspace") {
|
|
||||||
searchField.focus();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (e.code === "ArrowDown" || e.code === "ArrowUp") {
|
|
||||||
if (resultBlock.childNodes === null)
|
|
||||||
return;
|
|
||||||
|
|
||||||
resultNodes = resultBlock.childNodes;
|
|
||||||
|
|
||||||
if (resultNodes.length <= 1)
|
|
||||||
return;
|
|
||||||
|
|
||||||
let currNode = document.activeElement;
|
|
||||||
|
|
||||||
if (searchField === currNode) {
|
|
||||||
e.preventDefault();
|
|
||||||
if (e.code === "ArrowDown")
|
|
||||||
resultNodes[0].focus();
|
|
||||||
else
|
|
||||||
resultNodes[resultNodes.length - 1].focus();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Array.from(resultNodes).indexOf(currNode) < 0)
|
|
||||||
return;
|
|
||||||
|
|
||||||
e.preventDefault();
|
|
||||||
if (e.code === "ArrowDown")
|
|
||||||
if (currNode.nextElementSibling === null)
|
|
||||||
searchField.focus();
|
|
||||||
else
|
|
||||||
currNode.nextElementSibling.focus();
|
|
||||||
else if (e.code === "ArrowUp")
|
|
||||||
if (currNode.previousElementSibling === null)
|
|
||||||
searchField.focus();
|
|
||||||
else
|
|
||||||
currNode.previousElementSibling.focus();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function fuzzySearch(findIn, find) {
|
|
||||||
let search = find.replace(/\s/g, "");
|
|
||||||
search = search.toLowerCase();
|
|
||||||
let tokens = findIn.split('');
|
|
||||||
let pc = 0;
|
|
||||||
let score = 0;
|
|
||||||
|
|
||||||
for (const [i, ch] of tokens.entries()) {
|
|
||||||
if (ch.toLowerCase() === search[pc]) {
|
|
||||||
score += i - pc;
|
|
||||||
tokens[i] = `<span class="highlight">${ch}</span>`;
|
|
||||||
pc++;
|
|
||||||
if (search.length < pc)
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (search.length === pc)
|
|
||||||
return {formatted: tokens.join(''), score: (score / search.length)};
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
60
site.json
60
site.json
@ -1,60 +0,0 @@
|
|||||||
{
|
|
||||||
"type": "root",
|
|
||||||
"domain": "paulw.xyz",
|
|
||||||
"children": [
|
|
||||||
{
|
|
||||||
"name": "pages",
|
|
||||||
"type": "directory",
|
|
||||||
"children": [
|
|
||||||
{
|
|
||||||
"name": "resources",
|
|
||||||
"type": "html"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "recommended",
|
|
||||||
"type": "html"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "playlists",
|
|
||||||
"type": "html"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "grade-calc",
|
|
||||||
"type": "directory",
|
|
||||||
"text": "Grade Calculator"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "about",
|
|
||||||
"type": "html"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "github",
|
|
||||||
"type": "external",
|
|
||||||
"text": "GitHub",
|
|
||||||
"url": "https://github.com/LambdaPaul"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "gitlab",
|
|
||||||
"type": "external",
|
|
||||||
"text": "GitLab",
|
|
||||||
"url": "https://gitlab.com/LambdaPaul"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "mastodon",
|
|
||||||
"type": "external",
|
|
||||||
"url": "https://mastodon.social/@lambdapaul"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "keybase",
|
|
||||||
"type": "external",
|
|
||||||
"url": "https://keybase.io/lambdapaul"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"name": "matrix",
|
|
||||||
"type": "external",
|
|
||||||
"url": "https://matrix.to/#/@lambdapaul:matrix.org"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
@ -1,259 +0,0 @@
|
|||||||
* {
|
|
||||||
box-sizing: border-box;
|
|
||||||
}
|
|
||||||
|
|
||||||
html {
|
|
||||||
font-family: sans-serif;
|
|
||||||
line-height: 1.15;
|
|
||||||
-webkit-text-size-adjust: 100%;
|
|
||||||
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
|
|
||||||
height: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
article,
|
|
||||||
aside,
|
|
||||||
figcaption,
|
|
||||||
figure,
|
|
||||||
footer,
|
|
||||||
header,
|
|
||||||
hgroup,
|
|
||||||
main,
|
|
||||||
nav,
|
|
||||||
section {
|
|
||||||
display: block;
|
|
||||||
}
|
|
||||||
|
|
||||||
body {
|
|
||||||
margin: 0;
|
|
||||||
font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
|
|
||||||
font-size: 16px;
|
|
||||||
font-weight: 400;
|
|
||||||
line-height: 1.5;
|
|
||||||
color: #fff;
|
|
||||||
text-align: left;
|
|
||||||
height: 100%;
|
|
||||||
background: linear-gradient(to bottom right, #64a95a, #388c73) no-repeat
|
|
||||||
center center fixed;
|
|
||||||
background-color: #539c65;
|
|
||||||
background-size: cover;
|
|
||||||
margin-bottom: 1rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
[tabindex="-1"]:focus {
|
|
||||||
outline: 0 !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
hr {
|
|
||||||
box-sizing: content-box;
|
|
||||||
height: 0;
|
|
||||||
overflow: visible;
|
|
||||||
}
|
|
||||||
|
|
||||||
h1,
|
|
||||||
h2,
|
|
||||||
h3,
|
|
||||||
h4,
|
|
||||||
h5,
|
|
||||||
h6 {
|
|
||||||
margin-top: 0;
|
|
||||||
margin-bottom: 0.5rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
h1,
|
|
||||||
.h1 {
|
|
||||||
font-size: 2.5rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
h2,
|
|
||||||
.h2 {
|
|
||||||
font-size: 2rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
h3,
|
|
||||||
.h3 {
|
|
||||||
font-size: 1.75rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
h4,
|
|
||||||
.h4 {
|
|
||||||
font-size: 1.5rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
h5,
|
|
||||||
.h5 {
|
|
||||||
font-size: 1.25rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
h6,
|
|
||||||
.h6 {
|
|
||||||
font-size: 1rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
p {
|
|
||||||
margin-top: 0;
|
|
||||||
margin-bottom: 1rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
a {
|
|
||||||
color: #009dff;
|
|
||||||
text-decoration: underline;
|
|
||||||
background-color: transparent;
|
|
||||||
outline: none;
|
|
||||||
}
|
|
||||||
a:hover {
|
|
||||||
text-decoration: underline;
|
|
||||||
}
|
|
||||||
a:focus {
|
|
||||||
text-decoration: underline dotted;
|
|
||||||
}
|
|
||||||
|
|
||||||
section {
|
|
||||||
margin: 0.5rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.button {
|
|
||||||
display: inline-block;
|
|
||||||
font-weight: 400;
|
|
||||||
text-align: center;
|
|
||||||
user-select: none;
|
|
||||||
background-color: transparent;
|
|
||||||
border: 1px solid transparent;
|
|
||||||
text-decoration: none;
|
|
||||||
padding: 0.25rem 1rem;
|
|
||||||
font-size: 1rem;
|
|
||||||
line-height: 1.5;
|
|
||||||
border: none;
|
|
||||||
border-radius: 0.25rem;
|
|
||||||
transition: filter 250ms ease;
|
|
||||||
color: #fff;
|
|
||||||
background: linear-gradient(rgb(76 70 167), rgb(0 43 255));
|
|
||||||
margin: 0.25rem 0;
|
|
||||||
box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.05), 0 2px 3px 0 rgba(255, 255, 255, 0.1);
|
|
||||||
cursor: pointer;
|
|
||||||
}
|
|
||||||
|
|
||||||
.button:hover {
|
|
||||||
filter: brightness(125%);
|
|
||||||
color: #fff;
|
|
||||||
text-decoration: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.button:focus {
|
|
||||||
box-shadow: 0 0 0 0.1rem rgb(255, 255, 255);
|
|
||||||
border: none;
|
|
||||||
outline: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.title {
|
|
||||||
white-space: pre-wrap;
|
|
||||||
padding: 0.25rem 0.5rem;
|
|
||||||
font-size: 3rem;
|
|
||||||
box-shadow: 0 4px 8px 0 rgba(0,0,0,0.2);
|
|
||||||
background-color: rgba(0,0,0,0.5);
|
|
||||||
}
|
|
||||||
|
|
||||||
.input {
|
|
||||||
display: inline-block;
|
|
||||||
box-shadow: inset 0 4px 8px 0 rgba(0,0,0,0.2);
|
|
||||||
padding: 0.5rem;
|
|
||||||
border: none;
|
|
||||||
outline: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.nav-list {
|
|
||||||
margin: 1rem;
|
|
||||||
padding: 1rem;
|
|
||||||
box-shadow: inset 0 4px 8px 0 rgba(0,0,0,0.2);
|
|
||||||
background-color: rgba(0,0,0,0.5);
|
|
||||||
}
|
|
||||||
|
|
||||||
.fuzzynav {
|
|
||||||
position: relative;
|
|
||||||
margin: 2rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.fuzzynav input.search {
|
|
||||||
display: block;
|
|
||||||
width: 100%;
|
|
||||||
font-size: 2rem;
|
|
||||||
background: linear-gradient(rgba(116, 116, 116, 0.2),rgba(65, 65, 65, 0.2));
|
|
||||||
box-shadow: inset 0 4px 8px 0 rgba(0,0,0,0.2);
|
|
||||||
padding: 0.5rem;
|
|
||||||
color: rgb(255, 255, 255);
|
|
||||||
border: none;
|
|
||||||
outline: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
.fuzzynav input.search::placeholder {
|
|
||||||
color: rgb(214, 214, 214);
|
|
||||||
font-style: italic;
|
|
||||||
}
|
|
||||||
|
|
||||||
.block,
|
|
||||||
.fuzzynav div.results {
|
|
||||||
margin: 1rem;
|
|
||||||
padding: 1rem;
|
|
||||||
box-shadow: 0 4px 8px 0 rgba(0,0,0,0.2);
|
|
||||||
background-color: rgba(0,0,0,0.5);
|
|
||||||
}
|
|
||||||
span.clear {
|
|
||||||
clear: both;
|
|
||||||
display: block;
|
|
||||||
}
|
|
||||||
|
|
||||||
.nav-list a,
|
|
||||||
.fuzzynav div.results .hyperlink {
|
|
||||||
color: #009dff;
|
|
||||||
background-color: #539c65;
|
|
||||||
display: block;
|
|
||||||
padding: 0.5rem;
|
|
||||||
width: 100%;
|
|
||||||
margin: 0.5rem auto;
|
|
||||||
font-size: 1.2rem;
|
|
||||||
transition: 300ms cubic-bezier(0.075, 0.82, 0.165, 1);
|
|
||||||
text-decoration: none;
|
|
||||||
background: linear-gradient(to bottom right, #64a95a, #388c73) no-repeat
|
|
||||||
center center fixed;
|
|
||||||
}
|
|
||||||
|
|
||||||
.nav-list a:hover,
|
|
||||||
.fuzzynav div.results .hyperlink:hover {
|
|
||||||
text-decoration: none;
|
|
||||||
transform: scale(1.01);
|
|
||||||
}
|
|
||||||
|
|
||||||
.fuzzynav div.results .hyperlink:focus {
|
|
||||||
box-shadow: 0 0 1px 1px rgb(255, 255, 255);
|
|
||||||
}
|
|
||||||
|
|
||||||
.nav-list a,
|
|
||||||
.fuzzynav div.results .hyperlink .name {
|
|
||||||
color: #ffffff;
|
|
||||||
}
|
|
||||||
|
|
||||||
.fuzzynav div.results .hyperlink .link {
|
|
||||||
color: #0000FE;
|
|
||||||
text-align: right;
|
|
||||||
font-size: 1rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.fuzzynav div.results .hyperlink .highlight {
|
|
||||||
text-decoration: underline;
|
|
||||||
}
|
|
||||||
|
|
||||||
footer {
|
|
||||||
color: #fff;
|
|
||||||
float: right;
|
|
||||||
margin: 0.5rem;
|
|
||||||
}
|
|
||||||
|
|
||||||
.m-icon {
|
|
||||||
width: 256px;
|
|
||||||
height: 256px;
|
|
||||||
position: fixed;
|
|
||||||
bottom: 0;
|
|
||||||
left: 0;
|
|
||||||
z-index: -1;
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user