diff options
author | jsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68> | 2011-05-23 06:31:39 +0000 |
---|---|---|
committer | jsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68> | 2011-05-23 06:31:39 +0000 |
commit | bc2aa6314a8d82854a799fe1e750c05dcef1b492 (patch) | |
tree | 0fcda568552ed214683230b81793a9f69a467db1 | |
parent | 4aa0b8bca183523fab66e655ae6652bfea42255d (diff) |
Some Javascript cleanup, now working across all browsers including IE9.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1126329 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r-- | sca-cpp/trunk/modules/js/htdocs/all-min.js | 78 | ||||
-rw-r--r-- | sca-cpp/trunk/modules/js/htdocs/ui.js | 10 | ||||
-rw-r--r-- | sca-cpp/trunk/modules/js/htdocs/util.js | 18 | ||||
-rw-r--r-- | sca-cpp/trunk/modules/js/htdocs/xmlutil.js | 30 |
4 files changed, 51 insertions, 85 deletions
diff --git a/sca-cpp/trunk/modules/js/htdocs/all-min.js b/sca-cpp/trunk/modules/js/htdocs/all-min.js index bb79a5bb2d..b73c9ad5ea 100644 --- a/sca-cpp/trunk/modules/js/htdocs/all-min.js +++ b/sca-cpp/trunk/modules/js/htdocs/all-min.js @@ -1,21 +1,3 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ function cons(car,cdr){var a=new Array();a.push(car);return a.concat(cdr);} function car(l){return l[0];} function first(l){return car(l);} @@ -62,7 +44,8 @@ try{console.log(s);}catch(e){}}catch(e){} return true;} function debug(o){try{for(f in o){try{log('debug '+f+'='+o[f]);}catch(e){}}}catch(e){} return true;} -var config;if(isNil(config)) +function isIE(){if(typeof isIE.detected!='undefined') +return isIE.detected;isIE.detected=navigator.appName=='Microsoft Internet Explorer';return isIE.detected;};var config;if(isNil(config)) config={} function AssertException(){} AssertException.prototype.toString=function(){return'AssertException';};function assert(exp){if(!exp) @@ -77,8 +60,8 @@ return'';return' '+writeValue(car(l))+writeList(cdr(l));} if(!isList(v)) return writePrimitive(v);if(isNil(v)) return'()';return'('+writeValue(car(v))+writeList(cdr(v))+')';} -function memo(obj,key,f){if(!obj[memo]) -obj.memo={};if(obj.memo[key]) +function memo(obj,key,f){if(!('memo'in obj)){obj.memo={};return obj.memo[key]=f();} +if(key in obj.memo) return obj.memo[key];return obj.memo[key]=f();} function unmemo(obj){obj.memo={};return true;} function properties(o){var a=new Array();for(p in o) @@ -171,9 +154,7 @@ function readElements(l,childf){if(isNil(l)) return l;return cons(readElement(car(l),childf),readElements(cdr(l),childf));} function isXML(l){if(isNil(l)) return false;return car(l).substring(0,5)=='<?xml';} -function parseXML(l){var s=writeStrings(l);if(window.DOMParser){var p=new DOMParser();return p.parseFromString(s,"text/xml");} -var doc;try{doc=new ActiveXObject("MSXML2.DOMDocument");}catch(e){doc=new ActiveXObject("Microsoft.XMLDOM");} -doc.async='false';doc.loadXML(s);return doc;} +function parseXML(l){var s=writeStrings(l);var p=new DOMParser();return p.parseFromString(s,"text/xml");} function readXMLDocument(doc){var root=childElements(doc);if(isNil(root)) return mklist();return mklist(readElement(car(root),childAttributes));} function readXHTMLElement(xhtml){function ieChildAttributes(e){var a=filter(function(n){if(n.nodeType!=2||isNil(n.nodeValue)||n.nodeValue=='') @@ -187,16 +168,18 @@ return mklist(new XMLSerializer().serializeToString(doc));return mklist(doc.xml) function expandElementValues(n,l){if(isNil(l)) return l;return cons(cons(element,cons(n,car(l))),expandElementValues(n,cdr(l)));} function writeList(l,node,doc){if(isNil(l)) -return node;var token=car(l);if(isTaggedList(token,attribute)){node.setAttribute(attributeName(token).substring(1),''+attributeValue(token));}else if(isTaggedList(token,element)){function mkelem(tok,doc){function xmlns(l){if(isNil(l)) +return node;var token=car(l);if(isTaggedList(token,attribute)){if(isIE()){var aname=attributeName(token).substring(1);if(aname!='xmlns') +node.setAttribute(aname,''+attributeValue(token));}else +node.setAttribute(attributeName(token).substring(1),''+attributeValue(token));}else if(isTaggedList(token,element)){function mkelem(tok,doc){function xmlns(l){if(isNil(l)) return null;var t=car(l);if(isTaggedList(t,attribute)){if(attributeName(t).substring(1)=='xmlns') return attributeValue(t);} return xmlns(cdr(l));} -var ns=xmlns(elementChildren(tok));if(ns==null||!doc.createElementNS) +var ns=xmlns(elementChildren(tok));if(isIE()) +return doc.createElementNS(ns!=null?ns:node.namespaceURI,elementName(tok).substring(1));if(ns==null) return doc.createElement(elementName(tok).substring(1));return doc.createElementNS(ns,elementName(tok).substring(1));} if(elementHasValue(token)){var v=elementValue(token);if(isList(v)){var e=expandElementValues(elementName(token),v);writeList(e,node,doc);}else{var child=mkelem(token,doc);writeList(elementChildren(token),child,doc);node.appendChild(child);}}else{var child=mkelem(token,doc);writeList(elementChildren(token),child,doc);node.appendChild(child);}}else node.appendChild(doc.createTextNode(''+token));writeList(cdr(l),node,doc);return node;} -function mkXMLDocument(){if(document.implementation&&document.implementation.createDocument) -return document.implementation.createDocument('','',null);return new ActiveXObject("MSXML2.DOMDocument");} +function mkXMLDocument(){return document.implementation.createDocument('','',null);} function writeXML(l,xmlTag){var doc=mkXMLDocument();writeList(l,doc,doc);if(!xmlTag) return writeXMLDocument(doc);return mklist('<?xml version="1.0" encoding="UTF-8"?>\n'+writeXMLDocument(doc)+'\n');} var atom={};atom.entryElementValues=function(e){var lt=filter(selector(mklist(element,"'title")),e);var t=isNil(lt)?'':elementValue(car(lt));var li=filter(selector(mklist(element,"'id")),e);var i=isNil(li)?'':elementValue(car(li));var lc=filter(selector(mklist(element,"'content")),e);return append(mklist(element,"'entry",mklist(element,"'title",t),mklist(element,"'id",i)),isNil(lc)?mklist():mklist(mklist(element,"'content",elementValue(car(lc)))))};atom.entriesElementValues=function(e){if(isNil(e)) @@ -204,7 +187,7 @@ return e;return cons(atom.entryElementValues(car(e)),atom.entriesElementValues(c return false;return car(l).match('<entry')!=null&&car(l).match('<feed')==null&&car(l).match('="http://www.w3.org/2005/Atom"')!=null;};atom.readATOMEntryDocument=function(doc){var e=readXMLDocument(doc);if(isNil(e)) return mklist();return mklist(atom.entryElementValues(car(e)));};atom.readATOMEntry=function(l){return atom.readATOMEntryDocument(parseXML(l));};atom.isATOMFeed=function(l){if(!isXML(l)) return false;return car(l).match('<feed')!=null&&car(l).match('="http://www.w3.org/2005/Atom"')!=null;};atom.readATOMFeedDocument=function(doc){var f=readXMLDocument(doc);if(isNil(f)) -return mklist();var t=filter(selector(mklist(element,"'title")),car(f));var i=filter(selector(mklist(element,"'id")),car(f));var e=filter(selector(mklist(element,"'entry")),car(f));return mklist(append(mklist(element,"'feed",mklist(element,"'title",elementValue(car(t))),mklist(element,"'id",elementValue(car(i)))),atom.entriesElementValues(e)));};atom.readATOMFeed=function(l){return atom.readATOMFeedDocument(parseXML(l));};atom.entryElement=function(l){var title=elementValue(namedElementChild("'title",l));var id=elementValue(namedElementChild("'id",l));var content=namedElementChild("'content",l);var text=isNil(content)?false:elementHasValue(content);return append(append(mklist(element,"'entry",mklist(attribute,"'xmlns","http://www.w3.org/2005/Atom"),mklist(element,"'title",mklist(attribute,"'type","text"),title),mklist(element,"'id",id)),isNil(content)?mklist():append(mklist(element,"'content",mklist(attribute,"'type",text?"text":"application/xml")),text?mklist(elementValue(content)):elementChildren(content))),mklist(element,"'link",mklist(attribute,"'href",id)));};atom.entriesElements=function(l){if(isNil(l)) +return mklist();var t=filter(selector(mklist(element,"'title")),car(f));var i=filter(selector(mklist(element,"'id")),car(f));var e=filter(selector(mklist(element,"'entry")),car(f));return mklist(append(mklist(element,"'feed",mklist(element,"'title",elementValue(car(t))),mklist(element,"'id",elementValue(car(i)))),atom.entriesElementValues(e)));};atom.readATOMFeed=function(l){return atom.readATOMFeedDocument(parseXML(l));};atom.entryElement=function(l){var title=elementValue(namedElementChild("'title",l));var id=elementValue(namedElementChild("'id",l));var content=namedElementChild("'content",l);var text=isNil(content)?false:elementHasValue(content);return append(append(mklist(element,"'entry",mklist(attribute,"'xmlns","http://www.w3.org/2005/Atom"),mklist(element,"'title",mklist(attribute,"'type","text"),title),mklist(element,"'id",id)),isNil(content)?mklist():mklist(append(mklist(element,"'content",mklist(attribute,"'type",text?"text":"application/xml")),text?mklist(elementValue(content)):elementChildren(content)))),mklist(mklist(element,"'link",mklist(attribute,"'href",id))));};atom.entriesElements=function(l){if(isNil(l)) return l;return cons(atom.entryElement(car(l)),atom.entriesElements(cdr(l)));};atom.writeATOMEntry=function(ll){var l=isNil(ll)?ll:car(ll);return writeXML(mklist(atom.entryElement(l)),true);};atom.writeATOMFeed=function(ll){var l=isNil(ll)?ll:car(ll);var lt=filter(selector(mklist(element,"'title")),l);var t=isNil(lt)?'':elementValue(car(lt));var li=filter(selector(mklist(element,"'id")),l);var i=isNil(li)?'':elementValue(car(li));var f=mklist(element,"'feed",mklist(attribute,"'xmlns","http://www.w3.org/2005/Atom"),mklist(element,"'title",mklist(attribute,"'type","text"),car(l)),mklist(element,"'id",cadr(l)));var le=filter(selector(mklist(element,"'entry")),l);if(isNil(le)) return writeXML(mklist(f),true);if(!isNil(le)&&!isNil(car(le))&&isList(car(caddr(car(le))))){var fe=append(f,atom.entriesElements(caddr(car(le))));return writeXML(mklist(fe),true);} var fe=append(f,atom.entriesElements(le));return writeXML(mklist(fe),true);};var json={};json.Exception=function(code,message){this.name="JSONException";this.code=code;this.message=message;};json.Exception.prototype=new Error();json.Exception.prototype.toString=function(){return this.name+": "+this.message;};json.isJSArray=function(l){if(isNil(l)) @@ -241,8 +224,7 @@ return o.toString();if(o.constructor==Date) return'{javaClass: "java.util.Date", time: '+o.valueOf()+'}';if(o.constructor==Array){var v=[];for(var i=0;i<o.length;i++) v.push(json.toJSON(o[i]));return"["+v.join(", ")+"]";} var v=[];for(attr in o){if(o[attr]==null) -v.push("\""+attr+"\": null");else if(typeof o[attr]=="function") -;else +v.push("\""+attr+"\": null");else if(typeof o[attr]=="function");else v.push(json.escapeJSONString(attr)+": "+json.toJSON(o[attr]));} return"{"+v.join(", ")+"}";};var scdl={};scdl.composite=function(l){var cs=namedElementChildren("'composite",l);if(isNil(cs)) return cs;return car(cs);};scdl.components=function(l){var cs=namedElementChildren("'composite",l);if(isNil(cs)) @@ -250,9 +232,9 @@ return cs;return namedElementChildren("'component",car(cs));};scdl.promotions=fu return cs;return namedElementChildren("'service",car(cs));};scdl.promote=function(l){var puri=namedAttributeValue("'promote",l);if(isNil(puri)) return puri;return car(tokens(puri));};scdl.name=function(l){return namedAttributeValue("'name",l);};scdl.documentation=function(l){var d=namedElementChildren("'documentation",l);if(isNil(d)) return null;if(!elementHasValue(car(d))) -return null;var v=elementValue(car(d));return v;};scdl.title=function(l){return namedAttributeValue("'t:title",l);};scdl.style=function(l){return namedAttributeValue("'t:style",l);};scdl.color=function(l){return namedAttributeValue("'t:color",l);};scdl.x=function(l){return namedAttributeValue("'t:x",l);};scdl.y=function(l){return namedAttributeValue("'t:y",l);};scdl.implementation=function(l){function filterImplementation(v){return isElement(v)&&cadr(v).match("implementation.")!=null;} +return null;var v=elementValue(car(d));return v;};scdl.title=function(l){return namedAttributeValue("'title",l);};scdl.style=function(l){return namedAttributeValue("'style",l);};scdl.color=function(l){return namedAttributeValue("'color",l);};scdl.x=function(l){return namedAttributeValue("'x",l);};scdl.y=function(l){return namedAttributeValue("'y",l);};scdl.implementation=function(l){function filterImplementation(v){return isElement(v)&&cadr(v).match("implementation.")!=null;} var n=filter(filterImplementation,l);if(isNil(n)) -return null;return car(n);};scdl.implementationType=function(l){return elementName(l).substring(1);};scdl.uri=function(l){return namedAttributeValue("'uri",l);};scdl.align=function(l){return namedAttributeValue("'t:align",l);};scdl.visible=function(l){return namedAttributeValue("'t:visible",l);};scdl.clonable=function(l){return namedAttributeValue("'t:clonable",l);};scdl.services=function(l){return namedElementChildren("'service",l);};scdl.references=function(l){return namedElementChildren("'reference",l);};scdl.bindings=function(l){function filterBinding(v){return isElement(v)&&cadr(v).match("binding.")!=null;} +return null;return car(n);};scdl.implementationType=function(l){return elementName(l).substring(1);};scdl.uri=function(l){return namedAttributeValue("'uri",l);};scdl.align=function(l){return namedAttributeValue("'align",l);};scdl.visible=function(l){return namedAttributeValue("'visible",l);};scdl.clonable=function(l){return namedAttributeValue("'clonable",l);};scdl.services=function(l){return namedElementChildren("'service",l);};scdl.references=function(l){return namedElementChildren("'reference",l);};scdl.bindings=function(l){function filterBinding(v){return isElement(v)&&cadr(v).match("binding.")!=null;} return filter(filterBinding,l);};scdl.bindingType=function(l){return elementName(l).substring(1);};scdl.target=function(l){function targetURI(){function bindingsTarget(l){if(isNil(l)) return null;var u=scdl.uri(car(l));if(!isNil(u)) return u;return bindingsTarget(cdr(l));} @@ -261,19 +243,16 @@ return t;return bindingsTarget(scdl.bindings(l));} var turi=targetURI();if(isNil(turi)) return turi;return car(tokens(turi));};scdl.properties=function(l){return namedElementChildren("'property",l);};scdl.propertyValue=function(l){if(!elementHasValue(l)) return'';return elementValue(l);};scdl.nameToElementAssoc=function(l){if(isNil(l)) -return l;return cons(mklist(scdl.name(car(l)),car(l)),scdl.nameToElementAssoc(cdr(l)));};var ui={};ui.isIE=function(){if(typeof ui.isIE.detected!='undefined') -return ui.isIE.detected;ui.isIE.detected=navigator.appName=='Microsoft Internet Explorer';return ui.isIE.detected;};ui.ahref=function(loc,target,html){if(target=='_blank') +return l;return cons(mklist(scdl.name(car(l)),car(l)),scdl.nameToElementAssoc(cdr(l)));};var ui={};ui.ahref=function(loc,target,html){if(target=='_blank') return'<a href="'+loc+'" target="_blank">'+html+'</a>';return'<a href="javascript:void(0)" onclick="window.open(\''+loc+'\', \''+target+'\');">'+html+'</a>';};ui.menu=function(name,href,target){function Menu(n,h,t){this.name=n;this.href=h;this.target=isNil(t)?'_parent':t;this.content=function(){function complete(uri){var q=uri.indexOf('?');if(q!=-1) return complete(uri.substr(0,q));if(uri.match('.*\.html$')) return uri;if(uri.match('.*/$')) return uri+'index.html';return uri+'/index.html';} if(complete(this.href)!=complete(window.top.location.pathname)) return ui.ahref(this.href,this.target,'<span class="amenu">'+this.name+'</span>');return ui.ahref(this.href,this.target,'<span class="smenu">'+this.name+'</span>');};} -return new Menu(name,href,target);};ui.menubar=function(left,right){var bar='<table cellpadding="0" cellspacing="0" width="100%" class="tbar"><tr>'+ -'<td class="dtbar"><table border="0" cellspacing="0" cellpadding="0"><tr>';for(i in left) +return new Menu(name,href,target);};ui.menubar=function(left,right){var bar='<table cellpadding="0" cellspacing="0" width="100%" class="tbar"><tr>'+'<td class="dtbar"><table border="0" cellspacing="0" cellpadding="0"><tr>';for(i in left) bar=bar+'<td class="ltbar">'+left[i].content()+'</td>' -bar=bar+'</tr></table></td>'+ -'<td class="dtbar"><table border="0" cellpadding="0" cellspacing="0" align="right"><tr>';for(i in right) +bar=bar+'</tr></table></td>'+'<td class="dtbar"><table border="0" cellpadding="0" cellspacing="0" align="right"><tr>';for(i in right) bar=bar+'<td class="'+(i==0?'dtbar':'rtbar')+'">'+right[i].content()+'</td>' bar=bar+'</tr></table></td></tr></table>';return bar;};ui.selectSuggestion=function(node,value){for(;;){node=node.parentNode;if(node.tagName.toLowerCase()=='div') break;} @@ -283,9 +262,7 @@ input.hideSuggestDiv=function(){if(this.suggestDiv!=null){this.suggestDiv.style. input.showSuggestDiv=function(){if(this.suggestDiv==null){this.suggestDiv=document.createElement('div');this.suggestDiv.input=this;this.suggestDiv.className='suggest';input.parentNode.insertBefore(this.suggestDiv,input);this.suggestDiv.style.visibility='hidden';this.suggestDiv.style.zIndex='99';this.suggestDiv.selectSuggestion=function(value){this.input.selectSuggestion(value);}} var values=this.suggest();var items='';for(var i=0;i<values.length;i++){if(values[i].indexOf(this.value)==-1) continue;if(items.length==0) -items+='<table class="suggestTable">';items+='<tr><td class="suggestItem" '+ -'onmouseover="ui.hilightSuggestion(this, true)" onmouseout="ui.hilightSuggestion(this, false)" '+ -'onmousedown="ui.selectSuggestion(this, \''+values[i]+'\')">'+values[i]+'</td></tr>';} +items+='<table class="suggestTable">';items+='<tr><td class="suggestItem" '+'onmouseover="ui.hilightSuggestion(this, true)" onmouseout="ui.hilightSuggestion(this, false)" '+'onmousedown="ui.selectSuggestion(this, \''+values[i]+'\')">'+values[i]+'</td></tr>';} if(items.length!=0) items+='</table>';this.suggestDiv.innerHTML=items;if(items.length!=0){var node=input;var left=0;var top=0;for(;;){left+=node.offsetLeft;top+=node.offsetTop;node=node.offsetParent;if(node.tagName.toLowerCase()=='body') break;} @@ -309,20 +286,14 @@ return'';return' '+indent(i-1);} function rows(l,i){if(isNil(l)) return'';var e=car(l);if(!isList(e)) return rows(expandElementValues("'value",l),i);if(isList(car(e))) -return rows(expandElementValues("'value",l),i);if(elementHasValue(e)){var v=elementValue(e);if(!isList(v)){return'<tr><td class="datatdl">'+indent(i)+elementName(e).slice(1)+'</td>'+ -'<td class="datatdr tdw">'+(v!=null?v:'')+'</td></tr>'+ -rows(cdr(l),i);} +return rows(expandElementValues("'value",l),i);if(elementHasValue(e)){var v=elementValue(e);if(!isList(v)){return'<tr><td class="datatdl">'+indent(i)+elementName(e).slice(1)+'</td>'+'<td class="datatdr tdw">'+(v!=null?v:'')+'</td></tr>'+rows(cdr(l),i);} return rows(expandElementValues(elementName(e),v),i)+rows(cdr(l),i);} -return'<tr><td class="datatdl">'+indent(i)+elementName(e).slice(1)+'</td>'+ -'<td class="datatdr tdw">'+'</td></tr>'+ -rows(elementChildren(e),i+1)+ -rows(cdr(l),i);} +return'<tr><td class="datatdl">'+indent(i)+elementName(e).slice(1)+'</td>'+'<td class="datatdr tdw">'+'</td></tr>'+rows(elementChildren(e),i+1)+rows(cdr(l),i);} return'<table class="datatable '+(window.name=='dataFrame'?' databg':'')+'" style="width: 100%;">'+rows(l,0)+'</table>';} ui.datalist=function(l){function rows(l,i){if(isNil(l)) return'';var e=car(l);if(!isList(e)) return rows(expandElementValues("'value",l),i);if(isList(car(e))) -return rows(expandElementValues("'value",l),i);if(elementHasValue(e)){var v=elementValue(e);if(!isList(v)){return'<tr><td class="datatd tdw">'+(v!=null?v:'')+'</td></tr>'+ -rows(cdr(l),i);} +return rows(expandElementValues("'value",l),i);if(elementHasValue(e)){var v=elementValue(e);if(!isList(v)){return'<tr><td class="datatd tdw">'+(v!=null?v:'')+'</td></tr>'+rows(cdr(l),i);} return rows(expandElementValues(elementName(e),v),i)+rows(cdr(l),i);} return rows(elementChildren(e),i+1)+rows(cdr(l),i);} return'<table class="datatable '+(window.name=='dataFrame'?' databg':'')+'" style="width: 100%;">'+rows(l,0)+'</table>';} @@ -336,8 +307,7 @@ return o.toString();if(o.constructor==Date) return'{javaClass: "java.util.Date", time: '+o.valueOf()+'}';if(o.constructor==Array){var v=[];for(var i=0;i<o.length;i++) v.push(JSONClient.toJSON(o[i]));return"["+v.join(", ")+"]";} var v=[];for(attr in o){if(o[attr]==null) -v.push("\""+attr+"\": null");else if(typeof o[attr]=="function") -;else +v.push("\""+attr+"\": null");else if(typeof o[attr]=="function");else v.push(JSONClient.escapeJSONString(attr)+": "+JSONClient.toJSON(o[attr]));} return"{"+v.join(", ")+"}";};function HTTPBindingClient(name,uri){this.name=name;this.uri=uri;this.apply=this.createApplyMethod();} HTTPBindingClient.jsonrpcID=1;HTTPBindingClient.prototype.createApplyMethod=function(){var fn=function(){var methodName=arguments[0];var args=[];for(var i=1;i<arguments.length;i++) @@ -374,4 +344,4 @@ for(var i=0;i<HTTPBindingClient.msxmlNames.length;i++){try{HTTPBindingClient.htt HTTPBindingClient.httpFactory=null;throw new HTTPBindingClient.Exception(0,"Can't create XMLHttpRequest object");};var sca={};sca.httpclient=function(name,uri){return new HTTPBindingClient(name,uri);};sca.component=function(name){return new HTTPBindingClient(name,'/components/'+name);};sca.reference=function(comp,rname){return new HTTPBindingClient(comp.name+'/'+rname,"/references/"+comp.name+"/"+rname);};sca.defun=function(ref){function defapply(name){return function(){var args=new Array();args[0]=name;for(i=0,n=arguments.length;i<n;i++) args[i+1]=arguments[i];return this.apply.apply(this,args);};} for(f=1;f<arguments.length;f++){var fn=arguments[f];ref[fn]=defapply(fn);} -return ref;}; +return ref;};
\ No newline at end of file diff --git a/sca-cpp/trunk/modules/js/htdocs/ui.js b/sca-cpp/trunk/modules/js/htdocs/ui.js index db58f8b4e5..b0d159d07e 100644 --- a/sca-cpp/trunk/modules/js/htdocs/ui.js +++ b/sca-cpp/trunk/modules/js/htdocs/ui.js @@ -24,16 +24,6 @@ var ui = {}; /** - * Return true if the current browser is Internet Explorer. - */ -ui.isIE = function() { - if (typeof ui.isIE.detected != 'undefined') - return ui.isIE.detected; - ui.isIE.detected = navigator.appName == 'Microsoft Internet Explorer'; - return ui.isIE.detected; -}; - -/** * Build a portable <a href> tag. */ ui.ahref = function(loc, target, html) { diff --git a/sca-cpp/trunk/modules/js/htdocs/util.js b/sca-cpp/trunk/modules/js/htdocs/util.js index 69359fa167..b74eedc6ed 100644 --- a/sca-cpp/trunk/modules/js/htdocs/util.js +++ b/sca-cpp/trunk/modules/js/htdocs/util.js @@ -208,6 +208,16 @@ function debug(o) { } /** + * Return true if the current browser is Internet Explorer. + */ +function isIE() { + if (typeof isIE.detected != 'undefined') + return isIE.detected; + isIE.detected = navigator.appName == 'Microsoft Internet Explorer'; + return isIE.detected; +}; + +/** * External build configuration. */ var config; @@ -267,15 +277,17 @@ function writeValue(v) { * Apply a function and memoize its result. */ function memo(obj, key, f) { - if (!obj[memo]) + if (!('memo' in obj)) { obj.memo = {}; - if (obj.memo[key]) + return obj.memo[key] = f(); + } + if (key in obj.memo) return obj.memo[key]; return obj.memo[key] = f(); } /** - * Un-memoize store results. + * Un-memoize stored results. */ function unmemo(obj) { obj.memo = {}; diff --git a/sca-cpp/trunk/modules/js/htdocs/xmlutil.js b/sca-cpp/trunk/modules/js/htdocs/xmlutil.js index 3965596599..4d943cce75 100644 --- a/sca-cpp/trunk/modules/js/htdocs/xmlutil.js +++ b/sca-cpp/trunk/modules/js/htdocs/xmlutil.js @@ -111,19 +111,8 @@ function isXML(l) { */ function parseXML(l) { var s = writeStrings(l); - if (window.DOMParser) { - var p = new DOMParser(); - return p.parseFromString(s, "text/xml"); - } - var doc; - try { - doc = new ActiveXObject("MSXML2.DOMDocument"); - } catch (e) { - doc = new ActiveXObject("Microsoft.XMLDOM"); - } - doc.async = 'false'; - doc.loadXML(s); - return doc; + var p = new DOMParser(); + return p.parseFromString(s, "text/xml"); } /** @@ -196,7 +185,12 @@ function writeList(l, node, doc) { var token = car(l); if (isTaggedList(token, attribute)) { - node.setAttribute(attributeName(token).substring(1), '' + attributeValue(token)); + if (isIE()) { + var aname = attributeName(token).substring(1); + if (aname != 'xmlns') + node.setAttribute(aname, '' + attributeValue(token)); + } else + node.setAttribute(attributeName(token).substring(1), '' + attributeValue(token)); } else if (isTaggedList(token, element)) { @@ -213,7 +207,9 @@ function writeList(l, node, doc) { } var ns = xmlns(elementChildren(tok)); - if (ns == null || !doc.createElementNS) + if (isIE()) + return doc.createElementNS(ns != null? ns : node.namespaceURI, elementName(tok).substring(1)); + if (ns == null) return doc.createElement(elementName(tok).substring(1)); return doc.createElementNS(ns, elementName(tok).substring(1)); } @@ -244,9 +240,7 @@ function writeList(l, node, doc) { * Make a new XML document. */ function mkXMLDocument() { - if (document.implementation && document.implementation.createDocument) - return document.implementation.createDocument('', '', null); - return new ActiveXObject("MSXML2.DOMDocument"); + return document.implementation.createDocument('', '', null); } /** |