Notes on tads domexRSS swf/DOM based rss reader/styler.
/* Possible methods callable via domexRSS */
___________________________________________________________________________________________
loadRssXML
//All values are optional, if no url or div id is passed, the ones passed to the flash via flash vars
//will be used instead.
//Each value of the optional feed styles object can also be passed individually via flashvars
domexRSS("loadRssXML", 'theURL', 'theIDofDivToPutInto', optioanlFeedStylesObject);
Example:
var feedStylesObject = {
'linkDivStyle':'color:#00FF00',
'linkStyle':'color:red;text-decoration:none;',
'titleStyle':'font-family: helvetica, arial;font-size:125%;font-weight:bold',
'overallFeedStyle':'font-family:times;color:red',
'descriptionStyle':'font-family:arial;color:#C8C8C8'};
domexRSS("loadRssXML", "http://www.mysite.com/myrss.xml", "myDivID", feedStylesObject);
//or just
domexRSS("loadRssXML");
//see also notes on lagTime and the flashvars below
____________________________________________________________________________________________
establishFeedStyles
//establishes new styles for subsequent loadRssXML or applyFeedStyle calls
domexRSS("establishFeedStyles", feedStylesObject);
Example:
var feedStylesObject = {
'linkDivStyle':'color:#00FF00',
'linkStyle':'color:red;text-decoration:none;',
'titleStyle':'font-family: helvetica, arial;font-size:125%;font-weight:bold',
'overallFeedStyle':'font-family:times;color:red',
'descriptionStyle':'font-family:arial;color:#C8C8C8'};
domexRSS("establishFeedStyles", feedStylesObject);
______________________________________________________________________________________________
applyFeedStyles
//Applies the current style information to the feed within the div (by id) passed to it.
domexRSS("applyFeedStyles", idOfDivWithFeedStylesToBechanged);
Example:
domexRSS("applyFeedStyles", "RssContent2");
______________________________________________________________________________________________
changeFeedStyle
//This method calls establishFeedStyles, then applyFeedStyles for you.
//It is used to change the style of a feed that is already displayed.
//The first param is the feedStylesObject second param is the ID of the div holding the feed
domexRSS("changeFeedStyle", feedStylesObject, divID);
Example:
var feedStylesObject = {
'linkDivStyle':'color:#00FF00',
'linkStyle':'color:red;text-decoration:none;',
'titleStyle':'font-family: helvetica, arial;font-size:125%;font-weight:bold',
'overallFeedStyle':'font-family:times;color:red',
'descriptionStyle':'font-family:arial;color:#C8C8C8'};
domexRSS("changeFeedStyle", feedStylesObject, "RssContent2");
________________________________________________________________________________________________
/* End Methods */
/* -------------------------------------------------------------------------------------- */
/* The Properties available via domexRSS */
________________________________________________________________________________________________
rssURL : String
rssURL - (read/write) get set the URL to be loaded.
can also be set via flashvars
Example:
domexRSS("rssURL", "=", "myrss.xml"); //setting
var currentURL = domexRSS("rssURL"); //getting
_______________________________________________________________________________________________
outputDivID : String
outputDivID - (read/write) the ID of the div to put the feed into
can also be set via flashvars
Example:
domexRSS("outputDivID", "=", "newDIv"); //now any feed loaded will go in the div with the id "newDiv"
//replacing anything that may be there already
var currentDivID = domexRSS("outputDivID"); //getting
__________________________________________________________________________________________________
lagTime : Number
lagTime - (read only) the lagTime - can only be set via flashvars, otherwise it is 1500(milliseconds)
Use this variable to wait for the DOM to be loaded.
The more page info that is before the swf, the greater this number should be.
As with the example html page, your swf should be the last thing that gets put on the page,
then this lag time would apply, then domexRSS will be ready to be just called from the wrapper.
Noramlly, if your using the example as a template, 1000 is good enough, add about 1000 per every 100kb
that must load before the swf loads.
Example:
var theLagTime = domexRSS("lagTime"); //gets the lag time
domexRSS("lagTime", "=", 2000); //Error #1074 will alert via the browser
Setting the lagTime via flashvars:
...
var flashvars = {};
var params = {};
var atts = {};
...
params.allowscriptaccess = "sameDomain";
params.flashvars = "lagTime=1000";
swfobject.embedSWF("domexRss.swf", "divID", "700", "10", "9.0.0", false, flashvars, params, atts);
...
//more info on the flashvars below
______________________________________________________________________________________________________
currentStylesDefined : String
currentStylesDefined - (read only) returns the current styles defined.
Feed styles can only be set via one of the methods or flashvars.
this property is not settable via flashvars, truly read only.
good for an alert during debug, or to display to the user what the styles are.
Example:
domexRSS("currentStylesDefined"); //would return something like "titleStyles - '.....' " for each style.
//to change a feeds style use the changeFeedStyle method
_______________________________________________________________________________________________________
memoryHolder : Array
memoryHolder - (read/write) holds each loaded rss feed completely,
each feed is preceded by its coresponding div id.
This property is not settable via flashvars
what it looks like based on the example html page:
[ "RssContent", (full xml feed content), "RssContent2", (full xml feed content), ...ect... ]
__________________________________________________________________________________________________________
/* End properties */
/* -------------------------------------------------------------------------------------- */
/* Flashvars */
___________________________________________________________________________________________________________
//all variables settable via flashvars:
lagTime, rssURL, outputDivID, linkDivStyle, linkStyle, titleStyle, descriptionStyle, overallFeedStyle, noDOM
I advice using swfObject 2.2 to embed your swf.
The example html page uses it.
In the example page, after 2500 milliseconds the first feed is set to load.
we'll go over what is being done in the example, then show how we could pass a whole bunch of other flashvars also.
<script type="text/javascript">
//<![CDATA[
var flashvars = {}; //an empty object that is supposed to hold flashvars for the swf object
//it is better to just have a flashvars parameter
var params = {}; //an empty object that will hold the parameters for the swf
var atts = {}; //an empty object that can hold attributes for the swf
params.menu = "true"; //setting of individual param values into the awaiting params object
params.quality = "high"; //..
params.wmode = "opaque"; //..
params.swfliveconnect = "true"; //..
params.allowscriptaccess = "sameDomain"; //..
params.flashvars = "lagTime=1000"; //on this line we set the flashvars
//In this case, all that is set is the lagTime.
//all styles can be set from the flashvars
//as well as the outputDivID and the rssURL
//you just separate the variables with an amperstand - &
//Example:
//lagTime=1000&rssURL=myrss.xml&...ect... no quotes, the only quotes are around the whole thing.
//You can use plus signs to connect multiple lines - "..."+"...";
//And there's noDOM. Simply setting it disables the DOM interaction, if say, perhaps, you want to use
//the LocalConnection or some other means to invoke methods of this swf.
//lagTime is 1500 if not set via flashvars.
//rssURL must be set, either in the flashvars, or by calling domexRSS("rssURL", "=", (some rss file))
//also in the loadRssXML the url can be specified, which is what is used in the example (below)
//this line puts the swf in the page, the div you specified via id will be replaced with the swf object
//I've found it's best to therefore put a container div around the div that will become the object;
//for style purposes.
swfobject.embedSWF("domexRss.swf", "atadRssSwf", "700", "10", "9.0.0", false, flashvars, params, atts);
//Now begins the loading of the xml.
//The swf is the last thing to be put in the page,
//and the lag time is 1 second, so 2 seconds in loadRssXML is called,
//to it we pass the url of the xml to load, and the id of the div to put it in.
//the rss is formated based on any styles set, if non are set the defaults are used
//(please see the source code for the defaults.)
//Then, the innerHTML of the div you specified becomes the feed contents; title, link, decription.
//To load multiple feeds simply call the function again directed towards another div.
//Of course, the initial container divs should have already been set up, as in the example html page.
setTimeout("domexRSS('loadRssXML', 'atadrss.xml', 'RssContent2')", "2000");
//and that's it, after 2000 the feed should appear all styled and everything
//and it's style can be targeted and changed with the changeFeedStyle method (described above)
//and the memoryHolder array will have the full contents of the rss feed associated with the div
//Any calls to the same div overwrite the divs contents.
//a little extra:
function changeAnchorTargets() {
var allAs = document.getElementsByTagName("a");
for (var ai = 0; ai < allAs.length; ai++)
{ allAs[ai].setAttribute("target", "_blank");
allAs[ai].setAttribute("title", "Opens in another page."); }
}
//then half a second after that changeAnchorTargets is called to change the target of each anchor to "_blank"
//this is just an added function I've made for this example
setTimeout("changeAnchorTargets()", "2500");
//]]>
</script>
//we can pass a lot of flashvars this way:
...
params.flashvars="linkStyle=color:#c8c8c8&titleStyle=font-family:Century,Arial;font-size:25px;"+
"font-weight:bold;color:#0000FF&"+
"overallFeedStyle=width:700px;&"+
"descriptionStyle=font-family:Arial;font-size:small&outputDivID=RssContent2&rssURL=http://www.my.com/myrss.xml";
...
//then calling:
domexRSS("loadRssXML");
//will use the specs already defined by flashvars
_____________________________________________________________________________________________________
/* for playing around with the example html page,
this section has some javascript you can put in the address bar. */
javascript: domexRSS("loadRssXML"); //method that takes optional args
javascript: domexRSS("establishFeedStyles", someSpecs); //method that takes an object with name value pairs
javascript: alert(domexRSS("theLagTime")); //read only variable
javascript: alert(domexRSS("currentStylesDefined")); //read only variable
javascript: domexRSS("rssHolderDivID", "=", "RssContent2"); //read-write variable
javascript: domexRSS("rssURL", "=", "atadrss.xml"); //read-write variable
javascript: var someSpecs = {'linkStyle':'color:#FF0000','titleStyle':'font-family:Century;font-size:33px;'};
javascript: domexRSS("applyFeedStyles", "RssContent2");
javascript: domexRSS("changeFeedStyle", {'linkDivStyle':'color:#00FF00', 'linkStyle':'color:red;text-decoration:none;',
'titleStyle':'font-family: helvetica, arial;font-size:125%;font-weight:bold',
'overallFeedStyle':'font-family:times;color:black;width:700px;margin-left:auto;margin-right:auto;',
'descriptionStyle':'font-family:arial;color:#C8C8C8'}, "RssContent2");
javascript: var specs = {'linkDivStyle':'color:#00FF00', 'linkStyle':'color:red;text-decoration:none;',
'titleStyle':'font-family: helvetica, arial;font-size:125%;font-weight:bold',
'overallFeedStyle':'font-family:times;color:red', 'descriptionStyle':'font-family:arial;color:#C8C8C8'};
www.actiontad.com