Subversion Repositories Applications.papyrus

Rev

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