Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

..
Failed to load latest commit information.
README.textile
license.txt
yql_js_widget.html
yql_js_widget.js

README.textile

YQL-Utilities

This widget contains files associated with the construction of a JavaScript widget for displaying data obtained from YQL. This widget uses the following external utilities:

  • YUI GET – Obtains data from public YQL URI (avoids same origin policy issue)

There are two files associated with the widget:

yql_js_widget.js
This is the JavaScript widget that captures the YQL data and parses the formatting defined by the user. This file needs to be included where the YQL JS widget is to be displayed.

yql_js_widget.html
The HTML file displays sample methods for initializing and rendering a YQL widget. See the following example:

1.  <script type="text/javascript" src="yql_js_widget.js"></script>
2.  <div id="widgetContainer"></div>
3.  <script type="text/javascript">
4.  var config = {'debug' : true};
5.  var format = '<br style="clear:both" />{item.description}';
6.  var yqlQuery = 'select * from weather.forecast where location = 90210';
7.  var insertEl = 'widgetContainer';
8.  yqlWidget.push(yqlQuery, config, format, insertEl);
9.  yqlWidget.render();
10. </script>

Going through the above example, here is the definition for how to format the requests:

Line 1
Include the widget JavaScript file

Line 2
Create the container the you would like to drop the widget into (must have an id)

Line 4
(OPTIONAL) Define the config object. This object has the following available key / value pairs:

  • debug (true / false) – If set to true, status messages will be displayed via console.log during widget rendering

Line 5
Define the format string. This string will be what is inserted into the container defined on line 2 and will be added for each result returned by YQL and may contain HTML / CSS / JavaScript. Any text that is added between curly brackets (e.g. {test}) will be re-rendered as the associated data returned by YQL. For instance, if you go to the YQL Console and run the weather query, {item.description} will relate to the results at query→results→channel→item→description.

Line 6
Define the YQL query to pass to the public YQL URI.

Line 7
Define the id of the container you wish to insert the widget into

Line 8
Push the widget on the stack. If you have multiple widgets to be rendered, you would push each widget on the load stack using push before rendering (as seen on line 9). The push function accepts the following parameters:

  • YQL Query (REQUIRED) – The query defined on line 6
  • Config (OPTIONAL) – The config object defined on line 4
  • Format (REQUIRED) – The content to add for each result into the container defined
  • Insert Element (REQUIRED) – The id of the container to insert the widget into

Line 9
Render all widgets pushed onto the load stack

Code Contributions

This project only accepts contributions licensed under the BSD open source license. See the Open Source Initiative’s approved template below.
Each file submitted should contain the following information in the header:
// Created by Jonathan LeBlanc
// Copyright © Jonathan LeBlanc, 2010. All Rights Reserved.
// Licensed under the BSD (revised) open source license.

Below is the Open Source Initiative BSD License Template (http://opensource.org/licenses/bsd-license.php):

Copyright © <2010>, <Jonathan LeBlanc>
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  • Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  • Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  • Neither the name of the nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.


THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Something went wrong with that request. Please try again.