|
12 | 12 | this.mainContainer = null; |
13 | 13 |
|
14 | 14 | const root = document.getElementById('root'); |
15 | | - this.header = this.createAndAppend('header', root, { class: 'header' }); |
16 | | - this.createAndAppend('p', this.header, { text: account.name }); |
17 | | - this.mainContainer = this.createAndAppend('main', root, { |
| 15 | + this.header = View.createAndAppend('header', root, { class: 'header' }); |
| 16 | + View.createAndAppend('p', this.header, { text: account.name }); |
| 17 | + this.mainContainer = View.createAndAppend('main', root, { |
18 | 18 | id: 'main-container', |
19 | 19 | }); |
20 | 20 |
|
21 | 21 | this.model.fetchData(); |
22 | 22 | } |
23 | 23 |
|
24 | 24 | /** |
25 | | - * Receives data from the Subject to which this Observer is registered |
| 25 | + * Receives data from the Observable to which this Observer is registered |
26 | 26 | * and renders the data. |
27 | 27 | * @param {Object} state On object containing the Model state |
28 | 28 | */ |
|
46 | 46 | * @param {Object[]} repos An array of repository objects. |
47 | 47 | */ |
48 | 48 | renderSelect(repos) { |
49 | | - this.select = this.createAndAppend('select', this.header); |
| 49 | + this.select = View.createAndAppend('select', this.header); |
50 | 50 | // TODO: replace this comment and the console.log with your own code |
51 | | - console.log(repos); |
| 51 | + console.log('renderSelect', repos); |
52 | 52 | } |
53 | 53 |
|
54 | 54 | /** |
|
57 | 57 | */ |
58 | 58 | renderRepoDetails(repo) { |
59 | 59 | // TODO: replace this comment and the console.log with your own code |
60 | | - console.log(repo); |
| 60 | + console.log('renderRepoDetails', repo); |
61 | 61 | } |
62 | 62 |
|
63 | 63 | /** |
|
66 | 66 | */ |
67 | 67 | renderContributors(contributors) { |
68 | 68 | // TODO: replace this comment and the console.log with your own code |
69 | | - console.log(contributors); |
| 69 | + console.log('renderContributors', contributors); |
70 | 70 | } |
71 | 71 |
|
72 | 72 | /** |
|
75 | 75 | */ |
76 | 76 | renderError(err) { |
77 | 77 | // TODO: replace this comment and the console.log with your own code |
78 | | - console.log(err); |
| 78 | + console.log('renderError', err); |
79 | 79 | } |
80 | 80 |
|
81 | 81 | /** |
|
85 | 85 | * @param {HTMLElement} parent The parent element. |
86 | 86 | * @param {Object} options An object with attribute names and values. |
87 | 87 | */ |
88 | | - createAndAppend(name, parent, options = {}) { |
| 88 | + static createAndAppend(name, parent, options = {}) { |
89 | 89 | const elem = document.createElement(name); |
90 | 90 | parent.appendChild(elem); |
91 | 91 | Object.entries(options).forEach(([key, value]) => { |
|
0 commit comments