Visit Our Home Page
 Share this article on facebook  Tweet this article  digg this  Bookmark on del.icio.us  Bookmark on google  Bookmark on yahoo  Bookmark on stumble upon  Share this on MySpace  
Creativyst Docs 
Basic Information
Contact | News | Glossary | Site  
Twitter follow Button
(@NetlabLoligo)

  R
e
L
a
t
e
d


 
JSMsg Information
º Icon: JSMsg Button
JSMsg Basics
Free Download
º JSMsg Scrollers
º JSMsg Feeds
JSMsg Details
Concept Test Page

 


 
 




















 
 
 
Creativyst® JSMsg
Basic Information



JSMsg Basics

JSMsg is a JavaScript file convention that lets webmasters display content from blogs and newsfeed on their pages without access to server-side scripting. The JSMsg convention gives webpage designers complete control over layout and content usage.

To display content from a JSMsg file, simply include it in your page's HEAD section with a <SCRIPT> tag, then call the access functions where needed in your page's HTML. You may also call JSMsg functions from within your own JavaScript Scripts.

Here's an example of how to include a JSMsg.js file from an outside content source such as a news service or Blog in the HEAD section of a page.

 
 <SCRIPT TYPE="text/javascript" LANGUAGE="JAVASCRIPT"
     SRC="http://www.creativyst.com/Site/quotes/JSMsg.js">
</script>
 

Once you've included the source JSMsg file in the header of your HTML file, you may access its content through a standard set of simple functions. Here's a simple example of using JSMsg to display content in your page.

 
 <BR/>
 <script LANGUAGE="JAVASCRIPT">
     cqc.Msg( "Body");
     document.write("<BR>&nbsp;-");
     cqc.Msg( "Attrib");
 </SCRIPT>
 <BR/>
 

In this example the Msg() function is used to display a random quote and attribute that changes each time the page is reloaded.

You may include multiple JSMsg files from different sources in a single page. The namespace insures that you display only information from the source you want, where you want it.




Why Use JSMsg?
  • Webmaster can access your content with only client-side scripting
    The most important reason to publish your feed in JSMsg is so websites with no ability to run server-side scripts can still display your feeds.

  • JSMsg is flexible and powerful
    Webmasters who use JSMsg files to display dynamic content on their pages have complete control over how that content is displayed and presented.

  • JSMsg is "REST"ful, standard, and cross-browser
    Webmasters who use JSMsg files need not be concerned with cross browser issues because it works on any browser with JavaScript enabled.

  • JSMsg does not rely on proprietary software
    Webmasters and content providers need not be concerned with whether a visitor has installed the proper plug-ins or DLLs in order to see their content.



Displaying Content with JSMsg

There are six access functions, for now we will use the namespace "ns." (for "namespace"). The namespace will usually be different depending on the source, and in some cases you will be able to select what namespace to use:


Display functions (Msg)
Display parts of the content directly on the web page where they are called.

ns.Msg(MsgPart [,offset]);
Displays a part from a randomly selected entry that changes each time a page is loaded.

ns.MsgDay(MsgPart);
Displays a part from an entry that changes once a day.

ns.MsgN(MsgPart,Number);
Displays a part of the Nth entry in the JSMsg file, where N is specified with Number.


String functions (Get)
Return strings containing parts of the content so that you may use it within your own JavaScript

ns.Get(MsgPart [,offset]);
Return a part from a randomly selected entry that changes each time the page is loaded.

ns.GetDay(MsgPart);
Returns a part from an entry that changes once a day.

ns.GetN(MsgPart,Number);
Returns a part of the Nth entry in the JSMsg file, where N is the Number specified.

As has already been demonstrated, the simplest way to display content is with the "ns.Msg()". But JSMsg frees webmasters to choose whatever level of complexity and creativity they want.

For example, if the source is a set of headlines from a provider named NewsNymph.com with links to full stories. You could display the most recent (top most) headline in your page.

First, include NewsNymph's JSMsg.js file in the HEAD section of your page like this:

 
 <SCRIPT TYPE="text/javascript" LANGUAGE="JAVASCRIPT"
     SRC="http://www.NewsNymph.com/Feeds/JSMsg.js">
</script>
 

Next, display the top most story using the nn.GetN() function (assuming their namespace is "nn" for NewsNymph).

 
 <script LANGUAGE="JAVASCRIPT">

     var msg;
     msg = "Top Story:<BR><B>";
     msg += nn.GetN( "Title", 0 );
     msg += " </B><BR>";
     msg += nn.GetN( "Month2N", 0 );
     msg += "/";
     msg += nn.GetN( "Day2N", 0 );
     msg += "/";
     msg += nn.GetN( "Year4N", 0 );
     msg += "<BR><I>";
     msg += nn.GetN( "Desc", 0 );
     msg += "</I><BR>";

     document.write(msg);

 </SCRIPT>
Top Story:
NewsNymph Considers Publishing in JSMsg
06/25/2003
New syndication format will allow webmasters to show our content directly in HTML without need for special software.
 

This shows how the GetN() function can be used to display the first message in the JSMsg file in the frame (this is not a working example).

Message parts are labels used to access various parts of a message, such as the Title, Body, etc. The message parts used in the above example were "Title", "Day2N", "Month2N", "Year4N", and "Desc".

Message parts are all optional but at least one message part will be provided in the JSMsg.js file. Here are the message parts you may call from the six access functions.

  • Type
    A field to hold the type of the message. Such as "news story", "article", "quote", etc. This is optional, but may be useful, especially in instances where multiple JSMsg.js files are employed. Though, it may not provide any information which is not already inferred from the name space. If used it SHOULD be terse.
  • Title
    The title or headline of the message. News stories, article names, and other content will have a natural title. Some messages, like quotes and customer testimonials would not need to provide this message part.
  • Desc / SubHead / Description
    Meta-data about the message. A description. SHOULD also be used for the lead-in (sub-heading) in news stories.
  • Body / Content
    The body of the message. While many messages will include this part, others, such as news headlines wont.
  • Attrib / Source / Attribute
    The source or person or group who is thought to have first made the statement or originated the content. the is NOT the author per se, though in the case of a quote it might be thought of as such.
  • Author
    The person who is known to have authored the content. Use Attrib for quotes. If there is no Author field but there is an Attrib field, this part SHOULD return that.
  • Cat / Subject / Category
    A category or subject field associated with the message content.
  • Number / Numb
    The numeric position of the current message in the JSMsg file's list of messages. This is helpful for the functions such as ...Get() and ...Msg() that return part of a randomly selected message. Less obvious though, it is also helpful for the ...GetN/MsgN() functions since they wrap around and start counting from the begining when the JSMsg file runs out of messages. To get a count of total message in the JSMsg file, call ...MetaMsg("MetaCount");.

  • DayN, Day2N
    The day of the month (1 to 31) associated with the story/message. Usually just for news and announcements. Use Day2N to add a leading zero when the day number is only one digit.
  • MonthN, Month2N
    The month number (1 to 12) associated with the story/message. Usually just for news and announcements. Use Month2N to add a leading zero when the month is only one digit.
  • Year2N, Year4N
    The two or four digit year. Also, YearN SHOULD produce a 4 digit year. That is it should be the same as Year4N

  • Link
    A URL or URI associated with the message. This is especially helpful for linking news headlines to stories, or anywhere you want to link a terse message to greater detail.
  • LinkTitle
    A complete HTML consisting of the Title surrounded by an HTML anchor tag to the Link (<A HREF=Link...>Title</A>). This part must attempt to provide content even when one or the other of the two components are not provided, i.e.:
    • A Link with no Title
      Make an anchor to the link with the link itself as the hypertext.
    • A Title with no Link
      Return the title without surrounding it in an anchor tag.
    • No Title, no Link
      Return nothing ("")
  • Thumb
    A URL or URI to a graphic content associated with the message. This is useful for providing a picture to go with a headline. The graphic should be kept small for efficient bandwidth usage, but since it's a URI only, the user has the option of sizing it to taste within his own JavaScript (so don't make it too small).
  • Alt
    The Alt text that should go behind a graphic. This may be a terse description or just a copy of the description.




Display RSS Feeds with JSMFeed.pl

If the source site does not yet publish their content in JSMsg, but does publish using RSS, you can use a conversion script called JSMFeed.pl in the header section of your page. This script is provided for free download at creativyst.com. It will convert the content provider's RSS feed into a JSMsg file which you then use just like you would a native JSMsg.js file.

 
 <SCRIPT TYPE="text/javascript" LANGUAGE="JAVASCRIPT"
     SRC=
     "/your/cgi/JSMFeed.pl?ns=nn&url=http://NewsNymph.com/OurRss.xml">
</script>
 

In this case, ns is set to the namespace, which you choose, and url is set to the URL of the RSS file you want to use as a source.
You may use Creativyst® JSMFeed.pl when producing Internet or intranet based web sites for yourself, your employer, or your clients, but you may not distribute it or derivatives as downloadable content, or part of a package.




More Information & Resources
  • JSMsg: The Full Convention Definition
    This is a detailed document defining the JSMsg convention and providing resources for those content providers and programmers who write software that syndicates content and those who write display scripts.
  • JSMFeed.pl Information and Download Page
    This is the top information page for JSMFeed.pl; A script provided for free download by Creativyst, Inc. that lets webmasters use content syndicated in the popular RSS format.



Licensing and Permissions

JSMsg is a shared convention developed and published by Creativyst, Inc. You may use JSMsg in commercial and open source projects, provided you give credit to Creativyst, Inc. and follow the conditions set forth in the convention document.

JSMFeed.pl is a free download file produced by Creativyst, Inc. You may use Creativyst® JSMFeed.pl when producing Internet or intranet based web sites for yourself, your employer, or your clients, but you may not distribute it or derivatives as downloadable content, or part of a package.

This article is © Copyright, Creativyst, Inc. 2002 - 2008 ALL RIGHTS RESERVED.

Links to this paper are always welcome.

However, you may not copy, modify, or distribute this article without first obtaining express written permission from Creativyst, Inc. Those wishing to obtain permission to distribute this paper or derivatives in any form should contact Creativyst.




Frequently Asked Questions

Q. Can I link to your JSMsg file of quotes on my own page?
A. Sure. It's actually a great way to learn how to use the JSMsg convention. All we ask is that you let people know somewhere that it's from Creativyst by providing a link back.

Q. I arrived at this help file through a search engine. Where can I find the JSMFeed.pl script for download?
A. A good place to start is the information page for JSMFeed.pl at A fully functional example installation is available at Creativyst's web site: http://www.creativyst.com/Prod/18/.

Q. What is REST?
A. Representational State Transfer - A subject well beyond the scope of this help file. For a very authoritative discussion of REST, go to http://www.ics.uci.edu/~fielding/pubs/dissertation/rest_arch_style.htm

Q. I have a question that's not listed here, how do I get an answer?
A. Please feel free to contact us via email, using an online contact form or in our forums. We will usually respond within 24 hours.








 
© Copyright 2002 - 2008 Creativyst, Inc.
ALL RIGHTS RESERVED

Written by John Repici


With contributions by: