All pastes #2890 Raw Edit

duck

public text v1 · immutable
#2890 ·published 2004-12-11 22:33 UTC
rendered paste body
<html>
<head>
  <script>
    function DijjerObject() {
        // Reasonable defaults
        this.dijjerUrl = 'http://127.0.0.1:9115/';
        this.gifUrl = this.dijjerUrl + 'graph.gif';
        this.gifWidth = 256;
        this.interval = 500;
        this.attempts = 3;

        this.i = new Image();

        // try to load the picture and set the timer
        this.call = function() {
            this.i.src = this.gifUrl;
            setTimeout("Dijjer.check(1);", this.interval);
        }

        // check if the picture is loaded
        this.check = function(attempt) {
            if (this.i.width == this.gifWidth) {
                this.callback();
            } else {
                if (attempt < this.attempts) {
                    setTimeout( "Dijjer.check( " + (attempt+1) +" );", this.interval);
                } else {
                    this.i.src = '';
                    this.failure();
                }
            }
        }

        // dijjerify the url
        this.makeUrl = function(url) {
            return this.dijjerUrl + url;
        }

        // default callback, override this
        this.callback = function() {
            alert( "Dijjer found" );
        }

        // default failure, override this
        this.failure = function() {
            alert( "Dijjer not found" );
        }
    }
    var Dijjer;

    // --- cut ---

    function body_onLoad(){
        Dijjer = new DijjerObject();
        Dijjer.callback = dijjerFound;
        Dijjer.failure = dijjerNotFound;
        Dijjer.call();
    }

    function dijjerFound() {
        obj = document.getElementById('dijjerOutput');
        url = document.getElementById('dijjerUrl').value;
        obj.innerHTML = 'Dijjer detected; you can start the <a href="'+Dijjer.makeUrl(url)+'">download</a>';
    }

    function dijjerNotFound() {
        obj = document.getElementById('dijjerOutput');
        obj.innerHTML = 'Dijjer is not running, download it from <a href="http://dijjer.org/">dijjer.org</a>';
    }
  </script>
  <title>DijjerCheck Demo</title>
</head>
<body onLoad="body_onLoad();">

  <h1>DijjerCheck Demo</h1>

  <input id="dijjerUrl" type="text" value="http://www.archive.org/download/Evolutio2001/Evolutio2001.mpeg" size="80" readonly="readonly" />

  <br />
  <p>Status: <span id="dijjerOutput">Trying to detect Dijjer...</span></p>
  <p>This check requires JavaScript.<br />
  If you have that disabled or the detection doesn't work for you; be sure to
  <a href="http://dijjer.org/">install and run dijjer</a> and start the
  <a href="http://127.0.0.1:9115/http://www.archive.org/download/Evolutio2001/Evolutio2001.mpeg">
  download</a>.


<hr />
<p>Written by duck in 2004 and released into the public domain.</p>
</body>
</html>