Adobe
Products

Top destinations

  • Adobe Creative Cloud
  • Creative Suite
  • Adobe Marketing Cloud
  • Acrobat
  • Photoshop
  • SiteCatalyst
  • Students
  • Elements family

Adobe Creative Cloud

  • What is Adobe Creative Cloud?
  • Design
  • Web
  • Photography
  • Video
  • Students
  • Teams
  • Enterprise
  • Educational institutions

Design and photography

  • Photoshop
  • Illustrator
  • InDesign
  • Adobe Muse
  • Lightroom

Video

  • Adobe Premiere
  • After Effects

Web development and HTML5

  • Edge Tools & Services [opens in a new window]
  • Dreamweaver
  • Gaming [opens in a new window]

Adobe Marketing Cloud

  • What is Adobe Marketing Cloud?
  • Digital analytics
  • Social marketing
  • Web experience management
  • Testing and targeting
  • Media optimization

Analytics

  • SiteCatalyst
  • Adobe Discover
  • Insight

Social

  • Adobe Social

Experience Manager

  • CQ
  • Scene7

Target

  • Test&Target
  • Recommendations
  • Search&Promote

Media Optimizer

  • AdLens
  • AudienceManager
  • AudienceResearch

Document services

  • Acrobat
  • EchoSign [opens in a new window]
  • FormsCentral [opens in a new window]
  • SendNow [opens in a new window]
  • Acrobat.com [opens in a new window]

Publishing

  • Digital Publishing Suite

  • See all products
Business solutions

By business need

  • Digital analytics
  • Digital publishing
  • Document management
  • Media optimization
  • Social marketing
  • Testing and targeting
  • Video editing and serving
  • Web development [opens in a new window]
  • Web experience management
  • See all business needs

By industry

  • Broadcast
  • Education
  • Financial services
  • Government
  • Publishing
  • Retail
  • See all industries
Support & Learning

I need help

  • Products
  • Adobe Creative Cloud
  • Adobe Marketing Cloud
  • Forums [opens in a new window]

I want to learn

  • Training and tutorials
  • Certification [opens in a new window]
  • Adobe Developer Connection
  • Adobe Design Center
  • Adobe TV [opens in a new window]
  • Adobe Marketing Center
  • Adobe Labs [opens in a new window]
Download
  • Product trials
  • Adobe Flash Player
  • Adobe Reader
  • Adobe AIR
  • See all downloads
Company
  • Careers at Adobe
  • Investor Relations
  • Newsroom
  • Privacy
  • Corporate Social Responsibility
  • Customer Showcase
  • Contact us
  • More company info
Buy
  • For personal and professional use
  • For students, educators, and staff
  • For small and medium businesses
  • Volume Licensing
  • Special offers
  • Adobe Marketing Cloud sales [opens in a new window]
Search
 
Info Sign in
Why sign in? Sign in to manage your account and access trial downloads, product extensions, community areas, and more.
Welcome,
My Adobe
My orders
My information
My preferences
My products and services
Sign out
My cart
Privacy My Adobe
Adobe
Products Sections Buy   Search  
Solutions Company
Help Learning
Sign in Sign out Privacy My Adobe
Preorder Estimated Availability Date. Your credit card will not be charged until the product is shipped. Estimated availability date is subject to change. Preorder Estimated Availability Date. Your credit card will not be charged until the product is ready to download. Estimated availability date is subject to change.
Qty:
Purchase requires verification of academic eligibility
Subtotal
Promotions
Estimated shipping
Tax
Calculated at checkout
Total
Review and Checkout
Adobe Developer Connection / Dreamweaver Developer Center /

Creating a scoreboard in Spry in five easy steps

by Addam Driver

Addam Driver
  • www.reignwaterdesigns.com

Created

18 May 2008

Page tools

Share on Facebook
Share on Twitter
Share on LinkedIn
Bookmark
Print
data setDreamweaverdynamic websitenotificationSprySpryXML
Was this helpful?
Yes   No

By clicking Submit, you accept the Adobe Terms of Use.

 
Thanks for your feedback.

Requirements

Prerequisite knowledge

Familiarity with building web pages, CSS, JavaScript, and the Spry framework for Ajax.

User level

Intermediate

Required products

  • Dreamweaver (Download trial)

Sample files

  • scoreboard.zip (48 KB)

In this article, I will step you through the process of building a nifty, real-time scoreboard for your sports-viewing pleasures on your personal website. Using the Adobe Spry Data and Effects libraries, you are able not only to get scores and display them; you also have the ability to do exciting things by including notifications and other WOW factors.

Also, check out the following video to learn more about how I discovered and use Spry on the job.

This content requires Flash To view this content, JavaScript must be enabled, and you need the latest version of the Adobe Flash Player. To view this content, JavaScript must be enabled, and you need the latest version of the Adobe Flash Player.

Step 1: Prepare the data

The first step is to decide on the data you want to include on your scoreboard. For example, a typical scoreboard may contain the following details:

  • Location
  • Team names / Cities
  • Timeouts
  • Foul trouble
  • Scores

Then put the data into an XML file; for example:

<games> <game id="1"> <location>Staples Center, Los Angeles</location> <home> <teamName>Lakers</teamName> <teamCity>Los Angeles</teamCity> <teamStats timeOuts="2" foulTrouble="Kobie Bryant"> <score quarter="1">49</score> <score quarter="2">23</score> <score quarter="3">55</score> </teamStats> </home> <away> <teamName>Heat</teamName> <teamCity>Miami</teamCity> <teamStats timeOuts="5" foulTrouble="Shaq"> <score quarter="1">35</score> <score quarter="2">65</score> <score quarter="3">22</score> </teamStats> </away> </game> </games>

Next, you have to prepare the datasets.

Step 2: Prepare the datasets

When your XML data is ready, you need to prepare the datasets you are going to be working with. Follow these steps:

  1. In Dreamweaver, choose File > New > Basic page > JavaScript to create a new (external) JavaScript file and save it as games.js. This file will contain all of the necessary functions to make things work.
  2. Create the datasets to capture all the information you need. Start with the game information. To your JavaScript file, add:
var dsGames = new Spry.Data.XMLDataSet("games.xml", "games/game");

This is a dataset declaration. It will fetch the XML file andconvert it into a Spry dataset.

  1. Next, capture the home team information. Typically, this informationcontains a lot more data, so you can use the Spry subPaths function tocapture it. I also recommend you use the loadInterval feature toensure the scoreboard can update itself, in this case, every 3 seconds. The useCache option ensures that the new data is fetched from the server:
var dsHome = new Spry.Data.XMLDataSet("games.xml", "/games/game/home", { subPaths: ["teamStats", "teamStats/score" ], loadInterval:3000, useCache:false});
  1. Finally, get the away team information, which follows the same format you used in Step 3:
var dsAway = new Spry.Data.XMLDataSet("games.xml", "/games/game/away", { subPaths: ["teamStats", "teamStats/score" ], loadInterval:3000, useCache:false});

At this point, you're ready to build the HTML page that contains your data.

Step 3: Prepare the HTML page

To prepare the HTML page follow these steps:

  1. In Dreamweaver, choose File > New > Basic page > HTML to create a blank HTML page.
  2. Inside of the <head> section of the document, include the following Spry files. Ensure that the src paths match your file setup. Also, include them in the same order as shown here:
<script language="JavaScript" type="text/javascript" src="/spry/xpath.js"></script> <script language="JavaScript" type="text/javascript" src="/spry/SpryData.js"></script> <script language="JavaScript" type="text/javascript" src="/spry/SpryEffects.js"></script>
  1. Between the <body> tags of the document, add a <div> that will contain all the game information. This helps you keep everythingclean and in order. Now, add the attributes as show below. The spry:detailregion attribute tells Spry that it will be processing data within this tag. Thevalues are the three datasets that you defined above. The names should beseparated by a space:
<div spry:detailregion="dsGames dsHome dsAway"></div>
  1. Next, add some general game information. You want to use data references from the data sets to display the data from the data sets. For this demo, the only global variable is the location of the game. (You can add more as you see fit.) Place it inside of <h1> tags inside the games <div>. It should look something like this:
<div spry:detailregion="dsGames dsHome dsAway" > <h1>{dsGames::location}</h1> </div>

This displays the location data from the dsGames data set. Press F12 to preview the working page in the default browser. You should see "Staples Center, Los Angeles" in large text. If so, your Spry page is working properly. If not, check the code in the sample file and see what differs on your page.

  1. Create the scoreboard table. Inside of the <div>, insert a table (<table>) that will contain the information of each individual game as shown in this snippet:
<div spry:detailregion="dsGames dsHome dsAway" spry:repeat="dsGames"> <h1>{dsGames::location}</h1> <table cellpadding="0" cellspacing="0" border="1"> <tr> <th>&nbsp;</th> <th spry:repeat="dsHome">{dsHome::ds_RowNumberPlus1}</th> <th>Time Outs Used</th> <th>Foul Trouble</th> </tr> <tr> <td>{dsHome::teamName}</td> <td spry:repeat="dsHome" id="hq_{dsHome::teamStats/score/@quarter}">{dsHome::teamStats/score}</td> <td>{dsHome::teamStats/@timeOuts}</td> <td>{dsHome::teamStats/@foulTrouble}</td> </tr> <tr> <td>{dsAway::teamName}</td> <td spry:repeat="dsAway" id="aq_{dsAway::teamStats/score/@quarter}">{dsAway::teamStats/score}</td> <td>{dsAway::teamStats/@timeOuts}</td> <td>{dsAway::teamStats/@foulTrouble}</td> </tr> </table> </div>

This is the main part of the scorecard. Preview in browser to ensure it is working properly.

Step 4: Prepare score capturing for the WOW factor

Now that your scoreboard is up and running, you can add a notification feature that alerts users when a team has scored. There are obviously many different ways you can notify the viewer that something has changed. For this tutorial, you are going to highlight the box that contains the updated score.

The filter you create will capture the current scores, get the new set of scores and check to see if anything has changed. If they have changed, then find the location of the score and highlight the box.

Follow these steps:

  1. Create the filter function and score holder dataset. Inside of your JavaScript file, create the following variables and function:
var HScoreHolder = new Array(); // Home Score Holder var AScoreHolder = new Array(); // Away Score Holder var scoreHolder = new Array(); // Template Score Holder function GetScoreUpdateFunc(scoreHolder, prefixStr){ // Get score function }

This particular function is a wrapper for the real function. This enables you to use the filter as a template, so you can use it for more than one dataset (I'll explain that shortly). Here is the actual filter function:

var scoreHolder = new Array(); // Generic Score Holder function GetScoreUpdateFunc(scoreHolder, prefixStr){ // Get score function return function (ds, row, rowIndex){ // return the actual filter function return row; }; }
  1. Add a key:
var scoreHolder = new Array(); // Generic Score Holder function GetScoreUpdateFunc(scoreHolder, prefixStr){ // Get score function return function (ds, row, rowIndex){ // return the actual filter function var key = prefixStr+row['teamStats/score/@quarter']; // create a key for the games return row; }; }

Note that this key is basically the same value as the generated id for the score boxes in the markup. The key represents the location of the score. If you look in the mark-up above, you'll notice the following ID: id="aq_{dsAway::teamStats/score/@quarter}". This is a unique ID for each quarter. This way you can keep track of where each score is located. The var key = indicates the location of the score in its respective box.

  1. Capture and store the score information and return the regular data to the dataset:
var scoreHolder = new Array(); // Generic Score Holder function GetScoreUpdateFunc(scoreHolder, prefixStr){ // Get score function return function (ds, row, rowIndex){ // return the actual filter function var key = prefixStr+row['teamStats/score/@quarter']; // create a key for the games scoreHolder[key]= new Array(); // make each key an array scoreHolder[key]= row['teamStats/score']; // get the current scores return row; }; }
  1. Now you need a way to check the scores. Fortunately, JavaScript reads from the top down and left to right. So in between the key and the score holder array, you will insert a simple if statement that will call a function that then verifies whether the score holder array has been set. If so, it will then verify whether its value differs from the new scores. If it does, you will tell it to highlight the box from an orange color to white in 3 seconds. Here's the code:
var scoreHolder = new Array(); // Generic Score Holder function GetScoreUpdateFunc(scoreHolder, prefixStr){ // Get score function return function (ds, row, rowIndex){ // return the actual filter function var key = prefixStr+row['teamStats/score/@quarter']; // create a key for the games if(scoreHolder[key]){ // check for keys already set if(row['teamStats/score'] != scoreHolder[key]){ Spry.Effect.DoHighlight(key,{duration:3000,from:'#FB9A00', to:'#fff', restoreColor:'#fff'});// highlight the updated score box } } scoreHolder[key]= new Array(); // make each key an array scoreHolder[key]= row['teamStats/score']; // get the current scores return row; }; }

Step 5: Kick off the filter

Now that you've got it all set up, you can start on the filter. After GetScoreUpdateFunc, add two filter calls to the datasets (Home and Away) that will capture and check the data:

dsHome.filter(GetScoreUpdateFunc(HScoreHolder, "hq_")); // Filter for home scores... Check for updates dsAway.filter(GetScoreUpdateFunc(AScoreHolder, "aq_")); // Filter for away scores... Check for updates

Your scoreboard is now complete. If you update any of the scores inside of the XML, you will see it update on the page; you will also see the nifty little background orange color. For your reference, refer to the simple sample scoreboard I've included with this article.

You have various options to update your information. You can do it manually to see your new scoreboard application in action. Other methods include, using a back-end database to keep track of your scores and making a Spry-Ajax call to a PHP, JSP, ASP or other server-side application that will just fetch the new data for you in an XML format.

Where to go from here

Not bad what you can do with Spry, isn't it? If you want to take this even further, you could add a total score or other information like fouls, time-outs, and so on. Get creative and add multiple scoreboards or add more games to your XML.

More Like This

  • Creating a Spry XML data set
  • Using the Adobe Widget Browser
  • Which server-side technology should I choose?
  • Exchanging data using the Spry framework for Ajax and PHP
  • XML in the real world
  • Managing multiple subscriptions in PHP
  • Creating custom server behaviors and Dreamweaver extensions
  • Creating user-defined functions for ColdFusion 8 in Dreamweaver CS4
  • Building your first dynamic website – Part 1: Setting up the site and database
  • XSL overview

Tutorials and samples

Tutorials

  • Working with updated responsive layout features in the Dreamweaver CS6 update
  • Creating your first website – Part 3
  • Creating your first website – Part 2
  • Creating your first website – Part 5

Samples

  • Responsive design with jQuery marquee
  • Customizable starter design for jQuery Mobile
  • Customizable starter design for HTML5 video
  • Customizable starter design for multiscreen development

Products

  • Adobe Creative Cloud
  • Creative Suite
  • Adobe Marketing Cloud
  • Acrobat
  • Photoshop
  • Digital Publishing Suite
  • Elements family
  • SiteCatalyst
  • For education

Download

  • Product trials
  • Adobe Reader
  • Adobe Flash Player
  • Adobe AIR

Support & Learning

  • Product help
  • Forums

Buy

  • For personal and professional use
  • For students, educators, and staff
  • For small and medium businesses
  • Volume Licensing
  • Special offers

Company

  • News room
  • Partner programs
  • Corporate social responsibility
  • Career opportunities
  • Investor Relations
  • Events
  • Legal
  • Security
  • Contact Adobe
Choose your region United States (Change)
Choose your region Close

North America

Europe, Middle East and Africa

Asia Pacific

  • Canada - English
  • Canada - Français
  • Latinoamérica
  • México
  • United States

South America

  • Brasil
  • Africa - English
  • Österreich - Deutsch
  • Belgium - English
  • Belgique - Français
  • België - Nederlands
  • България
  • Hrvatska
  • Česká republika
  • Danmark
  • Eastern Europe - English
  • Eesti
  • Suomi
  • France
  • Deutschland
  • Magyarország
  • Ireland
  • Israel - English
  • ישראל - עברית
  • Italia
  • Latvija
  • Lietuva
  • Luxembourg - Deutsch
  • Luxembourg - English
  • Luxembourg - Français
  • الشرق الأوسط وشمال أفريقيا - اللغة العربية
  • Middle East and North Africa - English
  • Moyen-Orient et Afrique du Nord - Français
  • Nederland
  • Norge
  • Polska
  • Portugal
  • România
  • Россия
  • Srbija
  • Slovensko
  • Slovenija
  • España
  • Sverige
  • Schweiz - Deutsch
  • Suisse - Français
  • Svizzera - Italiano
  • Türkiye
  • Україна
  • United Kingdom
  • Australia
  • 中国
  • 中國香港特別行政區
  • Hong Kong S.A.R. of China
  • India - English
  • 日本
  • 한국
  • New Zealand
  • 台灣

Southeast Asia

  • Includes Indonesia, Malaysia, Philippines, Singapore, Thailand, and Vietnam - English

Copyright © 2013 Adobe Systems Incorporated. All rights reserved.

Terms of Use | Privacy | Cookies

Ad Choices

Reviewed by TRUSTe: site privacy statement