home *** CD-ROM | disk | FTP | other *** search
/ Chip 2003 November / Chip_2003-11_cd1.bin / software / dave / dqsd.exe / searches / viam.xml < prev    next >
Text File  |  2002-10-23  |  4KB  |  111 lines

  1. <search function="viam">
  2.   <name>Maps with viamichelin.com</name>
  3.   <category>People and Places</category>
  4.   <contributor>MLL</contributor>
  5.   <link>http://www.viamichelin.com/</link>
  6.   <description>
  7.   Find a map to any place in Europe with viamichelin.com
  8.     <div class="helpboxDescLabels">Optional switch:</div>
  9.     <table class="helpboxDescTable">
  10.       <tr><td>/size:{0|100|25|5|1}</td><td> - </td><td>map size (in km). Defaults to 0 (automatic).</td></tr>
  11.     </table>
  12.     <div class="helpboxDescLabels">Examples:</div>
  13.     <table class="helpboxDescTable">
  14.       <tr><td>viam place Berland, Bordeaux</td></tr>
  15.       <tr><td>viam rimini /size:100</td></tr>
  16.     </table>
  17.   </description>
  18.   <form name="viamf"
  19.         method="get"
  20.         action="http://www.viamichelin.com/viamichelin/fra/dyn/controller/ambiguousTest">
  21.     <input type="hidden" name="act" value="MapHomeVersMapDisplay" />
  22.     <input type="hidden" name="express" value="true" />
  23.     <input type="hidden" name="from" value="700" />
  24.     <input type="hidden" name="intMapScale" value="0" />
  25.     <input type="hidden" name="strCountry" value="EUR" />
  26.     <input type="hidden" name="strCity" value="" />
  27.     <input type="hidden" name="strAddress" value="" />
  28.   </form>
  29.   <script><![CDATA[
  30.     function viam(q)
  31.     {
  32.       /*
  33.       todo:
  34.       - add support for their very powerful driving directions
  35.         (but wonder if it's worth it : *lots* of switches needed)
  36.       */
  37.       
  38.       var args = parseArgs(q, "size");
  39.  
  40.       if( nullArgs("viam", args.q) )
  41.         return;
  42.  
  43.       var size = "0";
  44.       if( !( typeof args.switch_val["size"] == "undefined" || args.switch_val["size"] == "" ) )
  45.       {
  46.         size=args.switch_val["size"];
  47.       }
  48.  
  49.       // What follows is a fairly "ergonomic" parser for addresses I got & simplified from mp.xml.
  50.  
  51.       var address = "";
  52.       var city = "";
  53.  
  54.       // detect leading ### w w w st
  55.       var res = q.match(/^\s*(\d+(\s+\w+)+\s+(st|ave|rd|ln|dr|blvd|cir|ct|pkwy|pl|way|aly|pk|sq|ter|plz|rue|bd))[\s\.,;]*(.*)$/i);
  56.       if (res && res[1])
  57.       {
  58.         address = res[1];
  59.         city = res[4];
  60.       }
  61.  
  62.       // detect trailing comma or semicolon; prefer this way of finding city
  63.       res = q.match(/[\.,;]\s*([^\d][^,;]+)[\s\.,;]*$/i);
  64.       if (res && res[1])
  65.       {
  66.         city = res[1];
  67.         address = q.substring(0, res.index);
  68.       }
  69.  
  70.       // last resorts: we really want a city
  71.       if (city == "")
  72.       {
  73.         // drop requirement for street number and precise abbreviation and look for street
  74.         res = q.match(/^\s*((\w+\s+)+(st|ave|rd|ln|dr|blvd|cir|ct|pkwy|pl|way|aly|pk|sq|ter|plz|street|avenue|road|lane|drive|boulevard|circle|court|parkway|place|loop|alley|park|square|terrace|plaza|mall))[\s\.,;]*(.*)$/i);
  75.         if (res && res[1])
  76.         {
  77.           address = res[1];
  78.           city = res[4];
  79.         }
  80.         // has a number: city is last word
  81.         else if (q.match(/^\s*\d/))
  82.         {
  83.           res = q.match(/(\w+)[\s\.,;]*$/);
  84.           city = res[1];
  85.           address = q.substring(0, res.index);
  86.         }
  87.         // otherwise, looks like it doesn't have a street; city is whole thing
  88.         else
  89.         {
  90.           city = q;
  91.           address = "";
  92.         }
  93.       }
  94.  
  95.       document.viamf.strAddress.value = address;
  96.       document.viamf.intMapScale.value = size;
  97.       document.viamf.strCity.value = city;
  98.  
  99.       submitForm(viamf);
  100.     }
  101.   ]]></script>
  102.   <copyright>
  103.     The following applies if this file is included and distributed with Dave's Quick Search Deskbar:
  104.     Copyright (c) 2002 David Bau; Distributed under the terms of the GNU Public License, Version 2 (http://www.gnu.org/copyleft/gpl.txt)
  105.   </copyright>
  106.   <created_by>
  107.     This search file was initially created on 10/14/02 at 15:04:31
  108.     by Dave's Quick Search Deskbar Search Wizard version 0.9.1 (beta),
  109.     Copyright (c) 2002 Glenn Carr; Distributed under the terms of the GNU General Public License, Version 2
  110.   </created_by>
  111. </search>