martes, diciembre 20, 2005

Paginita AJAX para buscar chatis desde Flickr (flicker fliker jejeje)

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
<title>Fliker en Español AJAX PINO</title>
</head>
<body>
Fliker en Español AJAX PINO <br />
<script type="text/javascript" language="javascript">
function makeHttpRequest(url, callback_function, return_xml)
{
var http_request = false;





if (window.XMLHttpRequest) { // Mozilla, Safari,...
http_request = new XMLHttpRequest();
if (http_request.overrideMimeType) {
http_request.overrideMimeType('text/xml');
}
} else if (window.ActiveXObject) { // IE
try {
http_request = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
http_request = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {}
}
}

if (!http_request) {
alert('Unfortunatelly you browser doesn\'t support this feature.');
return false;
}
http_request.onreadystatechange = function() {
if (http_request.readyState == 4) {
if (http_request.status == 200) {
if (return_xml) {
eval(callback_function + '(http_request.responseXML)');
} else {
eval(callback_function + '(http_request.responseText)');
}
} else {
alert('There was a problem with the request.(Code: ' + http_request.status + ')');
}
}
}
http_request.open('GET', url, true);
http_request.send(null);
}

function alertContents(text) {
alert(text);
}

function writegetRecent(text) {
var result = document.getElementById("result");
var xmldoc = text;
var root_node = text.getElementsByTagName('photo');
result.innerHTML ="";
for (var i = 0; i < root_node.length; i++) {

id = root_node[i].getAttribute("id");
secret = root_node[i].getAttribute("secret");
server = root_node[i].getAttribute("server");
result.innerHTML += "<a href='http://static.flickr.com/"+server+"/"+id+"_"+secret+"_o.jpg' target='_blank'><img src='http://static.flickr.com/"+server+"/"+id+"_"+secret+"_s.jpg' hspace=5 vspace=5 alt=''></a>";

}

}

function getRecent(url) {
makeHttpRequest(url, 'writegetRecent',1);
}

function makeRequest(url) {
makeHttpRequest(url, 'alertContents');
}
</script>
<script>
getRecent('/flk/services/rest/?method=flickr.photos.search&api_key=pidetuapikeyenflickr&tags=erotic,girl&tag_mode=all')
</script>
<br />
<div id="result">Cargando...</div>
</body>
</html>

1 comentario:

Anónimo dijo...

y para q se supone q sirve esto? xD