comparison record.js @ 6:24aa8dccb170

Make XMPP actually work.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Tue, 31 Jan 2012 15:59:28 +0100
parents 03ef53b969bd
children
comparison
equal deleted inserted replaced
5:03ef53b969bd 6:24aa8dccb170
1 'use strict'; 1 'use strict';
2
3 /** Copyright (c) 2012 Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a copy
6 * of this software and associated documentation files (the "Software"), to
7 * deal in the Software without restriction, including without limitation the
8 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
9 * sell copies of the Software, and to permit persons to whom the Software is
10 * furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice shall be included in
13 * all copies or substantial portions of the Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21 * IN THE SOFTWARE.
22 */
2 23
3 var Record = function(jid, child) { 24 var Record = function(jid, child) {
4 this.creator = jid; 25 this.creator = jid;
5 this.creationDate = new Date; //FIXME: non-standard? 26 this.creationDate = new Date; //FIXME: non-standard?
6 this.update(jid, child); 27 this.update(jid, child);
29 this.pitarget = child.getAttributeNS(null, 'pitarget') || this.pitarget; 50 this.pitarget = child.getAttributeNS(null, 'pitarget') || this.pitarget;
30 this.pidata = child.getAttributeNS(null, 'pidata') || this.pidata; 51 this.pidata = child.getAttributeNS(null, 'pidata') || this.pidata;
31 } 52 }
32 }, 53 },
33 toDOM: function(records, dom) { 54 toDOM: function(records, dom) {
34 var element; 55 var element = null;
35 if (this.parent) 56 if (this.parent)
36 dom = records[this.parent].dom; 57 dom = records[this.parent].dom;
37 58
38 switch (this.type) { 59 switch (this.type) {
39 case 'processinginstruction': 60 case 'processinginstruction':
59 element = document.createTextNode(this.chdata); 80 element = document.createTextNode(this.chdata);
60 break; 81 break;
61 case 'comment': 82 case 'comment':
62 element = document.createComment(this.chdata); 83 element = document.createComment(this.chdata);
63 break; 84 break;
85 default:
86 console.log('BIG WARNING! Element type not supported.');
87 return;
64 } 88 }
65 89
66 dom.appendChild(element); 90 dom.appendChild(element);
67 this.dom = element; 91 this.dom = element;
68 }, 92 },