<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
    "http://www.w3.org/TR/html4/strict.dtd"
    >
<html lang="en">
<head>
    <title>OEmbed Proxy test</title>
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js"></script>
<script type="text/javascript">

var gProxyUrl = "./example-proxy.php";

function sample(aAId, aDivId) {
    var url = document.getElementById(aAId).href;
    var div = document.getElementById(aDivId);
    
    var jqxhr = $.getJSON(gProxyUrl,
                          {url: url, maxwidth: 425},
                          function(data, textStatus) {
            if (data.type) {
                if (data.type == "video" && data.html)
                    div.innerHTML = data.html;
                else if (data.type == "photo" && data.url)
                    div.innerHTML = '<img src="' + data.url + '">';
            }
        })
        .error(function(jqXHR, textStatus) {
            div.innerHTML = "request failed!";
        });
}

$(document).ready(function() {
    sample("test_youtube", "res_youtube");
    sample("test_dailymotion", "res_dailymotion");
    sample("test_vimeo", "res_vimeo");
    sample("test_flickr", "res_flickr");
});

</script>

<style type="text/css">
.sample {
    border: 1px solid gray;
    margin: 1em;
}
</style>
</head>

<body>
    <h1>OEmbed Proxy test</h1>
    <p><em>
        This page example use the <a href="http://jquery.com/">JQuery</a> library,
        linked online by Google.
    </em></p>
    
    <div class="sample">
        <p>
            <a id="test_youtube" href="http://www.youtube.com/watch?v=vk1HvP7NO5w">
                http://www.youtube.com/watch?v=vk1HvP7NO5w
            </a>
        </p>
        <div id="res_youtube">
            This div should display a youtube video, and not this text.
        </div>
    </div>
    
    <div class="sample">
        <p>
            <a id="test_dailymotion" href="http://www.dailymotion.com/video/x5ioet_phoenix-mars-lander_tech">
                http://www.dailymotion.com/video/x5ioet_phoenix-mars-lander_tech
            </a>
        </p>
        <div id="res_dailymotion">
            This div should display a Dailymotion video, and not this text.
        </div>
    </div>
    
    <div class="sample">
        <p>
            <a id="test_vimeo" href="http://www.vimeo.com/1211060">
                http://www.vimeo.com/1211060
            </a>
        </p>
        <div id="res_vimeo">
            This div should display a Vimeo video, and not this text.
        </div>
    </div>
    
    <div class="sample">
        <p><em>
            extended provider
        </em></p>
        <p>
            <a id="test_flickr" href="http://www.flickr.com/photos/fuffer2005/2435339994/">
                http://www.flickr.com/photos/fuffer2005/2435339994/
            </a>
        </p>
        <div id="res_flickr">
            This div should display a Flickr sample, and not this text.
        </div>
    </div>
    
</body>
</html>