Strict timing parsing
This commit is contained in:
parent
67f7f77690
commit
a9db0ee9e6
21
shower.js
21
shower.js
|
@ -188,9 +188,7 @@ window.shower = window.shower || (function(window, document, undefined) {
|
||||||
* @returns {Object} shower
|
* @returns {Object} shower
|
||||||
*/
|
*/
|
||||||
shower.init = function(slideSelector, progressSelector) {
|
shower.init = function(slideSelector, progressSelector) {
|
||||||
var timing,
|
var timing;
|
||||||
minutes,
|
|
||||||
seconds;
|
|
||||||
|
|
||||||
slideSelector = slideSelector || '.slide';
|
slideSelector = slideSelector || '.slide';
|
||||||
progressSelector = progressSelector || 'div.progress div';
|
progressSelector = progressSelector || 'div.progress div';
|
||||||
|
@ -205,25 +203,22 @@ window.shower = window.shower || (function(window, document, undefined) {
|
||||||
slides[i].id = i + 1;
|
slides[i].id = i + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
timing = shower._getData(slides[i], 'timing') || undefined;
|
timing = shower._getData(slides[i], 'timing');
|
||||||
|
|
||||||
// Parsing timing in [S] or [M:S] format
|
// Parsing timing in [S] or [M:S] format
|
||||||
// and returning it in milliseconds
|
// and returning it in milliseconds
|
||||||
if (timing && timing.split(':').length <= 2) {
|
if (timing && /^(\d{1,2}:)?\d{1,3}$/.test(timing)) {
|
||||||
if (timing.indexOf(':') !== -1) {
|
if (timing.indexOf(':') !== -1) {
|
||||||
timing = timing.split(':');
|
timing = timing.split(':');
|
||||||
minutes = parseInt(timing[0], 10),
|
timing = (parseInt(timing[0], 10) * 60 + parseInt(timing[1], 10)) * 1000;
|
||||||
seconds = parseInt(timing[1], 10);
|
|
||||||
timing = (minutes * 60 + seconds) * 1000;
|
|
||||||
} else {
|
} else {
|
||||||
seconds = parseInt(timing, 10);
|
timing = parseInt(timing, 10) * 1000;
|
||||||
timing = seconds * 1000;
|
|
||||||
}
|
}
|
||||||
if (slides[i].querySelector('.next')) {
|
if (timing === 0) {
|
||||||
timing = timing / (slides[i].querySelectorAll('.next').length + 1);
|
timing = false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
timing = undefined;
|
timing = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
shower.slideList.push(new Slide({
|
shower.slideList.push(new Slide({
|
||||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue