incredible! Scripts
This is a basic page for right now, but it'll give you what you need to know to make your own script actions. Scripts run in the context of the stream item and are essentially JavaScript. Many functions are just Enyo functions, so if you know all that, you should be good to go already.
Objects
Objects are just the parts of the stream item. Objects are not the actual content. Check on the functions section to see how to set or get the content of an item.
- item.author
- This is the author part of the item.
- item.avatar
- The avatar of the author.
- item.body
- This is the content area of the item. It will often contain HTML and not just plain text.
- item.border
- The colored (usually transparent) border around a stream item.
- item.footer
- This is the blue footer below the stream item. It is hidden by default for most services.
Variables
Variables are similar to Objects, except that they just return pure data and don't have other aspects.
- item.account
- Returns the associated account name of the stream item. For instance. If you Twitter name is "bob123" and the stream item was loaded in from your bob123 account, item.account would return "bob123".
- item.data
- Returns all of the raw API response data for the stream item. This will differ for every service. In order to interact with this data, you will need to familiarize yourself with that service's API documentation.
- item.date
- Returns the date the stream item was posted. Returns as a JavaScript timestamp integer in milliseconds.
- item.duplicates
- Returns an array of duplicate stream items associated with the current stream item, if any. Each item in the array has its own properties.
- item.fuzzyDate
- Returns a string of an approximate time the item was posted. Ex: "about 10 minutes ago"
- item.photos
- Returns an array of all the photos associated with the post. Usually only has a length of 0 or 1, but some Twitter posts have more than one photo.
- item.service
- Returns the name of the service (lowercase) for the stream item. ("foursquare","facebook","twitter","flickr",etc)
Functions
Most Enyo and JavaScript functions are available. Here are some useful ones.
- show()
- Makes the object visible. Useful for things like the footer that is hidden by default.
- hide()
- Makes the object hidden.
- getContent()
- Returns the content of the object. May contain HTML or plain text.
- setContent(strContent)
- Sets the content of the object
- addStyles(strStyles)
- Sets the CSS of the object. Accepts a string of CSS in the format of "property: value; secondProperty: newValue;"
Examples
Here are some code examples.
To make any stream item with duplicates have red text:
if(item.duplicates.length>0){
item.content.addStyles("color: #f00");
}
To display the app a user used to send a tweet and the time they sent it:
item.footer.show();
item.footer.setContent(item.fuzzyDate+" via "+item.data.source);
item.footer.addStyles("text-align: right;");
To make a user's avatar smaller and titled:
item.avatar.addStyles("width: 32px; -webkit-tramsform: rotate(-10deg);");