mirror of https://github.com/ShaYmez/xlxd.git
smooth page refresh with jquery
dynamically reload page body contents with jquery instead of just asking browser to reload whole page, this provides a fully smooth page refresh and keeps page scroll position on all browsers
This commit is contained in:
parent
02a6bf07a8
commit
dbc05c9b63
|
@ -94,32 +94,32 @@ else {
|
||||||
|
|
||||||
if ($PageOptions['PageRefreshActive']) {
|
if ($PageOptions['PageRefreshActive']) {
|
||||||
echo '
|
echo '
|
||||||
|
<script src="./js/jquery-1.12.4.min.js"></script>
|
||||||
<script>
|
<script>
|
||||||
var PageRefresh;
|
var PageRefresh;
|
||||||
|
|
||||||
function ReloadPage() {';
|
function ReloadPage() {
|
||||||
if (($_SERVER['REQUEST_METHOD'] === 'POST') || isset($_GET['do'])) {
|
$.get("./index.php'.(isset($_GET['show'])?'?show='.$_GET['show']:'').'", function(data) {
|
||||||
echo '
|
var BodyStart = data.indexOf("<bo"+"dy");
|
||||||
document.location.href = "./index.php';
|
var BodyEnd = data.indexOf("</bo"+"dy>");
|
||||||
if (isset($_GET['show'])) {
|
if ((BodyStart >= 0) && (BodyEnd > BodyStart)) {
|
||||||
echo '?show='.$_GET['show'];
|
BodyStart = data.indexOf(">", BodyStart)+1;
|
||||||
}
|
$("body").html(data.substring(BodyStart, BodyEnd));
|
||||||
echo '";';
|
}
|
||||||
} else {
|
})
|
||||||
echo '
|
.always(function() {
|
||||||
document.location.reload();';
|
PageRefresh = setTimeout(ReloadPage, '.$PageOptions['PageRefreshDelay'].');
|
||||||
}
|
});
|
||||||
echo '
|
|
||||||
}';
|
}';
|
||||||
|
|
||||||
if (!isset($_GET['show']) || (($_GET['show'] != 'liveircddb') && ($_GET['show'] != 'reflectors') && ($_GET['show'] != 'interlinks'))) {
|
if (!isset($_GET['show']) || (($_GET['show'] != 'liveircddb') && ($_GET['show'] != 'reflectors') && ($_GET['show'] != 'interlinks'))) {
|
||||||
echo '
|
echo '
|
||||||
PageRefresh = setTimeout(ReloadPage, '.$PageOptions['PageRefreshDelay'].');';
|
PageRefresh = setTimeout(ReloadPage, '.$PageOptions['PageRefreshDelay'].');';
|
||||||
}
|
}
|
||||||
echo '
|
echo '
|
||||||
|
|
||||||
function SuspendPageRefresh() {
|
function SuspendPageRefresh() {
|
||||||
clearTimeout(PageRefresh);
|
clearTimeout(PageRefresh);
|
||||||
}
|
}
|
||||||
</script>';
|
</script>';
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue