Hong-Phuc Bui
2025-01-16 2889de7f0c2d587a17fbd322af57c29e84238620
update parcel
25 files modified
2 files added
7 files deleted
10233 ■■■■ changed files
calendar/src/lib/calendar-v2.js 4 ●●●● patch | view | raw | blame | history
calendar/src/lib/calendar-view.js 37 ●●●●● patch | view | raw | blame | history
calendar/test-max.js 8 ●●●●● patch | view | raw | blame | history
calendar/test/lib/calendar-view-unittest.js 18 ●●●●● patch | view | raw | blame | history
css-demo/hsl.js 10 ●●●● patch | view | raw | blame | history
plot-experiment/package-lock.json 3611 ●●●●● patch | view | raw | blame | history
plot-experiment/package.json 4 ●●●● patch | view | raw | blame | history
plot-experiment/src/barnsley-fern.js 6 ●●●● patch | view | raw | blame | history
plot-experiment/src/study.js 18 ●●●●● patch | view | raw | blame | history
plot-experiment/src/timeout.js 11 ●●●●● patch | view | raw | blame | history
plot-experiment/test/lib/README.md 1 ●●●● patch | view | raw | blame | history
plot-experiment/test/study-test.js 23 ●●●●● patch | view | raw | blame | history
stundenplan/package-lock.json 6189 ●●●● patch | view | raw | blame | history
stundenplan/package.json 10 ●●●● patch | view | raw | blame | history
stundenplan/src/json-semester-effort.html 2 ●●● patch | view | raw | blame | history
stundenplan/src/lecture-example-usage.html 2 ●●● patch | view | raw | blame | history
stundenplan/src/lib/Graph-demo.js 2 ●●● patch | view | raw | blame | history
stundenplan/src/muster-semester.html 2 ●●● patch | view | raw | blame | history
stundenplan/src/muster-semester.js 10 ●●●● patch | view | raw | blame | history
stundenplan/src/semester-effort.html 2 ●●● patch | view | raw | blame | history
stundenplan/src/semester-effort.js 12 ●●●● patch | view | raw | blame | history
stundenplan/src/study.js 20 ●●●● patch | view | raw | blame | history
stundenplan/test/lib/Lecture-es5-test.js 10 ●●●● patch | view | raw | blame | history
stundenplan/test/lib/Lecture-test.js 14 ●●●● patch | view | raw | blame | history
stundenplan/test/lib/color-graph-demo.js 16 ●●●● patch | view | raw | blame | history
stundenplan/test/lib/muster-effort-test.js 6 ●●●● patch | view | raw | blame | history
stundenplan/test/study-test.js 8 ●●●● patch | view | raw | blame | history
textbased-programms/gravitation.html 18 ●●●●● patch | view | raw | blame | history
textbased-programms/gravitation.js 23 ●●●●● patch | view | raw | blame | history
textbased-programms/monitor.js 12 ●●●● patch | view | raw | blame | history
textbased-programms/newton-method-sqrt.js 10 ●●●● patch | view | raw | blame | history
textbased-programms/probeklausur-2.html 18 ●●●●● patch | view | raw | blame | history
textbased-programms/probeklausur-2.js 86 ●●●●● patch | view | raw | blame | history
textbased-programms/taylor-serie-exp.js 10 ●●●● patch | view | raw | blame | history
calendar/src/lib/calendar-v2.js
@@ -59,8 +59,8 @@
        }
        // calculate how many days of last month get place in the first week
        // of this month
        let dayOfFirstDate = weekDayOfDate(1, month, year);
        let diff = (7 + (dayOfFirstDate - Calendar._firstDayOfWeek)) % 7;
        const dayOfFirstDate = weekDayOfDate(1, month, year);
        const diff = (DAYS_IN_WEEK + (dayOfFirstDate - Calendar._firstDayOfWeek)) % DAYS_IN_WEEK;
        let countSpace = diff;
        let firstWeek = [];
        while(countSpace-- > 0) {
calendar/src/lib/calendar-view.js
@@ -65,3 +65,40 @@
    htmlSegment += "</table>";
    return htmlSegment;
}
export function verticalCalendar(calendar, location){
    const days = [
        [],
        [],
        [],
        [],
        [],
        [],
        []
    ];
    /*
    0 -> 1
    1 -> 2
    2 -> 3
    3 -> 4
    4 -> 5
    5 -> 6
    6 -> 0
    * */
    for(const [idx,day] of days.entries() ) {
        const idxOfWeekdays = (idx + location.firstDayOfWeek) % 7;
        const dayName = location.weekDays[idxOfWeekdays];
        day.push(`<td>${dayName}</td>`);
    }
    for(const week of calendar.weeks) {
        for(const [idx, day] of week.entries() ) {
            days[idx].push(`<td>${day}</td>`);
        }
    }
    let cal = "<table>\n";
    for(const day of days) {
        cal += "<tr>" + day.join("") + "</tr>\n"
    }
    cal += "</table>";
    return cal;
}
calendar/test-max.js
File was deleted
calendar/test/lib/calendar-view-unittest.js
@@ -1,5 +1,5 @@
import test from "ava";
import {asciiCalendar, domCalendar} from "../../src/lib/calendar-view.js";
import {asciiCalendar, domCalendar, verticalCalendar} from "../../src/lib/calendar-view.js";
const cal = {
   month: 1,
@@ -51,3 +51,19 @@
</table>`;
   t.is(html, result);
});
test("verticalCalendar", t =>{
   const vertical = verticalCalendar(cal, somewhere);
   const result = `    Januar 2021
Mo Di Mi Do Fr Sa So
            01 02 03
04 05 06 07 08 09 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 26 28 29 30 31 \n`
   //t.is(ascii, result);
   console.log(vertical);
});
css-demo/hsl.js
@@ -1,16 +1,16 @@
function adaptColor() {
    let hue = this.value;
    let color = `hsl(${hue}, 100%, 45%)`;
    let colorElement = document.getElementById("color");
    const hue = this.value;
    const color = `hsl(${hue}, 100%, 45%)`;
    const colorElement = document.getElementById("color");
    colorElement.style.backgroundColor = color;
    let colorCode = document.getElementById("colorCode");
    const colorCode = document.getElementById("colorCode");
    colorCode.innerText = color;
}
document.addEventListener('DOMContentLoaded', () => {
    let colorRegister = document.getElementById("hue");
    const colorRegister = document.getElementById("hue");
    adaptColor.apply(colorRegister);
    document.getElementById("hue").addEventListener("input", adaptColor);
});
plot-experiment/package-lock.json
Diff too large
plot-experiment/package.json
@@ -16,11 +16,11 @@
  "license": "MIT",
  "devDependencies": {
    "jest": "29.7.0",
    "parcel": "2.10.3",
    "parcel": "2.13.3",
    "process": "0.11.10"
  },
  "dependencies": {
    "jsxgraph": "1.10.0",
    "jsxgraph": "1.10.1",
    "onecolor": "4.1.0",
    "qunit": "^2.12.0"
  }
plot-experiment/src/barnsley-fern.js
@@ -58,15 +58,15 @@
 * generates points of Barnsley Fern.
 * */
function barnsley(n) {
    let m = [
    const m = [
        [ 0    ,  0    , 0     , 0.16 , 0.500   , 0    , 0.01],
        [ 0.85 ,  0.04 , -0.04 , 0.85 , 0.075   , 1.60 , 0.85],
        [ 0.20 , -0.26 , 0.23  , 0.22 , 0.400   , 1.60 , 0.07],
        [-0.15 ,  0.28 , 0.26  , 0.24 , 0.575   , 0.44 , 0.07]
    ];
    let p = [ m[0][6], m[0][6] + m[1][6], m[0][6] + m[1][6] + m[2][6] ];
    const p = [ m[0][6], m[0][6] + m[1][6], m[0][6] + m[1][6] + m[2][6] ];
    let x = 0, y = 0;
    let points = [ [x, y] ];
    const points = [ [x, y] ];
    for(let i = 0; i < n; ++i) {
        let r = Math.random();
        let f = 0;
plot-experiment/src/study.js
File was deleted
plot-experiment/src/timeout.js
File was deleted
plot-experiment/test/lib/README.md
File was deleted
plot-experiment/test/study-test.js
File was deleted
stundenplan/package-lock.json
Diff too large
stundenplan/package.json
@@ -16,12 +16,12 @@
  "author": "Hong-Phuc Bui",
  "license": "MIT",
  "devDependencies": {
    "esdoc": "^1.1.0",
    "esdoc-standard-plugin": "^1.0.0",
    "jest": "^29.7.0",
    "parcel": "^2.0.0-rc.0"
    "esdoc": "1.1.0",
    "esdoc-standard-plugin": "1.0.0",
    "jest": "29.7.0",
    "parcel": "2.13.3"
  },
  "dependencies": {
    "qunit": "^2.12.0"
    "qunit": "2.12.0"
  }
}
stundenplan/src/json-semester-effort.html
@@ -26,6 +26,6 @@
    <pre id="text-output"></pre>
</div>
<script src="json-semester-effort.js"></script>
<script src="json-semester-effort.js" type="module"></script>
</body>
</html>
stundenplan/src/lecture-example-usage.html
@@ -17,6 +17,6 @@
<div class="row">
    <pre id="text-output"></pre>
</div>
<script src="lecture-example-usage.js"></script>
<script src="lecture-example-usage.js" type="module"></script>
</body>
</html>
stundenplan/src/lib/Graph-demo.js
@@ -11,7 +11,7 @@
    }
    /**
     * (vertex:integer) => undefined
     * (vertex:integer) => this
     * @param vertex {Number} a vertex
     * @return this graph
     * */
stundenplan/src/muster-semester.html
@@ -31,6 +31,6 @@
    <pre id="text-output"></pre>
</div>
<script src="muster-semester.js"></script>
<script src="muster-semester.js" type="module"></script>
</body>
</html>
stundenplan/src/muster-semester.js
@@ -2,17 +2,17 @@
import {calculateSemesterEffort, makeEffortTable, parseCSV} from "./lib/muster-effort";
const OUTPUT_ELEMENT_ID = "text-output";
let terminal = new DomOutput(OUTPUT_ELEMENT_ID);
const terminal = new DomOutput(OUTPUT_ELEMENT_ID);
document.addEventListener("DOMContentLoaded",() =>{
    document.getElementById("run").addEventListener("click", main);
});
function main() {
    let input =  document.getElementById("argv").value;
    let lectures = parseCSV(input);
    let lecturesInformation = calculateSemesterEffort(lectures);
    let effortTable = makeEffortTable(lecturesInformation);
    const input =  document.getElementById("argv").value;
    const lectures = parseCSV(input);
    const lecturesInformation = calculateSemesterEffort(lectures);
    const effortTable = makeEffortTable(lecturesInformation);
    printEffortTable(effortTable);
}
stundenplan/src/semester-effort.html
@@ -19,6 +19,6 @@
    <pre id="text-output"></pre>
</div>
<script src="semester-effort.js"></script>
<script src="semester-effort.js" type="module"></script>
</body>
</html>
stundenplan/src/semester-effort.js
@@ -9,13 +9,13 @@
});
function main() {
    let lectures = [
    const lectures = [
        // ergänzen Sie die Vorlesungen hier. Die Struktur des Elementes finden Sie im Skript
    ];
    let lecturesInformation = []
    for(let lecture of lectures ) {
        let homework = calculateHomeworkTime(lecture.ects, lecture.sws/2);
        let newLecture = Object.assign({},lecture);
    const lecturesInformation = []
    for(const lecture of lectures ) {
        const homework = calculateHomeworkTime(lecture.ects, lecture.sws/2);
        const newLecture = Object.assign({},lecture);
        newLecture.homework = homework;
        lecturesInformation.push(newLecture);
    }
@@ -38,7 +38,7 @@
    let table = `<table><tr>
    <th class="name">Vorlesung</th><th class="effort">Aufwand pro Woche in Stunden</th>
</tr>\n`;
    for(let l of lecturesInformation) {
    for(const l of lecturesInformation) {
        table += `<tr><td class="name">${l.name}</td> <td class="effort">${l.homework}</td></tr>\n`
    }
    table += "</table>";
stundenplan/src/study.js
@@ -5,14 +5,28 @@
const CORONA_LECTURE_WEEKS = 13;
const ECTS_COST = 30;     // Wieviel Aufwand in Zeitstunden für einen ECST-Punkt
const DS_LENGTH = 1.5;    // Stunden pro Doppelstunden
const javascript = {
    "name": "Softwareentwicklung mit JavaScript",
    "ects": 5,
    "ds": 3
}
function calculateHomeworkEffort(lecture, lectureWeeks=LECTURE_WEEKS) {
    const timeOfEcts = lecture.ects * ECTS_COST;
    const sumTimePerweek = timeOfEcts / lectureWeeks;
    const lectureTimePerWeek = DS_LENGTH * lecture.ds;
    return sumTimePerweek - lectureTimePerWeek;
}
/**
 * TODO: Document
 * @return Zeitaufwand in Stunden / Woche
 * */
export function calculateHomeworkTime(ects, lecturePerWeek, lectureWeeks=LECTURE_WEEKS) {
    let timeOfEcts = ects * ECTS_COST; //Zeitstunden;
    let sumTimePerWeek = timeOfEcts / lectureWeeks;
    let lectureTimePerWeek = DS_LENGTH * lecturePerWeek;
    const timeOfEcts = ects * ECTS_COST; //Zeitstunden;
    const sumTimePerWeek = timeOfEcts / lectureWeeks;
    const lectureTimePerWeek = DS_LENGTH * lecturePerWeek;
    return sumTimePerWeek - lectureTimePerWeek;
}
stundenplan/test/lib/Lecture-es5-test.js
@@ -4,7 +4,7 @@
test("Lecture: constructor:", t=>{
    const name = "Informatic", ects = 5, sws = 3;
    let informatic = new Lecture(name, ects, sws, );
    const informatic = new Lecture(name, ects, sws, );
    t.is(informatic.name, name);
    t.is(informatic.sws, sws);
    t.is(informatic.ects, ects);
@@ -12,15 +12,15 @@
test("Lecture: get Effort", t =>{
    let computerScience = new Lecture("JavaScript", 5, 4);
    let effort = computerScience.effortPerWeek(15);
    const computerScience = new Lecture("JavaScript", 5, 4);
    const effort = computerScience.effortPerWeek(15);
    t.is(effort, 7);
    let lectures = [
    const lectures = [
        new Lecture("Informatik 1",     5, 4),
        new Lecture("Programmierung 1", 8, 5),
        new Lecture("JavaScript",       5, 4)
    ];
    let effortOfWeek = lectures.reduce( (acc, l) => l.effortPerWeek(15) + acc, 0);
    const effortOfWeek = lectures.reduce( (acc, l) => l.effortPerWeek(15) + acc, 0);
    const expected = 26.25;
    const tolerance = 0.01;
    t.truthy( Math.abs(effortOfWeek - expected) < tolerance );
stundenplan/test/lib/Lecture-test.js
@@ -4,7 +4,7 @@
test("Lecture: constructor:", t=>{
    const name = "Informatic", ects = 5, sws = 3;
    let informatic = new Lecture(name, ects, sws, );
    const informatic = new Lecture(name, ects, sws, );
    t.is(informatic.name, name);
    t.is(informatic.sws, sws);
    t.is(informatic.ects, ects);
@@ -12,15 +12,15 @@
test("Lecture: get Effort", t =>{
    let js = new Lecture("JavaScript", 5, 4);
    let effort = js.effortPerWeek(15);
    const js = new Lecture("JavaScript", 5, 4);
    const effort = js.effortPerWeek(15);
    t.is(effort, 7);
    let lectures = [
    const lectures = [
        new Lecture("Informatik 1",     5, 4),
        new Lecture("Programmierung 1", 8, 5),
        new Lecture("JavaScript",       5, 4)
    ];
    let effortOfWeek = lectures.reduce( (acc, l) => l.effortPerWeek(15) + acc, 0);
    const effortOfWeek = lectures.reduce( (acc, l) => l.effortPerWeek(15) + acc, 0);
    const expected = 26.25;
    const tolerance = 0.01;
    t.truthy( Math.abs(effortOfWeek - expected) < tolerance );
@@ -30,7 +30,7 @@
    const name = "JavaScript",
        ects = 5,
        sws = 4;
    let js = new Lecture(name, ects, sws);
    const js = new Lecture(name, ects, sws);
    t.is(js.name, name);
    t.is(js.ects, ects);
    t.is(js.sws, sws);
@@ -40,7 +40,7 @@
    const name = "JavaScript",
        ects = 5,
        sws = 4;
    let js = new Lecture("name", 1, 3);
    const js = new Lecture("name", 1, 3);
    js.ects = ects;
    js.sws = sws;
stundenplan/test/lib/color-graph-demo.js
@@ -7,11 +7,11 @@
 *
 * */
function greedyColorArray(g, vertexOrder) {
    let color = new Map();
    let usedNeighbourColors = [];
    const color = new Map();
    const usedNeighbourColors = [];
    color.set(vertexOrder[0], 0);
    for (let vertex of vertexOrder.slice(1)) {
        for(let nbr of g.adjacentOf(vertex)) {
    for (const vertex of vertexOrder.slice(1)) {
        for(const nbr of g.adjacentOf(vertex)) {
            const colorOfNbr = color.get(nbr);
            if (colorOfNbr >= 0) {
                usedNeighbourColors[colorOfNbr] = true;
@@ -23,7 +23,7 @@
            count++;
        }
        color.set(vertex, count);
        for(let nbr of g.adjacentOf(vertex)) {
        for(const nbr of g.adjacentOf(vertex)) {
            const colorOfNbr = color.get(nbr);
            if(colorOfNbr >= 0) {
                usedNeighbourColors[colorOfNbr] = false;
@@ -34,15 +34,15 @@
}
test.skip("Color Graph Array: type 1", t => {
    let lect = new Graph();
    const lect = new Graph();
    lect.addEdge(0, 1).addEdge(0, 2).addEdge(0, 3)
        .addEdge(1, 2).addEdge(1, 4)
        .addEdge(2, 5)
        .addEdge(3, 4).addEdge(3, 5)
        .addEdge(4, 5);
    console.log(lect);
    let vertices = [0, 1, 2, 3, 4, 5];
    let color = greedyColorArray(lect, vertices);
    const vertices = [0, 1, 2, 3, 4, 5];
    const color = greedyColorArray(lect, vertices);
    console.log(color);
    vertices = [0, 3, 4, 1, 5, 2];
    color = greedyColorArray(lect, vertices);
stundenplan/test/lib/muster-effort-test.js
@@ -3,12 +3,12 @@
test("makeEffortTable:", t=>{
    let testData = [
    const testData = [
        {name:"A", code:"DFBI-311", sws:4, ects: 4, homework:1},
        {name:"B", code:"DFBI-312", sws:3, ects: 4, homework:2}
    ];
    let html = makeEffortTable(testData);
    let expected = `<table>
    const html = makeEffortTable(testData);
    const expected = `<table>
    <tr><th class="name">Vorlesung</th><th class="effort">Aufwand pro Woche in Stunden</th></tr>
<tr><td class="name">A</td> <td class="effort">1</td></tr>
<tr><td class="name">B</td> <td class="effort">2</td></tr>
stundenplan/test/study-test.js
@@ -6,8 +6,8 @@
    const ECTS = 5;
    const EXPECTED = 7;
    const epsilon = 0.00001;
    let homeworkTime = Study.calculateHomeworkTime(ECTS, SWS);
    let diff = Math.abs((EXPECTED-homeworkTime)/EXPECTED );
    const homeworkTime = Study.calculateHomeworkTime(ECTS, SWS);
    const diff = Math.abs((EXPECTED-homeworkTime)/EXPECTED );
    t.truthy(diff < epsilon );
});
@@ -17,7 +17,7 @@
    const EXPECTED = 8.54;
    const lectureWeeks = 13;
    const epsilon = 0.1;
    let homeworkTime = Study.calculateHomeworkTime(ECTS, SWS, lectureWeeks);
    let diff = Math.abs((EXPECTED-homeworkTime)/EXPECTED );
    const homeworkTime = Study.calculateHomeworkTime(ECTS, SWS, lectureWeeks);
    const diff = Math.abs((EXPECTED-homeworkTime)/EXPECTED );
    t.truthy(diff < epsilon );
});
textbased-programms/gravitation.html
New file
@@ -0,0 +1,18 @@
<!DOCTYPE html>
<html lang="de">
<head>
    <meta charset="UTF-8">
    <title>Gravitation</title>
    <link rel="stylesheet" href="dom-output.css" />
    <link rel="stylesheet" href="dfhi.css" />
</head>
<body>
<button name="run" id="run" >Rerun</button>
<input type="text" id="argv" name="argv" />
<pre id="text-output"></pre>
<script type="module" src="gravitation.js"></script>
</body>
</html>
textbased-programms/gravitation.js
New file
@@ -0,0 +1,23 @@
// Übungblatt 1
/*
*
* */
/**
 * helloworld-html.js
 *
 */
import {terminal} from "./dfhi.js";
const G = 6.67430;
window.main = function(...argv) {
    /*const mass1 = parseFloat(argv[0]);
    const mass2 = parseFloat(argv[1]);
    const r = parseFloat(argv[2]);
    let force = G * mass1 * mass2 / (r*r);
    */
    //(a < b+ c) && (b < a + c) && (c < b + a);
    terminal.printh(force);
};
textbased-programms/monitor.js
@@ -7,13 +7,13 @@
window.main = function(...argv) {
    // b:h als ratio, Bruch (numerator/denominator)
    let numerator = Number.parseFloat(argv[0]);
    let denominator = Number.parseFloat(argv[1]);
    const numerator = Number.parseFloat(argv[0]);
    const denominator = Number.parseFloat(argv[1]);
    // d als Länge
    let r = numerator / denominator;
    let d = Number.parseFloat(argv[2]);
    let b = (d*r)/Math.sqrt(r*r + 1);
    let h = d/Math.sqrt(r*r + 1);
    const r = numerator / denominator;
    const d = Number.parseFloat(argv[2]);
    const b = (d*r)/Math.sqrt(r*r + 1);
    const h = d/Math.sqrt(r*r + 1);
    terminal.printl("Breite: ", b);
    terminal.printl("Höhe: ", h);
};
textbased-programms/newton-method-sqrt.js
@@ -6,11 +6,11 @@
import {terminal} from "./dfhi.js";
window.main = function(...argv) {
    let testData = [0, 1.25, 3.758, 4.229, 6.735, 123456.789, (1<<30) + 1];
    for(let c of testData) {
        let cquad = c*c;
        let csqrt = sqrt(cquad);
        let msqrt = Math.sqrt(cquad);
    const testData = [0, 1.25, 3.758, 4.229, 6.735, 123456.789, (1<<30) + 1];
    for(const c of testData) {
        const cquad = c*c;
        const csqrt = sqrt(cquad);
        const msqrt = Math.sqrt(cquad);
        terminal.printl({"quadrat": cquad, "sqrt":csqrt, "Math.sqrt":msqrt, "expected": c})
    }
};
textbased-programms/probeklausur-2.html
File was deleted
textbased-programms/probeklausur-2.js
File was deleted
textbased-programms/taylor-serie-exp.js
@@ -6,11 +6,11 @@
import {terminal} from "./dfhi.js";
window.main = function(...argv) {
    let x = Number.parseFloat(argv[0]);
    let variant1 = exp1(x);
    let variant2 = exp2(x);
    let variant3 = exp3(x);
    let variant4 = exp4(x);
    const x = Number.parseFloat(argv[0]);
    const variant1 = exp1(x);
    const variant2 = exp2(x);
    const variant3 = exp3(x);
    const variant4 = exp4(x);
    let expected = Math.exp(x);
    terminal.printl(
        `variant 1: ${variant1}