Libraries

JS Strict Data Types - Documentation

Tagged:  

JS Strict Data Types is JavaScript library that attempts to facilitate strict data types in JavaScript.

Below are the data types that are currently supported.

You can convert data types from one data type to another using the ConvertDataType method. The method accesses two parameters, the first is the variable that you want to convert and the second is a string value for the data type that you want to convert the variable to (Int for Integer, Float for Float, String for String and Boolean for Boolean). Below is an example of converting a variable from an Integer to a Float.

MyVar1 = new Int(MyVar1);
MyVar1 = ConvertDataType(MyVar1, "Float");
MyVar1.Set(253.345345);
alert(MyVar1.value);

JS Strict Data Types - Boolean

Tagged:  

Back to Main Documentation Page
The JS Strict Data Types Boolean method allows you to define a variable as a Boolean data type and maintain the value as a Boolean. The Boolean method returns true or false, but will accept true, false, 1 or 0.

To identify a variable as a Boolean you would write the below code (where OptionalBooleanValue is some Boolean value, if no value is inserted then an empty Boolean is returned).

MyVar1 = new Boolean(OptionalBooleanValue);

To return the data type of the Boolean you would use the DataType property.

alert(MyVar1.DataType);

To set the value of the Boolean to a new value you would use the below code (where BooleanValue is some Boolean value).

MyVar1.Set(BooleanValue);

To get the value of a Boolean you would use the value property (the below would display the value).

alert(MyVar1.value);

To compare if a Boolean is equal to the Boolean value you would use the CompareEq method as seen below (below is how you would use the CompareEq method in an if statement, where BooleanValue is some Boolean value).

if(MyVar1.CompareEq(BooleanValue)){
    alert("Statement is Equal");
{

To compare if a Boolean is not equal to the Boolean value you would use the CompareNotEq method as seen below (below is how you would use the CompareNotEq method in an if statement, where BooleanValue is some Boolean value).

if(MyVar1.CompareNotEq(BooleanValue)){
    alert("Statement is not Equal");
{

Below is an example of how you would use a function to maintain a Boolean value.

function TestFunction(MyVar1){
    //Set the Data Type of each Variable
    MyVar1 = new Boolean(MyVar1);
    alert("MyVar1 = " + MyVar.value);
}

JS Strict Data Types - String

Tagged:  

Back to Main Documentation Page
The JS Strict Data Types String method allows you to define a variable as a String data type and maintain the value as a String.

To identify a variable as a String you would write the below code (where OptionalStringValue is some String value, if no value is inserted then an empty string is returned).

MyVar1 = new String(OptionalStringValue);

To return the data type of the String you would use the DataType property.

alert(MyVar1.DataType);

To set the value of the String to a new value you would use the below code (where StringValue is some String value).

MyVar1.Set(StringValue);

To get the value of a String you would use the value property (the below would display the value).

alert(MyVar1.value);

To append a String value to the String you would use the append method as seen below (where StringValue is some String value).

MyVar1.append(StringValue);

To compare if a String is equal to the String value you would use the CompareEq method as seen below (below is how you would use the CompareEq method in an if statement, where StringValue is some String value).

if(MyVar1.CompareEq(StringValue)){
    alert("Statement is Equal");
{

To compare if a String is not equal to the String value you would use the CompareNotEq method as seen below (below is how you would use the CompareNotEq method in an if statement, where StringValue is some String value).

if(MyVar1.CompareNotEq(StringValue)){
    alert("Statement is not Equal");
{

Below is an example of how you would use a function to maintain a String value.

function TestFunction(MyVar1){
    //Set the Data Type of each Variable
    MyVar1 = new String(MyVar1);
    alert("MyVar1 = " + MyVar.value);
}

JS Strict Data Types - Integer

Tagged:  

Back to Main Documentation Page
The JS Strict Data Types Integer method allows you to define a variable as an Integer data type and maintain the value as an integer.

To identify a variable as an Integer you would write the below code (where OptionalIntegerValue is some Integer value, if no value is inserted then 0 is returned).

MyVar1 = new Int(OptionalIntegerValue);

To set the value of the Integer to a new value you would use the below code (where IntegerValue is some Integer value).

MyVar1.Set(IntegerValue);

To return the data type of the Integer you would use the DataType property.

alert(MyVar1.DataType);

To get the value of an integer you would use the value property (the below would display the value).

alert(MyVar1.value);

To add an Integer value to the Integer you would use the add method as seen below (where IntegerValue is some Integer value).

MyVar1.add(IntegerValue);

To subtract an Integer value from the Integer you would use the sub method as seen below (where IntegerValue is some Integer value).

MyVar1.sub(IntegerValue);

To divide the Integer by an Integer value you would use the div method as seen below (where IntegerValue is some Integer value).

MyVar1.div(IntegerValue);

To multiply the Integer by an Integer value you would use the mult method as seen below (where IntegerValue is some Integer value).

MyVar1.mult(IntegerValue);

To compare if an Integer is equal to the Integer value you would use the CompareEq method as seen below (below is how you would use the CompareEq method in an if statement, where IntegerValue is some Integer value).

if(MyVar1.CompareEq(IntegerValue)){
    alert("Statement is Equal");
{

To compare if an Integer is not equal to the Integer value you would use the CompareNotEq method as seen below (below is how you would use the CompareNotEq method in an if statement, where IntegerValue is some Integer value).

if(MyVar1.CompareNotEq(IntegerValue)){
    alert("Statement is not Equal");
{

To compare if the Integer value is greater than an Integer value you would use the CompareGrt method as seen below (below is how you would use the CompareGrt method in an if statement, where IntegerValue is some Integer value).

if(MyVar1.CompareGrt(IntegerValue)){
    alert("Statement Greater Than");
{

To compare if the Integer value is greater than or equal to an Integer value you would use the CompareGrtEq method as seen below (below is how you would use the CompareGrtEq method in an if statement, where IntegerValue is some Integer value).

if(MyVar1.CompareGrtEq(IntegerValue)){
    alert("Statement Greater Than or Equal");
{

To compare if the Integer value is less than an Integer value you would use the CompareLess method as seen below (below is how you would use the CompareLess method in an if statement, where IntegerValue is some Integer value).

if(MyVar1.CompareLess(IntegerValue)){
    alert("Statement Less Than");
{

To compare if the Integer value is less than or equal to an Integer value you would use the CompareLessEq method as seen below (below is how you would use the CompareLessEq method in an if statement, where IntegerValue is some Integer value).

if(MyVar1.CompareLessEq(IntegerValue)){
    alert("Statement Less Than or Equal");
{

Below is an example of how you would use a function to maintain an Integer value.

function TestFunction(MyVar1){
    //Set the Data Type of each Variable
    MyVar1 = new Int(MyVar1);
    alert("MyVar1 = " + MyVar.value);
}

Below is an example of how you would accomplish a for loop using the Integer method.

for(var a = new Int(0); a.value<20; a.add(1)){
    alert("a = " + a.value);
}

Learning the Yahoo! User Interface Library - Book

Tagged:  

I've been looking at a book from PACKT Publishing about Learning the Yahoo! User Interface Library. The book is one of the few good books available on the YUI. If you are like me you enjoy reading blogs for quicker reads, but for in-depth reads you find a traditional book better.

The book takes you from installing the YUI and and Code Placement through Ajax calls and Drag and Drop events. Learning the Yahoo! User Interface also takes you through debugging the YUI way and using content containers and tabs (just to name a few more topics).

Each chapter goes over a small example project about the topic of the chapter. For example Chapter 7 talks about navigation and AutoComplete with code for navigation options and a nice AutoComplete example. The book is well written and has an easy to follow format.

You can read the full table of contents here.

One thing that is really nice about books written by PACKT Publishing on an open source project is that they pay a royalty to the open source project. So, you not only get to learn about the open source project, but you also support it with the purchase of the book.

This book is a must for anybody that is interested in implementing a project with the YUI JavaScript library. I would recommend it for those of you that are new to YUI and even to those who have used it for a while.

You can purchase the book here (available in traditional and e-book formats).

If you want to see a fun application written with YUI check out World of Solitaire (watch out, you can spend quite a bit of time playing it!)

Bluff - JavaScript Graphs

If you want to display data in a graph dynamically in a web page, you have a few options. You can create your own library to create the Graph or use an existing one. If you decide against using the Google Chart API you may want to look into Bluff. Bluff is a JavaScript library that uses canvas (Google’s ExCanvas is used to allow Internet Explorer support) to create a graph on a web page.

Below is an example of a graph and the code that is used to create it.

        <canvas id="example"></canvas>
        
        <script type="text/javascript">
          var g = new Bluff.Line('example', 400);
          g.theme_37signals();
          g.title = 'My Graph';
        
          g.data('Apples', [1, 2, 3, 4, 4, 3]);
          g.data('Oranges', [4, 8, 7, 9, 8, 9]);
          g.data('Watermelon', [2, 3, 1, 5, 6, 8]);
          g.data('Peaches', [9, 9, 10, 8, 7, 9]);
        
          g.labels = {0: '2003', 2: '2004', 4: '2005'};
        
          g.draw();
        </script>

You can download Bluff here.

You can read more about Bluff here.

b9j.uri : A JavaScript URI Object

Robert Krimen has created a JavaScript URI Object capable of parsing, manipulating, and generating URIs. It splits up a URI into three objects: the URI, the path, and the query. Changes to the path or query objects are reflected in their respective URI. Armed with a wide array of methods, the b9j.uri object is well equipped to handle even the toughest of URIs.

Here's a overview of b9j.uri.URI from Robert:

  • Parses using Steven Levithan's parseUri 1.2
  • Easy path traversal (ascend to parent, descend to a child)
  • Set or add to the URI query (with proper encoding), get/interrogate the query (with proper decoding)
  • Add arbitrary data (unencoded) to the end of the query string, for extra flexibility
  • Manipulate/interrogate the scheme, user information (username & password), host, port, fragment, and more in a piecewise fashion
  • Add, change or strip the extension (html, js, css, ...) from a given URI

The code is available at http://appengine.bravo9.com/b9j/b9j.uri.js (19kb compressed / 5kb gzipped)

GWT 1.5 Released

The Google Web Toolkit (GWT) project has released version 1.5 of its Java-based web development library yesterday. The new release sports a host of new features such as:

  • Support for Java 5 language features (generics, enums, enhanced for loops, and static imports)
  • Improved performance of compiled JavaScript code
  • It is now possible to sublcass the JavaScriptObject class, creating "class overlays" that can be mapped to arbitrary JavaScript classes
  • Expanded JRE emulation library
  • A new high-performance DOM API
  • Default visual themes: Standard, Chrome, and Dark
  • Support for right-to-left languages

For a full list of the new features, see here.

The new version can be downloaded here.

YUI 3.0 Preview Release 1

The Yahoo! User Interface development team has released the first preview version of YUI 3.0. According to the team blog, there are 5 goals for the new release: lighter code (in kb), faster code (fewer HTTP requests, more compact code), greater API consistency, more powerful API capability, and more securable code.

What's New?

  • Sandboxing: each YUI instance can now be separated from other instances via YUI.use()
  • Modularity: YUI 3.0 is architected to use smaller, more re-usable modules.
  • Self-completing: With the seed file in place, you can tell YUI what modules you want to use, and it will download them in a single HTTP request.
  • Selectors: Elements can be targeted via CSS selector idioms (much like jQuery)
  • Enhanced Custom Events: Custom Events in YUI 3.0 have been enhanced with support for bubbling, stopping propagation, assigning/preventing default behaviors, among other things.
  • Nodes and NodeLists: You can now reference elements via Node and NodeList facades, allowing a more fluid API.
  • Chaining: YUI is adopting a fluent interface style, using method chaining to achieve greater expressiveness (and compactness)

For those who don't like the jQuery-style fluent interfaces in YUI 3.0, a more explicit/verbose API is still available. YUI 3.0 will not be completely backward compatible with YUI 2.0, but there will be a limited compatibility layer.

You can download the preview release here. A final release is not anticipated until next year.

CGLIB 2.2 Becomes Final

Tagged:  

From the "snuck by me department": CGLIB 2.2, which had hovered in beta for a seemingly endless period of time, became final in May of 2008. The brief release notes explain that it contains a patch for a race condition in MethodProxy as well as an upgrade to ASM 3.1. For those who aren't familiar with CGLIB, it is a very lightweight Java library originally created as a faster alternative to java.lang.reflect.Proxy. It has seen use in many well-known projects such as Hibernate, Spring, and more recently Google Guice.

Syndicate content