mirror of
https://github.com/KnugiHK/WhatsApp-Chat-Exporter.git
synced 2026-06-04 07:05:33 +00:00
Lazy loading of video for new theme
This commit is contained in:
@@ -51,8 +51,8 @@
|
|||||||
padding: 20px 0 20px 0;
|
padding: 20px 0 20px 0;
|
||||||
}
|
}
|
||||||
footer {
|
footer {
|
||||||
|
margin-top: 10px;
|
||||||
border-top: 2px solid #e3e6e7;
|
border-top: 2px solid #e3e6e7;
|
||||||
font-size: 2em;
|
|
||||||
padding: 20px 0 20px 0;
|
padding: 20px 0 20px 0;
|
||||||
}
|
}
|
||||||
article {
|
article {
|
||||||
@@ -243,8 +243,8 @@
|
|||||||
<source src="{{ msg.data }}" />
|
<source src="{{ msg.data }}" />
|
||||||
</audio>
|
</audio>
|
||||||
{% elif "video/" in msg.mime %}
|
{% elif "video/" in msg.mime %}
|
||||||
<video controls="controls" autobuffer="autobuffer">
|
<video class="lazy" autobuffer {% if msg.message_type|int == 13 or msg.message_type|int == 11 %}autoplay muted loop playsinline{%else%}controls{% endif %}>
|
||||||
<source src="{{ msg.data }}" />
|
<source type="{{ msg.mime }}" data-src="{{ msg.data }}" />
|
||||||
</video>
|
</video>
|
||||||
{% elif "/" in msg.mime %}
|
{% elif "/" in msg.mime %}
|
||||||
The file cannot be displayed here, however it should be located at <a href="./{{ msg.data }}">here</a>
|
The file cannot be displayed here, however it should be located at <a href="./{{ msg.data }}">here</a>
|
||||||
@@ -304,8 +304,8 @@
|
|||||||
<source src="{{ msg.data }}" />
|
<source src="{{ msg.data }}" />
|
||||||
</audio>
|
</audio>
|
||||||
{% elif "video/" in msg.mime %}
|
{% elif "video/" in msg.mime %}
|
||||||
<video controls="controls" autobuffer="autobuffer">
|
<video class="lazy" autobuffer {% if msg.message_type|int == 13 or msg.message_type|int == 11 %}autoplay muted loop playsinline{%else%}controls{% endif %}>
|
||||||
<source src="{{ msg.data }}" />
|
<source type="{{ msg.mime }}" data-src="{{ msg.data }}" />
|
||||||
</video>
|
</video>
|
||||||
{% elif "/" in msg.mime %}
|
{% elif "/" in msg.mime %}
|
||||||
The file cannot be displayed here, however it should be located at <a href="./{{ msg.data }}">here</a>
|
The file cannot be displayed here, however it should be located at <a href="./{{ msg.data }}">here</a>
|
||||||
@@ -365,4 +365,32 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
<script>
|
||||||
|
document.addEventListener("DOMContentLoaded", function() {
|
||||||
|
var lazyVideos = [].slice.call(document.querySelectorAll("video.lazy"));
|
||||||
|
|
||||||
|
if ("IntersectionObserver" in window) {
|
||||||
|
var lazyVideoObserver = new IntersectionObserver(function(entries, observer) {
|
||||||
|
entries.forEach(function(video) {
|
||||||
|
if (video.isIntersecting) {
|
||||||
|
for (var source in video.target.children) {
|
||||||
|
var videoSource = video.target.children[source];
|
||||||
|
if (typeof videoSource.tagName === "string" && videoSource.tagName === "SOURCE") {
|
||||||
|
videoSource.src = videoSource.dataset.src;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
video.target.load();
|
||||||
|
video.target.classList.remove("lazy");
|
||||||
|
lazyVideoObserver.unobserve(video.target);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
lazyVideos.forEach(function(lazyVideo) {
|
||||||
|
lazyVideoObserver.observe(lazyVideo);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
</script>
|
||||||
</html>
|
</html>
|
||||||
Reference in New Issue
Block a user