[OT] An artifact of possible interest...

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[OT] An artifact of possible interest...

Torsten Bergmann
Hi Dan,

Cool! Does it support namespaces?
If not see code below. Would be interesting to
see lively on the client and Squeak seaside on the
server side...

Cheers
Torsten


-------------------------------------------------------------------------

/*
 * Define a new global namespace
 *
 * @param {Object} namespace
 */
function Namespace(namespaceName)
{
 var nsParts = namespaceName.split(".");
 var root = window;

 for(var i=0; i<nsParts.length; i++)
 {
  if(typeof root[nsParts[i]] == "undefined")
   root[nsParts[i]] = new Object();
   root = root[nsParts[i]];
 }
}

/*Lets define the namespace */
Namespace('org.squeak.domain');

/* Class constructor */
org.squeak.domain.Person = function(firstName, lastName) {
        this.name = lastName;
        this.firstName = firstName;
}

org.squeak.domain.Person.prototype = {
        fullName: function () {
                return this.firstName + " " + this.name;
        }
}

/* Create an instance of person and call a method/function*/
var person = new org.squeak.domain.Person('Dan','Ingalls');
alert(person.fullName());

--
GMX FreeMail: 1 GB Postfach, 5 E-Mail-Adressen, 10 Free SMS.
Alle Infos und kostenlose Anmeldung: http://www.gmx.net/de/go/freemail

Reply | Threaded
Open this post in threaded view
|

Re: [OT] An artifact of possible interest...

Bert Freudenberg
On Oct 5, 2007, at 11:51 , [hidden email] wrote:

> Hi Dan,
>
> Cool! Does it support namespaces?

I'm sure that's the first thing it needs.

SCNR

- Bert -