Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add webpack workflow to support ES6 module and better dependency chec…
…king
- Loading branch information
1 parent
edd610f
commit 07042f2
Showing
18 changed files
with
3,148 additions
and
1,188 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
app/vendor/ | ||
*.bundle.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,4 +6,5 @@ dist | |
app/bower_components | ||
test/bower_components | ||
package | ||
|
||
*.bundle.js | ||
*.js.map |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"cSpell.enabled": false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,54 +1,52 @@ | ||
/* © 2016 int3ractive.com | ||
* @author Thanh | ||
*/ | ||
(function() { | ||
'use strict'; | ||
/** | ||
* The clock component | ||
* @type {Object} | ||
*/ | ||
nau.define('clock', { | ||
init(selector) { | ||
this.clock = $(selector); | ||
|
||
if (!this.clock) { | ||
throw new Error('Clock.start: cannot find Clock element with selector', selector); | ||
} | ||
|
||
// update time immediately | ||
this.currentTime = this.getCurrentTime(); | ||
this.render(); | ||
|
||
// check every second but only render when text is different | ||
this.tickId = setInterval(() => { | ||
const time = this.getCurrentTime(); | ||
if (!$.shallowEqual(time, this.currentTime)) { | ||
this.currentTime = time; | ||
this.render(); | ||
} | ||
}, 1000); | ||
}, | ||
|
||
stop() { | ||
if (this.tickId) { | ||
clearInterval(this.tickId); | ||
this.tickId = 0; | ||
} | ||
}, | ||
/** | ||
* The clock component | ||
* @type {Object} | ||
*/ | ||
export default { | ||
init(selector) { | ||
this.clock = $(selector); | ||
|
||
getCurrentTime() { | ||
let now = new Date(); | ||
let hours = now.getHours() < 10 ? '0' + now.getHours() : now.getHours(); | ||
let minutes = now.getMinutes() < 10 ? '0' + now.getMinutes() : now.getMinutes(); | ||
// let seconds = now.getSeconds() < 10 ? '0' + now.getSeconds() : now.getSeconds(); | ||
if (!this.clock) { | ||
throw new Error('Clock.start: cannot find Clock element with selector', selector); | ||
} | ||
|
||
return {hours, minutes}; | ||
}, | ||
// update time immediately | ||
this.currentTime = this.getCurrentTime(); | ||
this.render(); | ||
|
||
render() { | ||
let {hours, minutes} = this.currentTime; | ||
this.clock.innerHTML = `<span class="clock__hour">${hours}</span>:<span class="clock__minute">${minutes}</span>`; | ||
} | ||
}); | ||
// check every second but only render when text is different | ||
this.tickId = setInterval(() => { | ||
const time = this.getCurrentTime(); | ||
if (!$.shallowEqual(time, this.currentTime)) { | ||
this.currentTime = time; | ||
this.render(); | ||
} | ||
}, 1000); | ||
}, | ||
|
||
}()); | ||
stop() { | ||
if (this.tickId) { | ||
clearInterval(this.tickId); | ||
this.tickId = 0; | ||
} | ||
}, | ||
|
||
getCurrentTime() { | ||
const now = new Date(); | ||
const hours = now.getHours() < 10 ? `0${now.getHours()}` : now.getHours(); | ||
const minutes = now.getMinutes() < 10 ? `0${now.getMinutes()}` : now.getMinutes(); | ||
// let seconds = now.getSeconds() < 10 ? '0' + now.getSeconds() : now.getSeconds(); | ||
|
||
return { hours, minutes }; | ||
}, | ||
|
||
render() { | ||
const { hours, minutes } = this.currentTime; | ||
this.clock.innerHTML = | ||
`<span class="clock__hour">${hours}</span>:<span class="clock__minute">${minutes}</span>`; | ||
}, | ||
}; |
Oops, something went wrong.