Mercurial > eldonilo > lightstring
comparison stanza.js @ 29:1e6d2ca2daae
Adds a Lightstring.Stanza object and use it.
author | Sonny Piers <sonny.piers@gmail.com> |
---|---|
date | Sat, 28 Jan 2012 04:34:30 +0100 |
parents | |
children | c06ec02217ee |
comparison
equal
deleted
inserted
replaced
28:630b9579fe4a | 29:1e6d2ca2daae |
---|---|
1 'use strict'; | |
2 | |
3 /** | |
4 Copyright (c) 2011, Sonny Piers <sonny at fastmail dot net> | |
5 | |
6 Permission to use, copy, modify, and/or distribute this software for any | |
7 purpose with or without fee is hereby granted, provided that the above | |
8 copyright notice and this permission notice appear in all copies. | |
9 | |
10 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | |
11 WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | |
12 MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | |
13 ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | |
14 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | |
15 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | |
16 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | |
17 */ | |
18 | |
19 | |
20 /** | |
21 * @constructor Creates a new Stanza object. | |
22 * @param {String|Object} [aStanza] The XML or DOM content of the stanza | |
23 * @memberOf Lightstring | |
24 */ | |
25 Lightstring.Stanza = function(aStanza) { | |
26 if (typeof aStanza === 'string') { | |
27 this.XML = aStanza; | |
28 this.DOM = Lightstring.XML2DOM(this.XML); | |
29 } | |
30 else if (aStanza instanceof Element) { | |
31 this.DOM = aStanza; | |
32 this.XML = Lightstring.DOM2XML(this.DOM); | |
33 } | |
34 //ToDo error ? | |
35 else { | |
36 return null; | |
37 } | |
38 }; |