~ubuntu-branches/ubuntu/trusty/ntop/trusty

« back to all changes in this revision

Viewing changes to html/MochiKit/MockDOM.js

  • Committer: Bazaar Package Importer
  • Author(s): Ola Lundqvist
  • Date: 2008-06-15 14:38:28 UTC
  • mfrom: (2.1.11 intrepid)
  • Revision ID: james.westby@ubuntu.com-20080615143828-oalh84nda2hje4do
Tags: 3:3.3-11
Correction of Polish translation encoding, closes: #479490. Thanks
to Christian Perrier <bubulle@debian.org> for the help.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/***
 
2
    
 
3
MochiKit.MockDOM 1.3.1
 
4
 
 
5
See <http://mochikit.com/> for documentation, downloads, license, etc.
 
6
    
 
7
(c) 2005 Bob Ippolito.  All rights Reserved.
 
8
 
 
9
***/
 
10
if (typeof(MochiKit) == "undefined") {
 
11
    var MochiKit = {};
 
12
}
 
13
 
 
14
if (typeof(MochiKit.MockDOM) == "undefined") {
 
15
    MochiKit.MockDOM = {};
 
16
}
 
17
 
 
18
MochiKit.MockDOM.NAME = "MochiKit.MockDOM";
 
19
MochiKit.MockDOM.VERSION = "1.3.1";
 
20
 
 
21
MochiKit.MockDOM.__repr__ = function () {
 
22
    return "[" + this.NAME + " " + this.VERSION + "]";
 
23
};
 
24
 
 
25
MochiKit.MockDOM.toString = function () {
 
26
    return this.__repr__();
 
27
};
 
28
 
 
29
MochiKit.MockDOM.createDocument = function () {
 
30
    var doc = new MochiKit.MockDOM.MockElement("DOCUMENT");
 
31
    doc.body = doc.createElement("BODY");
 
32
    doc.appendChild(doc.body);
 
33
    return doc;
 
34
};
 
35
 
 
36
MochiKit.MockDOM.MockElement = function (name, data) {
 
37
    this.nodeName = name.toUpperCase();
 
38
    if (typeof(data) == "string") {
 
39
        this.nodeValue = data;
 
40
        this.nodeType = 3;
 
41
    } else {
 
42
        this.nodeType = 1;
 
43
        this.childNodes = [];
 
44
    }
 
45
    if (name.substring(0, 1) == "<") {
 
46
        var nameattr = name.substring(
 
47
            name.indexOf('"') + 1, name.lastIndexOf('"'));
 
48
        name = name.substring(1, name.indexOf(" "));
 
49
        this.nodeName = name.toUpperCase();
 
50
        this.setAttribute("name", nameattr);
 
51
    }
 
52
};
 
53
 
 
54
MochiKit.MockDOM.MockElement.prototype = {
 
55
    createElement: function (nodeName) {
 
56
        return new MochiKit.MockDOM.MockElement(nodeName);
 
57
    },
 
58
    createTextNode: function (text) {
 
59
        return new MochiKit.MockDOM.MockElement("text", text);
 
60
    },
 
61
    setAttribute: function (name, value) {
 
62
        this[name] = value;
 
63
    },
 
64
    getAttribute: function (name) {
 
65
        return this[name];
 
66
    },
 
67
    appendChild: function (child) {
 
68
        this.childNodes.push(child);
 
69
    },
 
70
    toString: function () {
 
71
        return "MockElement(" + this.nodeName + ")";
 
72
    }
 
73
};