Archive for the ajax Category

Welcome to probably the most useless blog post on the web.

Now you can happily animate stuff in the address bar (do you remember the nineties and nice status bar animations ? :) ) .

The beautiful online demo can be found here : Demo of animated address bar

HTML:
  1. <title>Totally usesless 'ajax' 'loading' image in the address bar as a spinning thing</title>
  2. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  3. <meta name="author" content="AF83.com" />
  4. <script language="JavaScript">

JavaScript:
  1. <!--
  2. /**
  3. *  Copyright (c) 2007, AF83
  4. *  All rights reserved.
  5. *
  6. *  Redistribution and use in source and binary forms, with or without modification,
  7. *  are permitted provided that the following conditions are met:
  8. *
  9. *  1° Redistributions of source code must retain the above copyright notice,
  10. *  this list of conditions and the following disclaimer.
  11. *
  12. *  2° Redistributions in binary form must reproduce the above copyright notice,
  13. *  this list of conditions and the following disclaimer in the documentation
  14. *  and/or other materials provided with the distribution.
  15. *
  16. *  3° Neither the name of AF83 nor the names of its contributors may be used
  17. *  to endorse or promote products derived from this software without specific
  18. *  prior written permission.
  19. *  THIS SOFTWARE IS PROVIDED BY THE COMPANY AF83 AND CONTRIBUTORS "AS IS"
  20. *  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
  21. *  THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
  22. *  PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
  23. *  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  24. *  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  25. *  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  26. *  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
  27. *  OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  28. *  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  29. *  EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  30. *
  31. *  @copyright  2007 AF83 Ori Pekelman
  32. *  @license    BSD License (3 Clause) http://www.opensource.org/licenses/bsd-license.php
  33. *  @package    Useless Stuff
  34. */
  35. // Configure :
  36. var TextBefore=' ...  Loading ... ';
  37. // End configuration
  38. var AddressBarLoaderTimeOut;
  39. var OriginalLocationHash = document.location.hash; // so we can restore original url
  40.  
  41. function loc_hash(a){
  42.  document.location.hash =TextBefore+a;
  43. }
  44.  
  45. function spinStart(){
  46.     AddressBarLoaderTimeOut=setTimeout("spinStart()",100);
  47.     loc_hash("|");
  48.     loc_hash("/");
  49.     loc_hash("-");
  50.     loc_hash("");
  51.     loc_hash("|");
  52.     loc_hash("/");
  53.     loc_hash("-");
  54.  }
  55.  function spinStop(){
  56.      document.location.hash=OriginalLocationHash;
  57.      clearTimeout(AddressBarLoaderTimeOut) ;
  58.      }
  59. // -->

HTML:
  1. </script>
  2. </head>
  3. <h1>Totally usesless 'ajax' 'loading' image in the address bar as a spinning thing</h1>
  4. <div style="margin:100px;height:100px;width:100px; background-color:#333;font-size:18;color:white;" onclick="spinStart();">Click on me to start address bar ajax loader</div>
  5. <div style="margin:100px;height:100px;width:100px; background-color:#333;font-size:18;color:white;" onclick="spinStop();">Click on me to stop</div>
  6. </body>
  7. </html>

Click to continue reading

For the benefit of those who participated in the Google developers day presentation a French only post.

Dans ce billet vous trouverez les sources et les présentation de la session Google Maps lors du Google Developers Day à Paris du 31 mai 2007 . Dans le poste du 25 mai vous pouvez trouver le code pour travailler avec les adresses françaises... Suivez ce lien pour la présentation de Clément Hallet sur les bases d'utilisation de Google Maps API et celui ci pour la présentation sur des thèmes plus avancés (géocodage côté serveur, chargement asynchrone des marquers et calcul des distances).

Ici vous pouvez télécharger le code d'exemple utilisé dans la présentation Google Maps API - Basics. Notez que la clé utilisée (ABQIAAAAyzlxpGWavaTREVb4HcYiUhT2yXp_ZAY8_ufC3CFXhHIE1NvwkxSYK1OvuhDXV84EQwe2sBFw6vUHtg) marchera sur http://localhost - adaptez la à vos besoins, pour générer votre propre clé Google Maps API cliquez ici (vous pouvez consulter mon billet sur la gestion de configuration par virtual host pour résoudre le problème des clés google utilisé conjointement avec mod_proxy et PHP ).

Click to continue reading

You must know the $ Function in prototype (also in jQuery and mootools) that helps you target elements in Javascript. Well, here's my take on it.

Here's the code :

JavaScript:
  1. function $( magic , node ){
  2.       //model : [@][id][:][tag]
  3.  
  4.       var keys = /^([\@]*)([\w+]*)([\:]*)([\w+]*)$/(magic);
  5.       var isArray = keys[1];
  6.       var id = keys[2];
  7.       var tag = keys[4];
  8.      
  9.       if( tag == "" ){tag = "*"}
  10.       if( node == undefined ){ node = document }
  11.      
  12.       var nodes = node.getElementsByTagName(tag);
  13.       var ret = new Array;
  14.       for( var i=0; i &lt;nodes.length; i++ ){
  15.             if( id != "" &amp;&amp; nodes[i].id != id ){continue}
  16.             ret.push( nodes[i] );
  17.       }
  18.      
  19.       if( isArray == "@" ){
  20.             return ret;
  21.       }else{
  22.             return ret[0];
  23.       }
  24.  
  25. }

How to use it :


$("mainHeader")
: returns the first node in document having "mainHeader" for id and anything for tag name.

$("clickMe:a") : returns the first node in document having "clickMe" for id and "a" for tag name.

$("@clickMe:a") : returns all nodes ( as an array ) in document having "clickMe" for id and "a" for tag name.

$("@:div") : returns all divs in document.

$(":img") : returns first img in document

$("@clear:div" , subNode ) : returns all nodes in DOM node "subNode" having "clear" for id and "div" for tag name.

$("@") : returns all DOM nodes in document.

And so on ...

Click to continue reading

Creative Commons License
This work is licensed under a Creative Commons Attribution 2.0 License.