<?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>unijimpe &#187; Mootools</title> <atom:link href="http://blog.unijimpe.net/category/mootools/feed/" rel="self" type="application/rss+xml" /><link>http://blog.unijimpe.net</link> <description>Desarrollo Web, SEO, Adsense</description> <lastBuildDate>Mon, 28 Nov 2011 03:18:21 +0000</lastBuildDate> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.3.1</generator> <item><title>Seguimiento de descargas con Google Analytics</title><link>http://blog.unijimpe.net/seguimiento-de-descargas-con-google-analytics/</link> <comments>http://blog.unijimpe.net/seguimiento-de-descargas-con-google-analytics/#comments</comments> <pubDate>Mon, 31 Oct 2011 02:48:19 +0000</pubDate> <dc:creator>unijimpe</dc:creator> <category><![CDATA[General]]></category> <category><![CDATA[Google]]></category> <category><![CDATA[Javascript]]></category> <category><![CDATA[jQuery]]></category> <category><![CDATA[Mootools]]></category> <category><![CDATA[Servicios Web]]></category> <category><![CDATA[analytics]]></category><guid isPermaLink="false">http://blog.unijimpe.net/?p=1299</guid> <description><![CDATA[<p>Google Analytics el popular servicio de estadísticas de visitas ofrece muchas características que permiten conocer al detalle la interacción que tiene el usuario con nuestra web. Una de ellas es hacer el seguimiento de todos los &#8230;</p>]]></description> <content:encoded><![CDATA[<p>Google Analytics el popular servicio de estadísticas de visitas ofrece muchas características que permiten conocer al detalle la interacción que tiene el usuario con nuestra web. Una de ellas es hacer el seguimiento de todos los archivos de descargas, esto no se hace de forma automática por lo que hay que agregar un código adicional.</p><p><strong>Utilizando Google Analytics</strong></p><p>El primer paso es utilizar el código de seguimiento en nuestra página, actualmente se utiliza la versión asincrona la cual se debe colocar justo antes de la etiqueta <code>&lt;/head&gt;</code></p><div class="syntax_hilite"><div id="javascript-8"><div class="javascript"><ol><li style="color:#3A6A8B;"><div style="">&lt;script type=<span style="color: #3366CC;">"text/javascript"</span>&gt;</div></li><li style="color:#26536A;"><div style="">&nbsp; <span style="color: #003366;">var</span> _gaq = _gaq || <span style="color: #66cc66;">&#91;</span><span style="color: #66cc66;">&#93;</span>;</div></li><li style="color:#3A6A8B;"><div style="">&nbsp; _gaq.<span style="color: #006600;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#91;</span><span style="color: #3366CC;">'_setAccount'</span>, <span style="color: #3366CC;">'UA-XXXXX-X'</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="color:#26536A;"><div style="">&nbsp; _gaq.<span style="color: #006600;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#91;</span><span style="color: #3366CC;">'_trackPageview'</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="color:#3A6A8B;"><div style="">&nbsp;</div></li><li style="color:#26536A;"><div style="">&nbsp; <span style="color: #66cc66;">&#40;</span><span style="color: #003366;">function</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp; <span style="color: #003366;">var</span> ga = document.<span style="color: #006600;">createElement</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'script'</span><span style="color: #66cc66;">&#41;</span>; ga.<span style="color: #006600;">type</span> = <span style="color: #3366CC;">'text/javascript'</span>; ga.<span style="color: #006600;">async</span> = <span style="color: #003366;">true</span>;</div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp; ga.<span style="color: #006600;">src</span> = <span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'https:'</span> == document.<span style="color: #006600;">location</span>.<span style="color: #006600;">protocol</span> ? <span style="color: #3366CC;">'https://ssl'</span> : <span style="color: #3366CC;">'http://www'</span><span style="color: #66cc66;">&#41;</span> + <span style="color: #3366CC;">'.google-analytics.com/ga.js'</span>;</div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp; <span style="color: #003366;">var</span> s = document.<span style="color: #006600;">getElementsByTagName</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'script'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#91;</span><span style="color: #CC0000;color:#800000;">0</span><span style="color: #66cc66;">&#93;</span>; s.<span style="color: #006600;">parentNode</span>.<span style="color: #006600;">insertBefore</span><span style="color: #66cc66;">&#40;</span>ga, s<span style="color: #66cc66;">&#41;</span>;</div></li><li style="color:#26536A;"><div style="">&nbsp; <span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="color:#3A6A8B;"><div style="">&lt;/script&gt;</div></li></ol></div></div></div><p></p><p>En donde <em>UA-XXXXX-X</em> es el código de seguimiento del sitio web el cual lo podemos obtener al registrar un sitio web en nuestra cuenta de Google Analytics.</p><p><strong>Seguimiento de descargas con Google Analytics</strong></p><p>Si en nuestra página tenemos archivos de descarga, en enlace de descarga es:</p><div class="syntax_hilite"><div id="html-9"><div class="html"><ol><li style="color:#3A6A8B;"><div style=""><span style="color: #009900;"><a href="http://december.com/html/4/element/a.html"><span style="color: #000000;">&lt;a</span></a> <span style="color: #000066;">href</span>=<span style="color: #ff0000;">"/files/map.pdf"</span><span style="color: #000000;">&gt;</span></a></span>map<span style="color: #009900;"><span style="color: #000000;">&lt;/a&gt;</span></span></div></li></ol></div></div></div><p></p><p>Para que Google Analytics pueda registrar las descargas es necesario agregar una llamada al método <em>_gaq.push</em> en donde el segundo parámetro es un nombre con el cual se identificará la descarga.</p><div class="syntax_hilite"><div id="html-10"><div class="html"><ol><li style="color:#3A6A8B;"><div style=""><span style="color: #009900;"><a href="http://december.com/html/4/element/a.html"><span style="color: #000000;">&lt;a</span></a> <span style="color: #000066;">href</span>=<span style="color: #ff0000;">"/files/map.pdf"</span> <span style="color: #000066;">onClick</span>=<span style="color: #ff0000;">"_gaq.push(['_trackPageview','/files/map.pdf']);"</span><span style="color: #000000;">&gt;</span></a></span>map<span style="color: #009900;"><span style="color: #000000;">&lt;/a&gt;</span></span></div></li></ol></div></div></div><p></p><p>El código es muy sencillo y hay que colocarlo en cada enlace de descarga que se tenga.</p><p><strong>Seguimiento de descargas con Google Analytics y Mootools</strong></p><p>Si utilizas Mootools en tu página, entonces puedes utilizarlo para agregar el código de seguimiento de manera sencilla. Para ello a todos los enlaces de descarga le agregaremos un estilo llamado <em>download</em>.</p><div class="syntax_hilite"><div id="html-11"><div class="html"><ol><li style="color:#3A6A8B;"><div style=""><span style="color: #009900;"><a href="http://december.com/html/4/element/a.html"><span style="color: #000000;">&lt;a</span></a> <span style="color: #000066;">href</span>=<span style="color: #ff0000;">"/files/map.pdf"</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">"download"</span><span style="color: #000000;">&gt;</span></a></span>map<span style="color: #009900;"><span style="color: #000000;">&lt;/a&gt;</span></span></div></li></ol></div></div></div><p></p><p>Luego podemos agregar el siguiente código con el cual se busca todos los enlaces con el estilo <em>download</em> y le agrega la llamada al método <em>_gaq.push</em>.</p><div class="syntax_hilite"><div id="javascript-12"><div class="javascript"><ol><li style="color:#3A6A8B;"><div style="">window.<span style="color: #006600;">addEvent</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'load'</span>, <span style="color: #003366;">function</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp;$$<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'.download'</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">addEvent</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'click'</span>,<span style="color: #003366;">function</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp; &nbsp; _gaq.<span style="color: #006600;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#91;</span><span style="color: #3366CC;">'_trackPageview'</span>, <span style="color: #000066;">this</span>.<span style="color: #006600;">get</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'href'</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">replace</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'http://'</span>,<span style="color: #3366CC;">''</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp;<span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="color:#3A6A8B;"><div style=""><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;</div></li></ol></div></div></div><p></p><p><strong>Seguimiento de descargas con Google Analytics y jQuery</strong></p><p>Si utilizamos jQuery podríamos modificar el código anterior el cual se convertiría en:</p><div class="syntax_hilite"><div id="javascript-13"><div class="javascript"><ol><li style="color:#3A6A8B;"><div style="">$<span style="color: #66cc66;">&#40;</span>document<span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">ready</span><span style="color: #66cc66;">&#40;</span><span style="color: #003366;">function</span> <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp;$<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'a.download'</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">click</span><span style="color: #66cc66;">&#40;</span><span style="color: #003366;">function</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp; &nbsp; _gaq.<span style="color: #006600;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#91;</span><span style="color: #3366CC;">'_trackPageview'</span>, $<span style="color: #66cc66;">&#40;</span><span style="color: #000066;">this</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">attr</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'href'</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">replace</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'http://'</span>,<span style="color: #3366CC;">''</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp;<span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="color:#3A6A8B;"><div style=""><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;</div></li></ol></div></div></div><p></p><p><strong>Seguimiento de descargas automático</strong></p><p>Si todas estas formas te parecen complicadas o ya tienes un sitio con muchas páginas y resulta complejo agregar el código de seguimiento, existe una solución llamada <a href="http://techoctave.com/c7/posts/58-entourage-js-automatic-download-tracking-for-asynchronous-google-analytics">Entourage.js</a> el cual agregará de forma automática el código de seguimiento a todos los enlaces que contengan archivos: .pdf, .zip, .doc, .xls, .ppt, .exe, .dmg, .mov, .avi y .mp3.</p><p>Para utilizar este método descargan los archivos y copian el archivo <em>entourage.min.js</em> y lo adjuntan a la página donde desean hacer el seguimiento, esto justo antes de colocar el código de Google Analytics.</p><div class="syntax_hilite"><div id="html-14"><div class="html"><ol><li style="color:#3A6A8B;"><div style=""><span style="color: #009900;"><a href="http://december.com/html/4/element/script.html"><span style="color: #000000;">&lt;script</span></a> <span style="color: #000066;">src</span>=<span style="color: #ff0000;">"js/entourage.min.js"</span><span style="color: #000000;">&gt;</span></a></span><span style="color: #009900;"><span style="color: #000000;">&lt;/script&gt;</span></span></div></li></ol></div></div></div><p></p><p>Esta pequeña librería con un tamaño de solo 579 bytes y que nos facilita de manera muy sencilla el trabajo de hacer el seguimiento de descargas en nuestra página.</p><p><strong>Mas Información</strong></p><ul><li><a href="http://code.google.com/apis/analytics/docs/tracking/asyncTracking.html">Google Analytics: Tracking Site Activity</a></li><li><a href="http://davidwalsh.name/track-file-downloads-google-analytics-mootools">Track File Downloads in Google Analytics Using MooTools</a></li><li><a href="http://techoctave.com/c7/posts/58-entourage-js-automatic-download-tracking-for-asynchronous-google-analytics">Entourage.js - Automatic Download Tracking for Asynchronous Google Analytics</a></li></ul><p style="font-size: 10px;border-top: 1px solid #666666;margin-top=12px;padding-top:6px;">&copy; 2006 - 2011 <a href="http://blog.unijimpe.net">unijimpe</a> - Utiliza este feed solo para uso personal, partes de este feed pueden ser utilizados mencionando al autor, no esta permitido publicar enteramente este feed para uso comercial sin permiso del autor.</p><br /> ]]></content:encoded> <wfw:commentRss>http://blog.unijimpe.net/seguimiento-de-descargas-con-google-analytics/feed/</wfw:commentRss> <slash:comments>4</slash:comments> </item> <item><title>Validar Formularios con Mootools</title><link>http://blog.unijimpe.net/validar-formularios-con-mootools/</link> <comments>http://blog.unijimpe.net/validar-formularios-con-mootools/#comments</comments> <pubDate>Mon, 31 May 2010 04:34:07 +0000</pubDate> <dc:creator>unijimpe</dc:creator> <category><![CDATA[General]]></category> <category><![CDATA[HTML]]></category> <category><![CDATA[Javascript]]></category> <category><![CDATA[Mootools]]></category> <category><![CDATA[estilos]]></category> <category><![CDATA[form]]></category> <category><![CDATA[validación]]></category><guid isPermaLink="false">http://blog.unijimpe.net/?p=1178</guid> <description><![CDATA[<p>En las ultimas versiones de <a href="http://mootools.net">Mootools</a> se ha comenzado a incluir la clase <a href="http://mootools.net/docs/more/Forms/Form.Validator">Form.Validator</a> la cual permite validar formularios de forma sencilla con muchas opciones predefinidas y con la posibilidad de extender con nuevas reglas de &#8230;</p>]]></description> <content:encoded><![CDATA[<p>En las ultimas versiones de <a href="http://mootools.net">Mootools</a> se ha comenzado a incluir la clase <a href="http://mootools.net/docs/more/Forms/Form.Validator">Form.Validator</a> la cual permite validar formularios de forma sencilla con muchas opciones predefinidas y con la posibilidad de extender con nuevas reglas de validación.</p><p><img src="http://blog.unijimpe.net/wp-content/uploads/2010/05/form-validate-mootools1.jpg" alt="" title="form-validate-mootools" width="200" height="286" /></p><p><strong>Preparando para Validar con Mootools</strong></p><p>Lo primero es descargar e incluir el archivo <a href="http://mootools.net/core">mootools.js</a> en nuestro documento, también se necesita descargar e incluir el archivo <a href="http://mootools.net/more">mootools-more.js</a> que debe contener las clases: <em>Form.Validator</em> y <em>Form.Validator.Inline</em>.</p><p><img src="http://blog.unijimpe.net/wp-content/uploads/2010/05/form-valid-config.jpg" alt="" title="form-valid-config" width="500" height="176" /></p><div class="syntax_hilite"><div id="html-21"><div class="html"><ol><li style="color:#3A6A8B;"><div style=""><span style="color: #009900;"><a href="http://december.com/html/4/element/script.html"><span style="color: #000000;">&lt;script</span></a> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">"text/javascript"</span> <span style="color: #000066;">src</span>=<span style="color: #ff0000;">"js/mootools.js"</span><span style="color: #000000;">&gt;</span></a></span><span style="color: #009900;"><span style="color: #000000;">&lt;/script&gt;</span></span></div></li><li style="color:#26536A;"><div style=""><span style="color: #009900;"><a href="http://december.com/html/4/element/script.html"><span style="color: #000000;">&lt;script</span></a> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">"text/javascript"</span> <span style="color: #000066;">src</span>=<span style="color: #ff0000;">"js/mootools-more.js"</span><span style="color: #000000;">&gt;</span></a></span><span style="color: #009900;"><span style="color: #000000;">&lt;/script&gt;</span></span></div></li></ol></div></div></div><p></p><p>También es necesario agregar tres estilos para indicar al usuario el resultado de la validación, estos estilos los creamos en la hoja de estilos de nuestro sitio web donde obviamente los colores y estilos los haremos para que se integren con nuestra web.</p><div class="syntax_hilite"><div id="css-22"><div class="css"><ol><li style="color:#3A6A8B;"><div style=""><span style="color: #6666ff;">.validation-passed </span><span style="color: #66cc66;">&#123;</span> <span style="color: #000000;">border-color</span>: <span style="color: #000000;">blue</span>; <span style="color: #66cc66;">&#125;</span> <span style="color: #808080; font-style: italic;">/* campo valido */</span></div></li><li style="color:#26536A;"><div style=""><span style="color: #6666ff;">.validation-failed </span><span style="color: #66cc66;">&#123;</span> <span style="color: #000000;">border-color</span>: <span style="color: #993333;">red</span>; <span style="color: #66cc66;">&#125;</span> <span style="color: #808080; font-style: italic;">/* campo invalido */</span></div></li><li style="color:#3A6A8B;"><div style=""><span style="color: #6666ff;">.validation-advice </span><span style="color: #66cc66;">&#123;</span> <span style="color: #000000;">color</span>: #C00; <span style="color: #000000;">font-size</span>: 10px; <span style="color: #66cc66;">&#125;</span> <span style="color: #808080; font-style: italic;">/* mensaje de error */</span></div></li></ol></div></div></div><p></p><p><strong>Validaciones Disponibles</strong></p><p>Lo primero es conocer todas las formas de validación disponibles</p><ul><li><strong>IsEmpty</strong>: devuelve verdadero si el campo esta vacío.</li><li><strong>required</strong>: el campo debe ser obligatorio o no debe estar vacío.</li><li><strong>minLength</strong>: verdadero si campo tiene mas de cierta cantidad de caracteres.</li><li><strong>maxLength</strong>: devuelve verdadero si el campo tiene menos de cierta cantidad de  caracteres.</li><li><strong>validate.numeric</strong>: verdadero si el campo es un número</li><li><strong>validate.integer</strong>: verdadero para números enteros, decimales no esta permitidos.</li><li><strong>validate.digits</strong>: verifica si el campo contiene números, espacios y caracteres de puntuación.</li><li><strong>validate.alpha</strong>: verdadero si el campo solo contiene letras.</li><li><strong>validate.alphanum</strong>: el campo es verdadero si contiene unicamente letras y números.</li><li><strong>validate.date</strong>: es verdadero si el campo contiene una fecha (<em>mm/dd/yyyy</em>).</li><li><strong>validate.email</strong>: verifica que el campo contenga un dirección de email.</li><li><strong>validate.url</strong>: verifica que el campo contenga una dirección URL.</li></ul><p><strong>Utilizando Form.Validator</strong></p><p>Para utilizar las formas de validación antes mencionadas estas se deben agregar como si fueran estilos. Si deseamos aplicar mas de una regla podemos hacerlo dejando un espacio en blanco. Veamos un ejemplo de un formulario de registro.</p><div class="syntax_hilite"><div id="html-23"><div class="html"><ol><li style="color:#3A6A8B;"><div style=""><span style="color: #009900;"><a href="http://december.com/html/4/element/form.html"><span style="color: #000000;">&lt;form</span></a> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">"frRegister"</span> <span style="color: #000066;">method</span>=<span style="color: #ff0000;">"post"</span> <span style="color: #000066;">action</span>=<span style="color: #ff0000;">""</span><span style="color: #000000;">&gt;</span></a></span></div></li><li style="color:#26536A;"><div style="">Name:</div></li><li style="color:#3A6A8B;"><div style=""><span style="color: #009900;"><a href="http://december.com/html/4/element/input.html"><span style="color: #000000;">&lt;input</span></a> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">"name"</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">"text"</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">"name"</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">"required"</span> /<span style="color: #000000;">&gt;</span></a></span></div></li><li style="color:#26536A;"><div style="">Username:</div></li><li style="color:#3A6A8B;"><div style=""><span style="color: #009900;"><a href="http://december.com/html/4/element/input.html"><span style="color: #000000;">&lt;input</span></a> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">"user"</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">"text"</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">"user"</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">"required validate-alphanum minLength:5"</span> /<span style="color: #000000;">&gt;</span></a></span></div></li><li style="color:#26536A;"><div style="">Password:</div></li><li style="color:#3A6A8B;"><div style=""><span style="color: #009900;"><a href="http://december.com/html/4/element/input.html"><span style="color: #000000;">&lt;input</span></a> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">"pass"</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">"text"</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">"pass"</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">"required validate-alphanum"</span> /<span style="color: #000000;">&gt;</span></a></span></div></li><li style="color:#26536A;"><div style="">Email:</div></li><li style="color:#3A6A8B;"><div style=""><span style="color: #009900;"><a href="http://december.com/html/4/element/input.html"><span style="color: #000000;">&lt;input</span></a> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">"email"</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">"text"</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">"email"</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">"required validate-email"</span> /<span style="color: #000000;">&gt;</span></a></span></div></li><li style="color:#26536A;"><div style="">Phone:</div></li><li style="color:#3A6A8B;"><div style=""><span style="color: #009900;"><a href="http://december.com/html/4/element/input.html"><span style="color: #000000;">&lt;input</span></a> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">"phone"</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">"text"</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">"phone"</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">"validate-digits"</span> /<span style="color: #000000;">&gt;</span></a></span></div></li><li style="color:#26536A;"><div style=""><span style="color: #009900;"><a href="http://december.com/html/4/element/input.html"><span style="color: #000000;">&lt;input</span></a> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">"button"</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">"btsend"</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">"btsend"</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">"Registro"</span> /<span style="color: #000000;">&gt;</span></a></span></div></li><li style="color:#3A6A8B;"><div style=""><span style="color: #009900;"><span style="color: #000000;">&lt;/form&gt;</span></span></div></li></ol></div></div></div><p></p><p>En el código mostrado hemos creado un formulario con 5 campos, a los cuales hemos aplicado las siguientes reglas:</p><p>- <em>name</em>: debe ser obligatorio y se acepta todos los caracteres.<br /> - <em>user</em>: es obligatorio, solo se aceptan letras y números y deber de 5 caracteres como mínimo.<br /> - <em>pass</em>: es obligatorio y solo se aceptan letras y números.<br /> - <em>email</em>: el texto ingresado debe ser una dirección de email válida y no puede ser vacía.<br /> - <em>phone</em>: campo opcional, pero si se llena solo acepta números, espacios y caracteres de puntuación.</p><p>Luego creamos una instancia del objeto <em>Form.Validator</em> que recibe como parámetro el identificador del formulario que deseamos validar, en seguida agregamos un evento al botón '<em>btsend</em>' el cual procederá a la validación cuando se haga click para enviar el formulario.</p><div class="syntax_hilite"><div id="javascript-24"><div class="javascript"><ol><li style="color:#3A6A8B;"><div style="">window.<span style="color: #006600;">addEvent</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'domready'</span>, <span style="color: #003366;">function</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp; <span style="color: #003366;">var</span> validate = <span style="color: #003366;">new</span> Form.<span style="color: #006600;">Validator</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">"frRegister"</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp; $<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'btsend'</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">addEvent</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'click'</span>, <span style="color: #003366;">function</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp; &nbsp; &nbsp; validate.<span style="color: #006600;">validate</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="color:#26536A;"><div style=""><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;</div></li></ol></div></div></div><p></p><p>Uniendo estos bloques de código tenemos nuestro primer ejemplo de validación con Mootools, podemos ver el resultado en <a href="http://samples.unijimpe.net/mootools-validate/basic.html">Mootools: Form.Validator - Basic</a>.</p><p><strong>Utilizando Form.Validator.Inline</strong></p><p>Si deseamos que al validar el formulario este muestre los mensajes de error junto a cada campo, de esta forma el usuario sabra exactamente cual es el error que tiene en el formulario. Para ello utilizaremos la clase Forma.Validator.Inline la cual tiene la misma sintaxis que el ejemplo anterior:</p><div class="syntax_hilite"><div id="javascript-25"><div class="javascript"><ol><li style="color:#3A6A8B;"><div style="">window.<span style="color: #006600;">addEvent</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'domready'</span>, <span style="color: #003366;">function</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp; <span style="color: #003366;">var</span> validate = <span style="color: #003366;">new</span> Form.<span style="color: #006600;">Validator</span>.<span style="color: #006600;">Inline</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">"frRegister"</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp; $<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'btsend'</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">addEvent</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'click'</span>, <span style="color: #003366;">function</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp; &nbsp; &nbsp; validate.<span style="color: #006600;">validate</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="color:#26536A;"><div style=""><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;</div></li></ol></div></div></div><p></p><p>Pueden ver el ejemplo funcionando en <a href="http://samples.unijimpe.net/mootools-validate/inline.html">Mootools: Form.Validator.Inline</a> y como se puede apreciar esta validación es mucho mas intuitiva para el usuario.</p><p><strong>Mostrando la validación en nuestro Idioma</strong></p><p>Por defecto los mensajes de la validación se muestran en Ingles, si deseamos cambiar de idioma por ejemplo a Español a estos mensajes entonces debemos incluir la clase <em>Form.Validator.Spanish</em> y luego inicializar en Mootools de la siguiente forma:</p><div class="syntax_hilite"><div id="javascript-26"><div class="javascript"><ol><li style="color:#3A6A8B;"><div style="">window.<span style="color: #006600;">addEvent</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'domready'</span>, <span style="color: #003366;">function</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp; MooTools.<span style="color: #006600;">lang</span>.<span style="color: #006600;">setLanguage</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">"es-ES"</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp; validate = <span style="color: #003366;">new</span> Form.<span style="color: #006600;">Validator</span>.<span style="color: #006600;">Inline</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">"frRegister"</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp; $<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'btsend'</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">addEvent</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'click'</span>, <span style="color: #003366;">function</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp; &nbsp; &nbsp; validate.<span style="color: #006600;">validate</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="color:#3A6A8B;"><div style=""><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;</div></li></ol></div></div></div><p></p><p>Pueden ver el resultado del ultimo ejemplo en <a href="http://samples.unijimpe.net/mootools-validate/language.html">Mootools: Form.Validator.Spanish</a> en donde las validaciones se muestran en Español.</p><p>Si estas opciones de validación no son suficientes puedes utilizar una clase adicionar con mas opciones de validación las cuales están documentadas en <a href="http://mootools.net/docs/more/Forms/Form.Validator.Extras">Additional InputValidators</a>.</p><p><strong>Resumiendo:</strong> para validar formularios con Mootools se deben descargar las clases adicionales <em>Form.Validator</em> y <em>Form.Validator.Inline</em>, crear los tres estilos para mostrar las validaciones, aplicar las reglas de validación como si se trataran de estilos. Finalmente se agrega una instancia de la clase <em>Form.Validator</em> para realizar las validaciones.</p><p style="text-align:left;"><a href="http://blog.unijimpe.net/download/mootools-validate.zip" title="Mootools Form.Validate"><img src="http://blog.unijimpe.net/btdown.png" border="0"></a></p><p><strong>Mas Información</strong></p><ul><li><a href="http://mootools.net/docs/more/Forms/Form.Validator">Mootools - Class: Form.Validator</a></li><li><a href="http://mootools.net/docs/more/Forms/Form.Validator.Extras">Mootools - Additional InputValidators</a></li><li><a href="http://mootools.net/docs/more/Core/Lang">Mootools - Class Instance: MooTools.lang</a></li><li><a href="http://mootools.net/blog/2010/04/30/more-than-meets-the-eye-form-validator/">More than Meets the Eye: Form Validator</a></li><li><a href="http://www.chipwreck.de/blog/2009/12/14/mootools-formvalidator-how-to-use-part-1/">Mootools FormValidator – How to use</a></li></ul><p style="font-size: 10px;border-top: 1px solid #666666;margin-top=12px;padding-top:6px;">&copy; 2006 - 2011 <a href="http://blog.unijimpe.net">unijimpe</a> - Utiliza este feed solo para uso personal, partes de este feed pueden ser utilizados mencionando al autor, no esta permitido publicar enteramente este feed para uso comercial sin permiso del autor.</p><br /> ]]></content:encoded> <wfw:commentRss>http://blog.unijimpe.net/validar-formularios-con-mootools/feed/</wfw:commentRss> <slash:comments>16</slash:comments> </item> <item><title>Publicar Archivos Flash con Mootools</title><link>http://blog.unijimpe.net/publicar-archivos-flash-con-mootools/</link> <comments>http://blog.unijimpe.net/publicar-archivos-flash-con-mootools/#comments</comments> <pubDate>Mon, 17 May 2010 04:37:25 +0000</pubDate> <dc:creator>unijimpe</dc:creator> <category><![CDATA[Flash]]></category> <category><![CDATA[General]]></category> <category><![CDATA[Javascript]]></category> <category><![CDATA[Mootools]]></category> <category><![CDATA[allowfullscreen]]></category> <category><![CDATA[flashvars]]></category> <category><![CDATA[swf]]></category> <category><![CDATA[swiff]]></category><guid isPermaLink="false">http://blog.unijimpe.net/?p=1165</guid> <description><![CDATA[<p><a href="http://mootools.net">Mootools</a> la popular librería javascript a partir de su versión 1.2 incluye una nueva clase llamada <strong>Swiff</strong> la cual permite incluir archivos Flash en documentos HTML, además permite agregar eventos y facilita la comunicación <em>Flash-Javascript</em>.&#8230;</p>]]></description> <content:encoded><![CDATA[<p><a href="http://mootools.net">Mootools</a> la popular librería javascript a partir de su versión 1.2 incluye una nueva clase llamada <strong>Swiff</strong> la cual permite incluir archivos Flash en documentos HTML, además permite agregar eventos y facilita la comunicación <em>Flash-Javascript</em>.</p><p><img src="http://blog.unijimpe.net/wp-content/uploads/2010/05/mootools-flash.jpg" alt="" title="mootools-flash" width="300" height="60" /></p><p><strong>Por que usar Mootools en lugar de SWFObject?</strong></p><p><em>SWFObject</em> es el método mas popular para embeber archivo SWF, pero si por alguna necesitad ya estas utilizando Mootools, entonces es preferible utilizarlo para incluir archivos Flash y evitarse llamar a diferentes archivos Javascript externos.</p><p><strong>Utilizar Swiff</strong></p><p>La primera forma es <a href="http://mootools.net/download">descargar Mootools</a> o también puedes utilizarlo directamente desde <a href="http://code.google.com/apis/ajaxlibs/documentation/index.html#mootools">Google Ajax Libraries</a>, de esta forma ni siquiera necesitar tener el archivo en tu hosting. Luego de incluir Mootools podremos utilizar la clase Swiff, el cual tiene la siguiente sintaxis.</p><div class="syntax_hilite"><div id="javascript-32"><div class="javascript"><ol><li style="color:#3A6A8B;"><div style=""><span style="color: #003366;">var</span> myswf = <span style="color: #003366;">new</span> Swiff<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'path-swf'</span>, <span style="color: #66cc66;">&#123;</span> width: ancho, height: alto, container: <span style="color: #3366CC;">'id'</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;</div></li></ol></div></div></div><p></p><p>Donde se tienen los siguientes parámetros:</p><ul><li><strong>path-swf</strong>: es la ruta al archivo SWF a incluir</li><li><strong>ancho</strong>: es el ancho del SWF expresado en pixels.</li><li><strong>alto</strong>: es el alto del SWF expresado en pixels.</li><li><strong>id</strong>: el identificador del elemento html donde se mostrará el SWF.</li></ul><p>Entonces por ejemplo si deseamos incluir un vídeo player de <em>500x320 pixels</em>, entonces el código a utilizar para mostrar el SWF sería de la forma:</p><div class="syntax_hilite"><div id="html-33"><div class="html"><ol><li style="color:#3A6A8B;"><div style=""><span style="color: #009900;"><a href="http://december.com/html/4/element/div.html"><span style="color: #000000;">&lt;div</span></a> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">"player"</span><span style="color: #000000;">&gt;</span></a></span><span style="color: #ddbb00;">&amp;nbsp;</span><span style="color: #009900;"><span style="color: #000000;">&lt;/div&gt;</span></span></div></li><li style="color:#26536A;"><div style=""><span style="color: #009900;"><a href="http://december.com/html/4/element/script.html"><span style="color: #000000;">&lt;script</span></a> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">"text/javascript"</span><span style="color: #000000;">&gt;</span></a></span></div></li><li style="color:#3A6A8B;"><div style="">var myswf = new Swiff('tubeplayer.swf', { width: 500, height: 320, container: 'player'});</div></li><li style="color:#26536A;"><div style=""><span style="color: #009900;"><span style="color: #000000;">&lt;/script&gt;</span></span></div></li></ol></div></div></div><p></p><p><strong>Utilizando Parámetros con Swiff</strong></p><p>Para pasar parámetros al archivo SWF que estamos incluyendo, podemos utilizar la propiedad <em>params</em> el cual contiene una lista de los parámetros a incluir. Entonces si por ejemplo deseamos permitir que el archivo flash pueda ejecutarse en pantalla completa y que el color de fondo sea negro tendríamos el siguiente código.</p><div class="syntax_hilite"><div id="html-34"><div class="html"><ol><li style="color:#3A6A8B;"><div style=""><span style="color: #009900;"><a href="http://december.com/html/4/element/div.html"><span style="color: #000000;">&lt;div</span></a> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">"player"</span><span style="color: #000000;">&gt;</span></a></span><span style="color: #ddbb00;">&amp;nbsp;</span><span style="color: #009900;"><span style="color: #000000;">&lt;/div&gt;</span></span></div></li><li style="color:#26536A;"><div style=""><span style="color: #009900;"><a href="http://december.com/html/4/element/script.html"><span style="color: #000000;">&lt;script</span></a> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">"text/javascript"</span><span style="color: #000000;">&gt;</span></a></span></div></li><li style="color:#3A6A8B;"><div style="">var myswf = new Swiff('tubeplayer.swf', {</div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp; &nbsp; width: 500,</div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp; &nbsp; height: 320,</div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp; &nbsp; container: 'player',</div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp; &nbsp; params: {allowFullScreen: 'true', bgcolor: '#00000'}</div></li><li style="color:#26536A;"><div style="">});</div></li><li style="color:#3A6A8B;"><div style=""><span style="color: #009900;"><span style="color: #000000;">&lt;/script&gt;</span></span></div></li></ol></div></div></div><p></p><p><strong>Pasando Variables con Swiff</strong></p><p>Para pasarle variables al archivo SWF, es necesario hacerlo utilizando <em>flashvars</em>, ello lo podemos hacer con la propiedad <em>vars</em>, entonces si deseamos pasar dos variables a nuestro player tendríamos el siguiente código.</p><div class="syntax_hilite"><div id="html-35"><div class="html"><ol><li style="color:#3A6A8B;"><div style=""><span style="color: #009900;"><a href="http://december.com/html/4/element/div.html"><span style="color: #000000;">&lt;div</span></a> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">"player"</span><span style="color: #000000;">&gt;</span></a></span><span style="color: #ddbb00;">&amp;nbsp;</span><span style="color: #009900;"><span style="color: #000000;">&lt;/div&gt;</span></span></div></li><li style="color:#26536A;"><div style=""><span style="color: #009900;"><a href="http://december.com/html/4/element/script.html"><span style="color: #000000;">&lt;script</span></a> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">"text/javascript"</span><span style="color: #000000;">&gt;</span></a></span></div></li><li style="color:#3A6A8B;"><div style="">var myswf = new Swiff('tubeplayer.swf', {</div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp; &nbsp; width: 500,</div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp; &nbsp; height: 320,</div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp; &nbsp; container: 'player',</div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp; &nbsp; params: {allowFullScreen: 'true', bgcolor: '#00000'},</div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp; &nbsp; vars: {autoPlay: 'true', videoId: 'FNQowwwwYa0'}</div></li><li style="color:#3A6A8B;"><div style="">});</div></li><li style="color:#26536A;"><div style=""><span style="color: #009900;"><span style="color: #000000;">&lt;/script&gt;</span></span></div></li></ol></div></div></div><p></p><p>Uniendo estos elementos tendremos el código completo para incluir archivo SWF en páginas HTML.</p><div class="syntax_hilite"><div id="html-36"><div class="html"><ol><li style="color:#3A6A8B;"><div style=""><span style="color: #009900;"><a href="http://december.com/html/4/element/html.html"><span style="color: #000000;">&lt;html</span></a> xmlns=<span style="color: #ff0000;">"http://www.w3.org/1999/xhtml"</span><span style="color: #000000;">&gt;</span></a></span></div></li><li style="color:#26536A;"><div style=""><span style="color: #009900;"><a href="http://december.com/html/4/element/head.html"><span style="color: #000000;">&lt;head&gt;</span></a></span></div></li><li style="color:#3A6A8B;"><div style=""><span style="color: #009900;"><a href="http://december.com/html/4/element/meta.html"><span style="color: #000000;">&lt;meta</span></a> <span style="color: #000066;">http-equiv</span>=<span style="color: #ff0000;">"Content-Type"</span> <span style="color: #000066;">content</span>=<span style="color: #ff0000;">"text/html; charset=UTF-8"</span> /<span style="color: #000000;">&gt;</span></a></span></div></li><li style="color:#26536A;"><div style=""><span style="color: #009900;"><a href="http://december.com/html/4/element/title.html"><span style="color: #000000;">&lt;title&gt;</span></a></span>Swiff Demo - unijimpe<span style="color: #009900;"><span style="color: #000000;">&lt;/title&gt;</span></span></div></li><li style="color:#3A6A8B;"><div style=""><span style="color: #009900;"><span style="color: #000000;">&lt;/head&gt;</span></span></div></li><li style="color:#26536A;"><div style=""><span style="color: #009900;"><a href="http://december.com/html/4/element/body.html"><span style="color: #000000;">&lt;body&gt;</span></a></span></div></li><li style="color:#3A6A8B;"><div style=""><span style="color: #009900;"><a href="http://december.com/html/4/element/div.html"><span style="color: #000000;">&lt;div</span></a> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">"player"</span><span style="color: #000000;">&gt;</span></a></span><span style="color: #ddbb00;">&amp;nbsp;</span><span style="color: #009900;"><span style="color: #000000;">&lt;/div&gt;</span></span></div></li><li style="color:#26536A;"><div style=""><span style="color: #009900;"><a href="http://december.com/html/4/element/script.html"><span style="color: #000000;">&lt;script</span></a> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">"text/javascript"</span> <span style="color: #000066;">src</span>=<span style="color: #ff0000;">"http://ajax.googleapis.com/ajax/libs/mootools/1.2.4/mootools.js"</span><span style="color: #000000;">&gt;</span></a></span><span style="color: #009900;"><span style="color: #000000;">&lt;/script&gt;</span></span></div></li><li style="color:#3A6A8B;"><div style=""><span style="color: #009900;"><a href="http://december.com/html/4/element/script.html"><span style="color: #000000;">&lt;script</span></a> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">"text/javascript"</span><span style="color: #000000;">&gt;</span></a></span></div></li><li style="color:#26536A;"><div style="">var myswf = new Swiff('tubeplayer.swf', {</div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp; &nbsp; width: 500,</div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp; &nbsp; height: 320,</div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp; &nbsp; container: 'player',</div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp; &nbsp; params: {allowFullScreen: 'true', bgcolor: '#00000'},</div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp; &nbsp; vars: {autoPlay: 'true', videoId: 'FNQowwwwYa0'}</div></li><li style="color:#26536A;"><div style="">});</div></li><li style="color:#3A6A8B;"><div style=""><span style="color: #009900;"><span style="color: #000000;">&lt;/script&gt;</span></span></div></li><li style="color:#26536A;"><div style=""><span style="color: #009900;"><span style="color: #000000;">&lt;/body&gt;</span></span></div></li><li style="color:#3A6A8B;"><div style=""><span style="color: #009900;"><span style="color: #000000;">&lt;/html&gt;</span></span></div></li></ol></div></div></div><p></p><p>Como pueden ver el código para mostrar archivos Flash, sencillo y sin utilizar librerías adicionales con lo cual ahorramos en velocidad de carga para nuestra web. Pueden ver el resultado del ejemplo funcionando en http://samples.unijimpe.net/swiff-swf/.</p><p style="text-align:left;"><a href="http://blog.unijimpe.net/download/swiff-swf.zip" title="SwiffDemo"><img src="http://blog.unijimpe.net/btdown.png" border="0"></a></p><p><strong>Mas Información</strong></p><ul><li><a href="http://mootools.net/docs/core/Utilities/Swiff">Mootools Docs: Swiff</a></li><li><a href="http://mootools.net/blog/2008/02/12/whats-new-in-12-swiff/">What’s New in 1.2: Swiff</a></li><li><a href="http://kb2.adobe.com/cps/127/tn_12701.html">Flash OBJECT and EMBED tag attributes</a></li></ul><p style="font-size: 10px;border-top: 1px solid #666666;margin-top=12px;padding-top:6px;">&copy; 2006 - 2011 <a href="http://blog.unijimpe.net">unijimpe</a> - Utiliza este feed solo para uso personal, partes de este feed pueden ser utilizados mencionando al autor, no esta permitido publicar enteramente este feed para uso comercial sin permiso del autor.</p><br /> ]]></content:encoded> <wfw:commentRss>http://blog.unijimpe.net/publicar-archivos-flash-con-mootools/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>MooEditable: Editor HTML con Mootools</title><link>http://blog.unijimpe.net/mooeditable-editor-html-con-mootools/</link> <comments>http://blog.unijimpe.net/mooeditable-editor-html-con-mootools/#comments</comments> <pubDate>Thu, 08 Oct 2009 18:45:04 +0000</pubDate> <dc:creator>unijimpe</dc:creator> <category><![CDATA[General]]></category> <category><![CDATA[HTML]]></category> <category><![CDATA[Mootools]]></category> <category><![CDATA[editor]]></category> <category><![CDATA[plugin]]></category> <category><![CDATA[textarea]]></category> <category><![CDATA[texto]]></category><guid isPermaLink="false">http://blog.unijimpe.net/?p=1097</guid> <description><![CDATA[<p><a href="http://cheeaun.github.com/mooeditable/">MooEditable</a> es un editor de texto escrito en <a href="http://mootools.net">Mootools</a>. Con esta librería podemos convertir nuestras cajas de texto  o <em>textareas</em> en editores HTML con solo utilizar pocas líneas de código javascript.</p><p>Este editor es compatible &#8230;</p>]]></description> <content:encoded><![CDATA[<p><a href="http://cheeaun.github.com/mooeditable/">MooEditable</a> es un editor de texto escrito en <a href="http://mootools.net">Mootools</a>. Con esta librería podemos convertir nuestras cajas de texto  o <em>textareas</em> en editores HTML con solo utilizar pocas líneas de código javascript.</p><p>Este editor es compatible con Internet Explorer 6/7/8, Firefox 2/3, Opera 9/10 y Safari 3/4, es ligero comparado con otras librerías como TinyMCE, se pueden personalizar los iconos y con una interfaz limpia.</p><p style="text-align:center;"><a href="http://samples.unijimpe.net/mooeditable/"><img src="http://blog.unijimpe.net/wp-content/uploads/2009/10/mooeditable.jpg" alt="mooeditable" title="mooeditable" width="488" height="249" /></a></p><p>Tiene las opciones básicas para formatear texto como: negrita, cursiva, subrayado, tachado, listas además soporte para incluir, imágenes, enlaces, archivos flash y finalmente se pueden incluir las acciones para <em>deshacer</em> y <em>rehacer</em>.</p><p><strong>Como Utilizar MooEditable</strong><br /> Para su funcionamiento se requiere primero Mootools, entonces primero se debe incluir el archivo <em>mootools.js</em> y <em>MooEditable.js</em>, también es necesario incluir la hoja de estilos MooEditable.css el cual incluirá los estilos e imagenes necesarias para el funcionamiento de la librería.</p><div class="syntax_hilite"><div id="html-40"><div class="html"><ol><li style="color:#3A6A8B;"><div style=""><span style="color: #009900;"><a href="http://december.com/html/4/element/link.html"><span style="color: #000000;">&lt;link</span></a> <span style="color: #000066;">rel</span>=<span style="color: #ff0000;">"stylesheet"</span> <span style="color: #000066;">href</span>=<span style="color: #ff0000;">"css/MooEditable.css"</span> /<span style="color: #000000;">&gt;</span></a></span></div></li><li style="color:#26536A;"><div style=""><span style="color: #009900;"><a href="http://december.com/html/4/element/script.html"><span style="color: #000000;">&lt;script</span></a> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">"text/javascript"</span> <span style="color: #000066;">src</span>=<span style="color: #ff0000;">"js/mootools.js"</span><span style="color: #000000;">&gt;</span></a></span><span style="color: #009900;"><span style="color: #000000;">&lt;/script&gt;</span></span></div></li><li style="color:#3A6A8B;"><div style=""><span style="color: #009900;"><a href="http://december.com/html/4/element/script.html"><span style="color: #000000;">&lt;script</span></a> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">"text/javascript"</span> <span style="color: #000066;">src</span>=<span style="color: #ff0000;">"js/MooEditable.js"</span><span style="color: #000000;">&gt;</span></a></span><span style="color: #009900;"><span style="color: #000000;">&lt;/script&gt;</span></span></div></li></ol></div></div></div><p></p><p>El siguiente paso es crear nuestro formulario en el cual debemos insertar un tag <em>textarea</em>, es necesario aplicarle un estilo a este tag para definir el ancho el cual se utilizará para crear el editor.</p><div class="syntax_hilite"><div id="html-41"><div class="html"><ol><li style="color:#3A6A8B;"><div style=""><span style="color: #009900;"><a href="http://december.com/html/4/element/textarea.html"><span style="color: #000000;">&lt;textarea</span></a> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">"content"</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">"content"</span> <span style="color: #000066;">rows</span>=<span style="color: #ff0000;">"10"</span> <span style="color: #000066;">style</span>=<span style="color: #ff0000;">"width: 400px;"</span><span style="color: #000000;">&gt;</span></a></span><span style="color: #009900;"><span style="color: #000000;">&lt;/textarea&gt;</span></span></div></li></ol></div></div></div><p></p><p>Finalmente asignamos el método <em>mooEditable</em> al elemento que contendrá el editor de texto. En nuestro caso se lo asignamos al elemento <em>content</em> que el textarea que hemos creado.</p><div class="syntax_hilite"><div id="javascript-42"><div class="javascript"><ol><li style="color:#3A6A8B;"><div style="">window.<span style="color: #006600;">addEvent</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'domready'</span>, <span style="color: #003366;">function</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span></div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp; $<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'content'</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">mooEditable</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="color:#3A6A8B;"><div style=""><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span></div></li></ol></div></div></div><p></p><p>Con lo cual obtenemos nuestro editor funcionando, pueden ver el resultado en <a href="http://samples.unijimpe.net/mooeditable/">mooeditable</a>. Hay  muchas opciones para personalizar al detalle este editor, para conocer mas acerca de las opciones pueden leer la documentación que viene en el archivo de descarga.</p><p style="text-align:left;"><a href="http://blog.unijimpe.net/download/mooeditable.zip" title="MooEditable"><img src="http://blog.unijimpe.net/btdown.png" border="0"></a></p><p style="font-size: 10px;border-top: 1px solid #666666;margin-top=12px;padding-top:6px;">&copy; 2006 - 2011 <a href="http://blog.unijimpe.net">unijimpe</a> - Utiliza este feed solo para uso personal, partes de este feed pueden ser utilizados mencionando al autor, no esta permitido publicar enteramente este feed para uso comercial sin permiso del autor.</p><br /> ]]></content:encoded> <wfw:commentRss>http://blog.unijimpe.net/mooeditable-editor-html-con-mootools/feed/</wfw:commentRss> <slash:comments>4</slash:comments> </item> <item><title>Mootools Image Cropping</title><link>http://blog.unijimpe.net/mootools-image-cropping/</link> <comments>http://blog.unijimpe.net/mootools-image-cropping/#comments</comments> <pubDate>Tue, 23 Sep 2008 01:31:04 +0000</pubDate> <dc:creator>unijimpe</dc:creator> <category><![CDATA[General]]></category> <category><![CDATA[Javascript]]></category> <category><![CDATA[Mootools]]></category> <category><![CDATA[box.net]]></category> <category><![CDATA[click]]></category> <category><![CDATA[CSS]]></category> <category><![CDATA[eventos]]></category> <category><![CDATA[PHP]]></category> <category><![CDATA[PNG]]></category> <category><![CDATA[Tools]]></category><guid isPermaLink="false">http://blog.unijimpe.net/?p=911</guid> <description><![CDATA[<p><a href="http://www.nwhite.net/MooCrop/">MooCrop</a> es una utilidad para cortar imágenes de forma visual en web utilizando <a href="http://mootools.net">Mootools</a>. Esta librería te permite seleccionar parte de una imagen de forma gráfica, esto unido a un script de servidor te permitirá &#8230;</p>]]></description> <content:encoded><![CDATA[<p><a href="http://www.nwhite.net/MooCrop/">MooCrop</a> es una utilidad para cortar imágenes de forma visual en web utilizando <a href="http://mootools.net">Mootools</a>. Esta librería te permite seleccionar parte de una imagen de forma gráfica, esto unido a un script de servidor te permitirá cortar imágenes sin necesidad de programas adicionales.</p><p style="text-align:center;"><a href="http://samples.unijimpe.net/moocrop/"><img src="http://blog.unijimpe.net/wp-content/uploads/2008/09/moocrop.jpg" alt="" title="moocrop" width="296" height="135" /></a></p><p><strong>Caracteristicas</strong><br /> MooCrop es altamente personalizable, entre las cualidades mas destacables tenemos:</p><ul><li>Completamente personalizable con CSS</li><li>Permite enmascarar la imagen a cortar.</li><li>Facilidad para escalar y mover las zonas a cortar.</li><li>Eventos personalizables.</li><li>Rápido, código limpio</li><li>Funciona en IE 6 &#038; 7, FF 2+, Opera 9.2 y Safari 2 &#038; 3..</li></ul><p><strong>Utilizando MooCrop</strong><br /> Lo primero es descargar las librerías: <a href="http://www.nwhite.net/MooCrop/js/mootools_compressed.js">mootools.js</a> y <a href="http://www.nwhite.net/MooCrop/js/MooCrop.js">MooCrop.js</a>. Luego de ello procedemos a incluir estas librerías en el header del HTML.</p><div class="syntax_hilite"><div id="html-47"><div class="html"><ol><li style="color:#3A6A8B;"><div style=""><span style="color: #009900;"><a href="http://december.com/html/4/element/script.html"><span style="color: #000000;">&lt;script</span></a> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">"text/javascript"</span> <span style="color: #000066;">src</span>=<span style="color: #ff0000;">"mootools.js"</span><span style="color: #000000;">&gt;</span></a></span><span style="color: #009900;"><span style="color: #000000;">&lt;/script&gt;</span></span></div></li><li style="color:#26536A;"><div style=""><span style="color: #009900;"><a href="http://december.com/html/4/element/script.html"><span style="color: #000000;">&lt;script</span></a> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">"text/javascript"</span> <span style="color: #000066;">src</span>=<span style="color: #ff0000;">"MooCrop.js"</span><span style="color: #000000;">&gt;</span></a></span><span style="color: #009900;"><span style="color: #000000;">&lt;/script&gt;</span></span></div></li></ol></div></div></div><p></p><p>El siguiente paso es colocar una imagen al cual hay que agregarle un identificador para luego llamarlo con esta librería.</p><div class="syntax_hilite"><div id="html-48"><div class="html"><ol><li style="color:#3A6A8B;"><div style=""><span style="color: #009900;"><a href="http://december.com/html/4/element/img.html"><span style="color: #000000;">&lt;img</span></a> <span style="color: #000066;">src</span>=<span style="color: #ff0000;">"image.jpg"</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">"imgcrop"</span> /<span style="color: #000000;">&gt;</span></a></span></div></li></ol></div></div></div><p></p><p>Luego llamamos a la clase MooCrop el cual recibe como parámetro el identificador de la imagen al cual  deseamos mostrar la opción para cortar la imagen, con esto ya tenemos la opcion para seleccionar la parte de la imagen que deseamos cortar.</p><div class="syntax_hilite"><div id="javascript-49"><div class="javascript"><ol><li style="color:#3A6A8B;"><div style="">window.<span style="color: #006600;">addEvent</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'load'</span>,<span style="color: #003366;">function</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span></div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp; <span style="color: #003366;">var</span> crop = <span style="color: #003366;">new</span> MooCrop<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'imgcrop'</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="color:#3A6A8B;"><div style=""><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;</div></li></ol></div></div></div><p></p><p>Ahora el siguiente paso es enviar los datos del bloque seleccionado a un script PHP el cual es el encargado de cortar la imagen original. Entonces lo que hacemos es agregar una función en el evento <em>Doble Click</em> el cual envía los datos al script <strong>crop.php</strong>.</p><div class="syntax_hilite"><div id="javascript-50"><div class="javascript"><ol><li style="color:#3A6A8B;"><div style="">window.<span style="color: #006600;">addEvent</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'load'</span>,<span style="color: #003366;">function</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span></div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp; <span style="color: #003366;">var</span> crop = <span style="color: #003366;">new</span> MooCrop<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'imgcrop'</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp; crop.<span style="color: #006600;">addEvent</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'onDblClk'</span>, <span style="color: #003366;">function</span><span style="color: #66cc66;">&#40;</span>img, crop, bound<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span></div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp; &nbsp; &nbsp; $<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'cropped'</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">src</span> = <span style="color: #3366CC;">"crop.php?action=crop&amp;w="</span>+crop.<span style="color: #006600;">width</span>+<span style="color: #3366CC;">"&amp;h="</span>+crop.<span style="color: #006600;">height</span>+<span style="color: #3366CC;">"&amp;x="</span>+crop.<span style="color: #006600;">left</span>+<span style="color: #3366CC;">"&amp;y="</span>+crop.<span style="color: #006600;">top</span>;</div></li><li style="color:#3A6A8B;"><div style="">&nbsp;&nbsp; &nbsp;<span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="color:#26536A;"><div style=""><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;</div></li></ol></div></div></div><p></p><p>Entonces uniendo estos elementos, tenemos listo nuestra aplicación para cortar imágenes al vuelo el cual puedes ver en <a href="http://samples.unijimpe.net/moocrop/">MooCrop Demo</a>. Este script lo puedes utilizar por ejemplo cuando tus usuarios suben sus fotos para darles la posibilidad de cortarlas antes de subirlas.</p><p style="text-align:center;"><a href="http://www.box.net/shared/2li8nyb8lj"><img src="http://blog.unijimpe.net/btdown.png" border="0"></a></p><p style="font-size: 10px;border-top: 1px solid #666666;margin-top=12px;padding-top:6px;">&copy; 2006 - 2011 <a href="http://blog.unijimpe.net">unijimpe</a> - Utiliza este feed solo para uso personal, partes de este feed pueden ser utilizados mencionando al autor, no esta permitido publicar enteramente este feed para uso comercial sin permiso del autor.</p><br /> ]]></content:encoded> <wfw:commentRss>http://blog.unijimpe.net/mootools-image-cropping/feed/</wfw:commentRss> <slash:comments>4</slash:comments> </item> <item><title>AutoClear en Formularios HTML</title><link>http://blog.unijimpe.net/autoclear-formularios-html/</link> <comments>http://blog.unijimpe.net/autoclear-formularios-html/#comments</comments> <pubDate>Tue, 19 Aug 2008 05:44:22 +0000</pubDate> <dc:creator>unijimpe</dc:creator> <category><![CDATA[General]]></category> <category><![CDATA[HTML]]></category> <category><![CDATA[Javascript]]></category> <category><![CDATA[Mootools]]></category> <category><![CDATA[click]]></category> <category><![CDATA[email]]></category> <category><![CDATA[eventos]]></category> <category><![CDATA[Tools]]></category><guid isPermaLink="false">http://blog.unijimpe.net/?p=881</guid> <description><![CDATA[<p>Uno de los métodos mas prácticos para indicar a los usuarios que tipo de información debe ingresar en los formularios es incluir un valor inicial. El siguiente ejemplo ayudará a mostrar valores por defecto los cuales  &#8230;</p>]]></description> <content:encoded><![CDATA[<p>Uno de los métodos mas prácticos para indicar a los usuarios que tipo de información debe ingresar en los formularios es incluir un valor inicial. El siguiente ejemplo ayudará a mostrar valores por defecto los cuales  se limpiarán al acceder al campo y volverán a mostrar el valor iniciar si no se ha ingresado información.</p><p style="text-align:center;"><a href="http://samples.unijimpe.net/autoclear/autoclear-javascript.html"><img src="http://blog.unijimpe.net/wp-content/uploads/2008/08/autoclear-forms.gif" alt="" title="autoclear-forms" width="135" height="179" /></a></p><p><strong>Preparando el Formulario</strong><br /> Lo primero es crear nuestro formulario, lo hacemos de la manera normal donde incluimos los valores iniciales que utilizaremos para indicar al usuario que valores ingresar.</p><div class="syntax_hilite"><div id="html-54"><div class="html"><ol><li style="color:#3A6A8B;"><div style=""><span style="color: #009900;"><a href="http://december.com/html/4/element/strong.html"><span style="color: #000000;">&lt;strong&gt;</span></a></span>Registro de Usuarios:<span style="color: #009900;"><span style="color: #000000;">&lt;/strong&gt;</span></span><span style="color: #009900;"><a href="http://december.com/html/4/element/br.html"><span style="color: #000000;">&lt;br</span></a> /<span style="color: #000000;">&gt;</span></a></span></div></li><li style="color:#26536A;"><div style="">Nombre: <span style="color: #009900;"><a href="http://december.com/html/4/element/input.html"><span style="color: #000000;">&lt;input</span></a> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">"text"</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">"name"</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">"Nombre"</span> /<span style="color: #000000;">&gt;</span></a></span><span style="color: #009900;"><a href="http://december.com/html/4/element/br.html"><span style="color: #000000;">&lt;br</span></a> /<span style="color: #000000;">&gt;</span></a></span></div></li><li style="color:#3A6A8B;"><div style="">Email: <span style="color: #009900;"><a href="http://december.com/html/4/element/input.html"><span style="color: #000000;">&lt;input</span></a> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">"text"</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">"name"</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">"Email"</span> /<span style="color: #000000;">&gt;</span></a></span><span style="color: #009900;"><a href="http://december.com/html/4/element/br.html"><span style="color: #000000;">&lt;br</span></a> /<span style="color: #000000;">&gt;</span></a></span></div></li><li style="color:#26536A;"><div style="">Web: <span style="color: #009900;"><a href="http://december.com/html/4/element/input.html"><span style="color: #000000;">&lt;input</span></a> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">"text"</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">"web"</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">"Direccion Web"</span> /<span style="color: #000000;">&gt;</span></a></span><span style="color: #009900;"><a href="http://december.com/html/4/element/br.html"><span style="color: #000000;">&lt;br</span></a> /<span style="color: #000000;">&gt;</span></a></span></div></li><li style="color:#3A6A8B;"><div style=""><span style="color: #009900;"><a href="http://december.com/html/4/element/input.html"><span style="color: #000000;">&lt;input</span></a> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">"btsend"</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">"button"</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">"Enviar"</span> /<span style="color: #000000;">&gt;</span></a></span></div></li></ol></div></div></div><p></p><p><strong>AutoClear Utilizando Javascript</strong><br /> La primero forma es utilizar solamente Javascript, para ello nos hemos basado en el script propuesto en <a href="http://perishablepress.com/press/2008/07/22/unobtrusive-javascript-autoclear-restore-multiple-inputs-focus/">Unobtrusive JavaScript: Auto-Clear and Restore Multiple Form Inputs on Focus</a>, este script se ejecuta al cargarse la página y recorre todos los elementos <em>input text</em> y guarda el valor inicial del formulario en la propiedad <strong>rel</strong>, luego agrega los eventos a ejecutarse en <strong>onfocus</strong>, <strong>onblur</strong> y <strong>ondblclick</strong>, en donde se verifica si se ha ingresado algún valor para mostrar la ayuda.</p><div class="syntax_hilite"><div id="javascript-55"><div class="javascript"><ol><li style="color:#3A6A8B;"><div style=""><span style="color: #003366;">function</span> init<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span></div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp; <span style="color: #003366;">var</span> inp = document.<span style="color: #006600;">getElementsByTagName</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'input'</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp; <span style="color: #000066;">for</span><span style="color: #66cc66;">&#40;</span><span style="color: #003366;">var</span> i = <span style="color: #CC0000;color:#800000;">0</span>; i &lt;inp.<span style="color: #006600;">length</span>; i++<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">if</span><span style="color: #66cc66;">&#40;</span>inp<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span>.<span style="color: #006600;">type</span> == <span style="color: #3366CC;">'text'</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; inp<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span>.<span style="color: #006600;">setAttribute</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'rel'</span>, inp<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span>.<span style="color: #006600;">defaultValue</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; inp<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span>.<span style="color: #000066;">onfocus</span> = <span style="color: #003366;">function</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">if</span><span style="color: #66cc66;">&#40;</span><span style="color: #000066;">this</span>.<span style="color: #006600;">value</span> == <span style="color: #000066;">this</span>.<span style="color: #006600;">getAttribute</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'rel'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">this</span>.<span style="color: #006600;">value</span> = <span style="color: #3366CC;">''</span>;</div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span> <span style="color: #000066;">else</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">return</span> <span style="color: #003366;">false</span>;</div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; inp<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span>.<span style="color: #000066;">onblur</span> = <span style="color: #003366;">function</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">if</span><span style="color: #66cc66;">&#40;</span><span style="color: #000066;">this</span>.<span style="color: #006600;">value</span> == <span style="color: #3366CC;">''</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">this</span>.<span style="color: #006600;">value</span> = <span style="color: #000066;">this</span>.<span style="color: #006600;">getAttribute</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'rel'</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span> <span style="color: #000066;">else</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">return</span> <span style="color: #003366;">false</span>;</div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; inp<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span>.<span style="color: #006600;">ondblclick</span> = <span style="color: #003366;">function</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">this</span>.<span style="color: #006600;">value</span> = <span style="color: #000066;">this</span>.<span style="color: #006600;">getAttribute</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'rel'</span><span style="color: #66cc66;">&#41;</span></div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div></li><li style="color:#3A6A8B;"><div style=""><span style="color: #66cc66;">&#125;</span></div></li><li style="color:#26536A;"><div style=""><span style="color: #000066;">if</span><span style="color: #66cc66;">&#40;</span>document.<span style="color: #006600;">childNodes</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp; window.<span style="color: #000066;">onload</span> = init</div></li><li style="color:#26536A;"><div style=""><span style="color: #66cc66;">&#125;</span></div></li></ol></div></div></div><p></p><p>Este script los colocamos en el header de nuestro HTML y ya tenemos el efecto <em>AutoClear</em> en nuestro formulario, podemos ver el resultado de este ejemplo en <a href="http://samples.unijimpe.net/autoclear/autoclear-javascript.html">autoclear-javascript.html</a> y si desean  pueden ver el código fuente para ver como si incluyo el script.</p><p><strong>AutoClear Utilizando Mootools</strong><br /> Si estamos utilizando <strong>Mootools</strong>, podemos reescribir esta función, utilizando los selectores de elementos y llamando a la función en el evento <em>domready</em> el cual es llamado cuando se ha cargado la página.</p><div class="syntax_hilite"><div id="javascript-56"><div class="javascript"><ol><li style="color:#3A6A8B;"><div style="">window.<span style="color: #006600;">addEvent</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'domready'</span>, <span style="color: #003366;">function</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp; inp = $$<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'input[type=text]'</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp; inp.<span style="color: #006600;">each</span><span style="color: #66cc66;">&#40;</span><span style="color: #003366;">function</span><span style="color: #66cc66;">&#40;</span>inp<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp; &nbsp; &nbsp; inp.<span style="color: #006600;">setProperty</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'rel'</span>, inp.<span style="color: #006600;">value</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp; &nbsp; &nbsp; inp.<span style="color: #006600;">addEvent</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'focus'</span>, <span style="color: #003366;">function</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span></div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #000066;">this</span>.<span style="color: #006600;">value</span> == <span style="color: #000066;">this</span>.<span style="color: #006600;">getProperty</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'rel'</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span></div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">this</span>.<span style="color: #006600;">value</span> = <span style="color: #3366CC;">''</span>;</div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp; &nbsp; &nbsp; inp.<span style="color: #006600;">addEvent</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'blur'</span>, <span style="color: #003366;">function</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span></div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">if</span> <span style="color: #66cc66;">&#40;</span><span style="color: #000066;">this</span>.<span style="color: #006600;">value</span> == <span style="color: #3366CC;">''</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span></div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">this</span>.<span style="color: #006600;">value</span> = <span style="color: #000066;">this</span>.<span style="color: #006600;">getProperty</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'rel'</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp; &nbsp; &nbsp; inp.<span style="color: #006600;">addEvent</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'dblclick'</span>, <span style="color: #003366;">function</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span></div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">this</span>.<span style="color: #006600;">value</span> = <span style="color: #000066;">this</span>.<span style="color: #006600;">getAttribute</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'rel'</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="color:#3A6A8B;"><div style=""><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;</div></li></ol></div></div></div><p></p><p>Nótese que hemos utilizado la función each de Mootools que nos permite recorrer todos los elemento del array que contienen los campos de texto, lo siguiente es agregar los eventos para detectar el focuso blur. Pueden ver el resultado de esta versión en <a href="http://samples.unijimpe.net/autoclear/autoclear-mootools.html">autoclear-mootools.html</a></p><p style="font-size: 10px;border-top: 1px solid #666666;margin-top=12px;padding-top:6px;">&copy; 2006 - 2011 <a href="http://blog.unijimpe.net">unijimpe</a> - Utiliza este feed solo para uso personal, partes de este feed pueden ser utilizados mencionando al autor, no esta permitido publicar enteramente este feed para uso comercial sin permiso del autor.</p><br /> ]]></content:encoded> <wfw:commentRss>http://blog.unijimpe.net/autoclear-formularios-html/feed/</wfw:commentRss> <slash:comments>8</slash:comments> </item> <item><title>JSON con Mootools</title><link>http://blog.unijimpe.net/json-con-mootools/</link> <comments>http://blog.unijimpe.net/json-con-mootools/#comments</comments> <pubDate>Mon, 21 Jul 2008 00:21:24 +0000</pubDate> <dc:creator>unijimpe</dc:creator> <category><![CDATA[General]]></category> <category><![CDATA[Javascript]]></category> <category><![CDATA[JSON]]></category> <category><![CDATA[Mootools]]></category> <category><![CDATA[AJAX]]></category> <category><![CDATA[API]]></category> <category><![CDATA[box.net]]></category> <category><![CDATA[buscador]]></category> <category><![CDATA[cache]]></category> <category><![CDATA[click]]></category> <category><![CDATA[Flash]]></category> <category><![CDATA[Google]]></category> <category><![CDATA[PHP]]></category> <category><![CDATA[PNG]]></category> <category><![CDATA[proxy]]></category> <category><![CDATA[Tools]]></category><guid isPermaLink="false">http://blog.unijimpe.net/?p=868</guid> <description><![CDATA[<p><strong>JSON</strong> (<em>JavaScript Object Notation</em>) es un formato basado en Javascript para intercambio de datos. JSON es una alternativa a XML pues brinda sencillez al momento de leer los datos, en Javascript puede ser analizado &#8230;</p>]]></description> <content:encoded><![CDATA[<p><strong>JSON</strong> (<em>JavaScript Object Notation</em>) es un formato basado en Javascript para intercambio de datos. JSON es una alternativa a XML pues brinda sencillez al momento de leer los datos, en Javascript puede ser analizado utilizando eval(), además provee sencillez para manipular los datos. Para mas información acerca de las diferencias con XML además de sus virtudes en: <a href="http://es.wikipedia.org/wiki/JSON">JSON</a>.</p><p style="text-align:center;"><a href="http://samples.unijimpe.net/json/search.html"><img src="http://blog.unijimpe.net/wp-content/uploads/2008/07/json-search.gif" alt="" title="json-search" width="400" height="162" class="alignnone size-full wp-image-869" /></a></p><p><strong>Obteniendo los datos</strong><br /> Para nuestro ejemplo vamos a utilizar <a href="http://code.google.com/apis/ajaxsearch/">Google AJAX Search API</a>, el cual es un servicio que nos utilizar los resultados de búsqueda de Google. No utilizaremos la funciones que provee Google si no que lo haremos utilizando JSON, para ello encontramos documentación en <a href="http://code.google.com/apis/ajaxsearch/documentation/reference.html#_intro_fonje">Flash and other Non-Javascript Environments</a>.</p><p>Si deseamos obtener los resultado de la búsqueda de la palabra Google, lo podemos hacer accediendo al siguiente URL:</p><p><a href="http://ajax.googleapis.com/ajax/services/search/web?v=1.0&#038;q=Google">http://ajax.googleapis.com/ajax/services/search/web?v=1.0&#038;q=Google</a></p><p>Este URL devolverá un objeto conteniendo los resultados de la búsqueda en un array ademas de estadísticas de resultados:</p><div class="syntax_hilite"><div id="javascript-65"><div class="javascript"><ol><li style="color:#3A6A8B;"><div style=""><span style="color: #66cc66;">&#123;</span> <span style="color: #3366CC;">"results"</span>: <span style="color: #66cc66;">&#91;</span></div></li><li style="color:#26536A;"><div style="">&nbsp; <span style="color: #66cc66;">&#123;</span></div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp;<span style="color: #3366CC;">"GsearchResultClass"</span>: <span style="color: #3366CC;">"GwebSearch"</span>,</div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp;<span style="color: #3366CC;">"unescapedUrl"</span>: <span style="color: #3366CC;">"http://en.wikipedia.org/wiki/Paris_Hilton"</span>,</div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp;<span style="color: #3366CC;">"url"</span>: <span style="color: #3366CC;">"http://en.wikipedia.org/wiki/Paris_Hilton"</span>,</div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp;<span style="color: #3366CC;">"visibleUrl"</span>: <span style="color: #3366CC;">"en.wikipedia.org"</span>,</div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp;<span style="color: #3366CC;">"cacheUrl"</span>: <span style="color: #3366CC;">"http://www.google.com/search?..."</span>,</div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp;<span style="color: #3366CC;">"title"</span>: <span style="color: #3366CC;">"<span style="color: #000099;">\u</span>003cb<span style="color: #000099;">\u</span>003eParis Hilton<span style="color: #000099;">\u</span>003c/b<span style="color: #000099;">\u</span>003e"</span>,</div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp;<span style="color: #3366CC;">"titleNoFormatting"</span>: <span style="color: #3366CC;">"Paris Hilton"</span>,</div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp;<span style="color: #3366CC;">"content"</span>: <span style="color: #3366CC;">"In 2006, she released her debut..."</span></div></li><li style="color:#3A6A8B;"><div style="">&nbsp; <span style="color: #66cc66;">&#125;</span>,</div></li><li style="color:#26536A;"><div style="">&nbsp; <span style="color: #66cc66;">&#123;</span></div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp;<span style="color: #3366CC;">"GsearchResultClass"</span>: <span style="color: #3366CC;">"GwebSearch"</span>,</div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp;<span style="color: #3366CC;">"unescapedUrl"</span>: <span style="color: #3366CC;">"http://www.imdb.com/name/nm0385296/"</span>,</div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp;<span style="color: #3366CC;">"url"</span>: <span style="color: #3366CC;">"http://www.imdb.com/name/nm0385296/"</span>,</div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp;<span style="color: #3366CC;">"visibleUrl"</span>: <span style="color: #3366CC;">"www.imdb.com"</span>,</div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp;<span style="color: #3366CC;">"cacheUrl"</span>: <span style="color: #3366CC;">"http://www.google.com/search?..."</span>,</div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp;<span style="color: #3366CC;">"title"</span>: <span style="color: #3366CC;">"<span style="color: #000099;">\u</span>003cb<span style="color: #000099;">\u</span>003eParis Hilton<span style="color: #000099;">\u</span>003c/b<span style="color: #000099;">\u</span>003e"</span>,</div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp;<span style="color: #3366CC;">"titleNoFormatting"</span>: <span style="color: #3366CC;">"Paris Hilton"</span>,</div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp;<span style="color: #3366CC;">"content"</span>: <span style="color: #3366CC;">"Self: Zoolander. Socialite..."</span></div></li><li style="color:#3A6A8B;"><div style="">&nbsp; <span style="color: #66cc66;">&#125;</span>,</div></li><li style="color:#26536A;"><div style="">&nbsp; ...</div></li><li style="color:#3A6A8B;"><div style="">&nbsp;<span style="color: #66cc66;">&#93;</span>,</div></li><li style="color:#26536A;"><div style="">&nbsp;<span style="color: #3366CC;">"cursor"</span>: <span style="color: #66cc66;">&#123;</span></div></li><li style="color:#3A6A8B;"><div style="">&nbsp; <span style="color: #3366CC;">"pages"</span>: <span style="color: #66cc66;">&#91;</span></div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp;<span style="color: #66cc66;">&#123;</span> <span style="color: #3366CC;">"start"</span>: <span style="color: #3366CC;">"0"</span>, <span style="color: #3366CC;">"label"</span>: <span style="color: #CC0000;color:#800000;">1</span> <span style="color: #66cc66;">&#125;</span>,</div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp;<span style="color: #66cc66;">&#123;</span> <span style="color: #3366CC;">"start"</span>: <span style="color: #3366CC;">"4"</span>, <span style="color: #3366CC;">"label"</span>: <span style="color: #CC0000;color:#800000;">2</span> <span style="color: #66cc66;">&#125;</span>,</div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp;<span style="color: #66cc66;">&#123;</span> <span style="color: #3366CC;">"start"</span>: <span style="color: #3366CC;">"8"</span>, <span style="color: #3366CC;">"label"</span>: <span style="color: #CC0000;color:#800000;">3</span> <span style="color: #66cc66;">&#125;</span>,</div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp;<span style="color: #66cc66;">&#123;</span> <span style="color: #3366CC;">"start"</span>: <span style="color: #3366CC;">"12"</span>,<span style="color: #3366CC;">"label"</span>: <span style="color: #CC0000;color:#800000;">4</span> <span style="color: #66cc66;">&#125;</span></div></li><li style="color:#26536A;"><div style="">&nbsp; <span style="color: #66cc66;">&#93;</span>,</div></li><li style="color:#3A6A8B;"><div style="">&nbsp; <span style="color: #3366CC;">"estimatedResultCount"</span>: <span style="color: #3366CC;">"59600000"</span>,</div></li><li style="color:#26536A;"><div style="">&nbsp; <span style="color: #3366CC;">"currentPageIndex"</span>: <span style="color: #CC0000;color:#800000;">0</span>,</div></li><li style="color:#3A6A8B;"><div style="">&nbsp; <span style="color: #3366CC;">"moreResultsUrl"</span>: <span style="color: #3366CC;">"http://www.google.com/search?..."</span></div></li><li style="color:#26536A;"><div style="">&nbsp;<span style="color: #66cc66;">&#125;</span></div></li><li style="color:#3A6A8B;"><div style=""><span style="color: #66cc66;">&#125;</span>, <span style="color: #CC0000;color:#800000;">200</span>, <span style="color: #003366;">null</span><span style="color: #66cc66;">&#41;</span></div></li></ol></div></div></div><p></p><p><strong>Creando un Proxy</strong><br /> Normalmente cuando se accede a datos JSON se hacen sobre el mismo dominio, pero como nosotros deseamos acceder a los datos de Google necesitamos crear un <em>proxy</em> para cambiar de dominio los datos recibidos. Esto por que nos browsers no permites acceder a datos de otros dominios. Entonces creamos el archivo <strong>proxy.php</strong>.</p><div class="syntax_hilite"><div id="php-66"><div class="php"><ol><li style="color:#3A6A8B;"><div style=""><span style="color:#0000FF;">$apiQue</span> = <span style="color:#FF0000;">"Google"</span>; <span style="color:#FF9933; font-style:italic;">// variable a consultar</span></div></li><li style="color:#26536A;"><div style=""><span style="color:#0000FF;">$apiKey</span> = <span style="color:#FF0000;">"tu_key_google"</span>; <span style="color:#FF9933; font-style:italic;">// key para acceder al servicio</span></div></li><li style="color:#3A6A8B;"><div style=""><span style="color:#0000FF;">$apiUrl</span> = <span style="color:#FF0000;">"http://ajax.googleapis.com/ajax/services/search/web"</span>;</div></li><li style="color:#26536A;"><div style=""><span style="color:#616100;">if</span> <span style="color:#006600;">&#40;</span><a href="http://www.php.net/isset"><span style="color:#000066;">isset</span></a><span style="color:#006600;">&#40;</span><span style="color:#0000FF;">$_GET</span><span style="color:#006600;">&#91;</span><span style="color:#FF0000;">'query'</span><span style="color:#006600;">&#93;</span><span style="color:#006600;">&#41;</span><span style="color:#006600;">&#41;</span><span style="color:#006600;">&#123;</span></div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp;<span style="color:#0000FF;">$apiQue</span> = <a href="http://www.php.net/urlencode"><span style="color:#000066;">urlencode</span></a><span style="color:#006600;">&#40;</span><span style="color:#0000FF;">$_GET</span><span style="color:#006600;">&#91;</span><span style="color:#FF0000;">'query'</span><span style="color:#006600;">&#93;</span><span style="color:#006600;">&#41;</span>;</div></li><li style="color:#26536A;"><div style=""><span style="color:#006600;">&#125;</span></div></li><li style="color:#3A6A8B;"><div style=""><a href="http://www.php.net/readfile"><span style="color:#000066;">readfile</span></a><span style="color:#006600;">&#40;</span><span style="color:#0000FF;">$apiUrl</span>.<span style="color:#FF0000;">"?v=1.0&amp;key="</span>.<span style="color:#0000FF;">$apiKey</span>.<span style="color:#FF0000;">"&amp;q="</span>.<span style="color:#0000FF;">$apiQue</span><span style="color:#006600;">&#41;</span>;</div></li></ol></div></div></div><p></p><p><strong>Cargando los datos con Mootools</strong><br /> La nueva versión de <a href="http://mootools.net">Mootools</a> trae el método <em>Request.JSON</em> que permite cargar y parsear automáticamente datos JSON, para nuestro caso cargaremos los datos del proxy recién creado y lo mostraremos utilizando la función <em>alert</em>. Primero incluimos la librería <em>Mootools</em> en el header de nuestro html y luego obtenemos los datos JSON.</p><div class="syntax_hilite"><div id="html-67"><div class="html"><ol><li style="color:#3A6A8B;"><div style=""><span style="color: #009900;"><a href="http://december.com/html/4/element/script.html"><span style="color: #000000;">&lt;script</span></a> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">"text/javascript"</span> <span style="color: #000066;">src</span>=<span style="color: #ff0000;">"mootools.js"</span><span style="color: #000000;">&gt;</span></a></span><span style="color: #009900;"><span style="color: #000000;">&lt;/script&gt;</span></span></div></li></ol></div></div></div><p></p><div class="syntax_hilite"><div id="javascript-68"><div class="javascript"><ol><li style="color:#3A6A8B;"><div style="">window.<span style="color: #006600;">addEvent</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'domready'</span>, <span style="color: #003366;">function</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp; <span style="color: #003366;">var</span> path = <span style="color: #3366CC;">"proxy.php?query=unijimpe"</span>;</div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp; <span style="color: #003366;">var</span> json = <span style="color: #003366;">new</span> Request.<span style="color: #006600;">JSON</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>url: path, onComplete: <span style="color: #000066;">onLoad</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp; json.<span style="color: #006600;">get</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp; <span style="color: #003366;">function</span> <span style="color: #000066;">onLoad</span><span style="color: #66cc66;">&#40;</span>obj<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span></div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003366;">var</span> results = obj.<span style="color: #006600;">responseData</span>.<span style="color: #006600;">results</span>;</div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">for</span> <span style="color: #66cc66;">&#40;</span>i=<span style="color: #CC0000;color:#800000;">0</span>; i&lt;results.<span style="color: #006600;">length</span>; i++<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003366;">var</span> tmp = results<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span>;</div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">alert</span><span style="color: #66cc66;">&#40;</span>i + <span style="color: #3366CC;">" --&gt; "</span> + tmp.<span style="color: #006600;">title</span> + <span style="color: #3366CC;">"<span style="color: #000099;">\n</span>"</span> + tmp.<span style="color: #006600;">url</span><span style="color: #66cc66;">&#41;</span></div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div></li><li style="color:#26536A;"><div style=""><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;</div></li></ol></div></div></div><p></p><p>Pueden ver el resultado en: <a href="http://samples.unijimpe.net/json/index.html">/json/index.html</a>.</p><p>Como pueden observar, la función onLoad se ejecuta cuando se ha completado la carga de los datos, dentro de esta función podemos acceder a los datos recién cargados como si fueran objetos es decir podemos acceder a todas sus propiedades utilizando el operador punto (<strong>.</strong>).</p><p>Entonces si deseamos mostrar la cantidad total de resultados podríamos hacer mediante <em>obj.estimatedResultCount</em>, entonces para acceder a los resultados de la búsqueda accedemos a <em>obj.responseData.results</em> el cual contiene un array con los resultados de la búsqueda por lo cual utilizamos un FOR para acceder a cada elemento.</p><p>Ahora si deseamos mostrar estos resultados como HTML y no como alerts, lo primero es crear un div en donde escribiremos los resultados y modificar brevemente nuestro script.</p><div class="syntax_hilite"><div id="javascript-69"><div class="javascript"><ol><li style="color:#3A6A8B;"><div style="">window.<span style="color: #006600;">addEvent</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'domready'</span>, <span style="color: #003366;">function</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp; <span style="color: #003366;">var</span> path = <span style="color: #3366CC;">"proxy.php?query=unijimpe"</span>;</div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp; <span style="color: #003366;">var</span> json = <span style="color: #003366;">new</span> Request.<span style="color: #006600;">JSON</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>url: path, onComplete: <span style="color: #000066;">onLoad</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp; json.<span style="color: #006600;">get</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp; <span style="color: #003366;">function</span> <span style="color: #000066;">onLoad</span><span style="color: #66cc66;">&#40;</span>obj<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span></div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003366;">var</span> tmpHTML = <span style="color: #3366CC;">""</span>;</div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003366;">var</span> results = obj.<span style="color: #006600;">responseData</span>.<span style="color: #006600;">results</span>;</div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">for</span> <span style="color: #66cc66;">&#40;</span>i=<span style="color: #CC0000;color:#800000;">0</span>; i&lt;results.<span style="color: #006600;">length</span>; i++<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003366;">var</span> tmp = results<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span>;</div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tmpHTML+= <span style="color: #3366CC;">"&lt;a href='"</span>+tmp.<span style="color: #006600;">url</span>+<span style="color: #3366CC;">"'&gt;"</span>+tmp.<span style="color: #006600;">title</span>+<span style="color: #3366CC;">"&lt;/a&gt;"</span>;</div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tmpHTML+= <span style="color: #3366CC;">"&lt;br /&gt;"</span>+tmp.<span style="color: #006600;">content</span>+<span style="color: #3366CC;">"&lt;br/&gt;"</span>;</div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tmpHTML+= <span style="color: #3366CC;">"&lt;i&gt;"</span>+tmp.<span style="color: #006600;">url</span>+<span style="color: #3366CC;">"&lt;/i&gt;&lt;br /&gt;&lt;br /&gt;"</span>;</div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp; &nbsp; &nbsp; $<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">"results"</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">set</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">"html"</span>, tmpHTML<span style="color: #66cc66;">&#41;</span>;</div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div></li><li style="color:#26536A;"><div style=""><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;</div></li></ol></div></div></div><p></p><div class="syntax_hilite"><div id="html-70"><div class="html"><ol><li style="color:#3A6A8B;"><div style=""><span style="color: #009900;"><a href="http://december.com/html/4/element/div.html"><span style="color: #000000;">&lt;div</span></a> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">"results"</span><span style="color: #000000;">&gt;</span></a></span>Loading...<span style="color: #009900;"><span style="color: #000000;">&lt;/div&gt;</span></span></div></li></ol></div></div></div><p></p><p>Pueden ver el resultado en: <a href="http://samples.unijimpe.net/json/json.html">/json/json.html</a>.</p><p>Finalmente, agregamos un campo te texto y un botón para crear un formulario de búsqueda para mostrar la potencia de JSON. Esto lo hacemos con el siguiente código.</p><div class="syntax_hilite"><div id="javascript-71"><div class="javascript"><ol><li style="color:#3A6A8B;"><div style="">window.<span style="color: #006600;">addEvent</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'domready'</span>, <span style="color: #003366;">function</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp; <span style="color: #003366;">var</span> path = <span style="color: #3366CC;">"proxy.php?query=unijimpe"</span>;</div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp; <span style="color: #003366;">var</span> json = <span style="color: #003366;">new</span> Request.<span style="color: #006600;">JSON</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>url: path, onComplete: <span style="color: #000066;">onLoad</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp; json.<span style="color: #006600;">get</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp; <span style="color: #003366;">function</span> <span style="color: #000066;">onLoad</span><span style="color: #66cc66;">&#40;</span>obj<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#123;</span></div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003366;">var</span> tmpHTML = <span style="color: #3366CC;">""</span>;</div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003366;">var</span> results = obj.<span style="color: #006600;">responseData</span>.<span style="color: #006600;">results</span>;</div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066;">for</span> <span style="color: #66cc66;">&#40;</span>i=<span style="color: #CC0000;color:#800000;">0</span>; i&lt;results.<span style="color: #006600;">length</span>; i++<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003366;">var</span> tmp = results<span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span>;</div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tmpHTML+= <span style="color: #3366CC;">"&lt;a href='"</span>+tmp.<span style="color: #006600;">url</span>+<span style="color: #3366CC;">"'&gt;"</span>+tmp.<span style="color: #006600;">title</span>+<span style="color: #3366CC;">"&lt;/a&gt;"</span>;</div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tmpHTML+= <span style="color: #3366CC;">"&lt;br /&gt;"</span>+tmp.<span style="color: #006600;">content</span>+<span style="color: #3366CC;">"&lt;br/&gt;"</span>;</div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; tmpHTML+= <span style="color: #3366CC;">"&lt;i&gt;"</span>+tmp.<span style="color: #006600;">url</span>+<span style="color: #3366CC;">"&lt;/i&gt;&lt;br /&gt;&lt;br /&gt;"</span>;</div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp; &nbsp; &nbsp; $<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">"results"</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">set</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">"html"</span>, tmpHTML<span style="color: #66cc66;">&#41;</span>;</div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div></li><li style="color:#26536A;"><div style="">&nbsp;</div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp; <span style="color: #003366;">function</span> sendSearch<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp; &nbsp; &nbsp; $<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">"results"</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">set</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">"html"</span>, <span style="color: #3366CC;">"Loading..."</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp; &nbsp; &nbsp; path = <span style="color: #3366CC;">"proxy.php?query="</span> + $<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">"q"</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">value</span>;</div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp; &nbsp; &nbsp; json = <span style="color: #003366;">new</span> Request.<span style="color: #006600;">JSON</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#123;</span>url:path, onComplete: <span style="color: #000066;">onLoad</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp; &nbsp; &nbsp; json.<span style="color: #006600;">get</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span></div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp;</div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp; $<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">"bt"</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">addEvent</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">"click"</span>, sendSearch<span style="color: #66cc66;">&#41;</span>;</div></li><li style="color:#3A6A8B;"><div style=""><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;</div></li></ol></div></div></div><p></p><div class="syntax_hilite"><div id="html-72"><div class="html"><ol><li style="color:#3A6A8B;"><div style=""><span style="color: #009900;"><a href="http://december.com/html/4/element/div.html"><span style="color: #000000;">&lt;div</span></a> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">"search"</span><span style="color: #000000;">&gt;</span></a></span></div></li><li style="color:#26536A;"><div style="">Buscador JSON</div></li><li style="color:#3A6A8B;"><div style=""><span style="color: #009900;"><a href="http://december.com/html/4/element/input.html"><span style="color: #000000;">&lt;input</span></a> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">"text"</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">"q"</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">"q"</span> /<span style="color: #000000;">&gt;</span></a></span></div></li><li style="color:#26536A;"><div style=""><span style="color: #009900;"><a href="http://december.com/html/4/element/input.html"><span style="color: #000000;">&lt;input</span></a> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">"submit"</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">"bt"</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">"bt"</span> <span style="color: #000066;">value</span>=<span style="color: #ff0000;">"Buscar"</span> /<span style="color: #000000;">&gt;</span></a></span></div></li><li style="color:#3A6A8B;"><div style=""><span style="color: #009900;"><span style="color: #000000;">&lt;/div&gt;</span></span></div></li><li style="color:#26536A;"><div style=""><span style="color: #009900;"><a href="http://december.com/html/4/element/div.html"><span style="color: #000000;">&lt;div</span></a> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">"results"</span><span style="color: #000000;">&gt;</span></a></span><span style="color: #ddbb00;">&amp;nbsp;</span><span style="color: #009900;"><span style="color: #000000;">&lt;/div&gt;</span></span></div></li></ol></div></div></div><p></p><p>Pueden ver el resultado en: <a href="http://samples.unijimpe.net/json/search.html">/json/search.html</a>.</p><p>Como pueden ver utilizando Mootools para manejar JSON es muy fácil el implementar aplicaciones con acceso remoto a datos o también llamado AJAX solo que no estamos utilizando XML y además tenemos la posibilidad de formatear a nuestro antojo los resultados obtenidos.</p><p style="text-align:center;"><a href="http://www.box.net/shared/6zzb80eo8w"><img src="http://blog.unijimpe.net/btdown.png" border="0"></a></p><p><strong>Mas Información</strong></p><ul><li><a href="http://es.wikipedia.org/wiki/JSON">JSON en Wikipedia</a></li><li><a href="http://docs.mootools.net/Request/Request">Mootools - Class: Request</a></li><li><a href="http://docs.mootools.net/Request/Request.JSON">Mootools - Class: Request.JSON</a></li></ul><p style="font-size: 10px;border-top: 1px solid #666666;margin-top=12px;padding-top:6px;">&copy; 2006 - 2011 <a href="http://blog.unijimpe.net">unijimpe</a> - Utiliza este feed solo para uso personal, partes de este feed pueden ser utilizados mencionando al autor, no esta permitido publicar enteramente este feed para uso comercial sin permiso del autor.</p><br /> ]]></content:encoded> <wfw:commentRss>http://blog.unijimpe.net/json-con-mootools/feed/</wfw:commentRss> <slash:comments>3</slash:comments> </item> <item><title>Mootools Calendar</title><link>http://blog.unijimpe.net/mootools-calendar/</link> <comments>http://blog.unijimpe.net/mootools-calendar/#comments</comments> <pubDate>Wed, 25 Jun 2008 03:37:57 +0000</pubDate> <dc:creator>unijimpe</dc:creator> <category><![CDATA[General]]></category> <category><![CDATA[Mootools]]></category> <category><![CDATA[box.net]]></category> <category><![CDATA[calendar]]></category> <category><![CDATA[CSS]]></category> <category><![CDATA[diseño]]></category> <category><![CDATA[Javascript]]></category> <category><![CDATA[plugin]]></category> <category><![CDATA[PNG]]></category> <category><![CDATA[Tools]]></category><guid isPermaLink="false">http://blog.unijimpe.net/?p=856</guid> <description><![CDATA[<p>Hoy les presente un plugin para <strong>Mootools</strong> el cual les permitirá insertar rápidamente un calendario en nuestros formularios y con un resultado altamente atractivo y profesional. Se trata de <a href="http://www.electricprism.com/aeron/calendar/">Calendar</a> una clase que permite incluir un &#8230;</p>]]></description> <content:encoded><![CDATA[<p>Hoy les presente un plugin para <strong>Mootools</strong> el cual les permitirá insertar rápidamente un calendario en nuestros formularios y con un resultado altamente atractivo y profesional. Se trata de <a href="http://www.electricprism.com/aeron/calendar/">Calendar</a> una clase que permite incluir un selector de fecha no-obstrusivo y accesible.</p><p style="text-align:center;"><a href="http://samples.unijimpe.net/moocalendar/"><img src="http://blog.unijimpe.net/wp-content/uploads/2008/06/moocalendar.gif" alt="" title="moocalendar" width="193" height="198" /></a></p><p><strong>Como usar Mootools Calendar</strong><br /> Lo primero es descargar la ultima versión de esta librería en <a href="http://www.electricprism.com/aeron/calendar/js/calendar.js">calendar.js</a>, además de ello es necesario tener Mootools el cual lo pueden descargar desde <a href="http://www.electricprism.com/aeron/calendar/js/mootools.js">mootools.js</a>, luego de ello debes crear un archivo CSS con los estilos que se aplicarán al calendario.</p><p>El siguiente paso es adjuntar las librerías Javascript a nuestro HTML y posteriormente los archivos CSS que contienen los estilos para nuestra página y nuestro calendario.</p><div class="syntax_hilite"><div id="html-77"><div class="html"><ol><li style="color:#3A6A8B;"><div style=""><span style="color: #009900;"><span style="color: #808080; font-style: italic;">&lt;!-- Incluimos el HTML --&gt;</span></span></div></li><li style="color:#26536A;"><div style=""><span style="color: #009900;"><a href="http://december.com/html/4/element/link.html"><span style="color: #000000;">&lt;link</span></a> <span style="color: #000066;">href</span>=<span style="color: #ff0000;">"styles.css"</span> <span style="color: #000066;">rel</span>=<span style="color: #ff0000;">"stylesheet"</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">"text/css"</span><span style="color: #000000;">&gt;</span></a></span></div></li><li style="color:#3A6A8B;"><div style=""><span style="color: #009900;"><a href="http://december.com/html/4/element/link.html"><span style="color: #000000;">&lt;link</span></a> <span style="color: #000066;">href</span>=<span style="color: #ff0000;">"calendar.css"</span> <span style="color: #000066;">rel</span>=<span style="color: #ff0000;">"stylesheet"</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">"text/css"</span><span style="color: #000000;">&gt;</span></a></span></div></li><li style="color:#26536A;"><div style=""><span style="color: #009900;"><span style="color: #808080; font-style: italic;">&lt;!-- Incluimos los Javascript --&gt;</span></span></div></li><li style="color:#3A6A8B;"><div style=""><span style="color: #009900;"><a href="http://december.com/html/4/element/script.html"><span style="color: #000000;">&lt;script</span></a> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">"text/javascript"</span> <span style="color: #000066;">src</span>=<span style="color: #ff0000;">"js/mootools.js"</span><span style="color: #000000;">&gt;</span></a></span><span style="color: #009900;"><span style="color: #000000;">&lt;/script&gt;</span></span></div></li><li style="color:#26536A;"><div style=""><span style="color: #009900;"><a href="http://december.com/html/4/element/script.html"><span style="color: #000000;">&lt;script</span></a> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">"text/javascript"</span> <span style="color: #000066;">src</span>=<span style="color: #ff0000;">"js/calendar.js"</span><span style="color: #000000;">&gt;</span></a></span><span style="color: #009900;"><span style="color: #000000;">&lt;/script&gt;</span></span></div></li></ol></div></div></div><p></p><p>El siguiente paso es crear nuestro formulario en el cual debemos incluir un campo de texto el cual contendrá a nuestro selector de fechas.</p><div class="syntax_hilite"><div id="html-78"><div class="html"><ol><li style="color:#3A6A8B;"><div style=""><span style="color: #009900;"><a href="http://december.com/html/4/element/input.html"><span style="color: #000000;">&lt;input</span></a> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">"text"</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">"fecha"</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">"fecha"</span> <span style="color: #000066;">size</span>=<span style="color: #ff0000;">"16"</span><span style="color: #000000;">&gt;</span></a></span></div></li></ol></div></div></div><p></p><p>Finalmente inicializamos el Calendario con una llamada al objeto Calendar el cual recibe como parámetros el identificador del campo al cual deseamos asignar el calendario y luego el formato en el cual deseamos se muestren las fechas.</p><div class="syntax_hilite"><div id="html-79"><div class="html"><ol><li style="color:#3A6A8B;"><div style=""><span style="color: #009900;"><a href="http://december.com/html/4/element/script.html"><span style="color: #000000;">&lt;script</span></a> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">"text/javascript"</span><span style="color: #000000;">&gt;</span></a></span></div></li><li style="color:#26536A;"><div style="">window.addEvent('domready', function() {</div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp; &nbsp; myCal = new Calendar({ fecha: 'd/m/Y' });</div></li><li style="color:#26536A;"><div style="">});</div></li><li style="color:#3A6A8B;"><div style=""><span style="color: #009900;"><span style="color: #000000;">&lt;/script&gt;</span></span></div></li></ol></div></div></div><p></p><p>Luego unimos todos los elementos para obtener el código final para mostrar un selector de fechas en nuestros formulario, todo de forma rápida y sencilla. Esta inicialización lo hacemos en el evento <strong>domready</strong> que es cuando se ha terminado de interpretar el <em>html</em> de nuestro web.</p><div class="syntax_hilite"><div id="html-80"><div class="html"><ol><li style="color:#3A6A8B;"><div style=""><span style="color: #009900;"><a href="http://december.com/html/4/element/html.html"><span style="color: #000000;">&lt;html&gt;</span></a></span></div></li><li style="color:#26536A;"><div style=""><span style="color: #009900;"><a href="http://december.com/html/4/element/head.html"><span style="color: #000000;">&lt;head&gt;</span></a></span></div></li><li style="color:#3A6A8B;"><div style=""><span style="color: #009900;"><a href="http://december.com/html/4/element/title.html"><span style="color: #000000;">&lt;title&gt;</span></a></span>Mootools Calendar<span style="color: #009900;"><span style="color: #000000;">&lt;/title&gt;</span></span></div></li><li style="color:#26536A;"><div style=""><span style="color: #009900;"><a href="http://december.com/html/4/element/link.html"><span style="color: #000000;">&lt;link</span></a> <span style="color: #000066;">href</span>=<span style="color: #ff0000;">"styles.css"</span> <span style="color: #000066;">rel</span>=<span style="color: #ff0000;">"stylesheet"</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">"text/css"</span><span style="color: #000000;">&gt;</span></a></span></div></li><li style="color:#3A6A8B;"><div style=""><span style="color: #009900;"><a href="http://december.com/html/4/element/link.html"><span style="color: #000000;">&lt;link</span></a> <span style="color: #000066;">href</span>=<span style="color: #ff0000;">"calendar.css"</span> <span style="color: #000066;">rel</span>=<span style="color: #ff0000;">"stylesheet"</span> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">"text/css"</span><span style="color: #000000;">&gt;</span></a></span></div></li><li style="color:#26536A;"><div style=""><span style="color: #009900;"><a href="http://december.com/html/4/element/script.html"><span style="color: #000000;">&lt;script</span></a> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">"text/javascript"</span> <span style="color: #000066;">src</span>=<span style="color: #ff0000;">"js/mootools.js"</span><span style="color: #000000;">&gt;</span></a></span><span style="color: #009900;"><span style="color: #000000;">&lt;/script&gt;</span></span></div></li><li style="color:#3A6A8B;"><div style=""><span style="color: #009900;"><a href="http://december.com/html/4/element/script.html"><span style="color: #000000;">&lt;script</span></a> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">"text/javascript"</span> <span style="color: #000066;">src</span>=<span style="color: #ff0000;">"js/calendar.js"</span><span style="color: #000000;">&gt;</span></a></span><span style="color: #009900;"><span style="color: #000000;">&lt;/script&gt;</span></span></div></li><li style="color:#26536A;"><div style=""><span style="color: #009900;"><a href="http://december.com/html/4/element/script.html"><span style="color: #000000;">&lt;script</span></a> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">"text/javascript"</span><span style="color: #000000;">&gt;</span></a></span></div></li><li style="color:#3A6A8B;"><div style="">window.addEvent('domready', function() {</div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp;myCal = new Calendar({ fecha: 'd/m/Y' });</div></li><li style="color:#3A6A8B;"><div style="">});</div></li><li style="color:#26536A;"><div style=""><span style="color: #009900;"><span style="color: #000000;">&lt;/script&gt;</span></span></div></li><li style="color:#3A6A8B;"><div style=""><span style="color: #009900;"><span style="color: #000000;">&lt;/head&gt;</span></span></div></li><li style="color:#26536A;"><div style=""><span style="color: #009900;"><a href="http://december.com/html/4/element/body.html"><span style="color: #000000;">&lt;body&gt;</span></a></span></div></li><li style="color:#3A6A8B;"><div style=""><span style="color: #009900;"><a href="http://december.com/html/4/element/h3.html"><span style="color: #000000;">&lt;h3&gt;</span></a></span>AGREGAR GASTO <span style="color: #009900;"><span style="color: #000000;">&lt;/h3&gt;</span></span></div></li><li style="color:#26536A;"><div style=""><span style="color: #009900;"><a href="http://december.com/html/4/element/form.html"><span style="color: #000000;">&lt;form</span></a> <span style="color: #000066;">method</span>=<span style="color: #ff0000;">"post"</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">"registro"</span><span style="color: #000000;">&gt;</span></a></span></div></li><li style="color:#3A6A8B;"><div style="">...</div></li><li style="color:#26536A;"><div style="">Fecha:</div></li><li style="color:#3A6A8B;"><div style=""><span style="color: #009900;"><a href="http://december.com/html/4/element/input.html"><span style="color: #000000;">&lt;input</span></a> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">"text"</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">"fecha"</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">"fecha"</span> <span style="color: #000066;">size</span>=<span style="color: #ff0000;">"16"</span><span style="color: #000000;">&gt;</span></a></span></div></li><li style="color:#26536A;"><div style="">...</div></li><li style="color:#3A6A8B;"><div style=""><span style="color: #009900;"><span style="color: #000000;">&lt;/form&gt;</span></span></div></li><li style="color:#26536A;"><div style=""><span style="color: #009900;"><span style="color: #000000;">&lt;/body&gt;</span></span></div></li><li style="color:#3A6A8B;"><div style=""><span style="color: #009900;"><span style="color: #000000;">&lt;/html&gt;</span></span></div></li></ol></div></div></div><p></p><p>Desde luego lo que queda en adelante es agregarle los estilos de acuerdo al diseño de nuestro web y adecuarlo al formulario que tenemos. Les dejo un ejemplo en <a href="http://samples.unijimpe.net/moocalendar/">moocalendar</a> y finalmente los archivos fuente de este ejemplo para que lo descarguen.</p><p style="text-align:center;"><a href="http://www.box.net/shared/hqvq14w8wc"><img src="http://blog.unijimpe.net/btdown.png" border="0"></a></p><p style="font-size: 10px;border-top: 1px solid #666666;margin-top=12px;padding-top:6px;">&copy; 2006 - 2011 <a href="http://blog.unijimpe.net">unijimpe</a> - Utiliza este feed solo para uso personal, partes de este feed pueden ser utilizados mencionando al autor, no esta permitido publicar enteramente este feed para uso comercial sin permiso del autor.</p><br /> ]]></content:encoded> <wfw:commentRss>http://blog.unijimpe.net/mootools-calendar/feed/</wfw:commentRss> <slash:comments>21</slash:comments> </item> <item><title>Swiff: Mootools Flash Plugin</title><link>http://blog.unijimpe.net/swiff-mootools-flash-plugin/</link> <comments>http://blog.unijimpe.net/swiff-mootools-flash-plugin/#comments</comments> <pubDate>Sat, 01 Mar 2008 05:48:13 +0000</pubDate> <dc:creator>unijimpe</dc:creator> <category><![CDATA[Flash]]></category> <category><![CDATA[General]]></category> <category><![CDATA[Google]]></category> <category><![CDATA[Mootools]]></category> <category><![CDATA[eventos]]></category> <category><![CDATA[flashvars]]></category> <category><![CDATA[Javascript]]></category> <category><![CDATA[player]]></category> <category><![CDATA[plugin]]></category> <category><![CDATA[swf]]></category> <category><![CDATA[SWFObject]]></category> <category><![CDATA[Tools]]></category><guid isPermaLink="false">http://blog.unijimpe.net/swiff-mootools-flash-plugin/</guid> <description><![CDATA[<p><a href="http://docs12b.mootools.net/Utilities/Swiff">Swiff</a> es una clase de Mootools que permite embeber archivos Flash en páginas html a semejanza de <a href="http://blog.deconcept.com/swfobject/">SWFObject</a>. Este clase fue desarrollada originalmente por <em>Harald Kirschner</em> para la librería <a href="http://digitarald.de/project/fancyupload/">FancyUpload</a> el cual permite hacer upload &#8230;</p>]]></description> <content:encoded><![CDATA[<p><a href="http://docs12b.mootools.net/Utilities/Swiff">Swiff</a> es una clase de Mootools que permite embeber archivos Flash en páginas html a semejanza de <a href="http://blog.deconcept.com/swfobject/">SWFObject</a>. Este clase fue desarrollada originalmente por <em>Harald Kirschner</em> para la librería <a href="http://digitarald.de/project/fancyupload/">FancyUpload</a> el cual permite hacer upload de archivos con barra de progreso de manera sencilla y ahora se esta incluyendo en la nueva versión de <em>Mootools 1.2</em> que aun esta en estado beta.</p><p><strong>Obteniendo Swiff</strong><br /> Para utilizar Swiff hay dos opciones. La primera es descargar la versión beta <a href="http://mootools.net/download/tags/1-2b2">Mootools 1.2beta2</a> en el cual podemos seleccionar Swiff de la lista de componentes y luego la incluimos en el header de nuestra página:</p><div class="syntax_hilite"><div id="html-85"><div class="html"><ol><li style="color:#3A6A8B;"><div style=""><span style="color: #009900;"><span style="color: #808080; font-style: italic;">&lt;!-- Si utilizamos mootools 1.2beta2 --&gt;</span></span></div></li><li style="color:#26536A;"><div style=""><span style="color: #009900;"><a href="http://december.com/html/4/element/script.html"><span style="color: #000000;">&lt;script</span></a> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">"text/javascript"</span> <span style="color: #000066;">src</span>=<span style="color: #ff0000;">"mootools.js"</span><span style="color: #000000;">&gt;</span></a></span><span style="color: #009900;"><span style="color: #000000;">&lt;/script&gt;</span></span></div></li></ol></div></div></div><p></p><p>La segunda forma es para cuando  se utiliza <em>Mootools 1.1</em>, podemos descargar sólo la librería <a href="http://digitarald.de/workspace/packages/Uploader/Swiff.Base.js">Swiff.Base.js</a> el cual es parte de la librería FancyUpload.</p><div class="syntax_hilite"><div id="html-86"><div class="html"><ol><li style="color:#3A6A8B;"><div style=""><span style="color: #009900;"><span style="color: #808080; font-style: italic;">&lt;!-- Si utilizamos mootools 1.1 --&gt;</span></span></div></li><li style="color:#26536A;"><div style=""><span style="color: #009900;"><a href="http://december.com/html/4/element/script.html"><span style="color: #000000;">&lt;script</span></a> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">"text/javascript"</span> <span style="color: #000066;">src</span>=<span style="color: #ff0000;">"mootools.js"</span><span style="color: #000000;">&gt;</span></a></span><span style="color: #009900;"><span style="color: #000000;">&lt;/script&gt;</span></span></div></li><li style="color:#3A6A8B;"><div style=""><span style="color: #009900;"><a href="http://december.com/html/4/element/script.html"><span style="color: #000000;">&lt;script</span></a> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">"text/javascript"</span> <span style="color: #000066;">src</span>=<span style="color: #ff0000;">"Swiff.Base.js"</span><span style="color: #000000;">&gt;</span></a></span><span style="color: #009900;"><span style="color: #000000;">&lt;/script&gt;</span></span></div></li></ol></div></div></div><p></p><p><strong>Utilizando Swiff</strong><br /> Para utilizar Swiff podemo utilizar la siguiente sintaxis, donde <em>'path'</em> es la ruta al swf a incluir, <em>w</em> es el ancho, <em>h</em> es la altura y <em>'iddiv'</em> es el identificador</p><div class="syntax_hilite"><div id="javascript-87"><div class="javascript"><ol><li style="color:#3A6A8B;"><div style=""><span style="color: #003366;">new</span> Swiff<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'path'</span>, <span style="color: #66cc66;">&#123;</span>width: w, height: h, container: <span style="color: #3366CC;">'iddiv'</span><span style="color: #66cc66;">&#125;</span><span style="color: #66cc66;">&#41;</span>;</div></li></ol></div></div></div><p></p><p>Luego si deseamos incluir un swf llamado <em>header.swf</em> en nuestra página en el div llamado <em>main</em>, tendríamos el siguiente código:</p><div class="syntax_hilite"><div id="html-88"><div class="html"><ol><li style="color:#3A6A8B;"><div style=""><span style="color: #009900;"><a href="http://december.com/html/4/element/html.html"><span style="color: #000000;">&lt;html&gt;</span></a></span></div></li><li style="color:#26536A;"><div style=""><span style="color: #009900;"><a href="http://december.com/html/4/element/head.html"><span style="color: #000000;">&lt;head&gt;</span></a></span></div></li><li style="color:#3A6A8B;"><div style=""><span style="color: #009900;"><a href="http://december.com/html/4/element/title.html"><span style="color: #000000;">&lt;title&gt;</span></a></span>Demo Swiff - unijimpe<span style="color: #009900;"><span style="color: #000000;">&lt;/title&gt;</span></span></div></li><li style="color:#26536A;"><div style=""><span style="color: #009900;"><a href="http://december.com/html/4/element/script.html"><span style="color: #000000;">&lt;script</span></a> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">"text/javascript"</span> <span style="color: #000066;">src</span>=<span style="color: #ff0000;">"mootools.js"</span><span style="color: #000000;">&gt;</span></a></span><span style="color: #009900;"><span style="color: #000000;">&lt;/script&gt;</span></span></div></li><li style="color:#3A6A8B;"><div style=""><span style="color: #009900;"><a href="http://december.com/html/4/element/script.html"><span style="color: #000000;">&lt;script</span></a> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">"text/javascript"</span><span style="color: #000000;">&gt;</span></a></span></div></li><li style="color:#26536A;"><div style="">window.addEvent('load', function() {</div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp; var myswf = new Swiff('swffull.swf', {</div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp; &nbsp; &nbsp; width: 600,</div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp; &nbsp; &nbsp; height: 450,</div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp; &nbsp; &nbsp; container: 'main'</div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp; });</div></li><li style="color:#26536A;"><div style="">});</div></li><li style="color:#3A6A8B;"><div style=""><span style="color: #009900;"><span style="color: #000000;">&lt;/script&gt;</span></span></div></li><li style="color:#26536A;"><div style=""><span style="color: #009900;"><span style="color: #000000;">&lt;/head&gt;</span></span></div></li><li style="color:#3A6A8B;"><div style=""><span style="color: #009900;"><a href="http://december.com/html/4/element/body.html"><span style="color: #000000;">&lt;body&gt;</span></a></span></div></li><li style="color:#26536A;"><div style=""><span style="color: #009900;"><a href="http://december.com/html/4/element/div.html"><span style="color: #000000;">&lt;div</span></a> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">"main"</span><span style="color: #000000;">&gt;</span></a></span>Flash Movie<span style="color: #009900;"><span style="color: #000000;">&lt;/div&gt;</span></span></div></li><li style="color:#3A6A8B;"><div style=""><span style="color: #009900;"><span style="color: #000000;">&lt;/body&gt;</span></span></div></li><li style="color:#26536A;"><div style=""><span style="color: #009900;"><span style="color: #000000;">&lt;/html&gt;</span></span></div></li></ol></div></div></div><p></p><p>El resultado de este ejemplo lo pueden ver en: <a href="http://samples.unijimpe.net/swiff/">Demo Swiff - unijimpe</a>. Obviamente hay muchas mas opciones al momento de insertar un swf como el color del fondo, pasarle <em>flashvars</em> e incluso agregarle eventos, esto lo pueden encontrar de forma detallada en la documentación en <a href="http://docs12b.mootools.net/Utilities/Swiff">Mootools Class: Swiff</a>.</p><p>Este método de inclusión de SWFs es muy practico cuando ya estamos utilizando Mootools y no deseamos utilizar una librería adicional para ejecutar flash en nuestra página. Pero si es que deseas controlar el swf al detalle (Por ejemplo la versión de Flash Player) siempre estará <strong>SWFObject</strong> el cual es el estándar para inclusión de SWFs.</p><p style="font-size: 10px;border-top: 1px solid #666666;margin-top=12px;padding-top:6px;">&copy; 2006 - 2011 <a href="http://blog.unijimpe.net">unijimpe</a> - Utiliza este feed solo para uso personal, partes de este feed pueden ser utilizados mencionando al autor, no esta permitido publicar enteramente este feed para uso comercial sin permiso del autor.</p><br /> ]]></content:encoded> <wfw:commentRss>http://blog.unijimpe.net/swiff-mootools-flash-plugin/feed/</wfw:commentRss> <slash:comments>3</slash:comments> </item> <item><title>Introducción a Mootools</title><link>http://blog.unijimpe.net/introduccion-a-mootools/</link> <comments>http://blog.unijimpe.net/introduccion-a-mootools/#comments</comments> <pubDate>Thu, 28 Feb 2008 02:37:26 +0000</pubDate> <dc:creator>unijimpe</dc:creator> <category><![CDATA[AJAX]]></category> <category><![CDATA[General]]></category> <category><![CDATA[Mootools]]></category> <category><![CDATA[CSS]]></category> <category><![CDATA[eventos]]></category> <category><![CDATA[Framework]]></category> <category><![CDATA[Javascript]]></category> <category><![CDATA[plugin]]></category> <category><![CDATA[Tools]]></category><guid isPermaLink="false">http://blog.unijimpe.net/introduccion-a-mootools/</guid> <description><![CDATA[<p><a href="http://mootools.net/">Mootools</a> es un <em>framework</em> Javascript muy potente que nos facilitará el desarrollo de interfaces visuales, efectos, manipulación del DOM, manejo de AJAX, entre otras muchas opciones. Además de ser muy ligera, tiene soporte para OOP y &#8230;</p>]]></description> <content:encoded><![CDATA[<p><a href="http://mootools.net/">Mootools</a> es un <em>framework</em> Javascript muy potente que nos facilitará el desarrollo de interfaces visuales, efectos, manipulación del DOM, manejo de AJAX, entre otras muchas opciones. Además de ser muy ligera, tiene soporte para OOP y además tiene multitud de plugins que te permitirán implementar variedad de aplicaciones fácilmente.</p><p style="text-align:center;"><img src='http://blog.unijimpe.net/wp-content/uploads/2008/02/mootools.gif' alt='mootools.gif' /></p><p><strong>Empezando con Mootools</strong><br /> Lo primero es descargar la librería, para ello puedes acceder a <a href="http://mootools.net/download">Download Mootools</a>, donde seleccionas los módulos a utilizar y el método de compresión, para nuestro caso seleccionamos todos los módulos. Descargaremos un archivo con el nombre <em>mootools-release-x.xx.js.txt</em> (Donde x.xx es la versión), el cual lo renombrados a <em>mootools.js</em> y lo colocamos al directorio de nuestro proyecto web.</p><p>El siguiente paso es incluir la librería en nuestro <em>html</em>, para poder utilizarlo, para ello colocamos en el header lo siguiente.</p><div class="syntax_hilite"><div id="html-94"><div class="html"><ol><li style="color:#3A6A8B;"><div style=""><span style="color: #009900;"><a href="http://december.com/html/4/element/script.html"><span style="color: #000000;">&lt;script</span></a> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">"text/javascript"</span> <span style="color: #000066;">src</span>=<span style="color: #ff0000;">"js/mootools.js"</span><span style="color: #000000;">&gt;</span></a></span><span style="color: #009900;"><span style="color: #000000;">&lt;/script&gt;</span></span></div></li></ol></div></div></div><p></p><p><strong>Detectando los Eventos de Carga</strong><br /> Lo siguiente que debemos hacer el crear un detector de eventos para ejecutar nuestras acciones una vez que se ha cargado la página. Si se llama a las funciones cuando aun no se ha completado la carga se generar errores pues aun hay elementos que no están disponibles.</p><p>Para ello existen dos eventos: <strong>domready</strong> que se ejecuta cuando todos los elementos de la página están listos, pero no espera por las imágenes y <strong>load</strong> que se ejecuta cuando toda la página incluyendo las imágenes se ha cargado, entonces tendríamos:</p><div class="syntax_hilite"><div id="html-95"><div class="html"><ol><li style="color:#3A6A8B;"><div style=""><span style="color: #009900;"><a href="http://december.com/html/4/element/script.html"><span style="color: #000000;">&lt;script</span></a> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">"text/javascript"</span><span style="color: #000000;">&gt;</span></a></span></div></li><li style="color:#26536A;"><div style="">window.addEvent('domready', function() {</div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp; &nbsp;// código - carga sin imágenes completa</div></li><li style="color:#26536A;"><div style="">});</div></li><li style="color:#3A6A8B;"><div style="">window.addEvent('load', function() {</div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp; &nbsp;// código - carga con imágenes completa</div></li><li style="color:#3A6A8B;"><div style="">});</div></li><li style="color:#26536A;"><div style=""><span style="color: #009900;"><span style="color: #000000;">&lt;/script&gt;</span></span></div></li></ol></div></div></div><p></p><p>Obviamente es mas rápido <strong>domready</strong> pues no espera que se carguen las imágenes pero ya se tiene disponible todos los elementos de la página para manipularlos.</p><p><strong>La función $ (dolar)</strong><br /> La función <strong>$()</strong> es equivalente a <em>document.getElementById(</em>) con el cual se puede acceder a un elemento mediante su identificador. Veamos los siguientes ejemplos:</p><div class="syntax_hilite"><div id="javascript-96"><div class="javascript"><ol><li style="color:#3A6A8B;"><div style="">document.<span style="color: #006600;">getElementById</span><span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'myDiv'</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #009900; font-style: italic;">// accede a mydiv</span></div></li><li style="color:#26536A;"><div style="">$<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'myDiv'</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #009900; font-style: italic;">// accede al elemento con id=mydiv </span></div></li></ol></div></div></div><p></p><p><strong>La función $$ (doble dolar)</strong><br /> La función <strong>$$()</strong> es equivalente a <em>document.getElementsByTagName()</em>, pero mas potente pues devuelve un array con los elementos que cumplen la condición.</p><div class="syntax_hilite"><div id="javascript-97"><div class="javascript"><ol><li style="color:#3A6A8B;"><div style="">$$<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'div'</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #009900; font-style: italic;">// Array de elementos Mootools</span></div></li><li style="color:#26536A;"><div style="">$$<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'a.external'</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #009900; font-style: italic;">// Array de enlaces con la class=external</span></div></li><li style="color:#3A6A8B;"><div style="">$$<span style="color: #66cc66;">&#40;</span><span style="color: #3366CC;">'a[href=#]'</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #009900; font-style: italic;">// Array de enlaces con href=# </span></div></li></ol></div></div></div><p></p><p><strong>Nuestro Primer Ejemplo</strong><br /> Una vez que tenemos los conceptos básicos, podemos implementar nuestro primer ejemplo, haremos que al cargar la página se aplique el estilo link a todos los enlaces de nuestro html, además pintamos de color rojo al div con nombre diverror, para ello tendríamos el siguiente código:</p><div class="syntax_hilite"><div id="html-98"><div class="html"><ol><li style="color:#3A6A8B;"><div style=""><span style="color: #009900;"><a href="http://december.com/html/4/element/script.html"><span style="color: #000000;">&lt;script</span></a> <span style="color: #000066;">type</span>=<span style="color: #ff0000;">"text/javascript"</span><span style="color: #000000;">&gt;</span></a></span></div></li><li style="color:#26536A;"><div style="">window.addEvent('domready', function() {</div></li><li style="color:#3A6A8B;"><div style="">&nbsp; &nbsp; $$('a').addClass('link');</div></li><li style="color:#26536A;"><div style="">&nbsp; &nbsp; $('diverror').setStyles('color: #CC0000');</div></li><li style="color:#3A6A8B;"><div style="">});</div></li><li style="color:#26536A;"><div style=""><span style="color: #009900;"><span style="color: #000000;">&lt;/script&gt;</span></span></div></li></ol></div></div></div><p></p><p><strong>Mas Información</strong><br /> Obviamente este es una pequeña introducción con los conceptos más básicos, mas adelante iremos desarrollando mas temas que nos ayudarán a comprender mas las capacidades de Mootools. Para mas información pueden les dejo una pequeña lista con recursos:</p><ul><li><a href="http://docs.mootools.net/">Mootools Docs</a></li><li><a href="http://demos.mootools.net/">Mootools Demos</a></li><li><a href="http://solutoire.com/2007/09/20/understanding-mootools-selectors-e-and-es/">Understanding Mootools Selectors $, $$, $E and $ES</a></li><li><a href="http://blog.mootools.net/2007/6/11/selectors-on-fire">Selectors on fire: a tale of pseudoselectors</a></li><li><a href="http://www.csslab.cl/2008/01/21/mootools-introduccin/">Mootools: introducción - CSSLab</a></li></ul><p style="font-size: 10px;border-top: 1px solid #666666;margin-top=12px;padding-top:6px;">&copy; 2006 - 2011 <a href="http://blog.unijimpe.net">unijimpe</a> - Utiliza este feed solo para uso personal, partes de este feed pueden ser utilizados mencionando al autor, no esta permitido publicar enteramente este feed para uso comercial sin permiso del autor.</p><br /> ]]></content:encoded> <wfw:commentRss>http://blog.unijimpe.net/introduccion-a-mootools/feed/</wfw:commentRss> <slash:comments>6</slash:comments> </item> </channel> </rss>
<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic
Page Caching using disk: enhanced (User agent is rejected)
Database Caching using disk: basic

Served from: blog.unijimpe.net @ 2012-02-08 11:26:45 -->
