diff --git a/emne2/Vinlotterix/model.js b/emne2/Vinlotterix/model.js index f3f3d11..b953182 100644 --- a/emne2/Vinlotterix/model.js +++ b/emne2/Vinlotterix/model.js @@ -11,12 +11,15 @@ const model = { }, // Felles data employees: [ - { id: 1, name: "Per" }, - { id: 2, name: "Pål" }, - { id: 3, name: "Espen" }, - { id: 4, name: "Anita" }, - { id: 5, name: "Kari" }, - { id: 6, name: "Gry" } + { id: 0, name: "Per" }, + { id: 1, name: "Pål" }, + { id: 2, name: "Espen" }, + { id: 3, name: "Anita" }, + { id: 4, name: "Kari" }, + { id: 5, name: "Gry" }, + { id: 6, name: "Ole" }, + { id: 7, name: "Hans" }, + { id: 8, name: "Anna" }, + { id: 9, name: "Anne" }, ], - } \ No newline at end of file diff --git a/emne2/Vinlotterix/view.js b/emne2/Vinlotterix/view.js index 40d693d..7e27615 100644 --- a/emne2/Vinlotterix/view.js +++ b/emne2/Vinlotterix/view.js @@ -1,17 +1,18 @@ function createMenu(){ return /*html*/ ` - + - +
+
`; } function updateViewHome(){ document.getElementById('app').innerHTML = /*HTML*/ ` -

Hello World!

+

Velkommen til Vinlotterix

${createMenu()} `; } @@ -35,13 +36,13 @@ function updateViewRules(){ } -function updateViewList(){ +function editList(){ let html = ''; const employees = model.employees; for (let i = 0; i < employees.length; i++){ const person = employees[i]; html += /*html*/ ` -
  • ${person.name}
  • +
  • ${person.id}${person.name}
  • `; } app.innerHTML = html + 'This is the list ' @@ -50,15 +51,34 @@ function updateViewList(){ function showWinnersView(){ let winners = []; let num = model.input.rules.numWinners; - + app.innerHTML = /*html*/ `

    Vinlotterix


    ${createMenu()} +

    Vinnere:

    + `; for (i = 0; i < num; i++){ index = Math.floor(Math.random() * (model.employees.length)); - console.log(index) - winners.push(model.employees[index]) + winners.push(model.employees[index]); } for (i = 0; i < winners.length; i++){ app.innerHTML += /*html*/ `

    ${winners[i].name}

    - `; console.log(winners[i].name)} + `;} +} + +function goToEditPage(id){ + const person = model.employees[id]; + let newPerson = ''; + app.innerHTML = /*html*/ ` + +

    Endre eller slett


    ${createMenu()} + + Navn:
    + `; + +} + +function changeList(id,name){ + console.log(id,name) + model.employees[id].name = name; + console.log(model.employees[id].name) } \ No newline at end of file