Skip to content

Commit

Permalink
updated
Browse files Browse the repository at this point in the history
  • Loading branch information
BaderSarah committed Jun 18, 2024
1 parent 07da907 commit 991a194
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 127 deletions.
107 changes: 0 additions & 107 deletions courses.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,113 +29,6 @@ <h2>Here you can add a new course.</h2>
<button id="add">Add</button>
</div>
<div class="course" id="courseId">
<!--
<div id="courseOdd">
<h2>course one - example - title</h2>
<h3 class="toDO">ToDo's :</h3>
<span class="toDos">
<ul>
<li>summary - time estimation</li>
<li>exercises - time estimation</li>
<li>And a third list item - time estimation</li>
<li>And a fourth list item - time estimation</li>
<li>And a fifth list item - time estimation</li>
</ul>
</span>
<p id="timeIndicator">Total remaining time on toDos:</p>
<h3 class="addToDoTitle">Add ToDo :</h3>
<span class="addToDo">
<span class="title">
<label> Title: </label>
<input type="text" id="inputTitle" placeholder="title" />
</span>
<span class="time">
<label> Time estimation: </label>
<input type="time" id="inputTime" />
</span>
<span class="urgency">
<label> Urgency: </label><br />
<input
type="radio"
name="option"
id="urgencyH"
value="high"
class="radioB"
/>
<label>high</label>
<input
type="radio"
name="option"
id="urgencyM"
value="medium"
class="radioB"
/>
<label>medium</label>
<input
type="radio"
name="option"
id="urgencyL"
value="low"
class="radioB"
/>
<label>low</label>
</span>
</span>
<button id="addToDo">Add ToDO</button>
</div>
<div id="courseEven">
<h2>course two - example - title</h2>
<h3 class="toDO">ToDo's :</h3>
<span class="toDos">
<ul>
<li>summary - time estimation</li>
<li>exercises - time estimation</li>
<li>And a third list item - time estimation</li>
<li>And a fourth list item - time estimation</li>
<li>And a fifth list item - time estimation</li>
</ul>
</span>
<p id="timeIndicator">Total remaining time on toDos:</p>
<h3 class="addToDoTitle">Add ToDo :</h3>
<span class="addToDo">
<span class="title">
<label> Title: </label>
<input type="text" id="inputTitle" placeholder="title" />
</span>
<span class="time">
<label> Time estimation: </label>
<input type="time" id="inputTime" />
</span>
<span class="urgency">
<label> Urgency: </label><br />
<input
type="radio"
name="option"
id="urgencyH"
value="high"
class="radioB"
/>
<label>high</label>
<input
type="radio"
name="option"
id="urgencyM"
value="medium"
class="radioB"
/>
<label>medium</label>
<input
type="radio"
name="option"
id="urgencyL"
value="low"
class="radioB"
/>
<label>low</label>
</span>
</span>
<button id="addToDo">Add ToDO</button>
</div> -->
</div>
</main>
<footer class="footer">
Expand Down
6 changes: 5 additions & 1 deletion css/stylesheetSchedule.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
--lightblue: #6292fd;
--pink: #e37383;
--green: rgb(158, 255, 158);
--yellow: rgb(255, 245, 158);
}

@font-face {
Expand Down Expand Up @@ -66,5 +67,8 @@ button {
}

#courseItem:nth-child(odd){

padding: 10px;
background-color: var(--yellow);
border-radius: 10px;
border: none;
}
9 changes: 9 additions & 0 deletions schedule.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,21 @@ <h1>Schedule</h1>
<tr>
<td>5:00</td>
<td rowspan="2" id="courseItem">Math (title)<br />summarizing</td>
<td rowspan="1" id="courseItem">Math (title)<br />summarizing</td>
<td rowspan="1" id="courseItem">Math (title)<br />summarizing</td>
<td rowspan="3" id="courseItem">Math (title)<br />summarizing</td>
</tr>
<tr>
<td>6:00</td>
</tr>
<tr>
<td>7:00</td>
<td></td>
<td></td>
<td rowspan="1" id="courseItem">Math (title)<br />summarizing</td>
<td rowspan="2 " id="courseItem">Math (title)<br />summarizing</td>
<td></td>
<td rowspan="3" id="courseItem">Math (title)<br />summarizing</td>
</tr>
<tr>
<td>8:00</td>
Expand Down
33 changes: 32 additions & 1 deletion src/Course.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,45 @@ export default class Course {
return this.#name;
}

static ToDo = class {
#title;
#time;
#urgency;

constructor(title, time, urgency){
this.#title = title;
this.#time = time;
this.#urgency = urgency;
}

get title(){
return this.#title;
}

get time(){
return this.#time;
}

get urgency(){
return this.#urgency;
}
}

addToDo(title, time, urgency) {
if (this.checkMaxToDos()) this.#toDos.push(new ToDo(title, time, urgency));
else throw new error("Max toDos reached!");
}

/*
addToDo(title, time, urgency) {
if (this.checkMaxToDos()) this.#toDos.push([title, time, urgency]);
else throw new error("Max toDos reached!");
}
*/

get toDOs() {
return this.#toDos;
}
}

checkMaxToDos() {
if (this.#toDos.length() <= 5) {
Expand Down
38 changes: 23 additions & 15 deletions src/CoursesComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@ export default class CoursesComponent {
lblTitleEl.innerText = "Title: ";
const inputTitleEl = document.createElement("input");
inputTitleEl.type = "text";
inputTitleEl.id = `inputTitle_${course.name}`;
// inputTitleEl.id = `inputTitle_${course.name}`;
inputTitleEl.id = `inputTitle`;
inputTitleEl.placeholder = "title";

spanTitleEl.appendChild(lblTitleEl);
Expand All @@ -127,7 +128,8 @@ export default class CoursesComponent {
lblTimeEl.innerText = "Time estimation: ";
const inputTimeEl = document.createElement("input");
inputTimeEl.type = "time";
inputTimeEl.id = `inputTime_${course.name}`;
// inputTimeEl.id = `inputTime_${course.name}`;
inputTimeEl.id = `inputTime`;

spanTimeEl.appendChild(lblTimeEl);
spanTimeEl.appendChild(inputTimeEl);
Expand All @@ -141,26 +143,28 @@ export default class CoursesComponent {

const inputUrgElOne = document.createElement("input");
inputUrgElOne.type = "radio";
inputUrgElOne.name = `option_${course.name}`;
inputUrgElOne.id = `urgencyH_${course.name}`;
inputUrgElOne.name = `option`;
inputUrgElOne.id = `urgencyH`;
inputUrgElOne.value = "high";
inputUrgElOne.className = "radioB";
const inputUrgElOneLbl = document.createElement("label");
inputUrgElOneLbl.innerText = "high";

const inputUrgElTwo = document.createElement("input");
inputUrgElTwo.type = "radio";
inputUrgElTwo.name = `option_${course.name}`;
inputUrgElTwo.id = `urgencyM_${course.name}`;
inputUrgElTwo.name = `option`;
inputUrgElTwo.id = `urgencyM`;
inputUrgElTwo.value = "medium";
inputUrgElTwo.className = "radioB";
const inputUrgElTwoLbl = document.createElement("label");
inputUrgElTwoLbl.innerText = "medium";

const inputUrgElThree = document.createElement("input");
inputUrgElThree.type = "radio";
inputUrgElThree.name = `option_${course.name}`;
inputUrgElThree.id = `urgencyL_${course.name}`;
// inputUrgElThree.name = `option_${course.name}`;
// inputUrgElThree.id = `urgencyL_${course.name}`;
inputUrgElThree.name = `option`;
inputUrgElThree.id = `urgencyL`;
inputUrgElThree.value = "low";
inputUrgElThree.className = "radioB";
const inputUrgElThreeLbl = document.createElement("label");
Expand All @@ -181,15 +185,19 @@ export default class CoursesComponent {

const btnElement = document.createElement("button");
btnElement.innerText = "Add ToDO";
btnElement.id = `addToDo_${course.name}`;
btnElement.id = "addToDo";
// btnElement.id = `addToDo_${course.name}`;

btnElement.onclick = () => {
const title = document.getElementById(`inputTitle_${course.name}`).value.trim();
const time = document.getElementById(`inputTime_${course.name}`).value;
const urgency = document.querySelector(`input[name="option_${course.name}"]:checked`).value;

if (title && time && urgency) {
this.#coursesRepository.addToDo(course.name, [title, time, urgency]);
// const title = document.getElementById(`inputTitle_${course.name}`).value; // .trim()
// const time = document.getElementById(`inputTime_${course.name}`).value;
// const urgency = document.querySelector(`input[name="option_${course.name}"]:checked`).value;
// const title = document.getElementById(`inputTitle`).value;
// const time = document.getElementById(`inputTime`).value;
// const urgency = document.querySelector(`input[name="option_${course.name}"]:checked`).value;

if (true) { // title && time && urgency
this.#coursesRepository.addToDoToCourse(course.name, "hallo", 2 , "medium"); // course.name, [title, time, urgency]
this.#setCoursesInStorage();
this.#toHtml();
}
Expand Down
9 changes: 6 additions & 3 deletions src/CoursesRepository.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export default class CoursesRepository {
}

giveCourse(name) {
console.log(this.#courses.find((c) => c.name === name));
return this.#courses.find((c) => c.name === name);
}

Expand All @@ -28,8 +29,10 @@ export default class CoursesRepository {
}

addToDoToCourse(name, title, time, urgency) {
const course = this.giveCourse(name);
course.addToDo(title, time, urgency);
let course = this.giveCourse(name);
course = () => {
addToDo(title, time, urgency);
};
}

// non
Expand All @@ -38,7 +41,7 @@ export default class CoursesRepository {
}

giveCoursesJSON() {
const coursesJSON = this.#courses.map((c) => c.toJSON());
const coursesJSON = this.#courses.map((c) => c.toJSON()); // ()
return coursesJSON;
}
}

0 comments on commit 991a194

Please sign in to comment.