|
@@ -27,7 +27,7 @@
|
|
|
Show.prototype.next = function() {
|
|
|
if (++this.index >= this.list.length) this.index = 0;
|
|
|
this.elapsed = 0;
|
|
|
- };
|
|
|
+ };
|
|
|
|
|
|
Show.prototype.prev = function() {
|
|
|
if (--this.index < 0) this.index = this.list.length-1;
|
|
@@ -35,14 +35,12 @@
|
|
|
};
|
|
|
|
|
|
Show.prototype.format = function(f, a) {
|
|
|
- let start = f.indexOf('%');
|
|
|
- if (f.length > start && f[start+1] === 's') {
|
|
|
- return f.replace('%s', a);
|
|
|
- } else if (f.length > start+3 && f[start+3] === 's') {
|
|
|
+ f = f.replaceAll('%s', a);
|
|
|
+ for (let start = f.indexOf('%'); f.length > start+3 && f[start+3] === 's'; ) {
|
|
|
let c = String(f[start+1]);
|
|
|
let w = parseInt(f[start+2]);
|
|
|
- let r = (a.length >= w) ? a : (new Array(w).join(c) + a).slice(-w);
|
|
|
- return f.replace(f.slice(start, start+4), r);
|
|
|
+ let r = (String(a).length >= w) ? a : (new Array(w).join(c)).concat(a).slice(-w);
|
|
|
+ f = f.replace(f.slice(start, start+4), r);
|
|
|
}
|
|
|
return f;
|
|
|
};
|
|
@@ -52,7 +50,7 @@
|
|
|
if (o.p.endsWith('.mp4') || o.p.endsWith('.webm') || o.p.endsWith('.ogg')) {
|
|
|
o.e = document.createElement('video');
|
|
|
o.e.addEventListener('error', () => { this.list.splice(this.list.indexOf(o), 1); }, {once: true});
|
|
|
- o.e.addEventListener('canplay', () => { o.d = (isNaN(delay) ? 1 : delay) * e.duration * 1000; }, {once: true});
|
|
|
+ o.e.addEventListener('canplay', () => { o.d = (isNaN(delay) ? 1 : delay) * o.e.duration * 1000; }, {once: true});
|
|
|
o.e.muted = true;
|
|
|
o.e.loop = true;
|
|
|
o.e.src = o.p;
|
|
@@ -93,12 +91,17 @@
|
|
|
let d = Date.now();
|
|
|
let o = this.list[this.index];
|
|
|
let vid = (o.e.tagName == 'VIDEO') ? 'video' : 'natural';
|
|
|
- o.e.className = (o.e[vid+'Width'] / o.e[vid+'Height'] < this.parent.clientWidth / this.parent.clientHeight) ? 'fillheight' : 'fillwidth';
|
|
|
+ if (o.e.src === this.parent.firstChild.src) o.e.className = this.parent.firstChild.className = (o.e[vid+'Width'] / o.e[vid+'Height'] < this.parent.clientWidth / this.parent.clientHeight) ? 'fillheight' : 'fillwidth';
|
|
|
if (this.parent.firstChild !== o.e && !o.loading) {
|
|
|
o.loading = true;
|
|
|
let parent = this.parent;
|
|
|
o.e.addEventListener(vid === 'video' ? 'canplay' : 'load', () => {
|
|
|
- parent.replaceChild(o.e, parent.firstChild);
|
|
|
+ if (vid === 'video') {
|
|
|
+ parent.replaceChild(o.e, parent.firstChild);
|
|
|
+ } else if (vid === 'natural' && parent.firstChild.tagName === 'VIDEO') {
|
|
|
+ parent.replaceChild(document.createElement('img'), parent.firstChild);
|
|
|
+ }
|
|
|
+ if (parent.firstChild.tagName === 'IMG') parent.firstChild.src = o.p;
|
|
|
if (vid === 'video') o.e.play();
|
|
|
delete o.loading
|
|
|
}, {once: true});
|