[OT] An artifact of possible interest...

astares at gmx.de astares at gmx.de
Fri Oct 5 09:51:04 UTC 2007


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



More information about the Squeak-dev mailing list