|
1 | | -var domReady = function(callback) { |
2 | | - var state = document.readyState ; |
3 | | - if ( state === 'interactive' || state === 'complete' ) { |
4 | | - callback() ; |
5 | | - } |
6 | | - else { |
| 1 | +const domReady = function (callback) { |
| 2 | + const state = document.readyState; |
| 3 | + if (state === 'interactive' || state === 'complete') { |
| 4 | + callback(); |
| 5 | + } else { |
7 | 6 | document.addEventListener('DOMContentLoaded', callback); |
8 | 7 | } |
9 | | -} ; |
10 | | - |
| 8 | +}; |
11 | 9 |
|
12 | | -domReady(function(){ |
13 | | - |
14 | | - var projectname = document.createElement('a'); |
| 10 | +domReady(() => { |
| 11 | + const projectname = document.createElement('a'); |
15 | 12 | projectname.classList.add('project-name'); |
16 | 13 | projectname.text = 'aureooms/js-random'; |
17 | | - projectname.href = './index.html' ; |
| 14 | + projectname.href = './index.html'; |
18 | 15 |
|
19 | | - var header = document.getElementsByTagName('header')[0] ; |
20 | | - header.insertBefore(projectname,header.firstChild); |
| 16 | + const header = document.querySelectorAll('header')[0]; |
| 17 | + header.insertBefore(projectname, header.firstChild); |
21 | 18 |
|
22 | | - var testlink = document.querySelector('header > a[data-ice="testLink"]') ; |
23 | | - testlink.href = 'https://coveralls.io/github/aureooms/js-random' ; |
24 | | - testlink.target = '_BLANK' ; |
| 19 | + const testlink = document.querySelector('header > a[data-ice="testLink"]'); |
| 20 | + testlink.href = 'https://coveralls.io/github/aureooms/js-random'; |
| 21 | + testlink.target = '_BLANK'; |
25 | 22 |
|
26 | | - var searchBox = document.querySelector('.search-box'); |
27 | | - var input = document.querySelector('.search-input'); |
| 23 | + const searchBox = document.querySelector('.search-box'); |
| 24 | + const input = document.querySelector('.search-input'); |
28 | 25 |
|
29 | | - // active search box when focus on searchBox. |
30 | | - input.addEventListener('focus', function(){ |
| 26 | + // Active search box when focus on searchBox. |
| 27 | + input.addEventListener('focus', () => { |
31 | 28 | searchBox.classList.add('active'); |
32 | 29 | }); |
33 | | - |
34 | 30 | }); |
0 commit comments