This repository has been archived on 2025-04-22. You can view files and clone it, but cannot push or open issues or pull requests.
ha_client/assets/js/cameraImgViewHelper.js
2020-02-20 21:48:22 +00:00

20 lines
651 B
JavaScript

var messageChannel = 'HA_entity_id_placeholder';
function fixCameraImgView() {
window.clearInterval(window.bodyDetectInterval);
var img = document.getElementsByTagName('img');
if (img && img.length) {
img[0].setAttribute('width', document.body.clientWidth);
img[0].removeAttribute('style');
setTimeout(function() {
window[messageChannel].postMessage(document.body.clientWidth / img[0].offsetHeight);
}, 100);
}
}
window.bodyDetectInterval = setInterval(function() {
if (document.body != null && document.getElementsByTagName('img').length) {
fixCameraImgView();
}
}, 100);