Subversion Repositories Applications.papyrus

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
1318 alexandre_ 1
/*
2
	Copyright (c) 2004-2006, The Dojo Foundation
3
	All Rights Reserved.
4
 
5
	Licensed under the Academic Free License version 2.1 or above OR the
6
	modified BSD license. For more information on Dojo licensing, see:
7
 
8
		http://dojotoolkit.org/community/licensing.shtml
9
*/
10
 
11
if (typeof window == "undefined") {
12
	dojo.raise("attempt to use adobe svg hostenv when no window object");
13
}
14
dojo.debug = function () {
15
	if (!djConfig.isDebug) {
16
		return;
17
	}
18
	var args = arguments;
19
	var isJUM = dj_global["jum"];
20
	var s = isJUM ? "" : "DEBUG: ";
21
	for (var i = 0; i < args.length; ++i) {
22
		s += args[i];
23
	}
24
	if (isJUM) {
25
		jum.debug(s);
26
	} else {
27
		dojo.hostenv.println(s);
28
	}
29
};
30
dojo.render.name = navigator.appName;
31
dojo.render.ver = parseFloat(navigator.appVersion, 10);
32
switch (navigator.platform) {
33
  case "MacOS":
34
	dojo.render.os.osx = true;
35
	break;
36
  case "Linux":
37
	dojo.render.os.linux = true;
38
	break;
39
  case "Windows":
40
	dojo.render.os.win = true;
41
	break;
42
  default:
43
	dojo.render.os.linux = true;
44
	break;
45
}
46
dojo.render.svg.capable = true;
47
dojo.render.svg.support.builtin = true;
48
dojo.render.svg.moz = ((navigator.userAgent.indexOf("Gecko") >= 0) && (!((navigator.appVersion.indexOf("Konqueror") >= 0) || (navigator.appVersion.indexOf("Safari") >= 0))));
49
dojo.render.svg.adobe = (window.parseXML != null);
50
dojo.hostenv.startPackage("dojo.hostenv");
51
dojo.hostenv.println = function (s) {
52
	try {
53
		var ti = document.createElement("text");
54
		ti.setAttribute("x", "50");
55
		ti.setAttribute("y", (25 + 15 * document.getElementsByTagName("text").length));
56
		ti.appendChild(document.createTextNode(s));
57
		document.documentElement.appendChild(ti);
58
	}
59
	catch (e) {
60
	}
61
};
62
dojo.hostenv.name_ = "svg";
63
dojo.hostenv.setModulePrefix = function (module, prefix) {
64
};
65
dojo.hostenv.getModulePrefix = function (module) {
66
};
67
dojo.hostenv.getTextStack = [];
68
dojo.hostenv.loadUriStack = [];
69
dojo.hostenv.loadedUris = [];
70
dojo.hostenv.modules_ = {};
71
dojo.hostenv.modulesLoadedFired = false;
72
dojo.hostenv.modulesLoadedListeners = [];
73
dojo.hostenv.getText = function (uri, cb, data) {
74
	if (!cb) {
75
		var cb = function (result) {
76
			window.alert(result);
77
		};
78
	}
79
	if (!data) {
80
		window.getUrl(uri, cb);
81
	} else {
82
		window.postUrl(uri, data, cb);
83
	}
84
};
85
dojo.hostenv.getLibaryScriptUri = function () {
86
};
87
dojo.hostenv.loadUri = function (uri) {
88
};
89
dojo.hostenv.loadUriAndCheck = function (uri, module) {
90
};
91
dojo.hostenv.loadModule = function (moduleName) {
92
	var a = moduleName.split(".");
93
	var currentObj = window;
94
	var s = [];
95
	for (var i = 0; i < a.length; i++) {
96
		if (a[i] == "*") {
97
			continue;
98
		}
99
		s.push(a[i]);
100
		if (!currentObj[a[i]]) {
101
			dojo.raise("dojo.require('" + moduleName + "'): module does not exist.");
102
		} else {
103
			currentObj = currentObj[a[i]];
104
		}
105
	}
106
	return;
107
};
108
dojo.hostenv.startPackage = function (moduleName) {
109
	var a = moduleName.split(".");
110
	var currentObj = window;
111
	var s = [];
112
	for (var i = 0; i < a.length; i++) {
113
		if (a[i] == "*") {
114
			continue;
115
		}
116
		s.push(a[i]);
117
		if (!currentObj[a[i]]) {
118
			currentObj[a[i]] = {};
119
		}
120
		currentObj = currentObj[a[i]];
121
	}
122
	return;
123
};
124
if (window.parseXML) {
125
	window.XMLSerialzer = function () {
126
		function nodeToString(n, a) {
127
			function fixText(s) {
128
				return String(s).replace(/\&/g, "&amp;").replace(/>/g, "&gt;").replace(/</g, "&lt;");
129
			}
130
			function fixAttribute(s) {
131
				return fixText(s).replace(/\"/g, "&quot;");
132
			}
133
			switch (n.nodeType) {
134
			  case 1:
135
				var name = n.nodeName;
136
				a.push("<" + name);
137
				for (var i = 0; i < n.attributes.length; i++) {
138
					if (n.attributes.item(i).specified) {
139
						a.push(" " + n.attributes.item(i).nodeName.toLowerCase() + "=\"" + fixAttribute(n.attributes.item(i).nodeValue) + "\"");
140
					}
141
				}
142
				if (n.canHaveChildren || n.hasChildNodes()) {
143
					a.push(">");
144
					for (var i = 0; i < n.childNodes.length; i++) {
145
						nodeToString(n.childNodes.item(i), a);
146
					}
147
					a.push("</" + name + ">\n");
148
				} else {
149
					a.push(" />\n");
150
				}
151
				break;
152
			  case 3:
153
				a.push(fixText(n.nodeValue));
154
				break;
155
			  case 4:
156
				a.push("<![CDA" + "TA[\n" + n.nodeValue + "\n]" + "]>");
157
				break;
158
			  case 7:
159
				a.push(n.nodeValue);
160
				if (/(^<\?xml)|(^<\!DOCTYPE)/.test(n.nodeValue)) {
161
					a.push("\n");
162
				}
163
				break;
164
			  case 8:
165
				a.push("<!-- " + n.nodeValue + " -->\n");
166
				break;
167
			  case 9:
168
			  case 11:
169
				for (var i = 0; i < n.childNodes.length; i++) {
170
					nodeToString(n.childNodes.item(i), a);
171
				}
172
				break;
173
			  default:
174
				a.push("<!--\nNot Supported:\n\n" + "nodeType: " + n.nodeType + "\nnodeName: " + n.nodeName + "\n-->");
175
			}
176
		}
177
		this.serializeToString = function (node) {
178
			var a = [];
179
			nodeToString(node, a);
180
			return a.join("");
181
		};
182
	};
183
	window.DOMParser = function () {
184
		this.parseFromString = function (s) {
185
			return parseXML(s, window.document);
186
		};
187
	};
188
	window.XMLHttpRequest = function () {
189
		var uri = null;
190
		var method = "POST";
191
		var isAsync = true;
192
		var cb = function (d) {
193
			this.responseText = d.content;
194
			try {
195
				this.responseXML = parseXML(this.responseText, window.document);
196
			}
197
			catch (e) {
198
			}
199
			this.status = "200";
200
			this.statusText = "OK";
201
			if (!d.success) {
202
				this.status = "500";
203
				this.statusText = "Internal Server Error";
204
			}
205
			this.onload();
206
			this.onreadystatechange();
207
		};
208
		this.onload = function () {
209
		};
210
		this.readyState = 4;
211
		this.onreadystatechange = function () {
212
		};
213
		this.status = 0;
214
		this.statusText = "";
215
		this.responseBody = null;
216
		this.responseStream = null;
217
		this.responseXML = null;
218
		this.responseText = null;
219
		this.abort = function () {
220
			return;
221
		};
222
		this.getAllResponseHeaders = function () {
223
			return [];
224
		};
225
		this.getResponseHeader = function (n) {
226
			return null;
227
		};
228
		this.setRequestHeader = function (nm, val) {
229
		};
230
		this.open = function (meth, url, async) {
231
			method = meth;
232
			uri = url;
233
		};
234
		this.send = function (data) {
235
			var d = data || null;
236
			if (method == "GET") {
237
				getURL(uri, cb);
238
			} else {
239
				postURL(uri, data, cb);
240
			}
241
		};
242
	};
243
}
244
dojo.requireIf((djConfig["isDebug"] || djConfig["debugAtAllCosts"]), "dojo.debug");
245