Skip to content

Commit

Permalink
Merge pull request #3 from wilicw/master
Browse files Browse the repository at this point in the history
Courses' credits calculator
  • Loading branch information
Vincent550102 authored Jul 12, 2022
2 parents db5fdcd + dbf9053 commit 0249447
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,11 @@
<body>
<nav class="navbar navbar-expand-lg bg-light sticky-top" tabindex="-1">
<div class="container-fluid">
<a class="navbar-brand" href="#" style="font-size: 2rem;">NCKU 選課模擬器</a>
<a class="navbar-brand" href="#" style="font-size: 1.5rem;">NCKU 選課模擬器
<span style="font-size: .7rem;" class="badge bg-secondary">
學分:<b id="credits">0</b>
</span>
</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse"
data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false"
aria-label="Toggle navigation">
Expand Down
16 changes: 15 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,20 @@ function addBtnModal(classId, classEle) {
})
}

function renderCredits() {
$.getJSON("111data.json", function (json) {
let currentCredits = 0
if (Cookies.get('classSess') === undefined)
return
var classSess = JSON.parse(atob(Cookies.get('classSess')))
classSess.forEach(element => {
console.log(element);
currentCredits += parseInt(json[element].credit)
})
$("#credits").text(currentCredits);
});
}

function renderClassbtn(classId, classEle, styleBagIndex) {
var btnstyle = pickbtnstyle(styleBagIndex)
classEle["time"].forEach(element => {
Expand Down Expand Up @@ -256,6 +270,7 @@ function copyToClipboard(copy_text) {


function updExportmess() {
renderCredits();
$("#urlButton_code").html(`<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-clipboard" viewBox="0 0 16 16">
<path d="M4 1.5H3a2 2 0 0 0-2 2V14a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V3.5a2 2 0 0 0-2-2h-1v1h1a1 1 0 0 1 1 1V14a1 1 0 0 1-1 1H3a1 1 0 0 1-1-1V3.5a1 1 0 0 1 1-1h1v-1z"/>
<path d="M9.5 1a.5.5 0 0 1 .5.5v1a.5.5 0 0 1-.5.5h-3a.5.5 0 0 1-.5-.5v-1a.5.5 0 0 1 .5-.5h3zm-3-1A1.5 1.5 0 0 0 5 1.5v1A1.5 1.5 0 0 0 6.5 4h3A1.5 1.5 0 0 0 11 2.5v-1A1.5 1.5 0 0 0 9.5 0h-3z"/>
Expand All @@ -279,7 +294,6 @@ function updExportmess() {
$("#export_input_url").attr("value", `${window.location.href.split('?')[0]}?share=${encodeURIComponent(Cookies.get('classSess'))}`)
$("#urlButton_url").attr("urlAttr", `${window.location.href.split('?')[0]}?share=${encodeURIComponent(Cookies.get('classSess'))}`)
}

}

function putExportCopyBtn() {
Expand Down

0 comments on commit 0249447

Please sign in to comment.