Join Now
Quality Rating:
  • Currently 0.0 / 5
(0.0 / 5 - 0 votes cast)
Expertise Level:
  • Currently 0.0 / 5
(0.0 / 5 - 0 votes cast)

This page was last modified 07:15, 28 March 2008.

Use prototype javascript library : basic operations (utility functions, etc) in WRT application

From Forum Nokia Wiki


Contents

Introdution

As you may know, Prototype is a famous cross-web-browser javascript library. It supports almost all current popular web browsers, such as FireFox, Safari, IE, Opera, etc. With the latest version(Prototype 1.6.0), it also supports AppleWebKit, an open source web engine provided by Apple Inc.

The Nokia Web Browser is built upon S60WebKit, a port of the open source WebKit project to the S60 platform. Nokia WRT(Web-RunTime) is based on it.

In this section, we will see how to do basic operations(utility functions) using prototype library[1].

Basic operations (Utility functions, etc)

Here is a list of the basic operations (dollar functions) provided by prototype library:

  • $() -- returns the element that has the id passed as an argument
  • $$() -- returns the elements that match CSS selectors
  • $A() -- converts the single argument it receives into an Array object.
  • $F() -- returns the value of any field input control
  • $H() -- converts objects into enumerable Hash objects that resemble associative arrays
  • $R() -- builds a range object.
  • $w() -- Splits a string into an Array, treating all whitespace as delimiters. Equivalent to Ruby's %w{foo bar} or Perl's qw(foo bar).

For detailed explanations of these functions, please go to http://prototypejs.org/api/utility

All of the above functions are tested in the example WRT application of this topic. For the convenience, the related source code of each test case is displayed in UI, and formatted by prettyprint.js for a better look.

All test cases of the above functions passed. The Try.these function is not tested, you can try it yourself.

Most of the examples(cases) come from this guidance: http://www.sergiopereira.com/articles/prototype.js.html (You may notice this guide is a note for prototype1.5.0, but it doesn't matter.)

The next topic will be String manipulations.

Download Sample Widget

Download sample wiget of this topic: Image:PrototypeBasicDemo.zip. To install it, just rename the suffix .zip to .wgz.

For the latest version, please go to http://code.google.com/p/prototypewrt/downloads/list

Related topics

References

  • Prototype javascript Home Page [2]
  • Use prototype [3]
  • Sample WRT applications Download [4]
 
Powered by MediaWiki