File: EzMaintenance/Resources/templates/__script.php

Recommend this page to a friend!
  Classes of Roni  >  EZ PHP Maintenance Mode  >  EzMaintenance/Resources/templates/__script.php  >  Download  
File: EzMaintenance/Resources/templates/__script.php
Role: Auxiliary script
Content type: text/plain
Description: Auxiliary script
Class: EZ PHP Maintenance Mode
Check if a site should be put in maintenance mode
Author: By
Last change:
Date: 1 year ago
Size: 728 bytes
 

Contents

Class file image Download
<script>
(function () {

    function httpStatus(url, callback) {
        var http = new XMLHttpRequest();
        http.open('HEAD', url);
        http.onreadystatechange = function () {
            if (this.readyState == this.DONE) {
                callback(this.status);
            }
        };
        http.send();
    }

    function reloadPage() {
        setTimeout('location.reload(true);', 1);
    }

    function reloadIfSiteUp() {
        httpStatus(location.href, function (sstatus) {
            if (sstatus == 503) {
                setTimeout(reloadIfSiteUp, <?php echo $interval * 1000 ?>)
            } else {
                reloadPage();
            }
        })
    }

    reloadIfSiteUp();
})();

</script>


For more information send a message to info at phpclasses dot org.