diff options
author | jsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68> | 2010-12-12 18:37:57 +0000 |
---|---|---|
committer | jsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68> | 2010-12-12 18:37:57 +0000 |
commit | aaffeb998351334a423f833b46066bc8f3a82357 (patch) | |
tree | aab28e35de2bfc9c1ef906f3dc9519b281ae1d63 /sca-cpp/trunk/modules/js/htdocs/atomutil.js | |
parent | e1a9fc541e79a545a696fd4a6373d1fa9ade1987 (diff) |
Refactor some of the Javascript scripts to use a different namespace per script.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1044875 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-cpp/trunk/modules/js/htdocs/atomutil.js')
-rw-r--r-- | sca-cpp/trunk/modules/js/htdocs/atomutil.js | 91 |
1 files changed, 46 insertions, 45 deletions
diff --git a/sca-cpp/trunk/modules/js/htdocs/atomutil.js b/sca-cpp/trunk/modules/js/htdocs/atomutil.js index 1c9137b668..3499948083 100644 --- a/sca-cpp/trunk/modules/js/htdocs/atomutil.js +++ b/sca-cpp/trunk/modules/js/htdocs/atomutil.js @@ -20,61 +20,62 @@ /** * ATOM data conversion functions. */ +var atom = new Object(); /** * Convert a list of elements to a list of values representing an ATOM entry. */ -function entryElementsToValues(e) { +atom.entryElementsToValues = 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 mklist(t, i, elementValue(car(lc))); -} +}; /** * Convert a list of elements to a list of values representing ATOM entries. */ -function entriesElementsToValues(e) { +atom.entriesElementsToValues = function(e) { if (isNil(e)) return e; - return cons(entryElementsToValues(car(e)), entriesElementsToValues(cdr(e))); -} + return cons(atom.entryElementsToValues(car(e)), atom.entriesElementsToValues(cdr(e))); +}; /** * Convert a list of strings to a list of values representing an ATOM entry. */ -function readATOMEntry(l) { +atom.readATOMEntry = function(l) { var e = readXML(l); if (isNil(e)) return mklist(); - return entryElementsToValues(car(e)); -} + return atom.entryElementsToValues(car(e)); +}; /** * Convert a list of values representy an ATOM entry to a value. */ -function entryValue(e) { +atom.entryValue = function(e) { var v = elementsToValues(mklist(caddr(e))); return cons(car(e), (cadr(e), cdr(car(v)))); -} +}; /** * Return true if a list of strings represents an ATOM feed. */ -function isATOMFeed(l) { +atom.isATOMFeed = function(l) { if (isNil(l)) return false; if (car(l).substring(0, 5) != "<?xml") return false; return car(l).match("<feed") != null; -} +}; /** * Convert a DOM document to a list of values representing an ATOM feed. */ -function readATOMFeedDocument(doc) { +atom.readATOMFeedDocument = function(doc) { var f = readXMLDocument(doc); if (isNil(f)) return mklist(); @@ -83,86 +84,86 @@ function readATOMFeedDocument(doc) { var e = filter(selector(mklist(element, "'entry")), car(f)); if (isNil(e)) return mklist(elementValue(car(t)), elementValue(car(i))); - return cons(elementValue(car(t)), cons(elementValue(car(i)), entriesElementsToValues(e))); -} + return cons(elementValue(car(t)), cons(elementValue(car(i)), atom.entriesElementsToValues(e))); +}; /** * Convert a list of strings to a list of values representing an ATOM feed. */ -function readATOMFeed(l) { - return readAtomFeedDocument(parseXML(l)); -} +atom.readATOMFeed = function(l) { + return atom.readAtomFeedDocument(parseXML(l)); +}; /** * Convert an ATOM feed containing elements to an ATOM feed containing values. */ -function feedValuesLoop(e) { - if (isNil(e)) - return e; - return cons(entryValue(car(e)), feedValuesLoop(cdr(e))); -} +atom.feedValues = function(e) { + function feedValuesLoop(e) { + if (isNil(e)) + return e; + return cons(entryValue(car(e)), feedValuesLoop(cdr(e))); + } -function feedValues(e) { return cons(car(e), cons(cadr(e), feedValuesLoop(cddr(e)))); -} +}; /** * Convert a list of values representy an ATOM entry to a list of elements. */ -function entryElement(l) { +atom.entryElement = function(l) { return mklist(element, "'entry", mklist(attribute, "'xmlns", "http://www.w3.org/2005/Atom"), mklist(element, "'title", mklist(attribute, "'type", "text"), car(l)), mklist(element, "'id", cadr(l)), mklist(element, "'content", mklist(attribute, "'type", (isList(caddr(l))? "application/xml" : "text")), caddr(l)), mklist(element, "'link", mklist(attribute, "'href", cadr(l)))); -} +}; /** * Convert a list of values representing ATOM entries to a list of elements. */ -function entriesElements(l) { +atom.entriesElements = function(l) { if (isNil(l)) return l; - return cons(entryElement(car(l)), entriesElements(cdr(l))); -} + return cons(atom.entryElement(car(l)), atom.entriesElements(cdr(l))); +}; /** * Convert a list of values representing an ATOM entry to an ATOM entry. */ -function writeATOMEntry(l) { - return writeXML(mklist(entryElement(l)), true); -} +atom.writeATOMEntry = function(l) { + return writeXML(mklist(atom.entryElement(l)), true); +}; /** * Convert a list of values representing an ATOM feed to an ATOM feed. */ -function writeATOMFeed(l) { +atom.writeATOMFeed = function(l) { 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))); if (isNil(cddr(l))) return writeXML(mklist(f), true); - var fe = append(f, entriesElements(cddr(l))); + var fe = append(f, atom.entriesElements(cddr(l))); return writeXML(mklist(fe), true); -} +}; /** * Convert an ATOM entry containing a value to an ATOM entry containing an item element. */ -function entryValuesToElements(v) { +atom.entryValuesToElements = function(v) { return cons(car(v), cons(cadr(v), valuesToElements(mklist(cons("'item", caddr(v)))))); -} +}; /** * Convert an ATOM feed containing values to an ATOM feed containing elements. */ -function feedValuesToElementsLoop(v) { - if (isNil(v)) - return v; - return cons(entryValuesToElements(car(v)), feedValuesToElementsLoop(cdr(v))); -} +atom.feedValuesToElements = function(v) { + function feedValuesToElementsLoop(v) { + if (isNil(v)) + return v; + return cons(atom.entryValuesToElements(car(v)), feedValuesToElementsLoop(cdr(v))); + } -function feedValuesToElements(v) { return cons(car(v), cons(cadr(v), feedValuesToElementsLoop(cddr(v)))); -} +}; |