Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Eliminate flicker in firefox brower #3024

Merged
merged 1 commit into from
Oct 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 24 additions & 17 deletions html/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -193,20 +193,27 @@ function SaveTORAndVPNConfig() {}

<script type="text/javascript">
function getImage() {
var img = $("<img />").attr('src', '<?php echo $image_name ?>?_ts=' + new Date().getTime())
.attr("id", "current")
.attr("class", "current")
.css("width", "100%")
.on('load', function () {
if (!this.complete || typeof this.naturalWidth == "undefined" || this.naturalWidth == 0) {
console.log('broken image!');
setTimeout(function () {
getImage();
}, 500);
} else {
$("#live_container").empty().append(img);
}
});
var newImg = new Image();
newImg.src = '<?php echo $image_name ?>?_ts=' + new Date().getTime();
newImg.id = "current";
newImg.class = "current";
newImg.style = "width: 100%";
newImg.decode().then(() => {
$("#current").attr('src', newImg.src)
.attr("id", "current")
.attr("class", "current")
.css("width", "100%")
.on('load', function () {
if (!this.complete || typeof this.naturalWidth == "undefined" || this.naturalWidth == 0) {
console.log('broken image!');
setTimeout(function () {
getImage();
}, 500);
} else {
$("#live_container").empty().append(newImg);
}
});
});
}

// Inititalize theme to light
Expand Down Expand Up @@ -284,7 +291,7 @@ function getImage() {
</li>
<li>
<a id="module" href="index.php?page=module"><i class="fa fa-bars fa-fw"></i> Module Manager</a>
</li>
</li>
<li>
<a id="LAN" href="index.php?page=LAN_info"><i class="fa fa-network-wired fa-fw"></i> <b>LAN</b> Dashboard</a>
</li>
Expand Down Expand Up @@ -445,7 +452,7 @@ function getImage() {
break;
case "module":
DisplayModule();
break;
break;

case "live_view":
default:
Expand Down Expand Up @@ -523,7 +530,7 @@ function topFunction() {
document.documentElement.scrollTop = 0; // For Chrome, Firefox, IE and Opera
}
}
<?php
<?php
}
?>
</script>
Expand Down
12 changes: 10 additions & 2 deletions html/public.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,13 @@

<script type="text/javascript">
function getImage(){
var img = $("<img />").attr('src', '<?php echo $image_name ?>?_ts=' + new Date().getTime())
var newImg = new Image();
newImg.src = '<?php echo $image_name ?>?_ts=' + new Date().getTime();
newImg.id = "current";
newImg.class = "current";
newImg.style = "width: 100%";
newImg.decode().then(() => {
$("#current").attr('src', newImg.src)
.attr("id", "current")
.attr("class", "current")
.css("width", "100%")
Expand All @@ -41,9 +47,11 @@ function getImage(){
getImage();
}, 500);
} else {
$("#live_container").empty().append(img);
$("#live_container").empty().append(newImg);
}
});
});

}

setInterval(function(){
Expand Down