joo.Class.prepare("package joo.http",

"import joo.util.PropertyAware",








"public class Cookie extends PropertyAware",[],function($jooPublic,$jooPrivate){with($jooPublic)with($jooPrivate)return[











"public _Cookie",function(key,properties){
this[_key]=key;
this[_super](properties);
},







"public setDomain",function(domain){
this[_domain]=domain;
return this;
},







"public setPath",function(path){
this[_path]=path;
return this;
},






"public setDuration",function(duration){
this[_duration]=duration;
return this;
},






"public setSecure",function(secure){
this[_secure]=secure;
return this;
},








"public save",function(value){
var cookie=[this[_key],"=",encodeURIComponent(value)];
if(this[_domain]){
cookie.push("; domain=",this[_domain]);
}
if(this[_path]){
cookie.push("; path=",this[_path]);
}
if(this[_duration]){
var date=new Date();
date.setTime(date.getTime()+this[_duration]*24*60*60*1000);
cookie.push("; expires=",date.toGMTString());
}
if(this[_secure]){
cookie.push("; secure");
}
window.document.cookie=cookie.join("");
return true;
},





"public load",function(){

var cookieKey=this[_key].replace(/([.*+?^${}()|[\]\/\\])/g,"\\$1");
var match=window.document.cookie.match("(?:^|;)\\s*"+cookieKey+"=([^;]*)");
return match?decodeURIComponent(match[1]):null;
},










"public remove",function(){
this[_duration]=-1;
this.save("");
},

"private var",{key: undefined},
"private var",{domain: undefined},
"private var",{path: undefined},
"private var",{duration: undefined},
"private var",{secure:false},
]}
);joo.Class.prepare("package joo.util",

"import joo.lang.JOObject",

"public class PropertyAware extends JOObject",["toMethodSuffix","toPropertyName","setProperties","toSetterName","setProperty","getProperty"],function($jooPublic,$jooPrivate){with($jooPublic)with($jooPrivate)return[

"public static const",{SET:"set"},
"public static const",{GET:"get"},
"public static const",{IS:"is"},
"private static const",{PREFIX_REG_EXP:function(){return RegExp.compile("^("+GET+"|"+IS+")[A-Z]");}},

"public static toMethodSuffix",function(prop){
return prop.charAt(0).toUpperCase()+prop.substring(1);
},
"public static toPropertyName",function(getterName){
var match=getterName.match(PREFIX_REG_EXP);
if(match){
var prefixLength=match[1].length;
return getterName.charAt(prefixLength).toLowerCase()+getterName.substring(prefixLength+1);
}
return null;
},

"public _PropertyAware",function(props){
this[_super]();
if(props){
this.updateProperties(props);
}
},

"public updateProperties",function(props){
setProperties(this,props);
},

"public static setProperties",function(bean,props){
for(var prop in props){
setProperty(bean,prop,props[prop]);
}
},
"public static toSetterName",function(prop){
return SET+toMethodSuffix(prop);
},

"public static setProperty",function(bean,prop,value){
var propSetterName=toSetterName(prop);
if(typeof bean[propSetterName]=="function"){

bean[propSetterName](value);
}else if(typeof bean["getClass"]!="function"||prop in bean){

bean[prop]=value;
}else{

throw new Error("Unknown property "+bean+"."+prop+" set to '"+value+"'.");
}
},
"public static getProperty",function(bean,prop){
var methodSuffix=toMethodSuffix(prop);
var propGetterName=GET+methodSuffix;
if(typeof bean[propGetterName]=="function"){

return bean[propGetterName]();
}
var boolPropGetterName=IS+methodSuffix;
if(typeof bean[boolPropGetterName]=="function"){

return bean[boolPropGetterName]();
}
return bean[prop];
},
]}
);joo.Class.prepare("package joox.cache",

"import joo.lang.JOObject",

"public class Dependency",[],function($jooPublic,$jooPrivate){with($jooPublic)with($jooPrivate)return[

"public _Dependency",function(base,property){
this[_super]();
this.base=base;
this.property=property;
this[_hashCodeValue]=JOObject.getHashCode(this.base)+"#"+this.property;
},
"public hashCode",function(){
return this[_hashCodeValue];
},
"public var",{base: undefined},
"public var",{property: undefined},
"private var",{hashCodeValue: undefined},
]}
);joo.Class.prepare("package joox.cache",

"import joo.util.PropertyAware",
"import joox.cache.DependencyTracker",

"public class DependencyAwareAspect extends PropertyAware",["instrumentClass"],function($jooPublic,$jooPrivate){with($jooPublic)with($jooPrivate)return[
"private static const",{DEBUG:false},

"private static functionWithName",function(f,name){
f["getName"]=function(){return name;};
return f;
},

"private static wrapGetter",function(propertyName,getter){
return function(){
DependencyTracker.addDependency(this,propertyName);
return getter.call(this);
};
},

"private static wrapSetter",function(propertyName,getter,setter){
return function(value){
var oldValue=getter.call(this);
var result=setter.call(this,value);
var newValue=getter.call(this);
if(oldValue!==newValue){
DependencyTracker.fireDependency(this,propertyName);
}
return result;
};
},

"public static instrumentClass",function(clazz){

if(DEBUG)
console.debug("Instrumenting "+clazz["getName"]()+"...");
var classPrototype=clazz.prototype;

for(var getterName in classPrototype){
var getter=classPrototype[getterName];

if(typeof getter=="function"){
var propertyName=PropertyAware.toPropertyName(getterName);
if(propertyName){

var setterName=PropertyAware.toSetterName(propertyName);
var setter=classPrototype[setterName];
if(typeof setter=="function"){
classPrototype[getterName]=functionWithName(wrapGetter(propertyName,getter),getterName);
classPrototype[setterName]=functionWithName(wrapSetter(propertyName,getter,setter),setterName);
if(DEBUG)
console.debug("Instrumenting "+clazz.getName()+"#"+propertyName);
}
}
}
}
},

]}
);joo.Class.prepare(


"package joox.cache",

"import joo.util.HashSet",
"import joo.util.GapArrayIterator",

"public class DependencySet extends HashSet",[],function($jooPublic,$jooPrivate){with($jooPublic)with($jooPrivate)return[

"public _DependencySet",function(listener){
this[_super]();
this[_listener]=listener;
},
"override public add",function(dependency){
if(this[_add](dependency)){
var base=dependency.base;
var propertyChangeListenersByName=base["_pcl"];
if(!propertyChangeListenersByName){
propertyChangeListenersByName=base["_pcl"]={};
}
var property=dependency.property;
var propertyChangeListeners=propertyChangeListenersByName[property];
if(!propertyChangeListeners){
propertyChangeListeners=propertyChangeListenersByName[property]=new HashSet();
}
propertyChangeListeners.add(this);
}
},
"override public remove",function(base,property){
this[_remove](new Dependency(base,property));
var depSet=base["_pcl"][property];
depSet.remove(this);
},
"override public clear",function(){
var it=this.iterator();
while(it.hasNext()){
var dependency=it.next();
var depSet=dependency.base["_pcl"][dependency.property];
depSet.remove(this);
}
this[_clear]();
},
"public propertyChanged",function(){
this[_listener].invalidated(this);
},
"private var",{listener: undefined},
]}
);joo.Class.prepare("package joox.cache",

"import joo.util.HashSet",
"import joo.util.GapArrayIterator",
"import joox.cache.DependencySet",
"import joox.cache.Dependency",

"public class DependencyTracker",["start","addDependency","stop","fireDependency"],function($jooPublic,$jooPrivate){with($jooPublic)with($jooPrivate)return[

"public static start",function(listener){
dependencies.push(new DependencySet(listener));
},
"public static addDependency",function(base,property){
var dependencyStack=dependencies;
if(dependencyStack.length>0){
var depSet=dependencyStack[dependencyStack.length-1];
depSet.add(new Dependency(base,property));
}
},
"public static stop",function(){
return dependencies.pop();
},
"public static fireDependency",function(base,property){
if(typeof base["_pcl"]=="object"){
var listeners=base["_pcl"][property];
if(listeners){
for(var listenerI=listeners.iterator();listenerI.hasNext();){
var listener=listenerI.next();
listener.propertyChanged();
}
}
}
},
"private static var",{dependencies:function(){return [];}},
]}
);joo.Class.prepare("package joox.el",

"import org.joo.el.AbstractExpression",
"import org.joo.el.BeanExpression",
"import org.joo.el.PropertyExpression",
"import joox.el.Expression",
"import joox.cache.DependencySet",
"import joox.cache.DependencyTracker",

"public class ConstantValueExpression extends Expression",[],function($jooPublic,$jooPrivate){with($jooPublic)with($jooPrivate)return[

"public _ConstantValueExpression",function(expressionString,value){
this[_super](expressionString,value);
},
"public getValue",function(elContext){
return this.getExpression().evaluate(elContext);









},
"public invalidated",function(dependencySet){

dependencySet.clear();
},
"public isReadOnly",function(){
return this[_readOnly];
},
"public setValue",function(elContext,newValue){
if(this.isReadOnly())
throw"Trying to set read-only property in expression "+this+".";
var exp=this.getExpression();

if(exp.getClass()===PropertyExpression){
var exps=exp.getSubexpressions();
var baseExp=exps[0];
var base=baseExp.evaluate(elContext);
var propertyExp=exps[1];
var property=propertyExp.evaluate(elContext);
elContext.getELResolver().setValue(elContext,base,property,newValue);
}else if(exp.getClass()===BeanExpression){
var beanExp=exp;
elContext.getVariableMapper().setVariable(beanExp.getBeanName(),newValue);
}

},
"private var",{readOnly:false},

]}
);joo.Class.prepare("package joox.el",

"import joox.el.ELResolver",
"import joox.el.FunctionMapper",
"import joox.el.VariableMapper",

"public class ELContext",[],function($jooPublic,$jooPrivate){with($jooPublic)with($jooPrivate)return[

"public static const",{instance:function(){return new ELContext(new ELResolver(),new FunctionMapper(),new VariableMapper());}},

"public _ELContext",function(elResolver,functionMapper,variableMapper){this[_super]();
this[_elResolver]=elResolver;
this[_functionMapper]=functionMapper;
this[_variableMapper]=variableMapper;
},
"public getELResolver",function(){
return this[_elResolver];
},
"public getFunctionMapper",function(){
return this[_functionMapper];
},
"public getVariableMapper",function(){
return this[_variableMapper];
},
"private var",{elResolver: undefined},
"private var",{functionMapper: undefined},
"private var",{variableMapper: undefined},
]}
);joo.Class.prepare("package joox.el",
"import joo.lang.JOObject",

"import joox.cache.DependencyTracker",
"import joo.util.PropertyAware",

"public class ELResolver",[],function($jooPublic,$jooPrivate){with($jooPublic)with($jooPrivate)return[

"public getValue",function(elContext,base,property){
if(base==null||base===undefined){
var valueExp=elContext.getVariableMapper().resolveVariable(property);
return valueExp?valueExp.getValue(elContext):undefined;
}
DependencyTracker.addDependency(base,property);
if(typeof property=="string"){
return PropertyAware.getProperty(base,property);
}

return base[property];
},
"public getType",function(elContext,base,property){
return joo.typeOf(base[property]);
},
"public isReadOnly",function(elContext,base,property){
return false;

},
"public setValue",function(elContext,base,property,value){
var oldValue;
if(typeof property=="string"){
oldValue=PropertyAware.getProperty(base,property);
PropertyAware.setProperty(base,property,value);
}else{
oldValue=base[property];
base[property]=value;
}
if(!JOObject.equal(oldValue,value)){
DependencyTracker.fireDependency(base,property);
}




},
]}
);joo.Class.prepare("package joox.el",

"import joo.lang.JOObject",
"import org.joo.el.AbstractExpression",
"import org.joo.el.ELParser",

"public class Expression extends JOObject",[],function($jooPublic,$jooPrivate){with($jooPublic)with($jooPrivate)return[

"protected static const",{PARSER:function(){return new ELParser();}},

"protected _Expression",function(expressionString,expression,
literalText){
this[_super]();
this[_expressionString]=expressionString;
this[_expression]=expression;
if(typeof literalText=="boolean"){
this[_literalText]=! !literalText;
}
},
"public getExpressionString",function(){
return this[_expressionString];
},
"public getExpression",function(){
return this[_expression];
},
"public isLiteralText",function(){
return this[_literalText];
},
"override public toString",function(){
return this.getExpressionString();
},
"private var",{expressionString: undefined},
"private var",{expression: undefined},
"private var",{literalText:false},
]}
);joo.Class.prepare("package joox.el",

"import org.joo.el.ELParser",
"import org.joo.el.Literal",
"import org.joo.el.AbstractExpression",
"import org.joo.el.BinaryExpression",
"import org.joo.el.PropertyExpression",
"import joox.el.ValueExpression",
"import joox.el.MethodExpression",

"public class ExpressionFactory",[],function($jooPublic,$jooPrivate){with($jooPublic)with($jooPrivate)return[

"public static const",{instance:function(){return new ExpressionFactory(new ELParser());}},
"public _ExpressionFactory",function(parser){
this[_super]();
this[_parser]=parser;
},
"public createValueExpression",function(elContext,expressionString){
var expression;
var readOnly=false;
try{
expression=this[_parser].parseLValue(expressionString);
}catch(e){
expression=this[_parser].parseRValue(expressionString);
readOnly=true;
}
return new ValueExpression(expressionString,expression,readOnly);
},
"public createIndexValueExpression",function(valueExpression,
offsetValueExpression,
relativeIndex){

if(typeof offsetValueExpression=="number"){
offsetValueExpression=this.createObjectValueExpression(offsetValueExpression);
}


return new ValueExpression(["(",valueExpression.getExpressionString(),")[",offsetValueExpression.getExpressionString(),
"+",relativeIndex,"]"].join(""),
new PropertyExpression(valueExpression.getExpression(),
BinaryExpression.create(offsetValueExpression.getExpression(),
ELParser.TOKENS.PLUS,
new Literal(null,relativeIndex))),
false);
},
"public createObjectValueExpression",function(object){
if(typeof object=="object"){

return{
getClass:function(){return ValueExpression;},
getValue:function(){return object;}
};
}
return new ValueExpression(String(object),new Literal(null,object));
},
"public createMethodExpression",function(elContext,expressionString){
return new MethodExpression(expressionString,this[_parser].parseMethodExpression(expressionString));
},
"private var",{parser: undefined},
]}
);joo.Class.prepare("package joox.el",

"public class FunctionMapper",[],function($jooPublic,$jooPrivate){with($jooPublic)with($jooPrivate)return[

"public setFunction",function(prefix,fun){
var withPrefix=this[_functions][prefix];
if(!withPrefix)
this[_functions][prefix]=withPrefix={};
withPrefix[fun.getName()]=fun;
},
"public resolveFunction",function(prefix,localName){
return this[_functions][localName];
},
"private var",{functions:function(){return {};}},
]}
);joo.Class.prepare("package joox.el",

"import joox.el.Expression",
"import org.joo.el.AbstractExpression",

"public class MethodExpression extends Expression",[],function($jooPublic,$jooPrivate){with($jooPublic)with($jooPrivate)return[

"public _MethodExpression",function(expressionString,expression){
this[_super](expressionString,expression);
},
"public invoke",function(elContext,parameters){

var exps=this.getExpression().getSubexpressions();
var beanExp=exps[0];
var bean=beanExp.evaluate(elContext);
var methodNameExp=exps[1];
var methodName=methodNameExp.evaluate(elContext);
var method=bean[methodName];
return method.apply(bean,parameters);
},
]}
);joo.Class.prepare("package joox.el",

"import joox.el.Expression",
"import org.joo.el.AbstractExpression",
"import org.joo.el.BeanExpression",
"import joox.cache.DependencyTracker",
"import joox.cache.DependencySet",
"import org.joo.el.PropertyExpression",

"public class ValueExpression extends Expression",[],function($jooPublic,$jooPrivate){with($jooPublic)with($jooPrivate)return[

"public _ValueExpression",function(expressionString,expression,readOnly){
this[_super](expressionString,expression);
this[_readOnly]=readOnly;
},
"public getValue",function(elContext){
return this.getExpression().evaluate(elContext);
var value=this[_cachedValue];
if(value===undefined){
DependencyTracker.start(this);
value=this[_cachedValue]=this.getExpression().evaluate(elContext);
DependencyTracker.stop();
}
return value;
},
"public invalidated",function(dependencySet){
this[_cachedValue]=undefined;
dependencySet.clear();
},
"public isReadOnly",function(elContext){
return this[_readOnly];
},
"public setValue",function(elContext,newValue){
if(this.isReadOnly())
throw"Trying to set read-only property in expression "+this+".";
var exp=this.getExpression();

if(exp.getClass()===PropertyExpression){
var exps=exp.getSubexpressions();
var baseExp=exps[0];
var base=baseExp.evaluate(elContext);
var propertyExp=exps[1];
var property=propertyExp.evaluate(elContext);
elContext.getELResolver().setValue(elContext,base,property,newValue);
}else if(exp.getClass()===BeanExpression){
var beanExp=exp;
elContext.getVariableMapper().setVariable(beanExp.getBeanName(),newValue);
}

},
"private var",{readOnly:false},
"private var",{cachedValue: undefined},
]}
);joo.Class.prepare("package joox.el",

"import joox.el.ExpressionFactory",
"import org.joo.el.AbstractExpression",

"public class VariableMapper",[],function($jooPublic,$jooPrivate){with($jooPublic)with($jooPrivate)return[

"public setVariable",function(name,valueExpression){
if(typeof valueExpression=="string"){
valueExpression=ExpressionFactory.instance.createValueExpression(valueExpression);
}
this[_variables][name]=valueExpression;
},
"public resolveVariable",function(name){
var exp=this[_variables][name];
if(exp)
return exp;

return ExpressionFactory.instance.createObjectValueExpression(eval(name));
},
"private var",{variables:function(){return {};}},
]}
);joo.Class.prepare("package joox.faces",

"import joox.faces.Transformer",
"import joo.util.PropertyAware",
"import joox.faces.component.UIComponent",

"public class TagLib",[],function($jooPublic,$jooPrivate){with($jooPublic)with($jooPrivate)return[

"private static const",{DEBUG:false},

"public _TagLib",function(uri,tagHandlers){
this[_super]();
this[_uri]=uri;
this[_componentClassByTagName]=tagHandlers;
},
"public getUri",function(){
return this[_uri];
},
"public createComponent",function(parent,tagName,element){
var componentClass=this[_componentClassByTagName][tagName];
var namespaceURI=Transformer.getNamespaceURI(element);
var htmlElementName;
if(namespaceURI=="http://www.w3.org/1999/xhtml"){
htmlElementName=(element.localName?element.localName:element.nodeName).toLowerCase();
}
if(typeof componentClass=="function"){
var properties={};
if(element.nodeType==Node.ELEMENT_NODE){
var attributes=element.attributes;
for(var i=0;i<attributes.length;++i){
var attr=attributes.item(i);
if(attr.specified){
var propParts=attr.name.split(":");
var propName=propParts.pop();
propName=propName.toLowerCase();
if(htmlElementName=="a"&&propName=="href"){
propName="value";
}else if(htmlElementName=="option"&&propName=="value"){
propName="itemValue";
}
var value=propName=="class"?element.className:propName=="for"?element.htmlFor:attr.value;
if(propName!="jsfc"){
if(propName=="class"){
propName="styleClass";
}


if(!(propName in properties)||propParts.length>0){
properties[propName]=value;
if(DEBUG)
console.debug("setting attribute "+attr.name+" as property "+propName+" to "+value);
}
}
}
}
}else if(element.nodeType==Node.TEXT_NODE){
properties.value=element.data;
}
var id=properties.id;
if(id){
delete properties.id;
}else{
id="_id"+(++idCnt);
}
var component=new componentClass(id);
component.setParent(parent);
if(htmlElementName){
component.elementName=htmlElementName;
if(typeof properties.value=="undefined"&&typeof component["setValue"]=="function"
&&element.firstChild&&element.firstChild.nodeType==Node.TEXT_NODE){
var textValue=element.firstChild.data;
if(textValue){
if(DEBUG)
console.debug("setting attribute value to text node child's data '"+textValue+"'.");
properties.value=textValue;

element.removeChild(element.firstChild);
}
}
}
PropertyAware.setProperties(component,properties);
if(DEBUG)
console.debug("returning component "+component);
return component;
}
return null;
},
"private var",{uri: undefined},
"private var",{componentClassByTagName:function(){return {};}},

"private static var",{idCnt:0},
]}
);joo.Class.prepare("package joox.faces",

"import joox.faces.TagLib",
"import joo.util.PropertyAware",
"import joox.el.ExpressionFactory",
"import joox.el.ELContext",
"import joox.el.VariableMapper",
"import joox.faces.component.UIComponent",
"import joox.faces.component.UIViewRoot",
"import org.apache.myfaces.custom.datalist.HtmlDataList",

"public class Transformer",["getNamespaceURI","main"],function($jooPublic,$jooPrivate){with($jooPublic)with($jooPrivate)return[

"private static const",{DEBUG:false},
"private static const",{tagLibByUri:function(){return [];}},
"private static const",{namespaceByPrefix:function(){return {f:"http://java.sun.com/jsf/core",
h:"http://java.sun.com/jsf/html",
t:"http://myfaces.apache.org/tomahawk",
HTML:"http://www.w3.org/1999/xhtml"};}},
"private static const",{jscfByElementName:function(){return {h1:"h:outputText",
h2:"h:outputText",
p:"h:outputText",
span:"h:outputText",
label:"h:outputLabel",
input:{text:"h:inputText",checkbox:"h:selectBooleanCheckbox"},
div:"h:panelGroup",
ul:"h:panelGroup",
li:"h:panelGroup",
a:"h:outputLink",
button:"h:commandButton",
select:"h:selectOneMenu",
img:"h:graphicImage",
option:"f:selectItem"};}},

"private static registerTagLib",function(tagLib){
tagLibByUri[tagLib.getUri()]=tagLib;
},
"public static getNamespaceURI",function(element){
var namespaceURI=element.namespaceURI;
if(namespaceURI){

namespaceURI=""+namespaceURI;
}else if(element.scopeName){
namespaceURI=namespaceByPrefix[element.scopeName];
}else if(element.nodeType==Node.ELEMENT_NODE){

namespaceURI="http://www.w3.org/1999/xhtml";
}
return namespaceURI;
},
"private static createTextNodeComponent",function(parent,childNodes,index){
if(typeof parent.getId=="function"){
var textNode=childNodes[index];
var data=textNode.data;
if(!/^[ \n]*$/.test(data)){
if(DEBUG)
console.debug("Found textNode "+parent.getId()+"["+index+"]: '"+data+"'.");
var tagLib=tagLibByUri["http://java.sun.com/jsf/html"];
tagLib.createComponent(parent,"outputText",textNode);
}
}
},

"private static createComponent",function(parent,element){
var tagName=element.localName?element.localName:element.nodeName;
var namespaceURI=getNamespaceURI(element);
if(namespaceURI=="http://www.w3.org/1999/xhtml"){
var jsfc=element.getAttribute("jsfc");
if(!jsfc){
jsfc=jscfByElementName[element.nodeName.toLowerCase()];
if(!jsfc){
return parent;
}
if(typeof jsfc=="object"){


jsfc=jsfc[element.type];
}
}
var parts=jsfc.split(":");
if(!parts.length==2){
throw new Error("jsfc must be of format namespace ':' tag.");
}
namespaceURI=namespaceByPrefix[parts[0]];
tagName=parts[1];
}
var tagLib=tagLibByUri[namespaceURI];
if(typeof tagLib=="object"){
if(DEBUG)
console.debug("creating component from tag-lib "+namespaceURI+" for tag "+tagName+" and element "+element.nodeName);
var component=tagLib.createComponent(parent,tagName,element);
if(DEBUG)
console.debug("created component from tag-lib "+namespaceURI+" for tag "+tagName+" and element "+element.nodeName+": "+component);
return component;
}
return null;
},
"private static createComponentAndChildren",function(parent,element){
var component=createComponent(parent,element);
if(component){
var childNodes=element.childNodes;
for(var i=0;i<childNodes.length;++i){
var childNode=childNodes[i];
switch(childNode.nodeType){
case Node.ELEMENT_NODE:
createComponentAndChildren(component,childNodes[i]);
break;
case Node.TEXT_NODE:
createTextNodeComponent(component,childNodes,i);
break;
}
}
}
return component;
},
"private static registerManagedBeans",function(){
var expressionFactory=ExpressionFactory.instance;
var variableMapper=ELContext.instance.getVariableMapper();
while(true){
var mBeanElem=window.document.getElementsByTagName("dir")[0];
if(!mBeanElem){
break;
}
var id=mBeanElem.getAttribute("id");
var clazz=mBeanElem.getAttribute("class");
if(!clazz){
clazz=mBeanElem.getAttribute("className");
}
var bean=eval("new "+clazz+"()");
var properties=mBeanElem.getElementsByTagName("property");
for(var c=0;c<properties.length;++c){
var property=properties[c];
var propertyName=property.getAttribute("name");
var value=property.getAttribute("value");
PropertyAware.setProperty(bean,propertyName,value);
}
mBeanElem.parentNode.removeChild(mBeanElem);
if(typeof bean["getObject"]=="function"){

bean=bean["getObject"]();
}
if(id){
variableMapper.setVariable(id,expressionFactory.createObjectValueExpression(bean));
}
}
},

"public static main",function(){

registerTagLib(new TagLib("http://java.sun.com/jsf/core",
{view:joox.faces.component.UIViewRoot,
facet:joox.faces.component.Facet,
selectItem:joox.faces.component.UISelectItem}
));
registerTagLib(new TagLib("http://java.sun.com/jsf/html",
{panelGroup:joox.faces.component.UIComponent,
outputText:joox.faces.component.html.HtmlOutputText,
outputLabel:joox.faces.component.html.HtmlOutputLabel,
outputLink:joox.faces.component.html.HtmlOutputLink,
commandButton:joox.faces.component.html.HtmlCommandButton,
commandLink:joox.faces.component.html.HtmlCommandLink,
inputText:joox.faces.component.html.HtmlInputText,
inputKey:joox.faces.component.html.HtmlInputKey,
dataTable:joox.faces.component.html.HtmlDataTable,
column:joox.faces.component.UIColumn,
graphicImage:joox.faces.component.html.HtmlGraphicImage,
selectOneMenu:joox.faces.component.html.HtmlSelectOneMenu,
selectBooleanCheckbox:joox.faces.component.html.HtmlSelectBooleanCheckbox}
));
registerTagLib(new TagLib("http://myfaces.apache.org/tomahawk",
{dataList:HtmlDataList}
));










registerManagedBeans();
var views=typeof window.document.getElementsByTagNameNS=="function"
?window.document.getElementsByTagNameNS("http://java.sun.com/jsf/core","view")
:window.document.getElementsByTagName("view");
if(views.length==0){
views=[];
var divs=window.document.getElementsByTagName("div");
for(var j=0;j<divs.length;++j){
var div=divs[j];
if(div.getAttribute("jsfc")=="f:view"){
views.push(divs[j]);
}
}
}
if(DEBUG&&console.open)
console.open();
if(DEBUG)
console.debug("found "+views.length+" views.");
for(var i=0;i<views.length;++i){
var viewElem=views[i];
if(viewElem.getAttribute("jsfc")=="f:view"||!("scopeName"in viewElem)||viewElem.scopeName=="f"){
if(DEBUG)
console.debug("processing "+viewElem.nodeName);
var view=createComponentAndChildren(null,viewElem);
viewElem.innerHTML="";
var newViewElem=view.create();
if(DEBUG)
console.debug(viewElem.nodeName+" -> "+newViewElem.nodeName);
viewElem.parentNode.replaceChild(newViewElem,viewElem);

}
}
},
]}
);joo.Class.prepare("package joox.faces.component",

"public class Facet",[],function($jooPublic,$jooPrivate){with($jooPublic)with($jooPrivate)return[

"public setParent",function(component){
this[_parent]=component;
},
"public getParent",function(){
return this[_parent];
},
"public setName",function(name){
this[_name]=name;
},
"public getName",function(){
return this[_name];
},
"private var",{parent: undefined},
"private var",{name: undefined},

"override public toString",function(){
return this[_name];
},
]}
);joo.Class.prepare("package joox.faces.component",

"import joox.faces.component.UIComponent",

"public class UIColumn extends UIComponent",[],function($jooPublic,$jooPrivate){with($jooPublic)with($jooPrivate)return[

"protected const",{elementName:"td"},
"public _UIColumn",function(id){
this[_super](id);
},
"public getHeader",function(){
return this.getFacet("header");
},
"public getFooter",function(){
return this.getFacet("footer");
},
]}
);joo.Class.prepare("package joox.faces.component",

"import joo.lang.JOObject",
"import joox.el.ExpressionFactory",
"import joox.el.ELContext",
"import joox.cache.DependencyTracker",
"import joox.faces.component.Facet",

"public class UIComponent extends JOObject",[],function($jooPublic,$jooPrivate){with($jooPublic)with($jooPrivate)return[

"protected const",{elementName:"div"},
"protected _UIComponent",function(id){
this[_super]();
this[_id]=id;
},
"public getId",function(){
return this[_id];
},
"public setBinding",function(binding){
var elContext=ELContext.instance;
var bindingVB=ExpressionFactory.instance.createValueExpression(elContext,binding);
bindingVB.setValue(elContext,this);
},
"protected createEL",function(value){
return typeof value=="string"&&value.indexOf("#{")>=0
?ExpressionFactory.instance.createValueExpression(ELContext.instance,value)
:value;
},
"protected evalEL",function(value){
return joo.typeOf(value)=="object"&&value.getClass()===joox.el.ValueExpression
?value.getValue(ELContext.instance)
:value;
},
"public isRendered",function(){
return this.evalEL(this[_rendered]);
},
"public setRendered",function(rendered){
this[_rendered]=this.createEL(rendered);
},
"public setElementName",function(elementName){
this.elementName=elementName;
},
"public getStyle",function(){
return this.evalEL(this[_style]);
},
"public setStyle",function(style){
this[_style]=this.createEL(style);
},
"public getStyleClass",function(){
return this.evalEL(this[_styleClass]);
},
"public setStyleClass",function(styleClass){
this[_styleClass]=this.createEL(styleClass);
},
"public getTitle",function(){
return this.evalEL(this[_title]);
},
"public setTitle",function(title){
this[_title]=this.createEL(title);
},
"public getParent",function(){
return this[_parent];
},
"public setParent",function(parent){
if(!parent){

this[_view]=this;
}else{
if(parent.getClass()===Facet){
var facet=parent;
parent=facet.getParent();
parent.getFacets()[facet.getName()]=this;
}else{
parent.getChildren().push(this);
}
this[_parent]=parent;
this[_view]=parent.getView();
this[_view].registerComponent(this);
}
},
"public getChildren",function(){
return this[_children];
},
"public getFacet",function(facetName){
return this[_facets][facetName];
},
"public getFacets",function(){
return this[_facets];
},
"public getView",function(){
return this[_view];
},
"protected getNode",function(clientId){
return window.document.getElementById(clientId);
},
"public render",function(idSuffix){
var clientId=this[_id]+idSuffix;
var element=this.getNode(clientId);
if(element&&"scopeName"in element&&element.scopeName!="HTML"){

element=null;
}
var thisView=this.getView();
if(!thisView.isInvalid(clientId)&&element){

this.renderChildren(element,idSuffix);
return element;
}else{
thisView.revalidate(clientId);
DependencyTracker.start({
invalidated:function(dependencySet){
thisView.invalidate(clientId);
dependencySet.clear();
}
});

var result=this[_internalRender](element,idSuffix);

DependencyTracker.stop();

return result;
}
},
"private internalRender",function(element,idSuffix){
if(!this.isRendered()){
if(element){
this.removeElement(element);
}
return null;
}
if(element&&element.nodeName.toLowerCase()!=this.elementName){
this.removeElement(element);
element=null;
}
if(!element){
element=this.createElement(idSuffix);
this.updateAttributes(element);
}else{
this.updateAttributes(element);
this.updateFacets(idSuffix);
}
this.renderChildren(element,idSuffix);
return element;
},

"protected removeElement",function(element){
element.parentNode.removeChild(element);
},
"protected createElement",function(idSuffix){
var thisElementName=this.getCreateElementName();

var element=window.document.createElement(thisElementName);
element.id=this[_id]+idSuffix;
return element;
},
"protected getCreateElementName",function(){
return this.elementName;
},
"protected updateFacets",function(idSuffix){
idSuffix;
},
"protected updateAttributes",function(element){
var thisStyleClass=this.getStyleClass();
if(thisStyleClass)

element.className=thisStyleClass;
var thisStyle=this.getStyle();
if(thisStyle)
element.style.cssText=thisStyle;
var thisTitle=this.getTitle();
if(typeof thisTitle=="string")
element.title=thisTitle;
},
"protected updateBooleanAttribute",function(element,name,value){
if(window.document["all"]&&name=="checked"){
element.defaultChecked=value;
}
if(value){
element.setAttribute(name,name);
}else{
element.removeAttribute(name);
}
element[name]=value;
return value;
},





"protected renderChildren",function(element,idSuffix){
var thisChildren=this.getChildren();
for(var i=0;i<thisChildren.length;++i){
var child=thisChildren[i];

child.isRendered();
var childElement=child.render(idSuffix);
if(childElement){
if(i>=element.childNodes.length||element.childNodes[i]!=childElement){
element.appendChild(childElement);
}

}
}
},
"protected restoreState",function(id){
return this.getParent().restoreState(id);
},
"protected addEventListener",function(element,eventName,
handlerFunction,handlerObject){
var srcComponent=this;
if(typeof handlerObject=="undefined"){
handlerObject=this;
}
var eventHandlerFunction=handlerObject
?function(event){return handlerFunction.call(handlerObject,event,srcComponent);}
:function(event){return handlerFunction(event,srcComponent);};
if(typeof element.addEventListener=="function"){
element.addEventListener(eventName,eventHandlerFunction,false);
}else{
element.attachEvent("on"+eventName,function(){
window.event.target=window.event.srcElement;
return eventHandlerFunction(window.event);
});
}
},
"private var",{view: undefined},
"private var",{id: undefined},
"private var",{rendered:function(){return ExpressionFactory.instance.createObjectValueExpression(true);}},
"private var",{style: undefined},
"private var",{styleClass: undefined},
"private var",{title: undefined},
"private var",{parent: undefined},
"private var",{children:function(){return [];}},
"private var",{facets:function(){return {};}},

"override public toString",function(){
return this[_id];
},
]}
);joo.Class.prepare("package joox.faces.component",

"import joox.faces.component.UIComponent",
"import joox.el.ELContext",
"import joox.el.ExpressionFactory",
"import joox.el.ValueExpression",

"public class UIData extends UIComponent",[],function($jooPublic,$jooPrivate){with($jooPublic)with($jooPrivate)return[

"public _UIData",function(id){
this[_super](id);
},
"public setVar",function(varName){
this[_varName]=varName;
},
"public getVar",function(){
return this[_varName];
},
"public setValue",function(value){
this[_value]=this.createEL(value);
},
"public getValue",function(){
return this.evalEL(this[_value]);
},
"public getFirst",function(){
return Number(this.evalEL(this[_first]));
},
"public setFirst",function(first){
this[_first]=this.createEL(first);
},
"public getRows",function(){
return Number(this.evalEL(this[_rows]));
},
"public setRows",function(rows){
this[_rows]=this.createEL(rows);
},
"public getRowCount",function(){

return this.getValue().length;
},
"public setRowIndex",function(rowIndex,first){
this[_rowIndex]=rowIndex;
var expressionFactory=ExpressionFactory.instance;
var varExpression=rowIndex==-1
?expressionFactory.createObjectValueExpression(undefined)
:expressionFactory.createIndexValueExpression(this[_value],this[_first],
rowIndex-(first===undefined?this.getFirst():first));
ELContext.instance.getVariableMapper().setVariable(this.getVar(),varExpression);
},
"public getRowIndex",function(){
return this[_rowIndex];
},
"override protected restoreState",function(id){
var lastColonPos=id.lastIndexOf(":");
if(lastColonPos<0){
return this.getParent().restoreState(id);

}
if(this.getParent().restoreState(id.substring(0,lastColonPos))){
var thisFirst=this.getFirst();
var thisRowIndex=thisFirst+Number(id.substring(lastColonPos+1));
if(thisRowIndex<this.getRowCount()){
this.setRowIndex(thisRowIndex,thisFirst);
return true;
}
}
return false;
},
"private var",{value: undefined},
"private var",{first:0},
"private var",{rows:0},
"private var",{varName: undefined},
"private var",{rowIndex:-1},
]}
);joo.Class.prepare("package joox.faces.component",

"import joox.faces.component.UIOutput",
"import joox.el.ELContext",

"public class UIInput extends UIOutput",[],function($jooPublic,$jooPrivate){with($jooPublic)with($jooPrivate)return[

"public _UIInput",function(id){
this[_super](id);
},
"protected isReadOnly",function(){
return this.getValueExpression().isReadOnly(ELContext.instance);
},
"public isDisabled",function(){
return this.evalEL(this[_disabled]);
},
"public setDisabled",function(disabled){
this[_disabled]=this.createEL(disabled);
},
"protected storeValue",function(value){
return this.getValueExpression().setValue(ELContext.instance,value);
},
"override protected updateAttributes",function(element){
this[_updateAttributes](element);
this.updateBooleanAttribute(element,"disabled",this.isReadOnly()||this.isDisabled());
},

"private var",{disabled:false},
]}
);joo.Class.prepare("package joox.faces.component",

"import joox.faces.component.UIComponent",

"public class UIOutput extends UIComponent",[],function($jooPublic,$jooPrivate){with($jooPublic)with($jooPrivate)return[

"public _UIOutput",function(id){
this[_super](id);
},
"public setValue",function(value){
this[_value]=this.createEL(value);
},
"public getValue",function(){
return this.evalEL(this[_value]);
},
"protected getValueExpression",function(){
return this[_value];
},
"private var",{value: undefined},
]}
);joo.Class.prepare("package joox.faces.component",

"import joox.faces.component.UIComponent",
"import joo.lang.JOObject",
"import joox.el.ELContext",
"import joox.el.ExpressionFactory",
"import joox.faces.component.html.HtmlSelectOneMenu",

"public class UISelectItem extends UIComponent",[],function($jooPublic,$jooPrivate){with($jooPublic)with($jooPrivate)return[

"protected const",{elementName:"option"},

"public _UISelectItem",function(id){
this[_super](id);
},
"public setItemLabel",function(itemLabel){
this[_itemLabel]=ExpressionFactory.instance.createValueExpression(ELContext.instance,itemLabel);
},
"public getItemLabel",function(){
return this[_itemLabel].getValue(ELContext.instance);
},
"public setItemValue",function(itemValue){
this[_itemValue]=ExpressionFactory.instance.createValueExpression(ELContext.instance,itemValue);
},
"public setValue",function(itemLabel){
this.setItemLabel(itemLabel);
},
"public getItemValue",function(){
return this[_itemValue].getValue(ELContext.instance);
},
"override protected updateAttributes",function(element){
this[_updateAttributes](element);
var evalItemValue=this.getItemValue();
element.setAttribute("value",evalItemValue);
var select=this.getParent();
this.updateBooleanAttribute(element,"selected",JOObject.equal(evalItemValue,select.getValue()));
var evalItemLabel=this.getItemLabel();
var textNode=element.firstChild;
if(textNode){
textNode.data=evalItemLabel;
}else{
element.appendChild(window.document.createTextNode(evalItemLabel));
}
},
"private var",{itemLabel: undefined},
"private var",{itemValue: undefined},
"override public toString",function(){
return this.getItemLabel()+": "+this.getItemValue();
},
]}
);joo.Class.prepare("package joox.faces.component",

"import joox.faces.component.UIComponent",
"import joo.html.Browser",
"import joo.util.HashSet",
"import joo.util.GapArrayIterator",

"public class UIViewRoot extends UIComponent",[],function($jooPublic,$jooPrivate){with($jooPublic)with($jooPrivate)return[

"private static const",{IS_OPERA:function(){return Browser.ENGINE===Browser.ENGINE_OPERA;}},

"public _UIViewRoot",function(id){
this[_super](id);
this.registerComponent(this);
},
"override protected restoreState",function(id){
if(id.indexOf(":")>=0)
throw"Assertion failed: View#restoreState must receive id without colon (':').";
return true;
},
"public create",function(){
var element=this.render("");
this[_invalidComponentClientIds]=new HashSet();
return element;
},
"override public render",function(){
if(this.isInvalid(this.getId())){

return this[_render]("");
}



for(var clientIdI=this[_invalidComponentClientIds].iterator();clientIdI.hasNext();){
var clientId=clientIdI.next();
if(clientId){
var parts=clientId.split(":");
var id=parts[0];
var component=this[_componentById]["_"+id];
if(!this[_isParentInvalid](component)){
var idSuffix=parts[1]?":"+parts[1]:"";
if(component.restoreState(clientId)){
component.render(idSuffix);
}

}

}
}

if(IS_OPERA){
var viewRootElement=this.getNode(this.getId());
var className=viewRootElement.className;
var dummyClassIndex=className.indexOf(" opera");
viewRootElement.className=dummyClassIndex==-1?className+" opera":className.substring(0,dummyClassIndex);
}
},
"public beansChanged",function(){
this.render();
},
"private isParentInvalid",function(component){
for(var parent=component.getParent();parent;parent=parent.getParent()){
if(this[_invalidComponentClientIds].contains(parent.getId())){
return true;
}
}
return false;
},
"public isInvalid",function(componentClientId){
return this[_invalidComponentClientIds]==null||this[_invalidComponentClientIds].contains(componentClientId);
},
"public invalidate",function(componentClientId){
if(this[_invalidComponentClientIds]!=null){
this[_invalidComponentClientIds].add(componentClientId);
}
},
"public revalidate",function(componentClientId){
if(this[_invalidComponentClientIds]!=null){
this[_invalidComponentClientIds].remove(componentClientId);
}
},
"public registerComponent",function(component){
this[_componentById]["_"+component.getId()]=component;
},
"private var",{invalidComponentClientIds: undefined},
"private var",{componentById:function(){return {};}},
]}
);joo.Class.prepare("package joox.faces.component.html",

"import joox.faces.component.html.HtmlOutputText",
"import joo.html.Browser",
"import joox.el.ELContext",
"import joox.el.ExpressionFactory",

"public class HtmlCommandButton extends HtmlOutputText",[],function($jooPublic,$jooPrivate){with($jooPublic)with($jooPrivate)return[

"protected const",{elementName:"button"},
"public _HtmlCommandButton",function(id){
this[_super](id);
},
"public setAction",function(action){
this[_action]=ExpressionFactory.instance.createMethodExpression(ELContext.instance,action);
},
"public setDisabled",function(disabled){
this[_disabled]=this.createEL(disabled);
},
"public isDisabled",function(){
return this.evalEL(this[_disabled]);
},
"public setEnabled",function(enabled){
this.setDisabled(typeof enabled=="boolean"?!enabled:"#{!"+enabled.substring(2));
},
"public setType",function(type){
this[_type]=this.createEL(type);
},
"public getType",function(){
return this.evalEL(this[_type]);
},
"private invokeAction",function(event){
var srcElement=event.srcElement;
if(srcElement.nodeType==Node.TEXT_NODE){
srcElement=srcElement.parentNode;
}
var clientId=srcElement.id;
this.restoreState(clientId);
var actionEvent={component:this,componentId:this.getId(),clientId:clientId};
this[_action].invoke(ELContext.instance,[actionEvent]);

this.getView().render();
event.returnValue=false;
return false;
},
"override protected getCreateElementName",function(){
if(Browser.ENGINE===Browser.ENGINE_IE6||Browser.ENGINE===Browser.ENGINE_IE7){

var evalType=this.getType();
if(evalType){
return"<"+this.elementName+" type='"+evalType+"'>";
}
}
return this[_getCreateElementName]();
},
"override protected createElement",function(idSuffix){
var element=this[_createElement](idSuffix);
var evalType=this.getType();
if(evalType){
element.setAttribute("type",evalType);
}
if(this[_action]){
this.addEventListener(element,"click",this[_invokeAction]);
}
return element;
},
"override protected updateAttributes",function(element){
this[_updateAttributes](element);
this.updateBooleanAttribute(element,"disabled",this.isDisabled());
},
"private var",{action: undefined},
"private var",{disabled:false},
"private var",{type:"button"},
]}
);joo.Class.prepare("package joox.faces.component.html",

"import joox.faces.component.html.HtmlCommandButton",

"public class HtmlCommandLink extends HtmlCommandButton",[],function($jooPublic,$jooPrivate){with($jooPublic)with($jooPrivate)return[

"protected const",{elementName:"a"},
"public _HtmlCommandLink",function(id){
this[_super](id);
},
"override public getType",function(){
return undefined;
},
"override protected createElement",function(idSuffix){
var element=this[_createElement](idSuffix);
element.setAttribute("href","#");
element.setAttribute("tabIndex","0");
return element;
},
]}
);joo.Class.prepare("package joox.faces.component.html",

"import joox.faces.component.UIData",
"import joox.faces.component.UIComponent",

"public class HtmlDataTable extends UIData",[],function($jooPublic,$jooPrivate){with($jooPublic)with($jooPrivate)return[

"protected const",{elementName:"table"},
"public _HtmlDataTable",function(id){
this[_super](id);
},
"override protected updateAttributes",function(element){
this[_updateAttributes](element);

this.getFirst();
this.getRows();
this.getValue();
},
"private createCaption",function(table,idSuffix){
var caption=this.getFacet("caption");
if(caption){
var captionElement=window.document.createElement("caption");
captionElement.appendChild(caption.render(idSuffix));
table.appendChild(captionElement);
}
},
"private updateCaption",function(idSuffix){
var caption=this.getFacet("caption");
if(caption){
caption.render(idSuffix);
}
},
"private createTableHeaderOrFooter",function(cellElementName,facetName,idSuffix){
var tableHeaderOrFooter=this.getFacet(facetName);
if(tableHeaderOrFooter){
var tr=window.document.createElement("tr");
var cellElement=window.document.createElement(cellElementName);
cellElement.setAttribute("colSpan",this.getChildren().length);

if(cellElementName=="th"){
cellElement.setAttribute("scope","colgroup");
}
var tableHeaderOrFooterElement=tableHeaderOrFooter.render(idSuffix);
cellElement.appendChild(tableHeaderOrFooterElement);
tr.appendChild(cellElement);
return tr;
}
return null;
},
"private updateTableHeaderOrFooter",function(facetName,idSuffix){
var tableHeaderOrFooter=this.getFacet(facetName);
if(tableHeaderOrFooter){
tableHeaderOrFooter.render(idSuffix);
}
},
"private createColumnHeaderOrFooter",function(cellElementName,facetName,idSuffix){
var tr=window.document.createElement("tr");
var children=this.getChildren();
for(var cellIndex=0;cellIndex<children.length;++cellIndex){
var headerOrFooter=children[cellIndex];
headerOrFooter=headerOrFooter.getFacet(facetName);
var headerOrFooterElement=headerOrFooter?headerOrFooter.render(idSuffix):null;
var cellElement=window.document.createElement(cellElementName);
if(headerOrFooterElement){
this[_hasColumn][facetName]=true;
cellElement.appendChild(headerOrFooterElement);
}
tr.appendChild(cellElement);
}
return this[_hasColumn][facetName]?tr:null;
},
"private updateColumnHeaderOrFooter",function(facetName,idSuffix){
if(this[_hasColumn][facetName]){
var children=this.getChildren();
for(var cellIndex=0;cellIndex<children.length;++cellIndex){
var headerOrFooter=children[cellIndex];
headerOrFooter=headerOrFooter.getFacet(facetName);
if(headerOrFooter){
headerOrFooter.render(idSuffix);
}
}
}
},
"private createSection",function(table,sectionElementName,member1,member2){
if(member1||member2){
var sectionElement=window.document.createElement(sectionElementName);
if(member1)
sectionElement.appendChild(member1);
if(member2)
sectionElement.appendChild(member2);
table.appendChild(sectionElement);
}
},
"override protected createElement",function(idSuffix){
var table=this[_createElement](idSuffix);
this[_createCaption](table,idSuffix);

var tableHeader=this[_createTableHeaderOrFooter]("th","header",idSuffix);
var columnHeader=this[_createColumnHeaderOrFooter]("th","header",idSuffix);
this[_createSection](table,"thead",tableHeader,columnHeader);

var columnFooter=this[_createColumnHeaderOrFooter]("td","footer",idSuffix);
var tableFooter=this[_createTableHeaderOrFooter]("td","footer",idSuffix);
this[_createSection](table,"tfoot",columnFooter,tableFooter);

return table;
},
"override protected updateFacets",function(idSuffix){

this[_updateCaption](idSuffix);

var elem;
elem=this[_updateTableHeaderOrFooter]("header",idSuffix);
elem=this[_updateColumnHeaderOrFooter]("header",idSuffix);

elem=this[_updateColumnHeaderOrFooter]("footer",idSuffix);
elem=this[_updateTableHeaderOrFooter]("footer",idSuffix);
},
"override protected renderChildren",function(table,idSuffix){
var children=this.getChildren();
var tBody=table.tBodies[0];
if(!tBody){
tBody=window.document.createElement("tbody");
table.appendChild(tBody);
}
var first=this.getFirst();
var last=this.getRowCount();
var rows=this.getRows();
if(rows>0&&first+rows<last){
last=first+rows;
}
for(var rowIndex=first;rowIndex<last;++rowIndex){
this.setRowIndex(rowIndex,first);
var tableRowIndex=rowIndex-first;
var rowIdSuffix=idSuffix+":"+tableRowIndex;
var row=tBody.rows[tableRowIndex];
if(!row){
row=window.document.createElement("tr");
tBody.appendChild(row);
}
for(var cellIndex=0;cellIndex<children.length;++cellIndex){
var child=children[cellIndex];
var cellElement=child.render(rowIdSuffix);
if(cellIndex>=row.cells.length||row.cells[cellIndex]!=cellElement){
row.appendChild(cellElement);
}
}
}
var lastRowIndex=last-first;
for(rowIndex=tBody.rows.length-1;rowIndex>=lastRowIndex;--rowIndex){
tBody.removeChild(tBody.lastChild);
}
this.setRowIndex(-1,-1);
},
"private var",{hasColumn:function(){return {header:false,footer:false};}},
]}
);joo.Class.prepare("package joox.faces.component.html",

"import joox.faces.component.UIComponent",
"import joox.el.ExpressionFactory",
"import joox.el.ELContext",

"public class HtmlGraphicImage extends UIComponent",[],function($jooPublic,$jooPrivate){with($jooPublic)with($jooPrivate)return[

"protected const",{elementName:"img"},
"public _HtmlGraphicImage",function(id){
this[_super](id);
},
"public setSrc",function(src){
this[_src]=ExpressionFactory.instance.createValueExpression(ELContext.instance,src);
},
"public getSrc",function(){
return this[_src].getValue(ELContext.instance);
},
"public setAlt",function(alt){
this[_alt]=ExpressionFactory.instance.createValueExpression(ELContext.instance,alt);
},
"public getAlt",function(){
return this[_alt].getValue(ELContext.instance);
},
"override protected updateAttributes",function(element){
this[_updateAttributes](element);
element.setAttribute("src",this.getSrc());
element.setAttribute("alt",this.getAlt());
},
"private var",{src: undefined},
"private var",{alt: undefined},
]}
);joo.Class.prepare("package joox.faces.component.html",

"import joox.faces.component.UIInput",
"import joox.faces.component.UIComponent",

"public class HtmlInputKey extends UIInput",[],function($jooPublic,$jooPrivate){with($jooPublic)with($jooPrivate)return[

"protected const",{elementName:"a"},
"public _HtmlInputKey",function(id){
this[_super](id);
},
"public setType",function(type){
if(type!="text"){
throw new Error("HtmlInputKey only supports type='text'.");
}
},
"override public render",function(idSuffix){
this.elementName=this.isDisabled()?"span":"a";
return this[_render](idSuffix);
},
"override protected createElement",function(idSuffix){
var element=this[_createElement](idSuffix);
if(element.nodeName.toLowerCase()=="a"){
element.setAttribute("href","#");
element.setAttribute("tabIndex","0");
this.addEventListener(element,"click",function(event,srcComponent){
element.focus();
return false;
},null);
this.addEventListener(element,"focus",function(event,srcComponent){
element.style.backgroundColor="lightblue";
},null);
this.addEventListener(element,"blur",function(event,srcComponent){
element.style.backgroundColor="";
},null);
this.addEventListener(element,"keydown",this[_changed]);
}
return element;
},
"override protected updateAttributes",function(element){
this[_updateAttributes](element);
var value=this.getValue();
var data;
if(value===undefined){
data="--";
}else if(value>=KeyEvent.DOM_VK_LEFT&&value<=KeyEvent.DOM_VK_DOWN){

data=String.fromCharCode(8592+value-37);
}else if(value>=KeyEvent.DOM_VK_F1&&value<=KeyEvent.DOM_VK_F24){
data="F"+(value-KeyEvent.DOM_VK_F1+1);
}else if(value>=KeyEvent.DOM_VK_NUMPAD0&&value<=KeyEvent.DOM_VK_NUMPAD9){
data="N"+(value-KeyEvent.DOM_VK_NUMPAD0);
}else{
switch(value){
case KeyEvent.DOM_VK_ADD:data="N+";break;
case KeyEvent.DOM_VK_SUBTRACT:data="N-";break;
case KeyEvent.DOM_VK_MULTIPLY:data="N*";break;
case KeyEvent.DOM_VK_DIVIDE:data="N/";break;
case KeyEvent.DOM_VK_PERIOD:data="N.";break;
default:

data=String.fromCharCode(value);
if(data.match(/\W/)){

data=String(value);
}
}
}
var textNode=element.firstChild;
if(textNode){
textNode.data=data;
}else{
element.appendChild(window.document.createTextNode(data));
}
},
"private changed",function(event,srcComponent){

if(event.keyCode>32){
var elem=event.srcElement;
var clientId=elem.id;
this.restoreState(clientId);
this.storeValue(event.keyCode);
this.getView().render();
if("preventDefault"in event&&"stopPropagation"in event){
event.preventDefault();
event.stopPropagation();
}
return false;
}
return true;
},
]}
);joo.Class.prepare("package joox.faces.component.html",

"import joox.faces.component.UIInput",
"import joox.faces.component.UIComponent",

"public class HtmlInputText extends UIInput",[],function($jooPublic,$jooPrivate){with($jooPublic)with($jooPrivate)return[

"protected const",{elementName:"input"},
"public _HtmlInputText",function(id){
this[_super](id);
},
"public setType",function(type){
if(type!="text"){
throw new Error("HtmlInputText only supports type='text'.");
}
},
"override protected createElement",function(idSuffix){
var element=this[_createElement](idSuffix);
element.setAttribute("type","text");
this.addEventListener(element,"focus",function(event,srcComponent){
element.style.borderColor="blue";
},null);
this.addEventListener(element,"blur",function(event,srcComponent){
element.style.borderColor="";
},null);
this.addEventListener(element,"change",this[_changed]);
return element;
},
"override protected updateAttributes",function(element){
this[_updateAttributes](element);
element.value=this.getValue();
},
"private changed",function(event,srcComponent){

var elem=event.srcElement;
var clientId=elem.id;
this.restoreState(clientId);
this.storeValue(elem.value);
this.getView().render();
return true;
},
]}
);joo.Class.prepare("package joox.faces.component.html",

"import joox.faces.component.html.HtmlOutputText",
"import joo.html.Browser",

"public class HtmlOutputLabel extends HtmlOutputText",[],function($jooPublic,$jooPrivate){with($jooPublic)with($jooPrivate)return[

"protected const",{elementName:"label"},
"private var",{forId: undefined},

"public _HtmlOutputLabel",function(id){
this[_super](id);
},
"public setFor",function(forId){
this[_forId]=forId;
},
"public getFor",function(){
return this[_forId];
},
"private focusForElement",function(){
var forElement=window.document.getElementById(this.getFor());
if(forElement&&!forElement.disabled){
var method=forElement.nodeName=="INPUT"&&(forElement.type=="checkbox"||forElement.type=="radio")
?"click":"focus";

window.setTimeout(function(){forElement[method]();});


}
},
"override protected createElement",function(idSuffix){
var element=this[_createElement](idSuffix);
if(Browser.ENGINE==Browser.ENGINE_IE6||Browser.ENGINE==Browser.ENGINE_IE7){
var thisForId=this.getFor();

if(thisForId){
this.addEventListener(element,"click",this[_focusForElement]);
}
}
return element;
},
"override public updateAttributes",function(element){
this[_updateAttributes](element);
var thisForId=this.getFor();
if(thisForId){
element.setAttribute("for",thisForId);
}
},
]}
);joo.Class.prepare("package joox.faces.component.html",

"import joox.faces.component.UIOutput",

"public class HtmlOutputLink extends UIOutput",[],function($jooPublic,$jooPrivate){with($jooPublic)with($jooPrivate)return[

"protected const",{elementName:"a"},
"public _HtmlOutputLink",function(id){
this[_super](id);
},
"public setTarget",function(target){
this[_target]=this.createEL(target);
},
"public getTarget",function(){
return this.evalEL(this[_target]);
},
"override protected updateAttributes",function(element){
this[_updateAttributes](element);
element.setAttribute("href",this.getValue());
element.setAttribute("target",this.getTarget());
},
"private var",{target: undefined},
]}
);joo.Class.prepare("package joox.faces.component.html",

"import joox.faces.component.UIOutput",

"public class HtmlOutputText extends UIOutput",[],function($jooPublic,$jooPrivate){with($jooPublic)with($jooPrivate)return[

"protected const",{elementName:"span"},
"private var",{textNodeIndex: undefined},

"public _HtmlOutputText",function(id){
this[_super](id);
},
"override protected createElement",function(idSuffix){
if(this.elementName=="#text"){
return window.document.createTextNode("");
}
return this[_createElement](idSuffix);
},
"override protected getNode",function(clientId){
var element=this[_getNode](clientId);
if(this.elementName=="#text"){
return element.childNodes[this[_textNodeIndex]];
}
return element;
},
"override public updateAttributes",function(element){
if(this.elementName=="#text")
return;
this[_updateAttributes](element);
var value=this.getValue();
var textNode=element.firstChild;
if(textNode){
textNode.data=value;
}else{
element.appendChild(window.document.createTextNode(value));
}
},
]}
);joo.Class.prepare("package joox.faces.component.html",

"import joox.faces.component.UIInput",
"import joox.faces.component.UIComponent",
"import joo.html.Browser",

"public class HtmlSelectBooleanCheckbox extends UIInput",[],function($jooPublic,$jooPrivate){with($jooPublic)with($jooPrivate)return[

"protected const",{elementName:"input"},
"public _HtmlSelectBooleanCheckbox",function(id){
this[_super](id);
},
"public setType",function(type){
if(type!="checkbox"){
throw new Error("HtmlSelectBooleanCheckbox only supports type='checkbox'.");
}
},
"override protected getCreateElementName",function(){
if(Browser.ENGINE===Browser.ENGINE_IE6||Browser.ENGINE===Browser.ENGINE_IE7){

return"<"+this.elementName+" type='checkbox'>";
}
return this[_getCreateElementName]();
},
"override protected createElement",function(idSuffix){
var element=this[_createElement](idSuffix);
element.setAttribute("type","checkbox");
this.addEventListener(element,"click",this[_changed]);
return element;
},
"override protected updateAttributes",function(element){
this[_updateAttributes](element);
this.updateBooleanAttribute(element,"checked",this.getValue());
},
"private changed",function(event,srcComponent){
var elem=event.srcElement;
var clientId=elem.id;
this.restoreState(clientId);
this.storeValue(! !elem.checked);
this.getView().render();
return true;
},
]}
);joo.Class.prepare("package joox.faces.component.html",

"import joox.faces.component.UIInput",
"import joox.faces.component.UISelectItem",
"import joox.faces.component.UIComponent",

"public class HtmlSelectOneMenu extends UIInput",[],function($jooPublic,$jooPrivate){with($jooPublic)with($jooPrivate)return[

"protected const",{elementName:"select"},
"public _HtmlSelectOneMenu",function(id){
this[_super](id);
},
"private updateProperty",function(event){
var clientId=event.srcElement.id;
this.restoreState(clientId);
var newValue=event.srcElement.value;

var children=this.getChildren();
for(var i=0;i<children.length;++i){
var child=children[i];
var itemValue=child.getItemValue();
if(String(itemValue)==newValue){

newValue=itemValue;
this.storeValue(itemValue);
this.getView().render();
return true;
}
}
return false;
},
"override protected createElement",function(idSuffix){
var element=this[_createElement](idSuffix);
if(this.getValueExpression()){
this.addEventListener(element,"change",this[_updateProperty]);
}
return element;
},
]}
);joo.Class.prepare("package joox.faces.controller",

"import joox.cache.DependencyAwareAspect",
"import joox.faces.component.UIData",

"public class DataPageController",[],function($jooPublic,$jooPrivate){with($jooPublic)with($jooPrivate)return[function()

{
DependencyAwareAspect.instrumentClass(DataPageController);
},

"public getRowCount",function(){
return this.getUiData().getRowCount();
},
"public setFirst",function(first){
this[_first]=Number(first);
},
"public getFirst",function(){
return this[_first];
},
"public setRows",function(rows){
this[_rows]=Number(rows);
},
"public getRows",function(){
return this[_rows];
},
"public isPreviousPageEnabled",function(){
return this.getFirst()>0;
},
"public previousPage",function(){
if(this.isPreviousPageEnabled()){
var newFirst=this.getFirst();
var thisRows=this.getRows();
newFirst=thisRows==0?0:Math.max(0,newFirst-thisRows);
this.setFirst(newFirst);
}
},
"public isNextPageEnabled",function(){
return this.getRows()>0&&this.getFirst()+this.getRows()<this.getRowCount();
},
"public nextPage",function(){
if(this.isNextPageEnabled()){
this.getUiData();
this.setFirst(this.getFirst()+this.getRows());
}
},

"public setUiData",function(uiData){
this[_uiData]=uiData;
},
"public getUiData",function(){
return this[_uiData];
},
"public getSelected",function(){
return! !this[_selection][this.getUiData().getRowIndex()];
},
"public setSelected",function(selected){
var index=this.getUiData().getRowIndex();
var thisSelection=this[_selection];
if(thisSelection[index]!=selected){
thisSelection[index]=selected;
this[_selectionCount]+=selected?1:-1;
}
},
"public getSelectionCount",function(){
return this[_selectionCount];
},
"public toggleSelectAll",function(){
var rowCount=this.getUiData().getRowCount();
if(this.getSelectionCount()==rowCount){
this[_selection]=[];
this[_selectionCount]=0;
}else{
var thisSelection=this[_selection];
for(var i=0;i<rowCount;++i){
thisSelection[i]=true;
}
this[_selectionCount]=rowCount;
}
},
"private var",{uiData: undefined},
"private var",{first:0},
"private var",{rows:0},
"private var",{selection:function(){return [];}},
"private var",{selectionCount:0},

"override public toString",function(){
return["DataPageController[",this[_uiData],"]"].join("");
},
]}
);joo.Class.prepare("package net.jangaron.ui",

"import joo.lang.JOObject",
"import joo.util.PropertyAware",
"import joo.css.Color",
"import net.jangaron.KeyMap",
"import net.jangaron.Position",
"import net.jangaron.TeamColor",

"public class Player extends JOObject",[],function($jooPublic,$jooPrivate){with($jooPublic)with($jooPrivate)return[

"private static const",{DEBUG:false},

"public _Player",function(props){
this[_super]();
PropertyAware.setProperties(this,props);
},

"public isUser",function(){
return this.user;
},

"public setUser",function(user){
this.user=user;
},

"public isVisible",function(){
return this.visible;
},

"public setVisible",function(visible){
this.visible=visible;
},

"public getName",function(){
return this.name;
},

"public setName",function(name){
this.name=name;
},

"public getTeam",function(){
return this.getTeamColor().getTeam();
},

"public getColor",function(){
return this.getTeamColor().getColor();
},

"public getTeamColor",function(){
return this.teamColor;
},

"public setTeamColor",function(teamColor){
this.teamColor=teamColor;
},

"public getKeyMap",function(){
return this.keyMap;
},

"public setKeyMap",function(keyMap){
this.keyMap=keyMap;
},

"public getMinSpeed",function(){
return this.minSpeed;
},

"public setMinSpeed",function(minSpeed){
this.minSpeed=minSpeed;
},

"public getMaxSpeed",function(){
return this.maxSpeed;
},

"public setMaxSpeed",function(maxSpeed){
this.maxSpeed=maxSpeed;
},

"public getHasViewPort",function(){
var hasViewPort=this.isVisible()||this.isUser();
if(DEBUG)
console.log("Player["+this+"].getHasViewPort("+hasViewPort+")="+hasViewPort);
return hasViewPort;
},

"public setHasViewPort",function(hasViewPort){
if(DEBUG)
console.log("Player["+this+"].setHasViewPort("+hasViewPort+")");
return this.setVisible(hasViewPort);
},

"override public hashCode",function(){
return this.id;
},

"override public equals",function(player){
return player&&this.id===player.id;
},

"override public toString",function(){
return this.name;
},

"public var",{id: undefined},
"public var",{user: undefined},
"public var",{visible: undefined},
"public var",{name: undefined},
"public var",{teamColor:function(){return TeamColor.GOLD_ORANGE;}},
"public var",{keyMap: undefined},
"public var",{minSpeed: undefined},
"public var",{maxSpeed: undefined},
"public var",{startPosition: undefined},
"public var",{style: undefined},
]}
);joo.Class.prepare("package net.jangaron.ui",

"import joo.lang.JOObject",
"import joo.lang.JsonBuilder",
"import joo.util.TimedExecutor",
"import joo.http.Cookie",
"import joo.html.Browser",
"import joo.html.Document",
"import joo.html.Element",
"import joo.css.URL",
"import net.jangaron.Position",
"import net.jangaron.Direction",
"import joo.sound.Sound",
"import joox.faces.component.UIViewRoot",
"import joox.faces.component.UIData",
"import joox.cache.DependencyTracker",
"import joox.cache.DependencyAwareAspect",
"import net.jangaron.Direction",
"import net.jangaron.Position",
"import net.jangaron.TeamColor",
"import net.jangaron.KeyMap",
"import net.jangaron.Grid",
"import net.jangaron.ui.Tabs",
"import net.jangaron.ui.Player",

"public class Settings extends JOObject",[],function($jooPublic,$jooPrivate){with($jooPublic)with($jooPrivate)return[

"private static const",{DEBUG:false},function()

{
DependencyAwareAspect.instrumentClass(Settings);
DependencyAwareAspect.instrumentClass(Player);
},

"private static const",{TEAM_PRESETS:function(){return {
"One on One":[TeamColor.GOLD_ORANGE,TeamColor.BLUE_BLUE,TeamColor.GREEN_GREEN,
TeamColor.EARTH_BROWN,TeamColor.WATER_AQUA,TeamColor.PINK_PINK],
"Users vs. MCP":[TeamColor.GOLD_ORANGE,TeamColor.GOLD_RED,TeamColor.GOLD_YELLOW,
TeamColor.BLUE_VIOLET,TeamColor.BLUE_BLUE,TeamColor.BLUE_BLUE],
"Lone Hero":[TeamColor.GOLD_ORANGE,
TeamColor.BLUE_VIOLET,TeamColor.BLUE_BLUE,
TeamColor.BLUE_BLUE,TeamColor.BLUE_BLUE,TeamColor.BLUE_BLUE],
"Pairs":[TeamColor.GOLD_ORANGE,TeamColor.GOLD_RED,
TeamColor.BLUE_VIOLET,TeamColor.BLUE_BLUE,
TeamColor.EARTH_BROWN,TeamColor.EARTH_SILICON]
};}},
"private static const",{TEAM_PRESET_NAMES:function(){
var names=[];
for(var name in TEAM_PRESETS){
names.push(name);
}
return names;
}},

"private const",{initializers:function(){return [
new Player({id:"1",user:true,visible:true,name:"Flynn",teamColor:TeamColor.GOLD_ORANGE,
keyMap:new KeyMap({
left:KeyEvent.DOM_VK_LEFT,right:KeyEvent.DOM_VK_RIGHT,
lookLeft:KeyEvent.DOM_VK_1,lookRight:KeyEvent.DOM_VK_3,lookBackwards:KeyEvent.DOM_VK_2,
faster:KeyEvent.DOM_VK_UP,slower:KeyEvent.DOM_VK_DOWN}),
minSpeed:25,maxSpeed:80}),
new Player({id:"2",user:false,visible:false,name:"Sark",teamColor:TeamColor.BLUE_VIOLET,
keyMap:new KeyMap({
left:KeyEvent.DOM_VK_A,right:KeyEvent.DOM_VK_D,
lookLeft:KeyEvent.DOM_VK_Q,lookRight:KeyEvent.DOM_VK_E,lookBackwards:KeyEvent.DOM_VK_X,
faster:KeyEvent.DOM_VK_W,slower:KeyEvent.DOM_VK_S}),
minSpeed:28,maxSpeed:80}),
new Player({id:"3",user:false,visible:false,name:"Tron",teamColor:TeamColor.GOLD_RED,
keyMap:new KeyMap({
left:KeyEvent.DOM_VK_F,right:KeyEvent.DOM_VK_H,
lookLeft:KeyEvent.DOM_VK_R,lookRight:KeyEvent.DOM_VK_Z,lookBackwards:KeyEvent.DOM_VK_B,
faster:KeyEvent.DOM_VK_T,slower:KeyEvent.DOM_VK_G}),
minSpeed:27,maxSpeed:80}),
new Player({id:"4",user:false,visible:false,name:"Blue 1",teamColor:TeamColor.BLUE_BLUE,
keyMap:new KeyMap({
left:KeyEvent.DOM_VK_J,right:KeyEvent.DOM_VK_L,
lookLeft:KeyEvent.DOM_VK_U,lookRight:KeyEvent.DOM_VK_O,lookBackwards:KeyEvent.DOM_VK_M,
faster:KeyEvent.DOM_VK_I,slower:KeyEvent.DOM_VK_K}),
minSpeed:26,maxSpeed:80}),
new Player({id:"5",user:false,visible:false,name:"Ram",teamColor:TeamColor.GOLD_YELLOW,
keyMap:new KeyMap({left:undefined,right:undefined,faster:undefined,slower:undefined}),
minSpeed:24,maxSpeed:80}),
new Player({id:"6",user:false,visible:false,name:"Blue 2",teamColor:TeamColor.BLUE_BLUE,
keyMap:new KeyMap({left:undefined,right:undefined,faster:undefined,slower:undefined}),
minSpeed:25,maxSpeed:80})
];}},

"public _Settings",function(){
this[_super]();
this[_createGridAnimationTimer]();
this[_tabs].selectedIndex=2;
for(var i=0;i<this[_initializers].length;++i){
this.players.push(this[_initializers][i]);
}
this.teamColors=TeamColor.TEAMS_AND_COLORS;
var storedSettingsStr=new Cookie("jangaron").load();
if(storedSettingsStr){
var storedSettings=JOObject.fromJsonString(storedSettingsStr);
if(DEBUG){
console.debug("retrieved settings, json:");
console.dir(storedSettings);
}
this.fromJson(storedSettings);
if(this.menuGridAnimated){
this[_gridAnimationTimer].start();
}
}
if(this.isSoundAvailable()){
this[_music]=new Sound("sound/ambient.mp3");
this[_sounds]={
click:new Sound("sound/beep.mp3"),
yes:new Sound("sound/yes.mp3"),
no:new Sound("sound/no.mp3"),
transportAndStart:new Sound("sound/transform-and-start.mp3")
};
this[_updateSoundVolume]();
this[_music].setVolume(this.musicVolume);
if(this.musicEnabled){
this[_music].start(0,32767);
}
}
window["settings"]=this;
},

"private createGridAnimationTimer",function(){
var body=Document.INSTANCE.getBody();
var gridOffset=new Position(33,33,Direction.NORTH);
body.setStyle({
backgroundImage:new URL("grid-large.png"),
backgroundRepeat:"repeat",
backgroundPosition:gridOffset
});
this[_gridAnimationTimer]=new TimedExecutor(function(){
var turn=Math.random();
if(turn<0.005){
gridOffset.turnLeft();
}else if(turn>0.995){
gridOffset.turnRight();
}
gridOffset.move(1);
gridOffset.x=(gridOffset.x+100)%100;
gridOffset.y=(gridOffset.y+100)%100;
body.setStyle({backgroundPosition:gridOffset});
},40);
},

"private removeGridAnimation",function(){
this[_gridAnimationTimer].stop();
this[_gridAnimationTimer]=null;
Document.INSTANCE.getBody().setStyle({backgroundImage:"none"});
},

"public isMenuGridAnimated",function(){
return this.menuGridAnimated;
},

"public setMenuGridAnimated",function(animate){
if(this[_setBoolean]("menuGridAnimated",animate)){
if(animate)
this[_gridAnimationTimer].start();
else
this[_gridAnimationTimer].stop();
}
},

"public getEngine",function(){
return Browser.ENGINE;
},

"private static USER_PREDICATE",function(p){
return p.isUser();
},

"public getUserPlayers",function(){
return this.getPlayers().filter(USER_PREDICATE);
},

"private static comparePlayers",function(p1,p2){
if(p1==p2)
return 0;
var p1tc=p1.getTeamColor();
var p2tc=p2.getTeamColor();
if(p1tc.equals(p2tc)){
return p1.id<p2.id?-1:1;
}
return TeamColor.TEAMS_AND_COLORS.indexOfEquals(p1tc)
-TeamColor.TEAMS_AND_COLORS.indexOfEquals(p2tc);
},

"public getPlayers",function(){
this.players.sort(comparePlayers);
return this.players;
},

"public setPlayers",function(players){
this.players=players;
},

"public getNumberOfPlayers",function(){
return this.getPlayers().length;
},

"public setNumberOfPlayers",function(n){
var delta=n-this.players.length;
if(delta>0){
this.addPlayers(delta);
}else if(delta<0){
this.deletePlayers(n,-delta);
}
},

"public getTabs",function(){
return this[_tabs];
},

"public getTeamPresetNames",function(){
return TEAM_PRESET_NAMES;
},

"public getTeamPresetName",function(){
return"";
},

"public setTeamPresetName",function(teamPresetName){
if(teamPresetName.length>0){
var teamPreset=TEAM_PRESETS[teamPresetName];
var plrs=this.players;
for(var i=0;i<plrs.length;++i){
var p=plrs[i];
p.setTeamColor(teamPreset[i]);
}
}
},

"private getSound",function(name){
return this[_sounds][name];
},

"public playSound",function(name){
if(this.isSoundAvailable()&&this.soundEnabled){
this[_getSound](name).start();
}
},

"private setBoolean",function(propertyName,value){
if(this[propertyName]!=value){
this[propertyName]=value;
if(this.isSoundAvailable()&&this.soundEnabled)
this[_getSound](value?"yes":"no").start();
return true;
}
return false;
},

"public getHighRim",function(){
return this.highRim;
},

"public setHighRim",function(value){
this[_setBoolean]("highRim",value);
},

"public getTransparentCycleWalls",function(){
return this.transparentCycleWalls;
},

"public setTransparentCycleWalls",function(value){
this[_setBoolean]("transparentCycleWalls",value);
},

"public getGenerateObstacles",function(){
return this.generateObstacles;
},

"public setGenerateObstacles",function(value){
this[_setBoolean]("generateObstacles",value);
},

"public isSoundAvailable",function(){
return Sound.isAvailable();
},

"public getSoundEnabled",function(){
return this.isSoundAvailable()&&this.soundEnabled;
},

"public setSoundEnabled",function(value){
this[_setBoolean]("soundEnabled",value);
},

"public getSoundVolume",function(){
return this.soundVolume;
},

"private updateSoundVolume",function(){
var value=this.soundVolume;
for(var s in this[_sounds]){
this[_getSound](s).setVolume(value);
}
},

"public setSoundVolume",function(value){
if(this.soundVolume!=value){
this.soundVolume=value;
this[_updateSoundVolume]();
return true;
}
return false;
},

"public getMusicEnabled",function(){
return this.isSoundAvailable()&&this.musicEnabled;
},

"public setMusicEnabled",function(value){
if(this[_setBoolean]("musicEnabled",value)){
if(value){
this[_music].start(0,32767);
}else{
this[_music].stop();
}
return true;
}
return false;
},

"public getMusicVolume",function(){
return this.musicVolume;
},

"public setMusicVolume",function(value){
if(this.musicVolume!=value){
this.musicVolume=value;
this[_music].setVolume(value);
return true;
}
return false;
},

"public isPlayerMaximumReached",function(){
return this.getPlayers().length>=this[_initializers].length;
},

"public isViewMaximumReached",function(){
var plrs=this.getPlayers();
if(plrs.length>=4){
var views=0;
for(var i=0;i<plrs.length;++i){
var player=plrs[i];
if(player.getHasViewPort()){
++views;
if(views>=4){
return true;
}
}
}
}
return false;
},

"public addPlayer",function(){
this.addPlayers(1);
},

"public addPlayers",function(n){
for(var i=0;i<this[_initializers].length;++i){
var initializer=this[_initializers][i];
if(!this.players.containsEquals(initializer)){
this.players.push(initializer);
if(--n==0)
break;
}
}
DependencyTracker.fireDependency(this,"players");
},

"public deletePlayer",function(actionEvent){
var uiData=actionEvent.component.getParent().getParent();
var i=uiData.getRowIndex();
this.deletePlayers(i,1);
},

"public deletePlayers",function(startIndex,n){
this.players.splice(startIndex,n);
DependencyTracker.fireDependency(this,"players");
},

"public isStartable",function(){
var onlyTeam;
var plrs=this.getPlayers();
for(var i=0;i<plrs.length;++i){
var player=plrs[i];
var team=player.getTeam();
if(!onlyTeam){
onlyTeam=team;
}else if(team!=onlyTeam){
return true;
}
}
return false;
},

"private doSave",function(){
var storedSettings=this.toJson();


return new Cookie("jangaron").setDuration(365).setDomain("").save(JOObject.toJsonString(storedSettings));
},

"public save",function(){
window.alert(this[_doSave]()
?"Settings saved successfully."
:"Sorry, settings could not be saved.\n"
+"Check your browser Cookie settings.\n"
+"If Cookies are allowed, the Cookie might be too large.");
},

"public reset",function(){
if(window.confirm("Really reset all settings to their default values?")){
new Cookie("jangaron").remove();
window.location["reload"]();
}
},

"public start",function(actionEvent){
if(!this.isStartable()){
window.alert("Please set up at least two players\nand two different teams before\nstarting the game!");
return;
}
this[_doSave]();
var view=actionEvent.component.getView();
view.setRendered(false);
view.invalidate(view.getId());
if(this.isSoundAvailable()&&this.soundEnabled){
var transportAndStart=this[_getSound]("transportAndStart");
this[_music].fade(transportAndStart.getDuration(),0);
transportAndStart.onSoundComplete=function(){
this[_doStart]();
}.bind(this);
transportAndStart.start();
}else{
if(this.isSoundAvailable()&&this.musicEnabled){
this[_music].fade(500,0);
}
this[_doStart]();
}
},

"private doStart",function(){
this[_calculateStartPositions]();
this[_removeGridAnimation]();
Grid.main(Number(this.width),Number(this.height),this.highRim,
this.transparentCycleWalls?.75:1,
this.generateObstacles?this.obstacleCnt:0,
this.musicEnabled?this.musicVolume:0,
this.soundEnabled?this.soundVolume:0,
this.players,
1000/Number(this.targetFPS));
},

"private calculateStartPositions",function(){
var startX=Math.round(this.width/2);
var startY=Math.round(this.height/2);
var startPositions=[
new Position(startX,10,Direction.NORTH),
new Position(startX,this.height-10,Direction.SOUTH),
new Position(10,startY,Direction.EAST),
new Position(this.width-10,startY,Direction.WEST),
new Position(10,10,Direction.EAST),
new Position(this.width-10,10,Direction.WEST)
];
var startPosByTeam={};
for(var i=0;i<this.players.length;++i){
var player=this.players[i];
var team=player.getTeam();
var startPosition=startPosByTeam[team];
if(!startPosition){
startPosition=startPosByTeam[team]=startPositions.shift();
}
player.startPosition=startPosition.clone();

if(startPosition.dir.dy){
var deltaX=startPosition.x-startX;
if(deltaX<=0)
deltaX-=10;
startPosition.x=startX-deltaX;
}else{
var deltaY=startPosition.y-startY;
if(deltaY<=0)
deltaY-=10;
startPosition.y=startY-deltaY;
}
}
},

"public getJangaronEMail",function(){
return["mailto:joo","jangaron.net"].join("@");
},

"public getMusicEMail",function(){
return["mailto:avi","jangaron.net"].join("@");
},

"private static const",{JSON_PROPERTIES:function(){return ["width","height","highRim","targetFPS","transparentCycleWalls",
"generateObstacles","obstacleCnt","musicEnabled","musicVolume","soundEnabled","soundVolume",
"showHelp","menuGridAnimated","players"];}},

"override protected addPropertiesToJson",function(result,jsonBuilder){
this[_addPropertiesToJson](result,jsonBuilder);
result["selectedTabIndex"]=this[_tabs].selectedIndex;
},

"override protected isJsonProperty",function(property){
return JSON_PROPERTIES.contains(property);
},

"override protected addPropertiesFromJson",function(json,jsonBuilder){
if("selectedTabIndex"in json){
this[_tabs].selectedIndex=json["selectedTabIndex"];
delete json["selectedTabIndex"];
}
this[_addPropertiesFromJson](json,jsonBuilder);
},

"public var",{teamColors: undefined},
"public var",{width:200},
"public var",{height:200},
"public var",{highRim:true},
"public var",{targetFPS:25},
"public var",{obstacleCnt:10},
"public var",{showHelp:false},
"public var",{players:function(){return [];}},
"private var",{tabs:function(){return new Tabs(["About","Instructions","Players","Grid settings","Sound"]);}},
"public var",{transparentCycleWalls:false},
"public var",{generateObstacles:false},
"public var",{soundEnabled:function(){return Browser.ENGINE!=Browser.ENGINE_OPERA;}},
"public var",{soundVolume:40},
"public var",{musicEnabled:true},
"public var",{musicVolume:40},
"private var",{music: undefined},
"private var",{sounds: undefined},
"public var",{menuGridAnimated:false},
"private var",{gridAnimationTimer: undefined},
]}
);joo.Class.prepare("package net.jangaron.ui",

"import joo.lang.JOObject",

"public class Tab extends JOObject",[],function($jooPublic,$jooPrivate){with($jooPublic)with($jooPrivate)return[

"public _Tab",function(tabs,index,name){
this[_super]();
this.tabs=tabs;
this.index=index;
this.name=name;
},

"public isSelected",function(){
return this.tabs.getSelectedIndex()==this.index;
},

"public select",function(){
this.tabs.setSelectedIndex(this.index);
},

"public var",{tabs: undefined},
"public var",{index: undefined},
"public var",{name: undefined},
]}
);joo.Class.prepare("package net.jangaron.ui",

"import joo.lang.JOObject",
"import joox.cache.DependencyAwareAspect",
"import net.jangaron.ui.Tab",

"public class Tabs extends JOObject",[],function($jooPublic,$jooPrivate){with($jooPublic)with($jooPrivate)return[function()

{
DependencyAwareAspect.instrumentClass(Tabs);
},

"public _Tabs",function(names){
this[_super]();
for(var i=0;i<names.length;++i){
this.tabs.push(new Tab(this,i,names[i]));
}
},

"public getSelectedIndex",function(){
return this.selectedIndex;
},

"public setSelectedIndex",function(selectedIndex){
this.selectedIndex=selectedIndex;
},

"public getTabs",function(){
return this.tabs;
},

"public getSelectedTab",function(){
return this.getTabs()[this.getSelectedIndex()];
},

"public var",{selectedIndex:0},
"public var",{tabs:function(){return [];}},
]}
);joo.Class.prepare("package org.apache.myfaces.custom.datalist",

"import joox.faces.component.UIData",
"import joox.faces.component.UIComponent",

"public class HtmlDataList extends UIData",[],function($jooPublic,$jooPrivate){with($jooPublic)with($jooPrivate)return[

"protected const",{elementName:"span"},
"public _HtmlDataList",function(id){
this[_super](id);
},
"override protected renderChildren",function(container,idSuffix){
var children=this.getChildren();
var dataCount=this.getValue().length;
var childElementIndex=0;
for(var rowIndex=0;rowIndex<dataCount;++rowIndex){

this.setRowIndex(rowIndex,0);
var rowIdSuffix=idSuffix+":"+rowIndex;
for(var childIndex=0;childIndex<children.length;++childIndex){

var child=children[childIndex];
var childElement=child.render(rowIdSuffix);

var oldChildElement=container.childNodes[childElementIndex++];
if(!oldChildElement){
container.appendChild(childElement);
}else if(oldChildElement!=childElement){

container.replaceChild(childElement,oldChildElement);
}
}
}
while(container.childNodes[childElementIndex]){
container.removeChild(container.lastChild);
}
this.setRowIndex(-1,-1);
return container;
},
]}
);joo.Class.prepare("package org.joo.el",

"import joo.lang.JOObject",
"import joox.el.ELContext",

"public class AbstractExpression extends JOObject",[],function($jooPublic,$jooPrivate){with($jooPublic)with($jooPrivate)return[

"private static const",{NO_SUBEXPS:function(){return [];}},

"public getLabel",function(){
throw new Error("AbstractExpression#getLabel(): abstract method.");
},
"public getSubexpressions",function(){
return NO_SUBEXPS;
},
"public evaluate",function(elContext){
if(!this[_expFunc]){
var expFuncText=
"with(new org.joo.el.EvalAdapter(elContext)) { return "+this.toString()+"; }";
this[_expFunc]=new Function("elContext",expFuncText);
}
return this[_expFunc](elContext);
},
"private var",{expFunc: undefined},
]}
);joo.Class.prepare("package org.joo.el",

"import org.joo.el.AbstractExpression",

"public class BeanExpression extends AbstractExpression",[],function($jooPublic,$jooPrivate){with($jooPublic)with($jooPrivate)return[

"public _BeanExpression",function(identifier){
this[_super]();
this[_beanName]=identifier.getName();
},
"public getBeanName",function(){
return this[_beanName];
},
"override public getLabel",function(){
return"BEAN "+this.getBeanName();
},
"override public toString",function(){
return["b(\"",this.getBeanName(),"\")"].join("");
},
"private var",{beanName: undefined},
]}
);joo.Class.prepare("package org.joo.el",

"import org.joo.el.AbstractExpression",
"import org.joo.el.ELParser",
"import org.joo.el.Literal",
"import joox.el.Expression",

"public class BinaryExpression extends AbstractExpression",["create"],function($jooPublic,$jooPrivate){with($jooPublic)with($jooPrivate)return[

"public static create",function(leftExp,binaryOp,rightExp){
if(leftExp.getClass()===Literal){
if(rightExp.getClass()===Literal){
var binaryExp=new BinaryExpression(leftExp,binaryOp,rightExp);
return new Literal(binaryExp.toString());
}else{
var TOKENS=ELParser.TOKENS;

if(binaryOp==TOKENS.AND||binaryOp==TOKENS.OR){
var leftValue=leftExp.evaluate();
return binaryOp==TOKENS.AND&&leftValue||binaryOp==TOKENS.OR&&!leftValue
?rightExp:leftExp;
}
}
}
return new BinaryExpression(leftExp,binaryOp,rightExp);
},
"public _BinaryExpression",function(leftExp,binaryOp,rightExp){
this[_super]();
this[_leftExp]=leftExp;
this[_binaryOp]=binaryOp;
this[_rightExp]=rightExp;
},
"override public getLabel",function(){
return this[_binaryOp].toString();
},
"override public getSubexpressions",function(){
return[this[_leftExp],this[_rightExp]];
},
"override public toString",function(){
return["(",this[_leftExp],this[_binaryOp].unparse(),this[_rightExp],")"].join("");
},
"private var",{leftExp: undefined},
"private var",{binaryOp: undefined},
"private var",{rightExp: undefined},
]}
);joo.Class.prepare("package org.joo.el",

"import org.joo.el.Literal",
"import org.joo.el.AbstractExpression",

"public class ConditionalExpression extends AbstractExpression",["create"],function($jooPublic,$jooPrivate){with($jooPublic)with($jooPrivate)return[

"public static create",function(conditionExp,thenExp,elseExp){
if(conditionExp.getClass()===Literal){
if(thenExp.getClass()===Literal&&elseExp.getClass()===Literal){
var conditionalExp=new ConditionalExpression(conditionExp,thenExp,elseExp);
return new Literal(conditionalExp.toString());
}else{
return conditionExp.evaluate()?thenExp:elseExp;
}
}
return new ConditionalExpression(conditionExp,thenExp,elseExp);
},
"public _ConditionalExpression",function(conditionExp,thenExp,elseExp){
this[_super]();
this[_conditionExp]=conditionExp;
this[_thenExp]=thenExp;
this[_elseExp]=elseExp;
},
"override public getLabel",function(){
return"? ... :";
},
"override public getSubexpressions",function(){
return[this[_conditionExp],this[_thenExp],this[_elseExp]];
},
"override public toString",function(){
return["(",this[_conditionExp],"?",this[_thenExp],":",this[_elseExp],")"].join(" ");
},
"private var",{conditionExp: undefined},
"private var",{thenExp: undefined},
"private var",{elseExp: undefined},
]}
);joo.Class.prepare("package org.joo.el",

"import joox.el.Expression",
"import org.joo.el.Token",
"import org.joo.el.Identifier",
"import org.joo.el.BeanExpression",
"import org.joo.el.PropertyExpression",
"import org.joo.el.UnaryExpression",
"import org.joo.el.BinaryExpression",
"import org.joo.el.ConditionalExpression",
"import org.joo.el.Literal",
"import joo.util.HashSet",

"public class ELParser",[],function($jooPublic,$jooPrivate){with($jooPublic)with($jooPrivate)return[

"public static const",{EXPRESSION_START_REG_EXP:/(?:^|[^\\])(#\{)/g},
"public static const",{TOKENS:function(){return {
COLON:new Token("COLON",[":"]),
QUESTIONMARK:new Token("QUESTIONMARK",["?"]),
BRACKET_OPEN:new Token("BRACKET_OPEN",["("]),
BRACKET_CLOSE:new Token("BRACKET_CLOSE",[")"]),
AND:new Token("AND",["&&","and"]),
OR:new Token("OR",["||","or"]),
PLUS:new Token("PLUS",["+"]),
MINUS:new Token("MINUS",["-"]),
MULT:new Token("MULT",["*"]),
DIV:new Token("DIV",["/","div"]),
MOD:new Token("MOD",["%","mod"]),
GT:new Token("GT",[">","gt"]),
LT:new Token("LT",["<","lt"]),
GE:new Token("GE",[">=","ge"]),
LE:new Token("LE",["<=","le"]),
EQ:new Token("EQ",["==","eq"]),
NE:new Token("NE",["!=","ne"]),
NOT:new Token("NOT",["!","not"]),
EMPTY:new Token("EMPTY",["empty"]),
DOT:new Token("DOT",["."]),
SQUARE_BRACKET_OPEN:new Token("SQUARE_BRACKET_OPEN",["["]),
SQUARE_BRACKET_CLOSE:new Token("SQUARE_BRACKET_CLOSE",["]"]),
COMMA:new Token("COMMA",[","]),
WHITE_SPACE:new Token("WHITE_SPACE",[" "]),
EXPRESSION_START:new Token("EXPRESSION_START",["#{"]),
EXPRESSION_END:new Token("EXPRESSION_END",["}"]),
EOS:new Token("EOS",[])
};}},
"public static const",{IDENTIFIER:"[a-zA-Z\\$_][a-zA-Z\\$_]*"},
"public static const",{INTEGER_LITERAL:"[0-9]+"},
"public static const",{EXPONENT:"([eE][\\+-]?[0-9]+)"},
"public static const",{FLOATING_POINT_LITERAL:function(){return "[0-9]+\\.[0-9]*"+EXPONENT+"?|\\.[0-9]+"+EXPONENT+"?|[0-9]+"+EXPONENT;}},
"public static const",{FLOATING_POINT_REG_EXP:function(){return RegExp.compile("^("+FLOATING_POINT_LITERAL+")$");}},
"public static const",{STRING_LITERAL:"'([^'\\\\]|\\\\'|\\\\\\\\)*'"
+"|\"([^\"\\\\]|\\\\\"|\\\\\\\\)*\""},
"public static const",{BOOLEAN_LITERAL:"true|false"},
"public static const",{NULL_LITERAL:"null"},
"public static const",{LITERAL:function(){return FLOATING_POINT_LITERAL+"|"+INTEGER_LITERAL+"|"+STRING_LITERAL+"|"+BOOLEAN_LITERAL+"|"+NULL_LITERAL;}},
"public static const",{LITERAL_REG_EXP:function(){return RegExp.compile("^("+LITERAL+")$");}},
"public static const",{TOKEN:function(){
var tokens=[IDENTIFIER,"|",LITERAL];
var SPECIAL_CHARS=/(\\|\^|\$|\*|\+|\?|\.|\(|\)|\||\{|\}|\,|\[|\])/g;
for(var token in Token.MATCHES){
tokens.push("|");
tokens.push(token.replace(SPECIAL_CHARS,"\\$1"));
}
return tokens.join("");
}},
"public static const",{TOKEN_REG_EXP:function(){return RegExp.compile(TOKEN,"g");}},
"public static const",{BINARY_OP:function(){return new HashSet([
TOKENS.AND,TOKENS.OR,TOKENS.PLUS,TOKENS.MINUS,TOKENS.MULT,
TOKENS.DIV,TOKENS.MOD,TOKENS.GT,TOKENS.LT,TOKENS.GE,
TOKENS.LE,TOKENS.EQ,TOKENS.NE
]);}},
"public static const",{UNARY_OP:function(){return new HashSet([
TOKENS.MINUS,TOKENS.NOT,TOKENS.EMPTY
]);}},
"public static const",{VALUE_SUFFIX:function(){return new HashSet([
TOKENS.DOT,TOKENS.SQUARE_BRACKET_OPEN
]);}},

"public toHTML",function(exp){
var out=[exp.getLabel()];
var subexps=exp.getSubexpressions();
if(subexps.length>0){
out.push("<ul>");
for(var i=0;i<subexps.length;++i){
out.push("<li>");
out.push(this.toHTML(subexps[i]));
out.push("</li>");
}
out.push("</ul>");
}
return out.join("");
},
"public getType",function(value){
if(value==null){
return"null";
}
var type=typeof value;
if(type=="number"){
type=Literal.FLOATING_POINT_REG_EXP.test(value)?"float":"integer";
}
return type;
},
"private startTokenize",function(el){
this[_el]=el;
this[_token]=undefined;
this[_tokenEndPos]=0;
this[_nextToken]();
},
"private nextToken",function(){

var startIndex=this[_tokenEndPos];
if(startIndex==this[_el].length){

return this[_setToken](TOKENS.EOS,startIndex,0);
}
var thisToken=this[_token];
var match;
if(!thisToken||thisToken==TOKENS.EXPRESSION_END){
EXPRESSION_START_REG_EXP.lastIndex=startIndex==0?0:startIndex-1;
match=EXPRESSION_START_REG_EXP.exec(this[_el]);
var string;
if(match){
var endIndex=match[0].length==3?match.index+1:match.index;
string=this[_el].substring(startIndex,endIndex);
}else{
string=this[_el].substring(startIndex);
}
if(string){
return this[_setToken](new Literal(null,string.replace(/\\#\{/g,"#{")),startIndex,string.length);
}
}
TOKEN_REG_EXP.lastIndex=startIndex;
var WHITE_SPACE=TOKENS.WHITE_SPACE;
while((match=TOKEN_REG_EXP.exec(this[_el]))!=null){
if(match.index!=startIndex){
throw"Syntax error: No token starts at "+startIndex+".";
}

var c=match[0];


thisToken=Token.MATCHES[c];
if(!thisToken){
if(LITERAL_REG_EXP.test(c)){
thisToken=new Literal(c);
}else{
thisToken=new Identifier(c);
}
}else if(thisToken==WHITE_SPACE){
++startIndex;
continue;
}
return this[_setToken](thisToken,startIndex,c.length);
}
},
"private setToken",function(token,start,length){
this[_tokenStartPos]=start;
this[_tokenEndPos]=start+length;
this[_token]=token;
return token;
},
"private consume",function(tokenSet){
var thisToken=this[_token];
if(tokenSet.contains(thisToken)){

this[_nextToken]();
return thisToken;
}

return null;
},
"private syntaxError",function(expected){
return new Error(["syntax error: expected ",expected,", found ",this[_token]," at character range ",this[_tokenStartPos],"-",this[_tokenEndPos],"."].join(""));
},
"private expect",function(tokenSet){
var thisToken=this[_consume](tokenSet);
if(!thisToken)
throw this[_syntaxError](tokenSet);
return thisToken;
},

"public parseLValue",function(el){
this[_startTokenize](el);
this[_expect](TOKENS.EXPRESSION_START);
var identifier=this[_consume](Identifier.TYPE);
var exp=identifier?new BeanExpression(identifier)
:this[_parseNonLiteralValuePrefix]();
if(!exp){
this[_syntaxError]("Identifier or NonLiteralValuePrefix");
}
exp=this[_parseValueSuffixes](exp);
this[_expect](TOKENS.EXPRESSION_END);
this[_expect](TOKENS.EOS);
return exp;
},

"public parseMethodExpression",function(el){
return this.parseLValue(el);
},

"public parseRValue",function(el){
this[_startTokenize](el);
var PLUS=TOKENS.PLUS;
var EOS=TOKENS.EOS;
var exp=null;
while(!this[_consume](EOS)){
var nextExp=this[_consume](Literal.TYPE);
if(!nextExp){
this[_expect](TOKENS.EXPRESSION_START);
nextExp=this[_parseExpression]();
this[_expect](TOKENS.EXPRESSION_END);
}
exp=exp?BinaryExpression.create(exp,PLUS,nextExp):nextExp;
}
if(!exp){
exp=new Literal(null,"");
}
return exp;
},

"private parseExpression",function(){
var exp=this[_parseUnaryExpression]();
if(!exp)
throw this[_syntaxError]("expression");
exp=this[_parseExpressionRest](exp);
var binaryOp;
while(binaryOp=this[_consume](BINARY_OP)){
var rightExp=this[_parseUnaryExpression]();
exp=BinaryExpression.create(exp,binaryOp,rightExp);
exp=this[_parseExpressionRest](exp);
}
return exp;
},

"private parseExpressionRest",function(exp){
if(this[_consume](TOKENS.QUESTIONMARK)){
var thenExp=this[_parseExpression]();
this[_expect](TOKENS.COLON);
var elseExp=this[_parseExpression]();
exp=ConditionalExpression.create(exp,thenExp,elseExp);
}
return exp;
},

"private parseUnaryExpression",function(){
var thisToken;
if(thisToken=this[_consume](UNARY_OP)){
return UnaryExpression.create(thisToken,this[_parseUnaryExpression]());
}else{
var exp=this[_consume](Literal.TYPE)||this[_parseNonLiteralValuePrefix]();
exp=this[_parseValueSuffixes](exp);
return exp;
}
},

"private parseNonLiteralValuePrefix",function(){
var exp=null;
if(this[_consume](TOKENS.BRACKET_OPEN)){
exp=this[_parseExpression]();
this[_expect](TOKENS.BRACKET_CLOSE);
}else{
var identifier=this[_consume](Identifier.TYPE);
if(identifier){
var scopeIdentifier=null;
var isFunction=! !this[_consume](TOKENS.COLON);
if(isFunction){
scopeIdentifier=identifier;
identifier=this[_expect](Identifier.TYPE);
}
if((isFunction?this[_expect]:this[_consume])(TOKENS.BRACKET_OPEN)){
var paramExps=[];
if(!this[_consume](TOKENS.BRACKET_CLOSE)){
do{
var paramExp=this[_parseExpression]();
paramExps.push(paramExp);
}while(this[_consume](TOKENS.COMMA));
this[_expect](TOKENS.BRACKET_CLOSE);
}
exp=new FunctionExpression(scopeIdentifier,identifier,paramExps);
}else{
exp=new BeanExpression(identifier);
}
}
}
return exp;
},

"private parseValueSuffixes",function(exp){
var valueSuffix;
while(valueSuffix=this[_parseValueSuffix]()){
exp=new PropertyExpression(exp,valueSuffix);
}
return exp;
},

"private parseValueSuffix",function(){
var exp=null;
if(this[_consume](TOKENS.DOT)){
var propertyIdentifier=this[_expect](Identifier.TYPE);
exp=new Literal("\""+propertyIdentifier.getName()+"\"");
}else if(this[_consume](TOKENS.SQUARE_BRACKET_OPEN)){
exp=this[_parseExpression]();
this[_expect](TOKENS.SQUARE_BRACKET_CLOSE);
}
return exp;
},
"private var",{el: undefined},
"private var",{token: undefined},
"private var",{tokenStartPos:-1},
"private var",{tokenEndPos:-1},
]}
);joo.Class.prepare("package org.joo.el",

"import joox.el.ELContext",

"public class EvalAdapter",[],function($jooPublic,$jooPrivate){with($jooPublic)with($jooPrivate)return[

"public _EvalAdapter",function(elContext){this[_super]();
this[_elContext]=elContext;
},
"public b",function(beanName){
return this.p(null,beanName);
},
"public p",function(base,property){
return this[_elContext].getELResolver().getValue(this[_elContext],base,property);
},
"public f",function(prefix,localName){
return this[_elContext].getFunctionMapper().resolveFunction(prefix,localName);
},
"public empty",function(obj){
if(obj===null)
return true;
var type=typeof obj;
if(type=="undefined"||type=="string"&&obj.length===0)
return true;
if(obj.constructor==Array){
return obj.length===0;
}
if(type=="object"){


for(var m in obj){
return false;
}
return true;
}
return false;
},
"private var",{elContext: undefined},
]}
);joo.Class.prepare("package org.joo.el",

"import org.joo.el.AbstractExpression",
"import joox.el.ELContext",

"public class FunctionExpression extends AbstractExpression",[],function($jooPublic,$jooPrivate){with($jooPublic)with($jooPrivate)return[

"public _FunctionExpression",function(scopeIdentifier,functionIdentifier,paramExps){
this[_super]();
if(scopeIdentifier)
this[_scopeIdentifier]=scopeIdentifier.getName();
this[_functionIdentifier]=functionIdentifier.getName();
this[_paramExps]=paramExps;
},
"public getName",function(){
return(this[_scopeIdentifier]?this[_scopeIdentifier]+":":"")+this[_functionIdentifier];
},
"override public getLabel",function(){
return this.getName()+"(...)";
},
"override public getSubexpressions",function(){
return this[_paramExps];
},
"override public evaluate",function(elContext){
var theFunction=eval(this[_scopeIdentifier]+"."+this[_functionIdentifier]);
var params=[];
for(var i=0;i<paramExps.length;++i){
var paramExp=this[_paramExps][i];
params.push(paramExp.evaluate(elContext));
}
theFunction.apply(null,params);
},
"override public toString",function(){
return["f(",this[_scopeIdentifier],",",this[_functionIdentifier],")(",this[_paramExps].join(", "),")"].join("");
},
"private var",{scopeIdentifier: undefined},
"private var",{functionIdentifier: undefined},
"private var",{paramExps: undefined},
]}
);joo.Class.prepare("package org.joo.el",

"import joo.lang.JOObject",

"public class Identifier extends JOObject",[],function($jooPublic,$jooPrivate){with($jooPublic)with($jooPrivate)return[

"public static const",{TYPE:function(){return new Identifier();}},
"public _Identifier",function(name){this[_super]();
this[_name]=name;
},
"public getName",function(){
return this[_name];
},

"public contains",function(token){
return token.getClass()==Identifier;
},
"public toString",function(){
return"IDENTIFIER";
},
"private var",{name: undefined},
]}
);joo.Class.prepare("package org.joo.el",

"import org.joo.el.AbstractExpression",

"public class Literal extends AbstractExpression",[],function($jooPublic,$jooPrivate){with($jooPublic)with($jooPrivate)return[

"public static const",{TYPE:function(){return new Literal();}},
"public _Literal",function(unparsedValue,value){
this[_super]();
if(value===undefined){
this[_unparsedValue]=unparsedValue;
}else{
this[_value]=value;
}
},
"public getUnparsedValue",function(){
return this[_unparsedValue];
},

"public contains",function(token){
return token.getClass()===Literal;
},
"override public hashCode",function(){
return"LITERAL";
},
"override public getLabel",function(){
return this.hashCode()+" "+this.toString();
},
"override public evaluate",function(){
if(this[_value]===undefined){
this[_value]=eval(this.getUnparsedValue());
}
return this[_value];
},
"override public toString",function(){
var val=this.evaluate();
if(typeof val=="string"){
return'"'+String(val).replace('"',"\\\"","g").replace(/\\/g,"\\\\")+'"';
}
return String(val);
},
"private var",{unparsedValue: undefined},
"private var",{value: undefined},
]}
);joo.Class.prepare("package org.joo.el",

"import org.joo.el.AbstractExpression",

"public class LiteralExpression extends AbstractExpression",[],function($jooPublic,$jooPrivate){with($jooPublic)with($jooPrivate)return[

"public static const",{TYPE:function(){return new LiteralExpression("");}},
"public _LiteralExpression",function(unparsedString){
this[_super]();
this[_string]=unparsedString.replace(/\\#\{/g,"#{");
},
"public getString",function(){
return this[_string];
},

"public contains",function(token){
return token.getClass()===LiteralExpression;
},
"override public hashCode",function(){
return"LITERAL_EXPRESSION";
},
"override public getLabel",function(){
return this.hashCode()+" "+this.toString();
},
"override public evaluate",function(){
return this.getString();
},
"override public toString",function(){
return'"'+this.getString().replace('"',"\\\"")+'"';
},
"private var",{string: undefined},
]}
);joo.Class.prepare("package org.joo.el",

"import org.joo.el.AbstractExpression",

"public class PropertyExpression extends AbstractExpression",[],function($jooPublic,$jooPrivate){with($jooPublic)with($jooPrivate)return[

"public _PropertyExpression",function(beanExp,propertyExp){
this[_super]();
this[_beanExp]=beanExp;
this[_propertyExp]=propertyExp;
},
"override public getLabel",function(){
return"PROPERTY";
},
"override public getSubexpressions",function(){
return[this[_beanExp],this[_propertyExp]];
},
"override public toString",function(){
return["p(",this[_beanExp],",",this[_propertyExp],")"].join("");
},
"private var",{beanExp: undefined},
"private var",{propertyExp: undefined},
]}
);joo.Class.prepare("package org.joo.el",

"import joo.lang.JOObject",

"public class Token extends JOObject",[],function($jooPublic,$jooPrivate){with($jooPublic)with($jooPrivate)return[

"public static const",{MATCHES:function(){return {};}},
"public _Token",function(token,matches){this[_super]();
this[_token]=token;
if(matches.length>0){
this[_unparsed]=matches[0];
for(var i=0;i<matches.length;++i){
MATCHES[matches[i]]=this;
}
}
},
"override public hashCode",function(){
return this[_token];
},

"public contains",function(token){
return this==token;
},
"public unparse",function(){
return this[_unparsed];
},
"override public toString",function(){
return this[_token];
},
"private var",{token: undefined},
"private var",{unparsed:""},
]}
);joo.Class.prepare("package org.joo.el",

"import org.joo.el.AbstractExpression",
"import org.joo.el.Literal",

"public class UnaryExpression extends AbstractExpression",["create"],function($jooPublic,$jooPrivate){with($jooPublic)with($jooPrivate)return[

"public static create",function(unaryOp,exp){
var unaryExp=new UnaryExpression(unaryOp,exp);
if(exp.getClass()===Literal){
return new Literal(unaryExp.toString());
}
return unaryExp;
},
"public _UnaryExpression",function(unaryOp,exp){
this[_super]();
this[_unaryOp]=unaryOp;
this[_exp]=exp;
},
"override public getLabel",function(){
return this[_unaryOp].toString();
},
"override public getSubexpressions",function(){
return[this[_exp]];
},
"override public toString",function(){
return["(",this[_unaryOp].unparse(),"(",this[_exp],"))"].join("");
},
"private var",{unaryOp: undefined},
"private var",{exp: undefined},
]}
);
