Skip to content

Commit

Permalink
fixed 3 code smells in frontend/todo.js
Browse files Browse the repository at this point in the history
  • Loading branch information
Pikay93 committed Feb 7, 2024
1 parent ee4c6e4 commit 637d6ca
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 9 deletions.
4 changes: 1 addition & 3 deletions Bericht.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
## Teilnehmer
Prathees Kumaravel -Matrikel Nr. 30248993

## GitHub und SonarQube Repo

## [GitHub](https://github.com/Pikay93/todo)
## SonarQube Repo

## [SonarQube](https://hopper.fh-swf.de/sonarqube/project/information?id=todo_pk_SQ)

Expand Down
4 changes: 1 addition & 3 deletions README_Aufgabe2.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
## Teilnehmer
Prathees Kumaravel -Matrikel Nr. 30248993

## GitHub und SonarQube Repo

## [GitHub](https://github.com/Pikay93/todo)
## SonarQube Repo

## [SonarQube](https://hopper.fh-swf.de/sonarqube/project/information?id=todo_pk_SQ)

Expand Down
6 changes: 3 additions & 3 deletions frontend/todo.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ function createTodoElement(todo) {
<div class="title">${todo.title}</div>
<div class="due">${due.toLocaleDateString()}</div>
<div class="actions">
<button class="status" onclick="changeStatus(${todo._id})">${status[todo.status || 0]}</button>
<button class="status" onclick="changeStatus(${todo._id})">${[todo.status || 0]}</button>
<button class="edit" onclick="editTodo(${todo._id})">Bearbeiten</button>
<button class="delete" onclick="deleteTodo(${todo._id})">Löschen</button>
</div>
Expand Down Expand Up @@ -149,7 +149,7 @@ function changeStatus(id) {
let todo = todos.find(t => t._id === id);
console.log("Changing status of todo: %o", todo);
if (todo) {
todo.status = (todo.status + 1) % status.length;
todo.status = (todo.status + 1) % length;
fetch(API + "/" + id, {
method: "PUT",
headers: {
Expand Down Expand Up @@ -209,7 +209,7 @@ function checkLogin(response) {

// redirect to login URL with proper parameters
window.location = LOGIN_URL + "?" + params.toString()
throw ("Need to log in")
throw new Error ("Need to log in");
}
else return response
}

0 comments on commit 637d6ca

Please sign in to comment.