Lively Kernel canvas * MIT license * * Includes enhancements by Scott Trenda * and Kris Kowal * * Accepts a date, a mask, or a date and a mask. * Returns a formatted version of the given date.]]> 99 ? Math.round(L / 10) : L), ]]> 0 ? "-" : "+") + pad(Math.floor(Math.abs(o) / 60) * 100 + Math.abs]]> 3 ? 0 : (d % 100 - d % 10 != 10) * d % 10] }; return mask.replace(token, function ($0) { return $0 in flags ? flags[$0] : $0.slice(1, $0.length - 1); }); }; }(); // Some common format strings dateFormat.masks = { "default": ]]> Draft-ODataMetadata40true savefalsenulltruenull SincetheMicrosoftODataJavascriptAPIdoesonlyworkontopofaserviceyoualreadynew/whosestructureyoualreadynew,wehaveto"build"ourownlib/waytogetthisstructure...161 Wikicontroltruetrue module('projects.ObjectExplorer.ObjectExplorerTreeNode').load();TreeNodeMorph.prototype.ICONCOLLAPSED='../projects/ObjectExplorer/media/collapsed.png';TreeNodeMorph.prototype.ICONEXPANDED='../projects/ObjectExplorer/media/expanded.png'; Object.subclass('XMLJSONPrettifier',{});Object.extend(XMLJSONPrettifier,{makePretty:function(input){varoutput={};input.each(function(key,value){if((key=='children')&&(valueinstanceofArray)){varsubs=output;value.each(function(ea){vartagName=ea['tagName'];varns=undefined;if(tagName.indexOf(':')>=0){ns=tagName.substring(0,tagName.indexOf(':'));tagName=tagName.substring(tagName.indexOf(':')+1);}if(tagName&&(tagName!='textNode')){subs[tagName]=subs[tagName]||[];subs[tagName].push(XMLJSONPrettifier.makePretty(ea));}if(ns)subs[tagName]._namespace=ns;});}elseif(key.startsWith('xmlns:')){output['_namespaces']=output['_namespaces']||{};output['_namespaces'][key.substr(6)]=value;}elseif(key=='tagName'){//donothing}else{varns;if(key.indexOf(':')>=0){ns=key.substring(0,key.indexOf(':'));key=key.substring(key.indexOf(':')+1);}if(parseInt(value).toString()==value)output[key]=parseInt(value);elseif(value=='true')output[key]=true;elseif(value=='false')output[key]=false;elseoutput[key]=value;if(ns)output[key]._namespace=ns;}});returnoutput;}});/*pretty=XLMJSONPrettifier.makePretty(json);explorer=newObjectExplorer({objectToExplore:pretty});explorer.openIn(WorldMorph.current(),pt(500,700));*/= 0) {\n\t\t\t\t\t\tns = tagName.substring(0, tagName.indexOf(':'));\n\t\t\t\t\t\ttagName = tagName.substring(tagName.indexOf(':') + 1);\n\t\t\t\t\t}\n\n\t\t\t\t\tif (tagName && (tagName != 'textNode')) {\n\t\t\t\t\t\tsubs[tagName] = subs[tagName] || [];\n\t\t\t\t\t\tsubs[tagName].push(XMLJSONPrettifier.makePretty(ea));\n\t\t\t\t\t}\n\n\t\t\t\t\tif (ns)\n\t\t\t\t\t\tsubs[tagName]._namespace = ns;\n\t\t\t\t});\n\t\t\t} else if (key.startsWith('xmlns:')) {\n\t\t\t\toutput['_namespaces'] = output['_namespaces'] || {};\n\t\t\t\toutput['_namespaces'][key.substr(6)] = value;\n\t\t\t} else if (key == 'tagName') {\n\t\t\t\t// do nothing\n\t\t\t} else {\n\t\t\t\tvar ns;\n\t\t\t\tif (key.indexOf(':') >= 0) {\n\t\t\t\t\tns = key.substring(0, key.indexOf(':'));\n\t\t\t\t\tkey = key.substring(key.indexOf(':') + 1);\n\t\t\t\t}\n\n\t\t\t\tif (parseInt(value).toString() == value)\n\t\t\t\t\toutput[key] = parseInt(value);\n\t\t\t\telse if (value == 'true')\n\t\t\t\t\toutput[key] = true;\n\t\t\t\telse if (value == 'false')\n\t\t\t\t\toutput[key] = false;\n\t\t\t\telse\n\t\t\t\t\toutput[key] = value;\n\n\t\t\t\tif (ns)\n\t\t\t\t\toutput[key]._namespace = ns;\n\t\t\t}\n\t\t});\n\n\t\treturn output;\n\t}\n});\n\n/*\npretty = XLMJSONPrettifier.makePretty(json);\nexplorer = new ObjectExplorer({objectToExplore: pretty});\nexplorer.openIn(WorldMorph.current(), pt(500,700));\n*/"]]>= 0) {\n\t\t\t\t\t\tns = tagName.substring(0, tagName.indexOf(':'));\n\t\t\t\t\t\ttagName = tagName.substring(tagName.indexOf(':') + 1);\n\t\t\t\t\t}\n\n\t\t\t\t\tif (tagName && (tagName != 'textNode')) {\n\t\t\t\t\t\tsubs[tagName] = subs[tagName] || [];\n\t\t\t\t\t\tsubs[tagName].push(XMLJSONPrettifier.makePretty(ea));\n\t\t\t\t\t}\n\n\t\t\t\t\tif (ns)\n\t\t\t\t\t\tsubs[tagName]._namespace = ns;\n\t\t\t\t});\n\t\t\t} else if (key.startsWith('xmlns:')) {\n\t\t\t\toutput['_namespaces'] = output['_namespaces'] || {};\n\t\t\t\toutput['_namespaces'][key.substr(6)] = value;\n\t\t\t} else if (key == 'tagName') {\n\t\t\t\t// do nothing\n\t\t\t} else {\n\t\t\t\tvar ns;\n\t\t\t\tif (key.indexOf(':') >= 0) {\n\t\t\t\t\tns = key.substring(0, key.indexOf(':'));\n\t\t\t\t\tkey = key.substring(key.indexOf(':') + 1);\n\t\t\t\t}\n\n\t\t\t\tif (parseInt(value).toString() == value)\n\t\t\t\t\toutput[key] = parseInt(value);\n\t\t\t\telse if (value == 'true')\n\t\t\t\t\toutput[key] = true;\n\t\t\t\telse if (value == 'false')\n\t\t\t\t\toutput[key] = false;\n\t\t\t\telse\n\t\t\t\t\toutput[key] = value;\n\n\t\t\t\tif (ns)\n\t\t\t\t\toutput[key]._namespace = ns;\n\t\t\t}\n\t\t});\n\n\t\treturn output;\n\t}\n});\n\n/*\npretty = XLMJSONPrettifier.makePretty(json);\nexplorer = new ObjectExplorer({objectToExplore: pretty});\nexplorer.openIn(WorldMorph.current(), pt(500,700));\n*/"]]>44truetruefalse truetrue false0.98728139904610350.11 true false true nullfalsetruenull XMLJSONPrettifierfalsenulltruefalse Xfalsenulltrue false false Mfalsenulltrue false false falsenulltrue false falsenullfalsefalsenullnullnullnullfalse url=newURL('http://services.odata.org/Northwind/Northwind.svc/$metadata');xml=newWebResource(url).get().content;xmlDOM=newDOMParser().parseFromString(xml,"text/xml").documentElement;conv=newlively.Helper.XMLConverter();json=conv.convertToJSON(xmlDOM);//edmx=convertEdmxJSON(json);edmx=XMLJSONPrettifier.makePretty(json);explorer=newObjectExplorer({objectToExplore:edmx});explorer.openIn(WorldMorph.current(),pt(500,100));truetruefalsenull truetruefalse false10.11 true false truefalse nullfalsetruenullfalse Doityourself-Metadataparsingfalsenulltruefalse Xfalsenulltrue false false Mfalsenulltrue false false falsenulltrue false falsenullfalsefalsenullnullnullnullfalse createLayer('SmartObjectLayer');layerClass(SmartObjectLayer,Object,{each:function(proceed,func){for(varkeyinthis){if(typeofthis[key]!='function'){func(key,this[key]);}}},select:function(proceed,func,asObject){asObject=asObject||false;varres;if(asObject)res={};elseres=[];for(varkeyinthis){if((typeofthis[key]!='function')&&func(key,this[key])){if(asObject)res[key]=this[key];elseres.push(key);}}returnres;},detect:function(proceed,func,asObject){asObject=asObject||false;varres=null;for(varkeyinthis){if((typeofthis[key]!='function')&&func(key,this[key])){if(asObject){res={};res[key]=this[key];}elseres=key;break;}}returnres;},});enableLayer(SmartObjectLayer);/*withLayers([SmartObjectLayer],function(){varobj={a:'1',b:'0',c:'1',f:function(){}};console.log(''+obj.select(function(key,value){returnvalue==1}));console.log(''+obj.detect(function(key,value){returnvalue==1}));console.log(''+obj.detect(function(key,value){returnvalue==42}));obj1=obj.select(function(key,value){returnvalue==1},true);obj2=obj.detect(function(key,value){returnvalue==1},true);});*/51truetruefalse truetrue false10.11 true false true nullfalsetruenull SmartObjects:-)falsenulltruefalse Xfalsenulltrue false false Mfalsenulltrue false false falsenulltrue false falsenullfalsefalsenullnullnullnullfalse convertEdmxJSON=function(json){varresult={};vartmp;tmp=json.detect(function(key,value){returnvalue=='http://schemas.microsoft.com/ado/2007/06/edmx';});varedmxNamespace=tmp.split(':')[1];vardataServices=json.children.detect(function(ea){returnea.tagName&&ea.tagName==edmxNamespace+':'+'DataServices';});varschema=dataServices.children.select(function(ea){returnea.tagName&&ea.tagName=='Schema';});schema=schema.collect(function(ea){return{Namespace:ea.Namespace,Association:ea.children.select(function(ea){returnea.tagName&&ea.tagName=='Association';}).collect(function(ea){return{End:ea.children.select(function(ea){returnea.tagName&&ea.tagName=='End'}).collect(function(ea){return{Role:ea.Role,Type:ea.Type,Multiplicity:ea.Multiplicity};}),ReferentialConstraint:(function(ea){ea=ea.children.detect(function(ea){returnea.tagName&&ea.tagName=='ReferentialConstraint'});if(ea==undefined)returnea;return{Principal:ea.children.detect(function(ea){returnea.tagName&&ea.tagName=='Principal'}),Dependent:ea.children.detect(function(ea){returnea.tagName&&ea.tagName=='Dependent'})};})(ea)};}),EntityType:ea.children.select(function(ea){returnea.tagName&&ea.tagName=='EntityType';}).collect(function(ea){return{Name:ea.Name,Key:ea.children.detect(function(ea){returnea.tagName&&ea.tagName=='Key'}).children.select(function(ea){returnea.tagName&&ea.tagName=='PropertyRef'}).collect(function(ea){return{Name:ea.Name};}),Property:ea.children.select(function(ea){returnea.tagName&&ea.tagName=='Property'}).collect(function(ea){return{Name:ea.Name,Type:ea.Type,Nullable:(ea.Nullable&&ea.Nullable=='false'?false:true),MaxLength:parseInt(ea.MaxLength),Unicode:ea.Unicode,FixedLength:ea.FixedLength};}),NavigationProperty:ea.children.select(function(ea){returnea.tagName&&ea.tagName=='NavigationProperty'}).collect(function(ea){return{Name:ea.Name,Relationship:ea.Relationship,FromRole:ea.FromRole,ToRole:ea.ToRole}})};}),EntityContainer:ea.children.select(function(ea){returnea.tagName&&ea.tagName=='EntityContainer';}),}});result={DataServices:{Schema:schema}};returnresult;}38truetruefalse truetrue false0.69902183013305730.11 true false true nullfalsetruenull Conversion-deprecated!falsenulltruefalse Xfalsenulltrue false false Mfalsenulltrue false false falsenulltrue false falsenullfalsefalsenullnullnullnullfalse null226