I want to introduce a little project I worked on a few weeks ago.  It is
an ECS like library written in JavaScript.  If you like writing HTML via
ECS, but are going to have situations where server side programming is
not available, you can try this.  Everything happens on the client side.
Because it is client side and interpreted it has been kept small.  This
means you have to be more specific.  Just look at my attached files and
You'll see what I mean.  Save the following code to seperate files and
try it.

You may notice this is copyrighted.  I did not use ECS code to make
this.  I cannot release it under any license because I wrote mostly at
work.  If you guys like the idea I will rewrite it using ECS code and
make it a TRUE SUBSET.  That way the resulting code will has an open
license.

Please give me feedback.



***************************
Begin Test.html
***************************
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<html>
<head>
        <title>Untitled</title>
        <script language="JavaScript" type="text/javascript"
src="miniECJS3.js"></script>
</head>

<body>

<script language="JavaScript" type="text/javascript">
        MyTable = new Table()
                .setAttribute("border", 1)
                .addElement(new Tr()
                        .addElement(new Td("Hello"))
                        .addElement(new Td("World!"))
                );
        document.write(MyTable);
</script>

</body>
</html>
********************************
End
********************************

***************************
Begin miniECSJS3.js
***************************
/*Mini Element Construction JavaScript Subset (miniECJS3.js)
This JavaScript class gains inspiration from the Element Construction
Set
at java.apache.org.  Only the idea was used.  It is original code and 
no GPL code was used.

� Copyright 2000 Rand Technology, Inc.  All rights reserved.
*/

function Element(element, content){
        //Prototyping
        this.addContent = addContent;
        this.addElement = addContent;
        this.setAttribute = setAttribute;
        this.toString = toString;
        this.write = write;
        this.initElement = initElement;
        this.element = element;
        this.content = content;
        //End Prototyping
        
        //Run Constructor
        this.initElement();
        
        function initElement() {
                if (!this.element) this.element = "";
                if (!this.content) this.content = "";
                this.attributes = "";
        }
                
        function addContent(content){
                this.content += content;
                return this;
        }
        
        function setAttribute(attribute, value){
                this.attributes += " " + attribute;
                if(String(value) != "undefined") this.attributes +=
"=\"" + value + "\"";
                //value as a string is evaluated because if value == 0,
it will evaluated as false
                return this;
        }

        function toString(){
                return "<" + this.element + this.attributes + ">\n" +
this.content + "</" + this.element + ">\n";
        }

        function write(){
                document.write(this.toString());
        }
        
}

//Some common elements
//Table.prototype = new Element();
//function Table(content){      
//      return new Element("table",content);
//}
function Table(content){
        return new Element("table",content);
}

function Tr(content){
        return new Element("tr",content);
}

function Td(content){
        return new Element("td",content);
}

function Select(content){
        return new Element("select",content);
}

function Option(content){
        return new Element("option",content);
}
********************************
End
********************************


--
------------------------------------------------------------
To subscribe:        [EMAIL PROTECTED]
To unsubscribe:      [EMAIL PROTECTED]
Archives and Other:  <http://java.apache.org/main/mail.html>
Problems?:           [EMAIL PROTECTED]

Reply via email to