forked from 92bondstreet/dress-up-virtuo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
38 lines (32 loc) · 1.12 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/* global VIRTUO*/
'use strict';
(() => {
const render = (actors) => {
const fragment = document.createDocumentFragment();
const div = document.createElement('div');
const template = actors.map(actor => {
return `
<div class="actor">
<span>${actor.who}</span>
<span>${actor.type}</span>
<span>${actor.amount}</span>
</div>
`;
}).join('');
div.innerHTML = template;
fragment.appendChild(div);
document.querySelector('#actors').innerHTML = '';
document.querySelector('#actors').appendChild(fragment);
};
const button = document.querySelector('#compute');
button.addEventListener('click', function onClick () {
const car = VIRTUO.getCar();
const begin = document.querySelector('#rental .js-begin').value;
const end = document.querySelector('#rental .js-end').value;
const distance = document.querySelector('#rental .js-distance').value;
const option = document.querySelector('#rental .js-option').checked;
const actors = VIRTUO.payActors(car, begin, end, distance, option);
render(actors);
return;
});
})();