<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:creativeCommons="http://backend.userland.com/creativeCommonsRssModule">

<channel>
	<title>Werner Creixell &#187; html</title>
	<atom:link href="http://profesores.elo.utfsm.cl/~wcreixell/index.html/?feed=rss2&#038;tag=html" rel="self" type="application/rss+xml" />
	<link>http://profesores.elo.utfsm.cl/~wcreixell</link>
	<description>Personal web page</description>
	<lastBuildDate>Fri, 20 Mar 2026 13:06:49 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.6.1</generator>
<creativeCommons:license>http://creativecommons.org/licenses/by-nc-sa/2.0/cl/</creativeCommons:license>		<item>
		<title>Twitter Searchs</title>
		<link>http://profesores.elo.utfsm.cl/~wcreixell/?p=141</link>
		<comments>http://profesores.elo.utfsm.cl/~wcreixell/?p=141#comments</comments>
		<pubDate>Wed, 16 Jun 2010 20:09:50 +0000</pubDate>
		<dc:creator>Werner Creixell</dc:creator>
				<category><![CDATA[SeminarioII]]></category>
		<category><![CDATA[Web Programming]]></category>
		<category><![CDATA[Ajax]]></category>
		<category><![CDATA[cross-domain]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[jacascript]]></category>
		<category><![CDATA[jquery]]></category>

		<guid isPermaLink="false">http://profesores.elo.utfsm.cl/~wcreixell/?p=141</guid>
		<description><![CDATA[In Seminario II the students were challenged to make a web page that displays a Twitter search. The &#8220;#chi&#8221; or &#8220;#worldcup&#8221; hash-tag search is performed and the results dynamically displayed. Dominique Naser solution, using jQuery, can be found here (gracias Dominique). First a simple form to input the search. &#60;html> &#60;head> &#60;meta http-equiv="Content-type" content="text/html; charset=utf-8"> [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>In Seminario II the students were challenged to make a web page that displays a Twitter search. The &#8220;#chi&#8221; or &#8220;#worldcup&#8221; hash-tag search is performed and the results dynamically displayed.</p>
<p>Dominique Naser solution, using <a href="http://jquery.com/">jQuery</a>, can be found <a href="http://profesores.elo.utfsm.cl/~wcreixell/domnique/index.php">here</a> (gracias Dominique).</p>
<p>First a simple form to input the search.</p>
<pre name="code" class="html">
&lt;html>
  &lt;head>
    &lt;meta http-equiv="Content-type" content="text/html; charset=utf-8">
    &lt;title>Buscador de Hashtags&lt;/title>
  &lt;/head>
  &lt;body>
        &lt;h2>Buscador&lt;/h2>
    &lt;form action="busca.php" method="post">
                &lt;input name="busqueda" type="text" size="50" style="text-align:left" />
                &lt;input name="" type="submit" size="10" value="Busca!" />&lt;br>
        &lt;/form>
  &lt;/body>
&lt;/html>
</pre>
<p>The Html file where the search and the results display is performed.</p>
<pre name="code" class="html">
&lt;!DOCTYPE HTML>

&lt;html>

  &lt;head>

    &lt;meta http-equiv="Content-type" content="text/html; charset=utf-8">

    &lt;title>Buscador de Hashtags&lt;/title>

	        &lt;script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js">&lt;/script>

        &lt;script type="text/javascript" src="http://github.com/malsup/corner/raw/master/jquery.corner.js?v2.09">&lt;/script>



	&lt;script>

	const MAX_RESULTS= 20;

function twitter_search() {

	var url = 'http://search.twitter.com/search.json?callback=?';

	// Iterating over the different search columns

	$('.twitter_search').each(function() {

		var container = $(this);

		// Search terms are specified in the 'title' attribute

		var search = container.attr('title');

		if (search) {

			var since_id = 0;

			if (container.children().length) {

				// Retrieve results since this id

				since_id = container.children(':first').attr('id').replace('#', '%23');

			}

			// Request the results

			$.getJSON(url, {'q': search, 'since_id': since_id}, function(data) {

				// Processing those results, if any

				if (data.results.length) {

					for (i in data.results.reverse()) {

						var r = data.results[i];

						// Creating the result container

						var div = $('&lt;div id="#' + r.id + '">&lt;/div>');

						// Don't show this element now

						div.hide();

						// Adding some styles through .twitter_result

						div.addClass('twitter_result');

						// Adding user's image

						div.append('&lt;img src="' + r.profile_image_url + '" alt="' + r.from_user + '" />');

						// Adding username

						div.append('&lt;a href="http://twitter.com/' + r.from_user + '">' + r.from_user + '&lt;/a>');

						// Adding tweet

						div.append('&lt;span>' + r.text + '&lt;/span>');

						// Adding corners

						div.corner();

						// Adding this result to the main container

						container.prepend(div);

						// Effect

						div.slideDown('slow');

					}

				}

				// Removing old tweets

				if (container.children().length > MAX_RESULTS) {

					// Negative index

					to_remove = MAX_RESULTS - container.children().length

					container.children().slice(to_remove).each(function() {

						$(this).slideUp();

					});

				}

			});

		}

	});

};

 

$(document).ready(function() {

	// Initial search 

	twitter_search();

	// Refresh the results every 5 seconds

	setInterval("twitter_search();", 5000);

});

	&lt;/script>

  &lt;/head>

  &lt;body>

	&lt;h2>Resultado&lt;/h2>

		

		&lt;div class="twitter_search" title="&lt;?php echo $_POST["busqueda"]; ?>">&lt;/div>	



  &lt;/body>

&lt;/html>

</pre>
<p>Diego Acevedo, used a <a href="http://jquery.com/">jQuery</a> plugin <a href="http://juitter.com">Juitter</a> (gracias Diego). You can found his solution <a href="http://profesores.elo.utfsm.cl/~wcreixell/diego/index.html">here</a></p>
<p>Both solutions  by pass the cross-domain restriction imposed by the browser.</p>
]]></content:encoded>
			<wfw:commentRss>http://profesores.elo.utfsm.cl/~wcreixell/?feed=rss2&#038;p=141</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Earthquakes in Google Maps</title>
		<link>http://profesores.elo.utfsm.cl/~wcreixell/?p=160</link>
		<comments>http://profesores.elo.utfsm.cl/~wcreixell/?p=160#comments</comments>
		<pubDate>Wed, 16 Jun 2010 15:10:43 +0000</pubDate>
		<dc:creator>Werner Creixell</dc:creator>
				<category><![CDATA[SeminarioII]]></category>
		<category><![CDATA[Web Programming]]></category>
		<category><![CDATA[html]]></category>
		<category><![CDATA[javascrip]]></category>
		<category><![CDATA[JSON]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://profesores.elo.utfsm.cl/~wcreixell/?p=160</guid>
		<description><![CDATA[In this example the Seminario II sutdents were asked to design a web page that display a Google map with earthquake information from the US Geological Survey USGS. Camilo Vera solution can be found here (gracias Camilo). Camilo&#8217;s php script is as follows: &#60;?php //header("Content-type= application/json"); $xml =simplexml_load_file("http://earthquakes.usgs.gov/earthquakes/catalogs/1day-M2.5.xml"); $i=0; //se recorren todos los nodos "entry" [&#8230;]]]></description>
				<content:encoded><![CDATA[<p>In this example the Seminario II sutdents were asked to design a web page that display a <a href="http://maps.google.com">Google map</a> with earthquake information from the <a href="http://www.usgs.gov/">US Geological Survey USGS</a>.</p>
<p>Camilo Vera solution can be found <a href="http://profesores.elo.utfsm.cl/~wcreixell/camilo/">here</a> (gracias Camilo).</p>
<p>Camilo&#8217;s php script is as follows:</p>
<pre name="code" class="php">
&lt;?php
//header("Content-type= application/json");
$xml =simplexml_load_file("http://earthquakes.usgs.gov/earthquakes/catalogs/1day-M2.5.xml");
$i=0;
//se recorren todos los nodos "entry"
foreach($xml->entry as $node){
    //se recuperan los datos que tiene un namespace especificado por la siguiente url
    $geo = $node->children("http://www.georss.org/georss");
    $json[$i][0]=$geo->point;
    $json[$i][1]=$node->title;
    $i++;
}
print(json_encode($json));
?>
</pre>
<p>The javascript is as follows:</p>
<pre name="code" class="javascript">
function initialize() {
    myLatlng = new google.maps.LatLng(-33.04299, -71.586657);
    var myOptions = {
      zoom: 3,
      center: myLatlng,
      mapTypeId: google.maps.MapTypeId.TERRAIN
    }
    //se crea una instancia de un mapa de google
    map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
    var request = crear_XmlHttpRequest();
    request.open("GET", "Conector.php", true);
    request.onreadystatechange = function() {
        if(request.readyState == 4 &#038;&#038; request.status == 200){
            var yw_json = request.responseText;
                      //dirty JSON evaluation
            var yw = eval('(' + yw_json + ')');
            var i;
            //se recorren el arreglo que contiene la informacion de las coordenadas y el nombre
            //del lugar donde ocurrio el terremoto
            for(i in yw){
                //la tercera dimension del arreglo es inutil, pero lamentablemente json_encode de php lo crea
                //se separan los dos puntos que determinan la coordenada
                coordenadas = yw[i][0][0].split(" ");
                //se guarda el nombre del lugar donde ocurrio el evento
                lugar = yw[i][1][0];
                //se crea el marcador en el mapa
                myLatlng = new google.maps.LatLng(coordenadas[0], coordenadas[1]);
                new google.maps.Marker({
                    position: myLatlng,
                    map: map,
                    title:lugar
                });
            }
        }
    }
    request.send(null);
  }

//Se define una funcion que retorne el objeto XMLHttpRequest dado que en la
//version 3 de la api de google se quito la clase GXmlHttp

function crear_XmlHttpRequest(){
    var httpRequest;
    if (window.XMLHttpRequest){
        //El explorador implementa la interfaz de forma nativa
	httpRequest = new XMLHttpRequest();
    }
    else if (window.ActiveXObject){
        //El explorador permite crear objetos ActiveX
	try {
            httpRequest = new ActiveXObject("MSXML2.XMLHTTP");
	} catch (e) {
            try {
                httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {}
        }
    }
    if (!httpRequest){
        alert("No ha sido posible crear una instancia de XMLHttpRequest");
    }
    return httpRequest;
}
</pre>
<p>The Html file is:</p>
<pre name="code" class="html">
&lt;html>
    &lt;head>
        &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        &lt;meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
        &lt;script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false">&lt;/script>
        &lt;script type="text/javascript" src="ajax_map.js">&lt;/script>
        &lt;title>&lt;/title>
    &lt;/head>
    &lt;body onload="initialize()">
        &lt;div id="map_canvas" style="width:100%; height:100%">&lt;/div>
        &lt;/body>
&lt;/html>
</pre>
<p>Alejandro Homes solution can be found <a href="http://profesores.elo.utfsm.cl/~wcreixell/alejandro/mapa.html">here</a> (gracias Alejandro). In this example the students used a php script as middle man to by pass the cross-domain restriction in web browsers.</p>
<p>The php script goes as follows:</p>
<pre name="code" class="php">
&lt;?php  

//First send the corresponding headers  

header("Content-type= application/json");  

 

//get the XML data from the URL  

$xml = simplexml_load_file("http://earthquake.usgs.gov/earthquakes/catalogs/1day-M2.5.xml");  



$count=0;

//traverse the SimpleXML object and store in a associative array  

foreach( $xml->entry as $entry ) 

{ 

	$aeo = $entry->children("http://www.georss.org/georss");

	$arr[$count] = array ('nombre'=>$entry->title,'fecha'=>$entry->updated,'geo_point'=>$aeo->point,'geo_elev'=>$aeo->elev);

	$count++;

}

  

//JSON enconde and print  

print(json_encode($arr));



?>
</pre>
<p>The html page is as follows:</p>
<pre name="code" class="html">
&lt;!DOCTYPE html "-//W3C//DTD XHTML 1.0 Strict//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
&lt;html xmlns="http://www.w3.org/1999/xhtml">
&lt;head>
	&lt;meta http-equiv="content-type" content="text/html; charset=utf-8"/>
	&lt;title>Google Maps JavaScript API Example&lt;/title>
	&lt;script src="http://maps.google.com/maps?file=api&#038;v=2&#038;key=ABQIAAAAw0DAzQTTbMAlKOPlgYZyaxT2yXp_ZAY8_ufC3CFXhHIE1NvwkxT4oLUvcIuwHQ71styNxZCnK2iqoQ"
		type="text/javascript">&lt;/script>
	&lt;script type="text/javascript">

	function reFresh() {
		location.reload(true)
	}


	function initialize() {
		if (GBrowserIsCompatible()) {

			function setMarker( punto, texto){

				var marker = new GMarker(punto, {draggable: false});

				GEvent.addListener(marker, "click", function(){
					// create the Google version of XMLHttpRequest object
					marker.openInfoWindowHtml(texto);
				});

				map.addOverlay(marker);
			}
			
			var map = new GMap2(document.getElementById("map_canvas"));
		
			var center = new GLatLng(-15,0);
		
			map.setCenter(center, 1);

			var request = GXmlHttp.create();
			request.open("GET", "usgs.php", true);
			request.onreadystatechange = function() 
			{
				if(request.readyState == 4 &#038;&#038; request.status == 200){
			
					var eq_json = request.responseText;
					var eq = eval('(' + eq_json + ')');
					
					var i;
					for(i in eq)
					{
						
						var lat_lng = eq[i].geo_point[0].split(" ");
						var titulo = eq[i].nombre[0].split(",");
						var magnitud = titulo[0].split(" ");
		
						var xhtml = "lugar = " + titulo[1] + ", " + titulo[2] + "&lt;br />";
						xhtml += "magnitud = " + magnitud[1] + "° Richter&lt;br />";
						xhtml += "fecha = " + eq[i].fecha[0] + "&lt;br />";
						xhtml += "elevación = " + eq[i].geo_elev[0]/1000 + " [Km]&lt;br />";
						xhtml += "posición = " + eq[i].geo_point[0] + "&lt;br />";
						
						var point = new GLatLng(lat_lng[0],lat_lng[1]);
						setMarker(point, xhtml);
					}
					//end for
				
				}
			}
			
			request.send(null);

		}
	window.setInterval("reFresh()",60000); //recarga la pag cada 1 minuto
	}​
	&lt;/script>
&lt;/head>
&lt;body onload="initialize()" onunload="GUnload()">
	&lt;div id="map_canvas" style="width: 700px; height:550px">&lt;/div>
&lt;/body>
&lt;/html>
</pre>
]]></content:encoded>
			<wfw:commentRss>http://profesores.elo.utfsm.cl/~wcreixell/?feed=rss2&#038;p=160</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
