Sign in

OpenSocial Dev App

Code Tab

< Help Index News Tab >

The Code Tab gives you an editing environment that allows you to write OpenSocial JavaScript code to run against the current container.

The Code Tab provides a toolbar to save and load your code samples. When you first load the tab, you will notice a large text area (4) containing sample OpenSocial code. You can run this code by pressing the Execute (5) button. To familiarize yourself with the OpenSocial APIs, try modifying the default code to perform different types of requests.

The code tab contains the following components:

  1. The drop down list contains a list of samples that you have saved. To load a sample, first select it from this list.
  2. Pressing the "Load" button will load the currently selected sample and place its contents into the code textbox.
  3. Pressing the "Save code as" button will prompt you to save the contents of the code textbox as a sample.
  4. The code textbox is where you will edit and run OpenSocial code.
  5. The "Execute" button runs the code that is currently present in the code textbox.
  6. The "Larger" button will increase the size of the code textbox by a few lines per click. Use this if you want more room to view your code.
  7. The "Smaller" button will decrease the size of the code textbox by a few lines per click.
  8. At the bottom of the code textbox is a div element for use by your code samples. If you need to insert HTML or DOM nodes into the page, use this element.

Code Tab API

The Code Tab supplies a JavaScript API which you may use in your samples. Here is a list of functions you may call from code in this section:

cls The cls method is shorthand for "CLear Screen". Use this to clear the output buffer, as covered below.
output Call the output method to print text. output can take a variable number of arguments, so you can print several variables on the same line without needing to perform string concatenation yourself. If you have firebug installed and enabled, output will also echo output to the firebug console, meaning that you can inspect objects that you print using output as well.
< Help Index News Tab >