diff options
author | jsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68> | 2011-02-02 10:04:44 +0000 |
---|---|---|
committer | jsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68> | 2011-02-02 10:04:44 +0000 |
commit | f07b324e6f0f2edb71c4dc1d6b63e8a3743c48a6 (patch) | |
tree | f9c59fa81f2d56b87066fc54b9b553ac4c43fd35 /sca-cpp/trunk/modules/js | |
parent | d8df0d6da27ac9c4c61863bc7700db7a871ae8d4 (diff) |
Support for wiring and unwiring references.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1066399 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-cpp/trunk/modules/js')
-rw-r--r-- | sca-cpp/trunk/modules/js/htdocs/elemutil.js | 34 | ||||
-rw-r--r-- | sca-cpp/trunk/modules/js/htdocs/ui.css | 8 | ||||
-rw-r--r-- | sca-cpp/trunk/modules/js/htdocs/uicyan.css | 8 | ||||
-rw-r--r-- | sca-cpp/trunk/modules/js/htdocs/util.js | 80 |
4 files changed, 30 insertions, 100 deletions
diff --git a/sca-cpp/trunk/modules/js/htdocs/elemutil.js b/sca-cpp/trunk/modules/js/htdocs/elemutil.js index f6f8dcd186..85eea29aa3 100644 --- a/sca-cpp/trunk/modules/js/htdocs/elemutil.js +++ b/sca-cpp/trunk/modules/js/htdocs/elemutil.js @@ -248,36 +248,10 @@ function namedElementChild(name, l) { */ /** - * Set the value of the attribute with the given name. + * Set the contents of an element. */ -function setNamedAttributeValue(name, v, l) { - var f = filter(function(v) { return isAttribute(v) && attributeName(v) == name; }, l); - if (!isNil(f)) { - - // Un-memoize attribute and change its value - unmemo(l, name); - car(f)[2] = '' + v; - return v; - } - - // Insert new attribute - insertn$(mklist(attribute, name, '' + v), l, 2); - return v; -} - -/** - * Set the value of an element. - */ -function setElementValue(v, l) { - if (elementHasValue(l)) { - - // Change existing element value - l[length(l) - 1] = v; - return v; - } - - // Append element value - $append(l, mklist(v)); - return v; +function setElement(l, e) { + setlist(l, e); + l.memo = {}; } diff --git a/sca-cpp/trunk/modules/js/htdocs/ui.css b/sca-cpp/trunk/modules/js/htdocs/ui.css index 7e57d184ba..2bb36f9319 100644 --- a/sca-cpp/trunk/modules/js/htdocs/ui.css +++ b/sca-cpp/trunk/modules/js/htdocs/ui.css @@ -57,21 +57,21 @@ vertical-align: middle; } a:link { -color: blue; +color: #598edd; } a:visited { -color: blue; +color: #598edd; } .amenu { -color: blue; +color: #598edd; text-decoration: underline } .smenu { font-weight: bold; -color: blue; +color: #598edd; text-decoration: underline } diff --git a/sca-cpp/trunk/modules/js/htdocs/uicyan.css b/sca-cpp/trunk/modules/js/htdocs/uicyan.css index 7e57d184ba..2bb36f9319 100644 --- a/sca-cpp/trunk/modules/js/htdocs/uicyan.css +++ b/sca-cpp/trunk/modules/js/htdocs/uicyan.css @@ -57,21 +57,21 @@ vertical-align: middle; } a:link { -color: blue; +color: #598edd; } a:visited { -color: blue; +color: #598edd; } .amenu { -color: blue; +color: #598edd; text-decoration: underline } .smenu { font-weight: bold; -color: blue; +color: #598edd; text-decoration: underline } diff --git a/sca-cpp/trunk/modules/js/htdocs/util.js b/sca-cpp/trunk/modules/js/htdocs/util.js index 873874c7be..2521b82311 100644 --- a/sca-cpp/trunk/modules/js/htdocs/util.js +++ b/sca-cpp/trunk/modules/js/htdocs/util.js @@ -52,10 +52,18 @@ function cddr(l) { return cdr(cdr(l)); } +function cdddr(l) { + return cdr(cdr(cdr(l))); +} + function caddr(l) { return car(cddr(l)); } +function cadddr(l) { + return car(cdddr(l)); +} + function append(a, b) { return a.concat(b); } @@ -213,16 +221,18 @@ function writeValue(v) { * Apply a function and memoize its result. */ function memo(obj, key, f) { - if (obj[key]) - return obj[key]; - return obj[key] = f(); + if (!obj[memo]) + obj.memo = {}; + if (obj.memo[key]) + return obj.memo[key]; + return obj.memo[key] = f(); } /** - * Un-memoize a value. + * Un-memoize store results. */ -function unmemo(obj, key) { - obj[key] = null; +function unmemo(obj) { + obj.memo = {}; return true; } @@ -276,63 +286,9 @@ function setcdr(a, b) { * Set the contents of a list. */ function setlist(a, b) { + if (b == a) + return b; a.length = 0; return setappend(a, b); } -/** - * Insert a value at a given position in a list. - */ -function insertn$(v, n, l) { - function upshift(i) { - if (i == n) - return true; - l[i] = l[i - 1]; - return upshift(i - 1); - } - - upshift(length(l)); - l[n] = v; - return l; -} - -/** - * Insert a value at the beginning of a list. - */ -function insert$(v, l) { - return insertn$(v, 0, l); -} - -/** - * Append a list at the end of a list. - */ -function append$(a, b) { - if (isNil(b)) - return a; - a.push(car(b)); - return append$(a, cdr(b)); -} - -/** - * Delete a value from a list. - */ -function delete$(v, l) { - function dnshift(i, max) { - if (i >= max) - return true; - l[i] = l[i + 1]; - return dnshift(i + 1, max); - } - - dnshift(n, length(l) - 1); - l.pop(); - return l; -} - -/** - * Delete a value at the beginning of a list. - */ -function delete$(l) { - return deleten$(l, 0); -} - |