<?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/"
	>

<channel>
	<title>Dave Ruiz blog &#187; Programación</title>
	<atom:link href="http://blog.daveruiz.net/category/programacion/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.daveruiz.net</link>
	<description>programador web freelance</description>
	<lastBuildDate>Fri, 27 Aug 2010 09:00:04 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>jQuery: Colocar puntos suspensivos cuando un texto no cabe en una linea.</title>
		<link>http://blog.daveruiz.net/programacion/jquery-colocar-puntos-suspensivos-cuando-un-texto-no-cabe-en-una-linea/</link>
		<comments>http://blog.daveruiz.net/programacion/jquery-colocar-puntos-suspensivos-cuando-un-texto-no-cabe-en-una-linea/#comments</comments>
		<pubDate>Thu, 26 Aug 2010 10:07:02 +0000</pubDate>
		<dc:creator>Dave Ruiz</dc:creator>
				<category><![CDATA[Programación]]></category>
		<category><![CDATA[ellipsis]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[puntos suspensivos]]></category>
		<category><![CDATA[textoverflow]]></category>

		<guid isPermaLink="false">http://blog.daveruiz.net/?p=356</guid>
		<description><![CDATA[Un pequeño script rápido y muy sencillo que he elaborado para jQuery, que hace lo que el título de esta entrada. Hasta ahora estaba usando uno de los textOverflow que andan por ahí, pero me estaban dando algún problema.

$.fn.ellipsis = function&#40;&#41; &#123; return this.each&#40; function&#40;&#41; &#123;
&#160;
	var tar = $&#40;this&#41;,
		ow, ls, tg, 
		tw=tar.css&#40;&#123;&#34;display&#34;:&#34;block&#34;,&#34;white-space&#34;:&#34;nowrap&#34;&#125;&#41;.width&#40;&#41;, 
		ot=tar.html&#40;&#41;, pt=ot,
		alt=tar.text&#40;&#41;,
		ok=false, 
		ct=false,
		el=' [...]]]></description>
			<content:encoded><![CDATA[<p>Un pequeño script rápido y muy sencillo que he elaborado para <strong>jQuery</strong>, que hace lo que el título de esta entrada. Hasta ahora estaba usando uno de los <em>textOverflow</em> que andan <a href="http://www.google.es/search?hl=es&amp;q=jquery+textoverflow&amp;aq=f&amp;aqi=&amp;aql=&amp;oq=&amp;gs_rfai=" target="_blank">por ahí</a>, pero me estaban dando algún problema.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">$.<span style="color: #660066;">fn</span>.<span style="color: #660066;">ellipsis</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">each</span><span style="color: #009900;">&#40;</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #003366; font-weight: bold;">var</span> tar <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
		ow<span style="color: #339933;">,</span> ls<span style="color: #339933;">,</span> tg<span style="color: #339933;">,</span> 
		tw<span style="color: #339933;">=</span>tar.<span style="color: #660066;">css</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span><span style="color: #3366CC;">&quot;display&quot;</span><span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;block&quot;</span><span style="color: #339933;">,</span><span style="color: #3366CC;">&quot;white-space&quot;</span><span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;nowrap&quot;</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">width</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> 
		ot<span style="color: #339933;">=</span>tar.<span style="color: #660066;">html</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> pt<span style="color: #339933;">=</span>ot<span style="color: #339933;">,</span>
		alt<span style="color: #339933;">=</span>tar.<span style="color: #660066;">text</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
		ok<span style="color: #339933;">=</span><span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">,</span> 
		ct<span style="color: #339933;">=</span><span style="color: #003366; font-weight: bold;">false</span><span style="color: #339933;">,</span>
		el<span style="color: #339933;">=</span><span style="color: #3366CC;">' &amp;hellip;'</span><span style="color: #339933;">;</span>
&nbsp;
	tar.<span style="color: #660066;">css</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span><span style="color: #3366CC;">&quot;position&quot;</span><span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;absolute&quot;</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000066; font-weight: bold;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>ok<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		ow <span style="color: #339933;">=</span> tar.<span style="color: #660066;">css</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span><span style="color: #3366CC;">&quot;width&quot;</span><span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;auto&quot;</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">width</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>ow <span style="color: #339933;">&gt;</span> tw<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			ls <span style="color: #339933;">=</span> pt.<span style="color: #660066;">lastIndexOf</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot; &quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			tg <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">new</span> RegExp<span style="color: #009900;">&#40;</span> <span style="color: #3366CC;">&quot;&lt;[^&gt;]*$&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;g&quot;</span> <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">test</span><span style="color: #009900;">&#40;</span> pt.<span style="color: #660066;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">0</span><span style="color: #339933;">,</span> ls<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>ls <span style="color: #339933;">&gt;</span> <span style="color: #CC0000;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> 
				pt <span style="color: #339933;">=</span> pt.<span style="color: #660066;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #CC0000;">0</span><span style="color: #339933;">,</span> ls<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				tar.<span style="color: #660066;">html</span><span style="color: #009900;">&#40;</span> pt <span style="color: #339933;">+</span> el <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				ct<span style="color: #339933;">=</span><span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
				tar.<span style="color: #660066;">html</span><span style="color: #009900;">&#40;</span> el <span style="color: #009900;">&#41;</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;title&quot;</span><span style="color: #339933;">,</span> alt<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				ok<span style="color: #339933;">=</span><span style="color: #003366; font-weight: bold;">true</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #339933;">!</span>tg<span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
		<span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span> 
			<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>ct<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				tar.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;title&quot;</span><span style="color: #339933;">,</span> alt<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				tar.<span style="color: #660066;">css</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span><span style="color: #3366CC;">&quot;display&quot;</span><span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;block&quot;</span><span style="color: #339933;">,</span><span style="color: #3366CC;">&quot;width&quot;</span><span style="color: #339933;">:</span>tw<span style="color: #339933;">+</span><span style="color: #3366CC;">&quot;px&quot;</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
			ok <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
	tar.<span style="color: #660066;">css</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span><span style="color: #3366CC;">&quot;position&quot;</span><span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;&quot;</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span></pre></div></div>

<p>Y para usarlo.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;.textodeunalinea&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">ellipsis</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span></pre></div></div>

<p><strong>Actualización 27-10-2010:</strong> Se han hecho algunas correcciones. Y un detalle; se porta un poquito mal cuando hay Html en el texto. Pendiente de corregir.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.daveruiz.net/programacion/jquery-colocar-puntos-suspensivos-cuando-un-texto-no-cabe-en-una-linea/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>JS: Convertir un objeto en una cadena XML</title>
		<link>http://blog.daveruiz.net/programacion/js-convertir-un-objeto-en-una-cadena-xml/</link>
		<comments>http://blog.daveruiz.net/programacion/js-convertir-un-objeto-en-una-cadena-xml/#comments</comments>
		<pubDate>Thu, 04 Mar 2010 09:53:33 +0000</pubDate>
		<dc:creator>Dave Ruiz</dc:creator>
				<category><![CDATA[Programación]]></category>

		<guid isPermaLink="false">http://blog.daveruiz.net/?p=308</guid>
		<description><![CDATA[Os dejo una pequeña y sencilla función para realizar esta tarea en Javascript. Evidentemente, está sujeto a las mejoras que creáis convenientes.

function XMLString&#40; object, name, recursiveCall &#41; &#123;
	var xml = &#34;&#34;, i;
	var isArray = typeof&#40;object&#41; === 'object' &#38;&#38; typeof&#40;object.length&#41; === 'number' &#38;&#38;  !&#40;object.propertyIsEnumerable&#40;'length'&#41;&#41; &#38;&#38; typeof&#40;object.splice === 'function'&#41;;
&#160;
	if &#40;!recursiveCall&#41;	&#123;
		xml += &#34;&#60;?xml version=\&#34;1.0\&#34; ?&#62;&#34;;;
		xml += &#34;&#60;&#34;+name+&#34; xmlns:xsi=\&#34;http://www.w3.org/2001/XMLSchema-instance\&#34; xmlns:xsd=\&#34;http://www.w3.org/2001/XMLSchema\&#34;&#62;&#34;;
	&#125; [...]]]></description>
			<content:encoded><![CDATA[<p>Os dejo una pequeña y sencilla función para realizar esta tarea en Javascript. Evidentemente, está sujeto a las mejoras que creáis convenientes.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">function</span> XMLString<span style="color: #009900;">&#40;</span> object<span style="color: #339933;">,</span> <span style="color: #000066;">name</span><span style="color: #339933;">,</span> recursiveCall <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #003366; font-weight: bold;">var</span> xml <span style="color: #339933;">=</span> <span style="color: #3366CC;">&quot;&quot;</span><span style="color: #339933;">,</span> i<span style="color: #339933;">;</span>
	<span style="color: #003366; font-weight: bold;">var</span> isArray <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">typeof</span><span style="color: #009900;">&#40;</span>object<span style="color: #009900;">&#41;</span> <span style="color: #339933;">===</span> <span style="color: #3366CC;">'object'</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #000066; font-weight: bold;">typeof</span><span style="color: #009900;">&#40;</span>object.<span style="color: #660066;">length</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">===</span> <span style="color: #3366CC;">'number'</span> <span style="color: #339933;">&amp;&amp;</span>  <span style="color: #339933;">!</span><span style="color: #009900;">&#40;</span>object.<span style="color: #660066;">propertyIsEnumerable</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'length'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #000066; font-weight: bold;">typeof</span><span style="color: #009900;">&#40;</span>object.<span style="color: #660066;">splice</span> <span style="color: #339933;">===</span> <span style="color: #3366CC;">'function'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>recursiveCall<span style="color: #009900;">&#41;</span>	<span style="color: #009900;">&#123;</span>
		xml <span style="color: #339933;">+=</span> <span style="color: #3366CC;">&quot;&lt;?xml version=<span style="color: #000099; font-weight: bold;">\&quot;</span>1.0<span style="color: #000099; font-weight: bold;">\&quot;</span> ?&gt;&quot;</span><span style="color: #339933;">;;</span>
		xml <span style="color: #339933;">+=</span> <span style="color: #3366CC;">&quot;&lt;&quot;</span><span style="color: #339933;">+</span><span style="color: #000066;">name</span><span style="color: #339933;">+</span><span style="color: #3366CC;">&quot; xmlns:xsi=<span style="color: #000099; font-weight: bold;">\&quot;</span>http://www.w3.org/2001/XMLSchema-instance<span style="color: #000099; font-weight: bold;">\&quot;</span> xmlns:xsd=<span style="color: #000099; font-weight: bold;">\&quot;</span>http://www.w3.org/2001/XMLSchema<span style="color: #000099; font-weight: bold;">\&quot;</span>&gt;&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span> <span style="color: #000066; font-weight: bold;">else</span> <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>isArray<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		xml <span style="color: #339933;">+=</span> <span style="color: #3366CC;">&quot;&lt;&quot;</span><span style="color: #339933;">+</span><span style="color: #000066;">name</span><span style="color: #339933;">+</span><span style="color: #3366CC;">&quot;&gt;&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">typeof</span><span style="color: #009900;">&#40;</span>object<span style="color: #009900;">&#41;</span> <span style="color: #339933;">===</span> <span style="color: #3366CC;">&quot;undefined&quot;</span> <span style="color: #339933;">||</span> object <span style="color: #339933;">==</span> <span style="color: #003366; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #3366CC;">&quot;&quot;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">//Nada</span>
	<span style="color: #000066; font-weight: bold;">else</span> <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">typeof</span><span style="color: #009900;">&#40;</span>object<span style="color: #009900;">&#41;</span> <span style="color: #339933;">===</span> <span style="color: #3366CC;">&quot;object&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #000066; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span>i <span style="color: #000066; font-weight: bold;">in</span> object<span style="color: #009900;">&#41;</span> xml <span style="color: #339933;">+=</span> XMLString<span style="color: #009900;">&#40;</span> object<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> isArray<span style="color: #339933;">?</span><span style="color: #000066;">name</span><span style="color: #339933;">:</span>i<span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// Un objeto o array</span>
	<span style="color: #000066; font-weight: bold;">else</span> xml <span style="color: #339933;">+=</span> object<span style="color: #339933;">;</span> <span style="color: #006600; font-style: italic;">// Un texto</span>
&nbsp;
	<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>isArray <span style="color: #339933;">||</span> <span style="color: #339933;">!</span>recursiveCall<span style="color: #009900;">&#41;</span> xml <span style="color: #339933;">+=</span> <span style="color: #3366CC;">&quot;&lt;/&quot;</span><span style="color: #339933;">+</span><span style="color: #000066;">name</span><span style="color: #339933;">+</span><span style="color: #3366CC;">&quot;&gt;&quot;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000066; font-weight: bold;">return</span> xml<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Y un ejemplo de uso sería:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> objeto <span style="color: #339933;">=</span> <span style="color: #009900;">&#123;</span>
	campo1 <span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;valor1&quot;</span><span style="color: #339933;">,</span>
	campo2 <span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;valor2&quot;</span><span style="color: #339933;">,</span>
	campo3 <span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;valor3&quot;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span> XMLString<span style="color: #009900;">&#40;</span> objeto<span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;XML&quot;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Donde el <strong>primer parámetro</strong> es el <span style="text-decoration: underline;">objeto a convertir</span>, y el <strong>segundo</strong> es el <span style="text-decoration: underline;">nombre del elemento raíz</span>. Con el ejemplo anterior obtendríamos como salida la siguiente cadena:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;XML</span> <span style="color: #000066;">xmlns:xsi</span>=<span style="color: #ff0000;">&quot;http://www.w3.org/2001/XMLSchema-instance&quot;</span> <span style="color: #000066;">xmlns:xsd</span>=<span style="color: #ff0000;">&quot;http://www.w3.org/2001/XMLSchema&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;campo1<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>valor1<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/campo1<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;campo2<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>valor2<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/campo2<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;campo3<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>valor3<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/campo3<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/XML<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>Con 4 cambios es posible convertirlo en código AS2 o AS3. Aunque en estos casos creo que hay métodos mejores y nativos para hacer esta función.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.daveruiz.net/programacion/js-convertir-un-objeto-en-una-cadena-xml/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Javascript: Habilitar :hover en todos los elementos para Internet Explorer con jQuery</title>
		<link>http://blog.daveruiz.net/programacion/javascript-habilitar-hover-en-todos-los-elementos-para-internet-explorer-con-jquery/</link>
		<comments>http://blog.daveruiz.net/programacion/javascript-habilitar-hover-en-todos-los-elementos-para-internet-explorer-con-jquery/#comments</comments>
		<pubDate>Thu, 12 Nov 2009 15:49:28 +0000</pubDate>
		<dc:creator>Dave Ruiz</dc:creator>
				<category><![CDATA[Programación]]></category>

		<guid isPermaLink="false">http://blog.daveruiz.net/?p=286</guid>
		<description><![CDATA[De todos es conocido el problema de emplear la pseudo-clase :hover con Internet Explorer 6. Este funciona solamente con los hipervínculos (&#60;a&#62;&#60;/a&#62;) dejando fuera al resto de elementos.
Con la ayuda de jQuery, podemos solventar de manera fácil este problema añadiendo unas lineas al inicio del script, y teniendo en cuenta una regla en el CSS [...]]]></description>
			<content:encoded><![CDATA[<p>De todos es conocido el problema de emplear la pseudo-clase <strong>:hover</strong> con Internet Explorer 6. Este funciona solamente con los hipervínculos (<em>&lt;a&gt;&lt;/a&gt;</em>) dejando fuera al resto de elementos.</p>
<p>Con la ayuda de <strong>jQuery</strong>, podemos solventar de manera fácil este problema añadiendo unas lineas al inicio del script, y teniendo en cuenta una regla en el CSS que contenga los estilos.</p>
<p>Por ejemplo, teniendo el siguiente CSS:</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #cc00cc;">#menu</span> li<span style="color: #3333ff;">:hover </span><span style="color: #00AA00;">&#123;</span>
<span style="color: #000000; font-weight: bold;">text-decoration</span><span style="color: #3333ff;">:underline</span><span style="color: #00AA00;">:</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<p>Habría que modificarlo tal que:</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;"><span style="color: #cc00cc;">#menu</span> li<span style="color: #3333ff;">:hover</span><span style="color: #00AA00;">,</span> <span style="color: #cc00cc;">#menu</span> li<span style="color: #6666ff;">.hover</span> <span style="color: #00AA00;">&#123;</span>
<span style="color: #000000; font-weight: bold;">text-decoration</span><span style="color: #00AA00;">:</span><span style="color: #993333;">underline</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<p>De manera que podamos acceder a dicho estilo mediante una clase.</p>
<p>Y ahora, solo quedaría realizar un script que añada la clase o la elimine según el evento llamado. Para ello emplearemos la función hover(mouseOver, mouseOut) que nos facilita jQuery.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">ready</span><span style="color: #009900;">&#40;</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>$.<span style="color: #660066;">browser</span>.<span style="color: #660066;">msie</span><span style="color: #009900;">&#41;</span> $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;*&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">hover</span><span style="color: #009900;">&#40;</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">addClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;hover&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">removeClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;hover&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Y a funcionar <img src='http://blog.daveruiz.net/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://blog.daveruiz.net/programacion/javascript-habilitar-hover-en-todos-los-elementos-para-internet-explorer-con-jquery/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>AS3: Detener descarga del componente FLVPlayback</title>
		<link>http://blog.daveruiz.net/programacion/as3-detener-descarga-del-componente-flvplayback/</link>
		<comments>http://blog.daveruiz.net/programacion/as3-detener-descarga-del-componente-flvplayback/#comments</comments>
		<pubDate>Fri, 04 Sep 2009 07:19:07 +0000</pubDate>
		<dc:creator>Dave Ruiz</dc:creator>
				<category><![CDATA[Programación]]></category>
		<category><![CDATA[as3]]></category>
		<category><![CDATA[componente]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[flv]]></category>
		<category><![CDATA[flvcomponent]]></category>
		<category><![CDATA[video]]></category>

		<guid isPermaLink="false">http://blog.daveruiz.net/?p=257</guid>
		<description><![CDATA[Por alguna razón, Adobe no implementó un método para detener la descarga de un archivo FLV cuando queremos eliminar un componente FLVPlayback. Puedes crear un reproductor FLV dinámicamente y luego destruirlo, pero si ha comenzado la reproducción el fichero FLV continuará descargándose hasta que termine.
La clase FLVPlayback implementa el método closeVideoPlayer( índice ) que permite [...]]]></description>
			<content:encoded><![CDATA[<p>Por alguna razón, Adobe no implementó un método para detener la descarga de un archivo FLV cuando queremos eliminar un componente FLVPlayback. Puedes crear un reproductor FLV dinámicamente y luego destruirlo, pero si ha comenzado la reproducción el fichero FLV continuará descargándose hasta que termine.</p>
<p>La clase FLVPlayback implementa el método <em>closeVideoPlayer( índice ) </em>que permite detener la descarga del archivo FLV que esté descargando, pero está limitado a cuando abres múltiples vídeos en un solo componente. La limitación consiste en no dejarte eliminar el la conexión de video con la que creaste el reproductor.</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">// Creamos el reproductor y lo ponemos a reproducir</span>
<span style="color: #000000; font-weight: bold;">var</span> <span style="color: #0066CC;">video</span>:FlvPlayback = <span style="color: #000000; font-weight: bold;">new</span> FlvPlayback<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #0066CC;">video</span>.<span style="color: #0066CC;">play</span><span style="color: #66cc66;">&#40;</span> <span style="color: #ff0000;">&quot;video.flv&quot;</span> <span style="color: #66cc66;">&#41;</span>;</pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">// Ahora intentamos cerrar el reproductor</span>
<span style="color: #0066CC;">video</span>.<span style="color: #0066CC;">stop</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #0066CC;">video</span>.<span style="color: #006600;">closeVideoPlayer</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;">// Debería detener la descarga, pero nos lanza un error</span>
<span style="color: #0066CC;">video</span> = <span style="color: #000000; font-weight: bold;">null</span>; <span style="color: #808080; font-style: italic;">// Para que el Garbage Collector lo elimine de memoria</span></pre></div></div>

<p>Si en el ejemplo omitimos <em>video.closeVideoPlayer(0)</em>, el reproductor se elimina, pero el vídeo continúa descargándose y consumiendo ancho de banda.</p>
<p>Esto puede ser un problema cuando haces uso de varias instancias de este componente, y debido a las circunstancias no puedes usar uno solo. Cada una de ellas llamará a la descarga de un FLV, y puede darse el caso de estar descargando varios FLV a la vez, con el consiguiente consumo de ancho de banda.</p>
<p>La solución, acceder a la primera instancia VideoPlayer y detenerlo uno mismo:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">// Ahora intentamos cerrar el reproductor</span>
<span style="color: #0066CC;">video</span>.<span style="color: #0066CC;">stop</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #0066CC;">video</span>.<span style="color: #006600;">getVideoPlayer</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #0066CC;">close</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;">// Ahora sí, detiene la descarga del archivo FLV</span>
<span style="color: #0066CC;">video</span> = <span style="color: #000000; font-weight: bold;">null</span>; <span style="color: #808080; font-style: italic;">// Para que el Garbage Collector lo elimine de memoria</span></pre></div></div>

<p>Algo muy sencillo, pero que ya me ha hecho perder algo de tiempo buscándolo <img src='http://blog.daveruiz.net/wp-includes/images/smilies/icon_razz.gif' alt=':P' class='wp-smiley' /> .  Aquí lo dejo como apunte.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.daveruiz.net/programacion/as3-detener-descarga-del-componente-flvplayback/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>Javascript: Cuando onload no es lanzado (actualizado)</title>
		<link>http://blog.daveruiz.net/programacion/cuando-onload-no-es-lanzado/</link>
		<comments>http://blog.daveruiz.net/programacion/cuando-onload-no-es-lanzado/#comments</comments>
		<pubDate>Tue, 11 Aug 2009 22:10:30 +0000</pubDate>
		<dc:creator>Dave Ruiz</dc:creator>
				<category><![CDATA[Programación]]></category>
		<category><![CDATA[complete]]></category>
		<category><![CDATA[error]]></category>
		<category><![CDATA[ie]]></category>
		<category><![CDATA[internet explorer]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[onload]]></category>

		<guid isPermaLink="false">http://blog.daveruiz.net/?p=238</guid>
		<description><![CDATA[En ocasiones, ocurre que el evento onLoad, por ejemplo, de una imagen no es lanzado a la hora de cargar una página.
Imaginemos que en el script de una página, una vez cargado el DOM, añadimos una función determinada cuando carga la imagen de cabecera:

&#60;script type=&#34;text/javascript&#34;&#62;
  // Función que ejecutamos al cargar el DOM de [...]]]></description>
			<content:encoded><![CDATA[<p>En ocasiones, ocurre que el evento <strong>onLoad</strong>, por ejemplo, de una imagen no es lanzado a la hora de cargar una página.</p>
<p>Imaginemos que en el script de una página, una vez cargado el DOM, añadimos una función determinada cuando carga la imagen de cabecera:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span><span style="color: #339933;">&gt;</span>
  <span style="color: #006600; font-style: italic;">// Función que ejecutamos al cargar el DOM de la página</span>
  window.<span style="color: #000066;">onload</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #003366; font-weight: bold;">var</span> cabecera <span style="color: #339933;">=</span> document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;cabecera&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #006600; font-style: italic;">// Funcion lanzada cuando carga la imagen 'cabecera'</span>
    cabecera.<span style="color: #000066;">onload</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;carga completa&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   <span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span></pre></div></div>

<p>Nos encontraremos con que en algún navegador (por ejemplo, Internet Explorer) lanza la primera vez el evento, pero en las posteriores cargas este no es lanzado.</p>
<p>La razón es que, en la segunda carga, la imagen se encuentra cacheada y por tanto el navegador carga la imagen en cuanto inserta el elemento <em>IMG</em>, lanzando el correspondiente evento <em>onLoad</em>. Como en ese preciso momento todavía estamos cargando la estructura de la página y el evento no ha sido asignado (no se asigna hasta la carga completa de la estructura), cuando queremos asignarlo ya es demasiado tarde.</p>
<p><del datetime="2009-08-12T06:19:12+00:00">Otros navegadores como Mozilla Firefox no lanzan los eventos hasta que se ha completado la carga del DOM, haciendo inexistente este problema.</del></p>
<p>Una solución sencilla es comprobar, después de asignar el evento <em>onLoad </em>a la imagen, si esta ya se encuentra cargada complétamente. Nos serviremos del parámetro <strong>complete</strong>. Si nos devuelve <em>true</em>, lanzamos el evento <em>onLoad</em> manualmente.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span><span style="color: #339933;">&gt;</span>
  <span style="color: #006600; font-style: italic;">// Función que ejecutamos al cargar el DOM de la página</span>
  window.<span style="color: #000066;">onload</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #003366; font-weight: bold;">var</span> cabecera <span style="color: #339933;">=</span> document.<span style="color: #660066;">getElementById</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;cabecera&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #006600; font-style: italic;">// Funcion lanzada cuando carga la imagen 'cabecera'</span>
    cabecera.<span style="color: #000066;">onload</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;carga completa&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>cabecera.<span style="color: #660066;">complete</span> <span style="color: #339933;">==</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span> cabecera.<span style="color: #000066;">onload</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span></pre></div></div>

<p><strong>Actualización:</strong></p>
<p>Me comenta Marc Palau (y con toda la razón) que el ejemplo anterior no es válido porque <em>onLoad</em> no es lanzado hasta que carga toda la página, incluidas las imágenes. En este caso, nunca seran llamados los eventos <em>onLoad</em> de las imágenes porque se están definiendo después de haberlas cargado.</p>
<p>Para reproducir el error, he preparado <a href="http://lab.daveruiz.net/jquery.problema_onload/">una prueba</a> en la que se testea el framework <strong>jQuery</strong> y la función <strong><a href="http://www.thefutureoftheweb.com/blog/adddomloadevent">addDOMLoadEvent</a></strong> (el ejemplo que ponen en el enlace añade la imagen dinámicamente y no lo reproduce). Del mismo modo, se presenta una solución para ambas basados en el mismo procedimiento comentado antes.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.daveruiz.net/programacion/cuando-onload-no-es-lanzado/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Resaltar automáticamente enlaces con jQuery</title>
		<link>http://blog.daveruiz.net/programacion/auto-marcado-de-enlaces-con-jquery/</link>
		<comments>http://blog.daveruiz.net/programacion/auto-marcado-de-enlaces-con-jquery/#comments</comments>
		<pubDate>Thu, 30 Jul 2009 09:27:25 +0000</pubDate>
		<dc:creator>Dave Ruiz</dc:creator>
				<category><![CDATA[Programación]]></category>
		<category><![CDATA[auto-highlight]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[marcado de enlaces]]></category>

		<guid isPermaLink="false">http://blog.daveruiz.net/?p=209</guid>
		<description><![CDATA[A modo de apunte, os dejo un método breve, usando jQuery, para resaltar los enlaces que apuntan a la página en la que nos encontramos. Muy útil, por ejemplo, para destacar en los menús la opción seleccionada automáticamente sin recurrir a PHP o a hacerlo manualmente:

$&#40;document&#41;.ready&#40; function&#40;&#41; &#123;
  var loc = document.location.href.split&#40;/[\?#]/&#41;.shift&#40;&#41;.replace&#40;/\/$/, ''&#41;;
&#160;
  [...]]]></description>
			<content:encoded><![CDATA[<p>A modo de apunte, os dejo un método breve, usando <a href="http://jquery.com/" target="_blank">jQuery</a>, para resaltar los enlaces que apuntan a la página en la que nos encontramos. Muy útil, por ejemplo, para destacar en los menús la opción seleccionada automáticamente sin recurrir a PHP o a hacerlo manualmente:</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">$<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">ready</span><span style="color: #009900;">&#40;</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #003366; font-weight: bold;">var</span> loc <span style="color: #339933;">=</span> document.<span style="color: #660066;">location</span>.<span style="color: #660066;">href</span>.<span style="color: #660066;">split</span><span style="color: #009900;">&#40;</span><span style="color: #009966; font-style: italic;">/[\?#]/</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">shift</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">replace</span><span style="color: #009900;">&#40;</span><span style="color: #009966; font-style: italic;">/\/$/</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">''</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;a&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">each</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">href</span> <span style="color: #339933;">==</span> loc<span style="color: #009900;">&#41;</span> $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">addClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;selected&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>El funcionamiento es muy simple. Recorre todos los elementos <strong>&lt;a&gt;</strong> de la página y compara el parámetro <strong>href</strong> con la url actual. Si coincide, añade la clase &#8216;<strong>selected</strong>&#8216; a dicho elemento. La clase &#8217;selected&#8217; deberá estar definida dentro de los estilos css de la página.</p>
<p>Un ejemplo <a href="http://lab.daveruiz.net/jquery.linkhighlight">aquí</a>.</p>
<p><strong>Actualización:</strong> Ahora no tiene en cuenta si la URL tiene barra al final o no (como en el caso de las carpetas)</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.daveruiz.net/programacion/auto-marcado-de-enlaces-con-jquery/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Precarga Flash de una sola linea.</title>
		<link>http://blog.daveruiz.net/programacion/precarga-flash-de-una-sola-linea/</link>
		<comments>http://blog.daveruiz.net/programacion/precarga-flash-de-una-sola-linea/#comments</comments>
		<pubDate>Wed, 03 Jun 2009 12:26:50 +0000</pubDate>
		<dc:creator>Dave Ruiz</dc:creator>
				<category><![CDATA[Programación]]></category>
		<category><![CDATA[as3]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[precarga]]></category>

		<guid isPermaLink="false">http://blog.daveruiz.net/?p=199</guid>
		<description><![CDATA[Una precarga (muy) sencilla para Flash (AS3).  Suponiendo que el primer fotograma está vacío, podemos incluir el siguiente código en la linea de tiempo principal:
stop(); root.loaderInfo.addEventListener(Event.COMPLETE, function(e:Event) { play(); });
Esto comenzará a reproducir el flash en cuanto termine de cargar. Además, podemos aprovechar el primer fotograma para poner un mensaje &#8216;cargando&#8230; &#8216;, que será lo [...]]]></description>
			<content:encoded><![CDATA[<p>Una <strong>precarga (muy) sencilla </strong>para Flash (<strong>AS3</strong>).  Suponiendo que el primer fotograma está vacío, podemos incluir el siguiente código en la linea de tiempo principal:</p>
<p><code>stop(); root.loaderInfo.addEventListener(Event.COMPLETE, function(e:Event) { play(); });</code></p>
<p>Esto comenzará a reproducir el flash en cuanto termine de cargar. Además, podemos aprovechar el primer fotograma para poner un mensaje &#8216;<em>cargando&#8230; </em>&#8216;, que será lo que se muestre mientras se completa la carga.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.daveruiz.net/programacion/precarga-flash-de-una-sola-linea/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Comparativa entre bucles Javascript</title>
		<link>http://blog.daveruiz.net/programacion/comparativa-entre-bucles-javascript/</link>
		<comments>http://blog.daveruiz.net/programacion/comparativa-entre-bucles-javascript/#comments</comments>
		<pubDate>Fri, 29 May 2009 14:38:48 +0000</pubDate>
		<dc:creator>Dave Ruiz</dc:creator>
				<category><![CDATA[Programación]]></category>
		<category><![CDATA[bucles]]></category>
		<category><![CDATA[comparativa]]></category>
		<category><![CDATA[for]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[while]]></category>

		<guid isPermaLink="false">http://blog.daveruiz.net/?p=184</guid>
		<description><![CDATA[Extendiendo el artículo original de aNieto2k, &#8220;for reverso para grandes interaciones en Javascript&#8220;, he modificado el test que ha creado para realizar una comparativa entre los bucles for y while, sumando o restando valores e incrementándolo mediante las formas i++ y ++i. En este caso, he fijado el número de iteraciones a 5.000.000.
El resultado: probadlo [...]]]></description>
			<content:encoded><![CDATA[<p>Extendiendo el artículo original de <a href="http://www.anieto2k.com">aNieto2k</a>, <strong><a title="Enlace a for reverso para grandes interaciones en Javascript" rel="bookmark" href="http://www.anieto2k.com/2009/05/28/for-reverso-para-grandes-interaciones-en-javascript/">&#8220;for reverso para grandes interaciones en Javascript</a></strong>&#8220;, he modificado el test que ha creado para realizar una comparativa entre los bucles<em> for</em> y <em>while</em>, sumando o restando valores e incrementándolo mediante las formas <em>i++</em> y <em>++i</em>. En este caso, he fijado el número de iteraciones a 5.000.000.</p>
<p>El resultado: probadlo <a href="http://lab.daveruiz.net/test.comparativa-bucles/">vosotros mismos</a>. Yo obtuve los siguientes valores, con un Firefox 3.0.10:</p>
<blockquote><p>[ for i++ ] tiempo: 246ms. (5000000 iteraciones)<br />
[ while i++ ] tiempo: 225ms. (5000000 iteraciones)<br />
[ for ++i ] tiempo: 247ms. (5000000 iteraciones)<br />
[ while ++i ] tiempo: 221ms. (5000000 iteraciones)<br />
[ for i-- ] tiempo: 229ms. (5000000 iteraciones)<br />
[ while i-- ] tiempo: 213ms. (5000000 iteraciones)<br />
[ for --i ] tiempo: 221ms. (5000000 iteraciones)<br />
[ while --i ] tiempo: 212ms. (5000000 iteraciones)</p></blockquote>
<p>Según estos resultados, en Javascript al menos, daría prácticamente igual emplear la forma i++ e ++i. El ganador, un <em><strong>while &#8212; </strong></em>por goleada <img src='http://blog.daveruiz.net/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> .</p>
<p>Actualización: Acabo de probarlo en IE7, y salta una advertencia de que un script puede estar ralentizando la web (¡si la espera no llega a medio segundo!). Dicha advertencia falsea los tiempos de todas las pruebas (hasta que no pulsas &#8216;aceptar&#8217; no para de correr el tiempo), así recomiendo ejecutarla en cualquier otro navegador. Por cierto, ¡¡impresionante cómo va el <a href="http://www.google.com/chrome/">Chrome 2</a>!!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.daveruiz.net/programacion/comparativa-entre-bucles-javascript/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CSS3 round borders por doquier</title>
		<link>http://blog.daveruiz.net/programacion/css3-round-borders-po-doquier/</link>
		<comments>http://blog.daveruiz.net/programacion/css3-round-borders-po-doquier/#comments</comments>
		<pubDate>Thu, 02 Apr 2009 15:22:51 +0000</pubDate>
		<dc:creator>Dave Ruiz</dc:creator>
				<category><![CDATA[Experimentos]]></category>
		<category><![CDATA[Programación]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[borders]]></category>
		<category><![CDATA[css3]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[round]]></category>

		<guid isPermaLink="false">http://blog.daveruiz.net/?p=153</guid>
		<description><![CDATA[Mientras llega o no la revisión de CSS Level3 ¿Como quedarán mis páginas favoritas con bordes redondeados?

javascript:function a&#40;c&#41; &#123; j=document.getElementsByTagName&#40;&#34;*&#34;&#41;; for &#40;i in j&#41; &#123; if&#40;j&#91;i&#93;.style&#41; j&#91;i&#93;.style.WebkitBorderRadius=j&#91;i&#93;.style.MozBorderRadius=c+&#34;px&#34;; &#125; &#125;;a&#40;15&#41;


Y un ejemplo de cómo queda:

Qué cuco queda youtube  

]]></description>
			<content:encoded><![CDATA[<p>Mientras llega o no la revisión de <a title="W3C - CSS3" href="http://www.w3.org/TR/css3-roadmap/" target="_blank">CSS Level3</a> ¿Como quedarán mis páginas favoritas con bordes redondeados?</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;">javascript<span style="color: #339933;">:</span><span style="color: #003366; font-weight: bold;">function</span> a<span style="color: #009900;">&#40;</span>c<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> j<span style="color: #339933;">=</span>document.<span style="color: #660066;">getElementsByTagName</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;*&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000066; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span>i <span style="color: #000066; font-weight: bold;">in</span> j<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>j<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">style</span><span style="color: #009900;">&#41;</span> j<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">style</span>.<span style="color: #660066;">WebkitBorderRadius</span><span style="color: #339933;">=</span>j<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>.<span style="color: #660066;">style</span>.<span style="color: #660066;">MozBorderRadius</span><span style="color: #339933;">=</span>c<span style="color: #339933;">+</span><span style="color: #3366CC;">&quot;px&quot;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span> <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>a<span style="color: #009900;">&#40;</span><span style="color: #CC0000;">15</span><span style="color: #009900;">&#41;</span></pre></div></div>

<p style="text-align: center;"><a title="Aplicar bordes redondeados" href="javascript:function a(c) { j=document.getElementsByTagName('*'); for (i in j) { if(j[i].style) j[i].style.WebkitBorderRadius=j[i].style.MozBorderRadius=c+'px'; } };a(15)"><img class="size-full wp-image-222 aligncenter no-shadow" title="Aplicar bordes redondeados" src="http://blog.daveruiz.net/wp-content/uploads/favoritos.png" alt="Aplicar bordes redondeados" width="220" height="47" /></a></p>
<p>Y un ejemplo de cómo queda:</p>
<p style="text-align: center;"><a href="http://www.w3.org"><img class="size-full wp-image-170 aligncenter" title="Ejemplo de border-radius sobre w3.org" src="http://blog.daveruiz.net/wp-content/uploads/w3c.jpg" alt="Ejemplo de border-radius sobre w3.org" width="400" height="206" /></a></p>
<p style="text-align: left;">Qué cuco queda youtube <img src='http://blog.daveruiz.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p style="text-align: center;"><a href="http://www.youtube.com"><img class="size-full wp-image-174 aligncenter" title="Ejemplo de border-radius sobre youtube.com" src="http://blog.daveruiz.net/wp-content/uploads/youtube_rounded.jpg" alt="Youtube.com con bordes redondeados" width="400" height="169" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.daveruiz.net/programacion/css3-round-borders-po-doquier/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fuentes no estandar en tu web con jQuery</title>
		<link>http://blog.daveruiz.net/programacion/fuentes-no-estandar-en-tu-web-con-jquery/</link>
		<comments>http://blog.daveruiz.net/programacion/fuentes-no-estandar-en-tu-web-con-jquery/#comments</comments>
		<pubDate>Tue, 10 Feb 2009 09:43:29 +0000</pubDate>
		<dc:creator>Dave Ruiz</dc:creator>
				<category><![CDATA[Open Source]]></category>
		<category><![CDATA[Programación]]></category>
		<category><![CDATA[estandar]]></category>
		<category><![CDATA[fuentes]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[replacefonts]]></category>
		<category><![CDATA[Web]]></category>

		<guid isPermaLink="false">http://blog.daveruiz.net/?p=103</guid>
		<description><![CDATA[Se trata de un código no intrusivo y accesible que símplemente sustituye el contenido de una selección por una imagen a base de tocar la hoja de estilos.
Para que funcione corréctamente necesitaremos la ayuda de jQuery y, evidentemente, tener instalada la fuente que queremos representar (solo en tu equipo). La técnica consta de los siguientes [...]]]></description>
			<content:encoded><![CDATA[<p>Se trata de un código no intrusivo y accesible que símplemente sustituye el contenido de una selección por una imagen a base de tocar la hoja de estilos.</p>
<p>Para que funcione corréctamente necesitaremos la ayuda de <a title="jQuery" href="http://jquery.com/" target="_blank">jQuery</a> y, evidentemente, <strong>tener instalada la fuente que queremos representar</strong> (solo en tu equipo). La técnica consta de los siguientes pasos:</p>
<ol>
<li>Incluir en la cabecera el script en cuestión:
<pre>&lt;script type="text/javascript" src="jquery.js"&gt;&lt;/script&gt;
&lt;script type="text/javascript" src="jquery.replacefonts.js"&gt;&lt;/script&gt;</pre>
</li>
<li>Llamar a la función con el selector que nosotros deseemos. Para este ejemplo tomaremos todos los contenedores con la clase &#8220;titulo&#8221;:
<pre>&lt;script type="text/javascript"&gt;&lt;!--
   $(".titulo").replacefonts();
--&gt;&lt;/script&gt;</pre>
</li>
<p>Ya tenemos el script funcionando, pero nos falta crear las imágenes que contienen los textos. Para ello emplearemos cualquier editor de imágenes sencillo (creo que vale hasta el mismísimo paint) y la función de capturar pantalla del sistema. Continuamos con los siguientes pasos:</p>
<li>Abrimos la página que estamos modificando con el explorador, pero añadiéndole al final de la URL lo siguiente: <em>#dev</em>. Esto hará que se muestre un recuadro rojo alrededor de los elementos de la clase &#8220;titulo&#8221; que no han cargado imagen, facilitando así la tarea de recorte.
<p align="center"><a href="http://blog.daveruiz.net/wp-content/uploads/recorte1.jpg"><img class="aligncenter size-medium wp-image-116" title="Area de recorte" src="http://blog.daveruiz.net/wp-content/uploads/recorte1-300x96.jpg" alt="" width="300" height="96" /></a></p>
</li>
<li>Una vez hechas todas las capturas las guardamos. Por defecto el script va a buscar las imagenes a la carpeta <em>img/titles/</em> y con extensión <em>.gif</em>. Esto <span style="text-decoration: underline;">se puede modificar en las primeras lineas del script</span>. Y respecto al <strong>nombre </strong>que se ha de poner, si el elemento tiene el <strong>atríbuto ID</strong> lo empleará para generar el nombre, de lo contrario generará un nombre <strong>a partir del texto del contenido</strong> empleando solo las <span style="text-decoration: underline;">letras en minúsculas</span>. Por ejemplo:
<pre>HOTEL RESERVATION / Registration Deadline: 31/12/2010</pre>
<p>pasaría a ser:</p>
<pre>hotelreservationregistrationdeadline31122010.gif</pre>
</li>
</ol>
<p>Y esto es todo. Ventajas veo al usar este método:</p>
<ul>
<li>Si no esta habilitado javascript simplemente te deja el texto con la siguiente fuente disponible.</li>
<li>La edición de imagenes se limita a capturar y recortar el area señalada en rojo, sin tener que reescribir todos los textos.</li>
<li>Vemos realmente cómo va a quedar en la página antes de crear la imagen.</li>
<li>Usando los nombres generados automáticamente, al cambiar el contenido del texto cambia la imagen. Así prevenimos que el texto real no coincida con el de la imagen.</li>
</ul>
<p><strong>Actualización: </strong>Más tarde encuentro este enlace: <a href="http://www.disenorama.com/articulos/reemplazo-de-textos-una-comparacion" target="_blank">http://www.disenorama.com/articulos/reemplazo-de-textos-una-comparacion</a>, donde explican varios métodos, pros y contras para realizar esto mismo. Como siempre, es muy difícil innovar en estas cosas. <img src='http://blog.daveruiz.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p><strong>Actualización: </strong>He actualizado el código. Ahora detecta si la fuente está instalada (gracias al código de<a title="Lalit lab" href="http://www.lalit.org/lab/javascript-css-font-detect" target="_blank"> Lalit</a>) y no hace nada en caso afirmativo. Además, si el elemento a sustituir es un contenedor de enlace <em>&lt;A&gt;</em> para el evento mouseover establece la imagen con el mismo nombre acabado en &#8216;_hover&#8217;, simulando la pseudoclase :hover.</p>
<p>[Descarga: <a title="Descarga jquery.replacefonts.js" href="http://lab.daveruiz.net/jquery.replacefonts/jquery.replacefonts.js" target="_blank">http://lab.daveruiz.net/jquery.replacefonts/jquery.replacefonts.js</a>]</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.daveruiz.net/programacion/fuentes-no-estandar-en-tu-web-con-jquery/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
