javascript Syndicate content

Creating a reading list in App Cloud

Adam Mark's picture
Posted by Adam Mark on February 10, 2012.
Tags: javascript, cache

The function bc.core.cache() is great for all kinds of things: saving user preferences, saving application state, or saving "favorites," as in a reading list.

Here are some functions for managing an array of "favorites" in the cache. In this case, the favorites are news articles (objects), each identified by a unique ID:

Share:

Working with the DOM in App Cloud

Adam Mark's picture
Posted by Adam Mark on February 10, 2012.
Tags: javascript, HTML, dom, app cloud

Apps are full of lists—articles, videos, events, and so on—and these lists are often created dynamically with JavaScript. Say you're creating a list of news articles. Your HTML might begin like this:

<ul id="articles">

</ul>

How should you fill the empty <ul> with content? There are two basic approaches:

Share:

"Lazy Loading" your views in App Cloud

Adam Mark's picture
Posted by Adam Mark on February 7, 2012.
Tags: javascript, app cloud

"Lazy loading" doesn't mean you're lazy. It's simply a technique for deferring an operation until it's absolutely necessary.

If your template has multiple views, you should consider building up each view when the user enters it—and not before. You'll save memory and improve the performance of your app by preventing all your business logic across all your views from running at the same time.

Share:

Organizing your App Cloud code

Adam Mark's picture
Posted by Adam Mark on February 7, 2012.
Tags: javascript, app cloud

App Cloud templates can be organized in any form or fashion, with one exception: the manifest file must be at the root of the template directory. Otherwise, you can use any conventions you like.

In my templates, I like to have one JavaScript file per HTML file. For example:

Share:

Cross-domain requests with the App Cloud Device API

Adam Mark's picture
Posted by Adam Mark on February 2, 2012.
Tags: javascript, device, app cloud

If you're trying to make AJAX requests from within the Workshop app—for example, with $.get() or $.ajax()—you'll notice nothing happens. Why? AJAX requests cannot be made across different domains.

App Cloud provides a device method for this very reason:

bc.device.fetchContentsOfURL(url, successCallback, errorCallback);

This asynchronous method can be used to load any kind of textual data, from JSON to XML to HTML. For example:

Share:

Improve your App Cloud code with JSHint

Adam Mark's picture
Posted by Adam Mark on February 2, 2012.
Tags: javascript, app cloud

Looking for a great JavaScript validator? Check out JSHint. (We use it in the App Cloud SDK.) Be prepared for lots of warnings! You can throttle them down by turning off certain options like not requiring "===" in equality statements (although this is usually a good thing).

Share:

Working with device error codes in App Cloud

Adam Mark's picture
Posted by Adam Mark on February 2, 2012.
Tags: javascript, device, app cloud

Whenever you interact with native device capabilities, be prepared to handle errors. Device functions return an error code whenever things don't go according to plan. For example, when scanning a QR code:

Share:

Caching data feeds in App Cloud

Adam Mark's picture
Posted by Adam Mark on January 31, 2012.
Tags: javascript, cache, app cloud

Caching data with bc.core.cache() will improve the performance and "stickiness" of your app. Here are three reasons to do it:

1. Speed up your app

Seconds matter, especially in mobile phone apps. While you're waiting for new data to load from the server, you can display cached data. Often, the data will be the same. In any case, you're giving the user something to process instead of just a spinning wheel.

Share:

Understanding tap events in App Cloud

Adam Mark's picture
Posted by Adam Mark on January 26, 2012.
Tags: jQuery, javascript, app cloud

Remember doing stuff like this?

<div id="hello" onclick="alert('hello!')">Hello</div>

Or this?

document.getElementById("hello").onclick = function (evt) {
    alert("hello!");
});

Or this?

document.getElementById("hello").addEventListener("click", function (evt) {
    alert("hello!");
});

Or this, with jQuery?

Share:

JavaScript Player API example

Grant Goodman's picture
Posted by Grant Goodman on April 9, 2009.
Tags: player api, javascript

We have a new code sample and article that shows how to use the JavaScript Player API to create and remove a player in a page dynamically. Read more.

Share:

Developer action for Brightcove -- new SDKs for PHP and JavaScript

Jeremy Allaire's picture
Posted by Jeremy Allaire on February 20, 2009.
Tags: developer, sdk, javascript, php

Some great activity happening in our developer community, with new open SDKs released for Brightcove's APIs for PHP and JavaScript developers.  It's exciting to see online video moving into being a real set of developer platforms that web developers can use for integrating video and rich media into their sites in easy ways.

Share: