Tutorial on how Chickenfoot script works ...

Discussion in 'Chickenfoot Scripts' started by Graham, Nov 3, 2006.

  1. Graham

    Graham Developer Staff Member

    <h2>Search ...</h2>

    You need to write a chickenfoot script and trigger it on this page to run your custom searches. This also requires Firefox.


    Number: 2525
    Street: H Street
    Suburb: Bakersfield
    City: Ca
    Zip: 93301
    Number&amp;Street: 2525 H Street
    City&amp;State: Bakersfield, Ca 93301

    This is a brief explanation as to how the searchprovider.html script works to bring up the provider's map on yahoo.com.


    The above is the result seen using Firefox when the Firefox icon is pressed on the Providers tab for a Dr Mitts who has been setup as a provider on the demo server. Each line has a label, and the data follows with a new line for each data item.

    Different web services require different types of data to allow the search to work and so Synapse EMR is providing a range of the same data in different formats.

    Let's walk thru the script line by line. As you will see, we only need two lines from the above searchprovider.html page.
    <pre id="pre">// This chickenscript grabs the address details
    // and brings up the appropriate map in the USA. Change "United States" to "Canada" if you need this.</pre><pre id="pre">These are just comment lines.

    try { street = find(/Number&amp;Street: (.*)/).groups[1]; }
    catch(e) {
    street = ''; // this is two single quotes
    }</pre><pre id="pre">This line says ... match the text "Number&amp;Street:" on the page.
    Then grab each character that follows until the end of the line, and assign it to the variable "street"
    If there is an error, then make the variable "street" just a blank.
    In the above instance, street is given the value "2525 H Street"
    </pre><pre id="pre">try { city = find(/City&amp;State: (.*)/).groups[1]; }
    catch(e) {
    city = '';
    }
    </pre><pre id="pre">This line says ... match the text "City&amp;State:" on the page.
    Then grab each character that follows until the end of the line, and assign it to the variable "city"
    If there is an error, then make the variable "city" just a blank.

    In the above instance, city is given the value ": Bakersfield, Ca 93301"
    </pre><pre id="pre">with(openTab('http://maps.yahoo.com/', true)) {</pre><pre id="pre">Now, ask Firefox to open a new tab, and browse to http://maps.yahoo.com

    enter("Address",street);</pre><pre id="pre">In the field associated with the text "Address" enter the value of the variable "street" which is "2525 H Street"

    enter("City",city);

    In the field associated with the text "City" enter the value of the variable "city" which is "Bakersfield, Ca 93301"

    pick("United States");</pre><pre id="pre">Now on the drop down list, pick "United States".</pre><pre id="pre"> click("Get Map");</pre><pre id="pre">Now simulate a left mouse click on the button "Get Map".</pre><pre id="pre">
    }
    </pre>

    The maps.yahoo.com page now has all the information it
  2. DrO

    DrO New Member

    Thank you Graham

Share This Page