Last active
February 14, 2019 15:06
-
-
Save kenwebb/7764627e9ff25ff37fa78563be75377b to your computer and use it in GitHub Desktop.
Sugar Javascript library
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<!--Xholon Workbook http://www.primordion.com/Xholon/gwt/ MIT License, Copyright (C) Ken Webb, Thu Feb 14 2019 10:05:43 GMT-0500 (Eastern Standard Time)--> | |
<XholonWorkbook> | |
<Notes><![CDATA[ | |
Xholon | |
------ | |
Title: Sugar Javascript library | |
Description: | |
Url: http://www.primordion.com/Xholon/gwt/ | |
InternalName: 7764627e9ff25ff37fa78563be75377b | |
Keywords: | |
My Notes | |
-------- | |
February 14, 2019 | |
I downloaded [3]. | |
References | |
---------- | |
(1) https://sugarjs.com/ | |
(2) https://github.com/andrewplummer/Sugar | |
(3) https://raw.githubusercontent.com/andrewplummer/Sugar/2.0.4/dist/sugar.js | |
) https://raw.githubusercontent.com/andrewplummer/Sugar/2.0.4/dist/sugar.min.js | |
]]></Notes> | |
<_-.XholonClass> | |
<PhysicalSystem/> | |
<Sugar/> | |
</_-.XholonClass> | |
<xholonClassDetails> | |
</xholonClassDetails> | |
<PhysicalSystem> | |
<Sugar/> | |
</PhysicalSystem> | |
<Sugarbehavior implName="org.primordion.xholon.base.Behavior_gwtjs"><![CDATA[ | |
var me, Sugar, Array, count, beh = { | |
postConfigure: function() { | |
me = this.cnode.parent(); | |
$wnd.xh.require("sugar.min.js"); | |
Sugar = null; | |
count = 0; | |
}, | |
act: function() { | |
//me.println(this.toString()); | |
if (!Sugar && $wnd.Sugar) { | |
Sugar = $wnd.Sugar; | |
if (Sugar) { | |
count = 1; // 1 | |
Array = Sugar.Array; | |
} | |
} | |
if (Sugar) { | |
switch (count) { | |
case 1: | |
var friday = Sugar.Date.create('last week Friday'); | |
me.println(friday); | |
break; | |
case 2: | |
var rnum = Sugar.Number.random(1, 100); | |
me.println(rnum); | |
break; | |
case 3: | |
// Sugar Array methods are added to the standard JS Array prototype | |
var arr = Array.unique([1,2,2,3]); | |
me.println(arr); | |
break; | |
case 4: | |
// Chainables | |
var arr = new Sugar.Array([1,2]); | |
me.println(arr.concat([2,3]).unique().raw); | |
var num = new Sugar.Number(3.1415); | |
me.println(num.round(1).toFixed(2).raw); | |
break; | |
case 5: | |
// Object | |
var data = {users: {}}; | |
var obj = new Sugar.Object(data); | |
me.println(data); | |
me.println(JSON.stringify(data)); | |
me.println(obj); | |
me.println(obj.has('users').raw); // true | |
me.println(obj.has('users')); | |
break; | |
case 6: | |
// Object | |
var data = {users: [{profile: {hobbies: "Life"}}, | |
{profile: {hobbies: "Universe"}}, | |
{profile: {hobbies: "Movies"}}]}; | |
var obj = new Sugar.Object(data); | |
me.println(data); | |
me.println(JSON.stringify(data)); | |
me.println(obj); | |
me.println(obj.get('users[2].profile.hobbies').raw); // Movies | |
break; | |
case 7: | |
// | |
break; | |
case 8: | |
// | |
break; | |
case 9: | |
// | |
break; | |
case 10: | |
// | |
break; | |
default: | |
break; | |
} | |
count++; | |
} | |
} | |
} | |
//# sourceURL=Sugarbehavior.js | |
]]></Sugarbehavior> | |
<SvgClient><Attribute_String roleName="svgUri"><![CDATA[data:image/svg+xml, | |
<svg width="100" height="50" xmlns="http://www.w3.org/2000/svg"> | |
<g> | |
<title>Sugar</title> | |
<rect id="PhysicalSystem/Sugar" fill="#98FB98" height="50" width="50" x="25" y="0"/> | |
<g> | |
<title>star</title> | |
<rect id="PhysicalSystem/Sugar/*" fill="#6AB06A" height="50" width="10" x="80" y="0"/> | |
</g> | |
</g> | |
</svg> | |
]]></Attribute_String><Attribute_String roleName="setup">${MODELNAME_DEFAULT},${SVGURI_DEFAULT}</Attribute_String></SvgClient> | |
</XholonWorkbook> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment