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