1 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> |
---|
2 |
<html><head><title></title><meta http-equiv="Content-type" content="text/html; charset=windows-1251" /> |
---|
3 |
<style> |
---|
4 |
table.dBug_array,table.dBug_object,table.dBug_resource,table.dBug_resourceC,table.dBug_xml { |
---|
5 |
font-family:Verdana, Arial, Helvetica, sans-serif; color:#000000; font-size:12px; |
---|
6 |
} |
---|
7 |
|
---|
8 |
.dBug_arrayHeader, |
---|
9 |
.dBug_objectHeader, |
---|
10 |
.dBug_resourceHeader, |
---|
11 |
.dBug_resourceCHeader, |
---|
12 |
.dBug_xmlHeader |
---|
13 |
{ font-weight:bold; color:#FFFFFF; } |
---|
14 |
|
---|
15 |
/* array */ |
---|
16 |
table.dBug_array { background-color:#006600; } |
---|
17 |
table.dBug_array td { background-color:#FFFFFF; } |
---|
18 |
table.dBug_array td.dBug_arrayHeader { background-color:#009900; } |
---|
19 |
table.dBug_array td.dBug_arrayKey { background-color:#CCFFCC; } |
---|
20 |
|
---|
21 |
/* object */ |
---|
22 |
table.dBug_object { background-color:#0000CC; } |
---|
23 |
table.dBug_object td { background-color:#FFFFFF; } |
---|
24 |
table.dBug_object td.dBug_objectHeader { background-color:#4444CC; } |
---|
25 |
table.dBug_object td.dBug_objectKey { background-color:#CCDDFF; } |
---|
26 |
|
---|
27 |
/* resource */ |
---|
28 |
table.dBug_resourceC { background-color:#884488; } |
---|
29 |
table.dBug_resourceC td { background-color:#FFFFFF; } |
---|
30 |
table.dBug_resourceC td.dBug_resourceCHeader { background-color:#AA66AA; } |
---|
31 |
table.dBug_resourceC td.dBug_resourceCKey { background-color:#FFDDFF; } |
---|
32 |
|
---|
33 |
/* resource */ |
---|
34 |
table.dBug_resource { background-color:#884488; } |
---|
35 |
table.dBug_resource td { background-color:#FFFFFF; } |
---|
36 |
table.dBug_resource td.dBug_resourceHeader { background-color:#AA66AA; } |
---|
37 |
table.dBug_resource td.dBug_resourceKey { background-color:#FFDDFF; } |
---|
38 |
table.dBug_resource td.dBug_resourceKey2 { background-color:#FFDDFF; } |
---|
39 |
|
---|
40 |
/* xml */ |
---|
41 |
table.dBug_xml { background-color:#888888; } |
---|
42 |
table.dBug_xml td { background-color:#FFFFFF; } |
---|
43 |
table.dBug_xml td.dBug_xmlHeader { background-color:#AAAAAA; } |
---|
44 |
table.dBug_xml td.dBug_xmlKey { background-color:#DDDDDD; } |
---|
45 |
</style> |
---|
46 |
<script type="text/javascript"> |
---|
47 |
|
---|
48 |
|
---|
49 |
|
---|
50 |
|
---|
51 |
|
---|
52 |
|
---|
53 |
|
---|
54 |
|
---|
55 |
|
---|
56 |
|
---|
57 |
|
---|
58 |
|
---|
59 |
var Prototype = { |
---|
60 |
Version: '1.4.0', |
---|
61 |
ScriptFragment: '(?:<script.*?>)((\n|\r|.)*?)(?:<\/script>)', |
---|
62 |
|
---|
63 |
emptyFunction: function() {}, |
---|
64 |
K: function(x) {return x} |
---|
65 |
} |
---|
66 |
|
---|
67 |
var Class = { |
---|
68 |
create: function() { |
---|
69 |
return function() { |
---|
70 |
this.initialize.apply(this, arguments); |
---|
71 |
} |
---|
72 |
} |
---|
73 |
} |
---|
74 |
|
---|
75 |
var Abstract = new Object(); |
---|
76 |
|
---|
77 |
Object.extend = function(destination, source) { |
---|
78 |
for (property in source) { |
---|
79 |
destination[property] = source[property]; |
---|
80 |
} |
---|
81 |
return destination; |
---|
82 |
} |
---|
83 |
|
---|
84 |
Object.inspect = function(object) { |
---|
85 |
try { |
---|
86 |
if (object == undefined) return 'undefined'; |
---|
87 |
if (object == null) return 'null'; |
---|
88 |
return object.inspect ? object.inspect() : object.toString(); |
---|
89 |
} catch (e) { |
---|
90 |
if (e instanceof RangeError) return '...'; |
---|
91 |
throw e; |
---|
92 |
} |
---|
93 |
} |
---|
94 |
|
---|
95 |
Function.prototype.bind = function() { |
---|
96 |
var __method = this, args = $A(arguments), object = args.shift(); |
---|
97 |
return function() { |
---|
98 |
return __method.apply(object, args.concat($A(arguments))); |
---|
99 |
} |
---|
100 |
} |
---|
101 |
|
---|
102 |
Function.prototype.bindAsEventListener = function(object) { |
---|
103 |
var __method = this; |
---|
104 |
return function(event) { |
---|
105 |
return __method.call(object, event || window.event); |
---|
106 |
} |
---|
107 |
} |
---|
108 |
|
---|
109 |
Object.extend(Number.prototype, { |
---|
110 |
toColorPart: function() { |
---|
111 |
var digits = this.toString(16); |
---|
112 |
if (this < 16) return '0' + digits; |
---|
113 |
return digits; |
---|
114 |
}, |
---|
115 |
|
---|
116 |
succ: function() { |
---|
117 |
return this + 1; |
---|
118 |
}, |
---|
119 |
|
---|
120 |
times: function(iterator) { |
---|
121 |
$R(0, this, true).each(iterator); |
---|
122 |
return this; |
---|
123 |
} |
---|
124 |
}); |
---|
125 |
|
---|
126 |
var Try = { |
---|
127 |
these: function() { |
---|
128 |
var returnValue; |
---|
129 |
|
---|
130 |
for (var i = 0; i < arguments.length; i++) { |
---|
131 |
var lambda = arguments[i]; |
---|
132 |
try { |
---|
133 |
returnValue = lambda(); |
---|
134 |
break; |
---|
135 |
} catch (e) {} |
---|
136 |
} |
---|
137 |
|
---|
138 |
return returnValue; |
---|
139 |
} |
---|
140 |
} |
---|
141 |
|
---|
142 |
|
---|
143 |
|
---|
144 |
var PeriodicalExecuter = Class.create(); |
---|
145 |
PeriodicalExecuter.prototype = { |
---|
146 |
initialize: function(callback, frequency) { |
---|
147 |
this.callback = callback; |
---|
148 |
this.frequency = frequency; |
---|
149 |
this.currentlyExecuting = false; |
---|
150 |
|
---|
151 |
this.registerCallback(); |
---|
152 |
}, |
---|
153 |
|
---|
154 |
registerCallback: function() { |
---|
155 |
setInterval(this.onTimerEvent.bind(this), this.frequency * 1000); |
---|
156 |
}, |
---|
157 |
|
---|
158 |
onTimerEvent: function() { |
---|
159 |
if (!this.currentlyExecuting) { |
---|
160 |
try { |
---|
161 |
this.currentlyExecuting = true; |
---|
162 |
this.callback(); |
---|
163 |
} finally { |
---|
164 |
this.currentlyExecuting = false; |
---|
165 |
} |
---|
166 |
} |
---|
167 |
} |
---|
168 |
} |
---|
169 |
|
---|
170 |
|
---|
171 |
|
---|
172 |
function $() { |
---|
173 |
var elements = new Array(); |
---|
174 |
|
---|
175 |
for (var i = 0; i < arguments.length; i++) { |
---|
176 |
var element = arguments[i]; |
---|
177 |
if (typeof element == 'string') |
---|
178 |
element = document.getElementById(element); |
---|
179 |
|
---|
180 |
if (arguments.length == 1) |
---|
181 |
return element; |
---|
182 |
|
---|
183 |
elements.push(element); |
---|
184 |
} |
---|
185 |
|
---|
186 |
return elements; |
---|
187 |
} |
---|
188 |
Object.extend(String.prototype, { |
---|
189 |
stripTags: function() { |
---|
190 |
return this.replace(/<\/?[^>]+>/gi, ''); |
---|
191 |
}, |
---|
192 |
|
---|
193 |
stripScripts: function() { |
---|
194 |
return this.replace(new RegExp(Prototype.ScriptFragment, 'img'), ''); |
---|
195 |
}, |
---|
196 |
|
---|
197 |
extractScripts: function() { |
---|
198 |
var matchAll = new RegExp(Prototype.ScriptFragment, 'img'); |
---|
199 |
var matchOne = new RegExp(Prototype.ScriptFragment, 'im'); |
---|
200 |
return (this.match(matchAll) || []).map(function(scriptTag) { |
---|
201 |
return (scriptTag.match(matchOne) || ['', ''])[1]; |
---|
202 |
}); |
---|
203 |
}, |
---|
204 |
|
---|
205 |
evalScripts: function() { |
---|
206 |
return this.extractScripts().map(eval); |
---|
207 |
}, |
---|
208 |
|
---|
209 |
escapeHTML: function() { |
---|
210 |
var div = document.createElement('div'); |
---|
211 |
var text = document.createTextNode(this); |
---|
212 |
div.appendChild(text); |
---|
213 |
return div.innerHTML; |
---|
214 |
}, |
---|
215 |
|
---|
216 |
unescapeHTML: function() { |
---|
217 |
var div = document.createElement('div'); |
---|
218 |
div.innerHTML = this.stripTags(); |
---|
219 |
return div.childNodes[0] ? div.childNodes[0].nodeValue : ''; |
---|
220 |
}, |
---|
221 |
|
---|
222 |
toQueryParams: function() { |
---|
223 |
var pairs = this.match(/^\??(.*)$/)[1].split('&'); |
---|
224 |
return pairs.inject({}, function(params, pairString) { |
---|
225 |
var pair = pairString.split('='); |
---|
226 |
params[pair[0]] = pair[1]; |
---|
227 |
return params; |
---|
228 |
}); |
---|
229 |
}, |
---|
230 |
|
---|
231 |
toArray: function() { |
---|
232 |
return this.split(''); |
---|
233 |
}, |
---|
234 |
|
---|
235 |
camelize: function() { |
---|
236 |
var oStringList = this.split('-'); |
---|
237 |
if (oStringList.length == 1) return oStringList[0]; |
---|
238 |
|
---|
239 |
var camelizedString = this.indexOf('-') == 0 |
---|
240 |
? oStringList[0].charAt(0).toUpperCase() + oStringList[0].substring(1) |
---|
241 |
: oStringList[0]; |
---|
242 |
|
---|
243 |
for (var i = 1, len = oStringList.length; i < len; i++) { |
---|
244 |
var s = oStringList[i]; |
---|
245 |
camelizedString += s.charAt(0).toUpperCase() + s.substring(1); |
---|
246 |
} |
---|
247 |
|
---|
248 |
return camelizedString; |
---|
249 |
}, |
---|
250 |
|
---|
251 |
inspect: function() { |
---|
252 |
return "'" + this.replace('\\', '\\\\').replace("'", '\\\'') + "'"; |
---|
253 |
} |
---|
254 |
}); |
---|
255 |
|
---|
256 |
String.prototype.parseQuery = String.prototype.toQueryParams; |
---|
257 |
|
---|
258 |
var $break = new Object(); |
---|
259 |
var $continue = new Object(); |
---|
260 |
|
---|
261 |
var Enumerable = { |
---|
262 |
each: function(iterator) { |
---|
263 |
var index = 0; |
---|
264 |
try { |
---|
265 |
this._each(function(value) { |
---|
266 |
try { |
---|
267 |
iterator(value, index++); |
---|
268 |
} catch (e) { |
---|
269 |
if (e != $continue) throw e; |
---|
270 |
} |
---|
271 |
}); |
---|
272 |
} catch (e) { |
---|
273 |
if (e != $break) throw e; |
---|
274 |
} |
---|
275 |
}, |
---|
276 |
|
---|
277 |
all: function(iterator) { |
---|
278 |
var result = true; |
---|
279 |
this.each(function(value, index) { |
---|
280 |
result = result && !!(iterator || Prototype.K)(value, index); |
---|
281 |
if (!result) throw $break; |
---|
282 |
}); |
---|
283 |
return result; |
---|
284 |
}, |
---|
285 |
|
---|
286 |
any: function(iterator) { |
---|
287 |
var result = true; |
---|
288 |
this.each(function(value, index) { |
---|
289 |
if (result = !!(iterator || Prototype.K)(value, index)) |
---|
290 |
throw $break; |
---|
291 |
}); |
---|
292 |
return result; |
---|
293 |
}, |
---|
294 |
|
---|
295 |
collect: function(iterator) { |
---|
296 |
var results = []; |
---|
297 |
this.each(function(value, index) { |
---|
298 |
results.push(iterator(value, index)); |
---|
299 |
}); |
---|
300 |
return results; |
---|
301 |
}, |
---|
302 |
|
---|
303 |
detect: function (iterator) { |
---|
304 |
var result; |
---|
305 |
this.each(function(value, index) { |
---|
306 |
if (iterator(value, index)) { |
---|
307 |
result = value; |
---|
308 |
throw $break; |
---|
309 |
} |
---|
310 |
}); |
---|
311 |
return result; |
---|
312 |
}, |
---|
313 |
|
---|
314 |
findAll: function(iterator) { |
---|
315 |
var results = []; |
---|
316 |
this.each(function(value, index) { |
---|
317 |
if (iterator(value, index)) |
---|
318 |
results.push(value); |
---|
319 |
}); |
---|
320 |
return results; |
---|
321 |
}, |
---|
322 |
|
---|
323 |
grep: function(pattern, iterator) { |
---|
324 |
var results = []; |
---|
325 |
this.each(function(value, index) { |
---|
326 |
var stringValue = value.toString(); |
---|
327 |
if (stringValue.match(pattern)) |
---|
328 |
results.push((iterator || Prototype.K)(value, index)); |
---|
329 |
}) |
---|
330 |
return results; |
---|
331 |
}, |
---|
332 |
|
---|
333 |
include: function(object) { |
---|
334 |
var found = false; |
---|
335 |
this.each(function(value) { |
---|
336 |
if (value == object) { |
---|
337 |
found = true; |
---|
338 |
throw $break; |
---|
339 |
} |
---|
340 |
}); |
---|
341 |
return found; |
---|
342 |
}, |
---|
343 |
|
---|
344 |
inject: function(memo, iterator) { |
---|
345 |
this.each(function(value, index) { |
---|
346 |
memo = iterator(memo, value, index); |
---|
347 |
}); |
---|
348 |
return memo; |
---|
349 |
}, |
---|
350 |
|
---|
351 |
invoke: function(method) { |
---|
352 |
var args = $A(arguments).slice(1); |
---|
353 |
return this.collect(function(value) { |
---|
354 |
return value[method].apply(value, args); |
---|
355 |
}); |
---|
356 |
}, |
---|
357 |
|
---|
358 |
max: function(iterator) { |
---|
359 |
var result; |
---|
360 |
this.each(function(value, index) { |
---|
361 |
value = (iterator || Prototype.K)(value, index); |
---|
362 |
if (value >= (result || value)) |
---|
363 |
result = value; |
---|
364 |
}); |
---|
365 |
return result; |
---|
366 |
}, |
---|
367 |
|
---|
368 |
min: function(iterator) { |
---|
369 |
var result; |
---|
370 |
this.each(function(value, index) { |
---|
371 |
value = (iterator || Prototype.K)(value, index); |
---|
372 |
if (value <= (result || value)) |
---|
373 |
result = value; |
---|
374 |
}); |
---|
375 |
return result; |
---|
376 |
}, |
---|
377 |
|
---|
378 |
partition: function(iterator) { |
---|
379 |
var trues = [], falses = []; |
---|
380 |
this.each(function(value, index) { |
---|
381 |
((iterator || Prototype.K)(value, index) ? |
---|
382 |
trues : falses).push(value); |
---|
383 |
}); |
---|
384 |
return [trues, falses]; |
---|
385 |
}, |
---|
386 |
|
---|
387 |
pluck: function(property) { |
---|
388 |
var results = []; |
---|
389 |
this.each(function(value, index) { |
---|
390 |
results.push(value[property]); |
---|
391 |
}); |
---|
392 |
return results; |
---|
393 |
}, |
---|
394 |
|
---|
395 |
reject: function(iterator) { |
---|
396 |
var results = []; |
---|
397 |
this.each(function(value, index) { |
---|
398 |
if (!iterator(value, index)) |
---|
399 |
results.push(value); |
---|
400 |
}); |
---|
401 |
return results; |
---|
402 |
}, |
---|
403 |
|
---|
404 |
sortBy: function(iterator) { |
---|
405 |
return this.collect(function(value, index) { |
---|
406 |
return {value: value, criteria: iterator(value, index)}; |
---|
407 |
}).sort(function(left, right) { |
---|
408 |
var a = left.criteria, b = right.criteria; |
---|
409 |
return a < b ? -1 : a > b ? 1 : 0; |
---|
410 |
}).pluck('value'); |
---|
411 |
}, |
---|
412 |
|
---|
413 |
toArray: function() { |
---|
414 |
return this.collect(Prototype.K); |
---|
415 |
}, |
---|
416 |
|
---|
417 |
zip: function() { |
---|
418 |
var iterator = Prototype.K, args = $A(arguments); |
---|
419 |
if (typeof args.last() == 'function') |
---|
420 |
iterator = args.pop(); |
---|
421 |
|
---|
422 |
var collections = [this].concat(args).map($A); |
---|
423 |
return this.map(function(value, index) { |
---|
424 |
iterator(value = collections.pluck(index)); |
---|
425 |
return value; |
---|
426 |
}); |
---|
427 |
}, |
---|
428 |
|
---|
429 |
inspect: function() { |
---|
430 |
return '#<Enumerable:' + this.toArray().inspect() + '>'; |
---|
431 |
} |
---|
432 |
} |
---|
433 |
|
---|
434 |
Object.extend(Enumerable, { |
---|
435 |
map: Enumerable.collect, |
---|
436 |
find: Enumerable.detect, |
---|
437 |
select: Enumerable.findAll, |
---|
438 |
member: Enumerable.include, |
---|
439 |
entries: Enumerable.toArray |
---|
440 |
}); |
---|
441 |
var $A = Array.from = function(iterable) { |
---|
442 |
if (!iterable) return []; |
---|
443 |
if (iterable.toArray) { |
---|
444 |
return iterable.toArray(); |
---|
445 |
} else { |
---|
446 |
var results = []; |
---|
447 |
for (var i = 0; i < iterable.length; i++) |
---|
448 |
results.push(iterable[i]); |
---|
449 |
return results; |
---|
450 |
} |
---|
451 |
} |
---|
452 |
|
---|
453 |
Object.extend(Array.prototype, Enumerable); |
---|
454 |
|
---|
455 |
Array.prototype._reverse = Array.prototype.reverse; |
---|
456 |
|
---|
457 |
Object.extend(Array.prototype, { |
---|
458 |
_each: function(iterator) { |
---|
459 |
for (var i = 0; i < this.length; i++) |
---|
460 |
iterator(this[i]); |
---|
461 |
}, |
---|
462 |
|
---|
463 |
clear: function() { |
---|
464 |
this.length = 0; |
---|
465 |
return this; |
---|
466 |
}, |
---|
467 |
|
---|
468 |
first: function() { |
---|
469 |
return this[0]; |
---|
470 |
}, |
---|
471 |
|
---|
472 |
last: function() { |
---|
473 |
return this[this.length - 1]; |
---|
474 |
}, |
---|
475 |
|
---|
476 |
compact: function() { |
---|
477 |
return this.select(function(value) { |
---|
478 |
return value != undefined || value != null; |
---|
479 |
}); |
---|
480 |
}, |
---|
481 |
|
---|
482 |
flatten: function() { |
---|
483 |
return this.inject([], function(array, value) { |
---|
484 |
return array.concat(value.constructor == Array ? |
---|
485 |
value.flatten() : [value]); |
---|
486 |
}); |
---|
487 |
}, |
---|
488 |
|
---|
489 |
without: function() { |
---|
490 |
var values = $A(arguments); |
---|
491 |
return this.select(function(value) { |
---|
492 |
return !values.include(value); |
---|
493 |
}); |
---|
494 |
}, |
---|
495 |
|
---|
496 |
indexOf: function(object) { |
---|
497 |
for (var i = 0; i < this.length; i++) |
---|
498 |
if (this[i] == object) return i; |
---|
499 |
return -1; |
---|
500 |
}, |
---|
501 |
|
---|
502 |
reverse: function(inline) { |
---|
503 |
return (inline !== false ? this : this.toArray())._reverse(); |
---|
504 |
}, |
---|
505 |
|
---|
506 |
shift: function() { |
---|
507 |
var result = this[0]; |
---|
508 |
for (var i = 0; i < this.length - 1; i++) |
---|
509 |
this[i] = this[i + 1]; |
---|
510 |
this.length--; |
---|
511 |
return result; |
---|
512 |
}, |
---|
513 |
|
---|
514 |
inspect: function() { |
---|
515 |
return '[' + this.map(Object.inspect).join(', ') + ']'; |
---|
516 |
} |
---|
517 |
}); |
---|
518 |
var Hash = { |
---|
519 |
_each: function(iterator) { |
---|
520 |
for (key in this) { |
---|
521 |
var value = this[key]; |
---|
522 |
if (typeof value == 'function') continue; |
---|
523 |
|
---|
524 |
var pair = [key, value]; |
---|
525 |
pair.key = key; |
---|
526 |
pair.value = value; |
---|
527 |
iterator(pair); |
---|
528 |
} |
---|
529 |
}, |
---|
530 |
|
---|
531 |
keys: function() { |
---|
532 |
return this.pluck('key'); |
---|
533 |
}, |
---|
534 |
|
---|
535 |
values: function() { |
---|
536 |
return this.pluck('value'); |
---|
537 |
}, |
---|
538 |
|
---|
539 |
merge: function(hash) { |
---|
540 |
return $H(hash).inject($H(this), function(mergedHash, pair) { |
---|
541 |
mergedHash[pair.key] = pair.value; |
---|
542 |
return mergedHash; |
---|
543 |
}); |
---|
544 |
}, |
---|
545 |
|
---|
546 |
toQueryString: function() { |
---|
547 |
return this.map(function(pair) { |
---|
548 |
return pair.map(encodeURIComponent).join('='); |
---|
549 |
}).join('&'); |
---|
550 |
}, |
---|
551 |
|
---|
552 |
inspect: function() { |
---|
553 |
return '#<Hash:{' + this.map(function(pair) { |
---|
554 |
return pair.map(Object.inspect).join(': '); |
---|
555 |
}).join(', ') + '}>'; |
---|
556 |
} |
---|
557 |
} |
---|
558 |
|
---|
559 |
function $H(object) { |
---|
560 |
var hash = Object.extend({}, object || {}); |
---|
561 |
Object.extend(hash, Enumerable); |
---|
562 |
Object.extend(hash, Hash); |
---|
563 |
return hash; |
---|
564 |
} |
---|
565 |
ObjectRange = Class.create(); |
---|
566 |
Object.extend(ObjectRange.prototype, Enumerable); |
---|
567 |
Object.extend(ObjectRange.prototype, { |
---|
568 |
initialize: function(start, end, exclusive) { |
---|
569 |
this.start = start; |
---|
570 |
this.end = end; |
---|
571 |
this.exclusive = exclusive; |
---|
572 |
}, |
---|
573 |
|
---|
574 |
_each: function(iterator) { |
---|
575 |
var value = this.start; |
---|
576 |
do { |
---|
577 |
iterator(value); |
---|
578 |
value = value.succ(); |
---|
579 |
} while (this.include(value)); |
---|
580 |
}, |
---|
581 |
|
---|
582 |
include: function(value) { |
---|
583 |
if (value < this.start) |
---|
584 |
return false; |
---|
585 |
if (this.exclusive) |
---|
586 |
return value < this.end; |
---|
587 |
return value <= this.end; |
---|
588 |
} |
---|
589 |
}); |
---|
590 |
|
---|
591 |
var $R = function(start, end, exclusive) { |
---|
592 |
return new ObjectRange(start, end, exclusive); |
---|
593 |
} |
---|
594 |
|
---|
595 |
var Ajax = { |
---|
596 |
getTransport: function() { |
---|
597 |
return Try.these( |
---|
598 |
function() {return new ActiveXObject('Msxml2.XMLHTTP')}, |
---|
599 |
function() {return new ActiveXObject('Microsoft.XMLHTTP')}, |
---|
600 |
function() {return new XMLHttpRequest()} |
---|
601 |
) || false; |
---|
602 |
}, |
---|
603 |
|
---|
604 |
activeRequestCount: 0 |
---|
605 |
} |
---|
606 |
|
---|
607 |
Ajax.Responders = { |
---|
608 |
responders: [], |
---|
609 |
|
---|
610 |
_each: function(iterator) { |
---|
611 |
this.responders._each(iterator); |
---|
612 |
}, |
---|
613 |
|
---|
614 |
register: function(responderToAdd) { |
---|
615 |
if (!this.include(responderToAdd)) |
---|
616 |
this.responders.push(responderToAdd); |
---|
617 |
}, |
---|
618 |
|
---|
619 |
unregister: function(responderToRemove) { |
---|
620 |
this.responders = this.responders.without(responderToRemove); |
---|
621 |
}, |
---|
622 |
|
---|
623 |
dispatch: function(callback, request, transport, json) { |
---|
624 |
this.each(function(responder) { |
---|
625 |
if (responder[callback] && typeof responder[callback] == 'function') { |
---|
626 |
try { |
---|
627 |
responder[callback].apply(responder, [request, transport, json]); |
---|
628 |
} catch (e) {} |
---|
629 |
} |
---|
630 |
}); |
---|
631 |
} |
---|
632 |
}; |
---|
633 |
|
---|
634 |
Object.extend(Ajax.Responders, Enumerable); |
---|
635 |
|
---|
636 |
Ajax.Responders.register({ |
---|
637 |
onCreate: function() { |
---|
638 |
Ajax.activeRequestCount++; |
---|
639 |
}, |
---|
640 |
|
---|
641 |
onComplete: function() { |
---|
642 |
Ajax.activeRequestCount--; |
---|
643 |
} |
---|
644 |
}); |
---|
645 |
|
---|
646 |
Ajax.Base = function() {}; |
---|
647 |
Ajax.Base.prototype = { |
---|
648 |
setOptions: function(options) { |
---|
649 |
this.options = { |
---|
650 |
method: 'post', |
---|
651 |
asynchronous: true, |
---|
652 |
parameters: '' |
---|
653 |
} |
---|
654 |
Object.extend(this.options, options || {}); |
---|
655 |
}, |
---|
656 |
|
---|
657 |
responseIsSuccess: function() { |
---|
658 |
return this.transport.status == undefined |
---|
659 |
|| this.transport.status == 0 |
---|
660 |
|| (this.transport.status >= 200 && this.transport.status < 300); |
---|
661 |
}, |
---|
662 |
|
---|
663 |
responseIsFailure: function() { |
---|
664 |
return !this.responseIsSuccess(); |
---|
665 |
} |
---|
666 |
} |
---|
667 |
|
---|
668 |
Ajax.Request = Class.create(); |
---|
669 |
Ajax.Request.Events = |
---|
670 |
['Uninitialized', 'Loading', 'Loaded', 'Interactive', 'Complete']; |
---|
671 |
|
---|
672 |
Ajax.Request.prototype = Object.extend(new Ajax.Base(), { |
---|
673 |
initialize: function(url, options) { |
---|
674 |
this.transport = Ajax.getTransport(); |
---|
675 |
this.setOptions(options); |
---|
676 |
this.request(url); |
---|
677 |
}, |
---|
678 |
|
---|
679 |
request: function(url) { |
---|
680 |
var parameters = this.options.parameters || ''; |
---|
681 |
if (parameters.length > 0) parameters += '&_='; |
---|
682 |
|
---|
683 |
try { |
---|
684 |
this.url = url; |
---|
685 |
if (this.options.method == 'get' && parameters.length > 0) |
---|
686 |
this.url += (this.url.match(/\?/) ? '&' : '?') + parameters; |
---|
687 |
|
---|
688 |
Ajax.Responders.dispatch('onCreate', this, this.transport); |
---|
689 |
|
---|
690 |
this.transport.open(this.options.method, this.url, |
---|
691 |
this.options.asynchronous); |
---|
692 |
|
---|
693 |
if (this.options.asynchronous) { |
---|
694 |
this.transport.onreadystatechange = this.onStateChange.bind(this); |
---|
695 |
setTimeout((function() {this.respondToReadyState(1)}).bind(this), 10); |
---|
696 |
} |
---|
697 |
|
---|
698 |
this.setRequestHeaders(); |
---|
699 |
|
---|
700 |
var body = this.options.postBody ? this.options.postBody : parameters; |
---|
701 |
this.transport.send(this.options.method == 'post' ? body : null); |
---|
702 |
|
---|
703 |
} catch (e) { |
---|
704 |
this.dispatchException(e); |
---|
705 |
} |
---|
706 |
}, |
---|
707 |
|
---|
708 |
setRequestHeaders: function() { |
---|
709 |
var requestHeaders = |
---|
710 |
['X-Requested-With', 'XMLHttpRequest', |
---|
711 |
'X-Prototype-Version', Prototype.Version]; |
---|
712 |
|
---|
713 |
if (this.options.method == 'post') { |
---|
714 |
requestHeaders.push('Content-type', |
---|
715 |
'application/x-www-form-urlencoded'); |
---|
716 |
|
---|
717 |
|
---|
718 |
|
---|
719 |
|
---|
720 |
|
---|
721 |
if (this.transport.overrideMimeType) |
---|
722 |
requestHeaders.push('Connection', 'close'); |
---|
723 |
} |
---|
724 |
|
---|
725 |
if (this.options.requestHeaders) |
---|
726 |
requestHeaders.push.apply(requestHeaders, this.options.requestHeaders); |
---|
727 |
|
---|
728 |
for (var i = 0; i < requestHeaders.length; i += 2) |
---|
729 |
this.transport.setRequestHeader(requestHeaders[i], requestHeaders[i+1]); |
---|
730 |
}, |
---|
731 |
|
---|
732 |
onStateChange: function() { |
---|
733 |
var readyState = this.transport.readyState; |
---|
734 |
if (readyState != 1) |
---|
735 |
this.respondToReadyState(this.transport.readyState); |
---|
736 |
}, |
---|
737 |
|
---|
738 |
header: function(name) { |
---|
739 |
try { |
---|
740 |
return this.transport.getResponseHeader(name); |
---|
741 |
} catch (e) {} |
---|
742 |
}, |
---|
743 |
|
---|
744 |
evalJSON: function() { |
---|
745 |
try { |
---|
746 |
return eval(this.header('X-JSON')); |
---|
747 |
} catch (e) {} |
---|
748 |
}, |
---|
749 |
|
---|
750 |
evalResponse: function() { |
---|
751 |
try { |
---|
752 |
return eval(this.transport.responseText); |
---|
753 |
} catch (e) { |
---|
754 |
this.dispatchException(e); |
---|
755 |
} |
---|
756 |
}, |
---|
757 |
|
---|
758 |
respondToReadyState: function(readyState) { |
---|
759 |
var event = Ajax.Request.Events[readyState]; |
---|
760 |
var transport = this.transport, json = this.evalJSON(); |
---|
761 |
|
---|
762 |
if (event == 'Complete') { |
---|
763 |
try { |
---|
764 |
(this.options['on' + this.transport.status] |
---|
765 |
|| this.options['on' + (this.responseIsSuccess() ? 'Success' : 'Failure')] |
---|
766 |
|| Prototype.emptyFunction)(transport, json); |
---|
767 |
} catch (e) { |
---|
768 |
this.dispatchException(e); |
---|
769 |
} |
---|
770 |
|
---|
771 |
if ((this.header('Content-type') || '').match(/^text\/javascript/i)) |
---|
772 |
this.evalResponse(); |
---|
773 |
} |
---|
774 |
|
---|
775 |
try { |
---|
776 |
(this.options['on' + event] || Prototype.emptyFunction)(transport, json); |
---|
777 |
Ajax.Responders.dispatch('on' + event, this, transport, json); |
---|
778 |
} catch (e) { |
---|
779 |
this.dispatchException(e); |
---|
780 |
} |
---|
781 |
|
---|
782 |
|
---|
783 |
if (event == 'Complete') |
---|
784 |
this.transport.onreadystatechange = Prototype.emptyFunction; |
---|
785 |
}, |
---|
786 |
|
---|
787 |
dispatchException: function(exception) { |
---|
788 |
(this.options.onException || Prototype.emptyFunction)(this, exception); |
---|
789 |
Ajax.Responders.dispatch('onException', this, exception); |
---|
790 |
} |
---|
791 |
}); |
---|
792 |
|
---|
793 |
Ajax.Updater = Class.create(); |
---|
794 |
|
---|
795 |
Object.extend(Object.extend(Ajax.Updater.prototype, Ajax.Request.prototype), { |
---|
796 |
initialize: function(container, url, options) { |
---|
797 |
this.containers = { |
---|
798 |
success: container.success ? $(container.success) : $(container), |
---|
799 |
failure: container.failure ? $(container.failure) : |
---|
800 |
(container.success ? null : $(container)) |
---|
801 |
} |
---|
802 |
|
---|
803 |
this.transport = Ajax.getTransport(); |
---|
804 |
this.setOptions(options); |
---|
805 |
|
---|
806 |
var onComplete = this.options.onComplete || Prototype.emptyFunction; |
---|
807 |
this.options.onComplete = (function(transport, object) { |
---|
808 |
this.updateContent(); |
---|
809 |
onComplete(transport, object); |
---|
810 |
}).bind(this); |
---|
811 |
|
---|
812 |
this.request(url); |
---|
813 |
}, |
---|
814 |
|
---|
815 |
updateContent: function() { |
---|
816 |
var receiver = this.responseIsSuccess() ? |
---|
817 |
this.containers.success : this.containers.failure; |
---|
818 |
var response = this.transport.responseText; |
---|
819 |
|
---|
820 |
if (!this.options.evalScripts) |
---|
821 |
response = response.stripScripts(); |
---|
822 |
|
---|
823 |
if (receiver) { |
---|
824 |
if (this.options.insertion) { |
---|
825 |
new this.options.insertion(receiver, response); |
---|
826 |
} else { |
---|
827 |
Element.update(receiver, response); |
---|
828 |
} |
---|
829 |
} |
---|
830 |
|
---|
831 |
if (this.responseIsSuccess()) { |
---|
832 |
if (this.onComplete) |
---|
833 |
setTimeout(this.onComplete.bind(this), 10); |
---|
834 |
} |
---|
835 |
} |
---|
836 |
}); |
---|
837 |
|
---|
838 |
Ajax.PeriodicalUpdater = Class.create(); |
---|
839 |
Ajax.PeriodicalUpdater.prototype = Object.extend(new Ajax.Base(), { |
---|
840 |
initialize: function(container, url, options) { |
---|
841 |
this.setOptions(options); |
---|
842 |
this.onComplete = this.options.onComplete; |
---|
843 |
|
---|
844 |
this.frequency = (this.options.frequency || 2); |
---|
845 |
this.decay = (this.options.decay || 1); |
---|
846 |
|
---|
847 |
this.updater = {}; |
---|
848 |
this.container = container; |
---|
849 |
this.url = url; |
---|
850 |
|
---|
851 |
this.start(); |
---|
852 |
}, |
---|
853 |
|
---|
854 |
start: function() { |
---|
855 |
this.options.onComplete = this.updateComplete.bind(this); |
---|
856 |
this.onTimerEvent(); |
---|
857 |
}, |
---|
858 |
|
---|
859 |
stop: function() { |
---|
860 |
this.updater.onComplete = undefined; |
---|
861 |
clearTimeout(this.timer); |
---|
862 |
(this.onComplete || Prototype.emptyFunction).apply(this, arguments); |
---|
863 |
}, |
---|
864 |
|
---|
865 |
updateComplete: function(request) { |
---|
866 |
if (this.options.decay) { |
---|
867 |
this.decay = (request.responseText == this.lastText ? |
---|
868 |
this.decay * this.options.decay : 1); |
---|
869 |
|
---|
870 |
this.lastText = request.responseText; |
---|
871 |
} |
---|
872 |
this.timer = setTimeout(this.onTimerEvent.bind(this), |
---|
873 |
this.decay * this.frequency * 1000); |
---|
874 |
}, |
---|
875 |
|
---|
876 |
onTimerEvent: function() { |
---|
877 |
this.updater = new Ajax.Updater(this.container, this.url, this.options); |
---|
878 |
} |
---|
879 |
}); |
---|
880 |
document.getElementsByClassName = function(className, parentElement) { |
---|
881 |
var children = ($(parentElement) || document.body).getElementsByTagName('*'); |
---|
882 |
return $A(children).inject([], function(elements, child) { |
---|
883 |
if (child.className.match(new RegExp("(^|\\s)" + className + "(\\s|$)"))) |
---|
884 |
elements.push(child); |
---|
885 |
return elements; |
---|
886 |
}); |
---|
887 |
} |
---|
888 |
|
---|
889 |
|
---|
890 |
|
---|
891 |
if (!window.Element) { |
---|
892 |
var Element = new Object(); |
---|
893 |
} |
---|
894 |
|
---|
895 |
Object.extend(Element, { |
---|
896 |
visible: function(element) { |
---|
897 |
return $(element).style.display != 'none'; |
---|
898 |
}, |
---|
899 |
|
---|
900 |
toggle: function() { |
---|
901 |
for (var i = 0; i < arguments.length; i++) { |
---|
902 |
var element = $(arguments[i]); |
---|
903 |
Element[Element.visible(element) ? 'hide' : 'show'](element); |
---|
904 |
} |
---|
905 |
}, |
---|
906 |
|
---|
907 |
hide: function() { |
---|
908 |
for (var i = 0; i < arguments.length; i++) { |
---|
909 |
var element = $(arguments[i]); |
---|
910 |
element.style.display = 'none'; |
---|
911 |
} |
---|
912 |
}, |
---|
913 |
|
---|
914 |
show: function() { |
---|
915 |
for (var i = 0; i < arguments.length; i++) { |
---|
916 |
var element = $(arguments[i]); |
---|
917 |
element.style.display = ''; |
---|
918 |
} |
---|
919 |
}, |
---|
920 |
|
---|
921 |
remove: function(element) { |
---|
922 |
element = $(element); |
---|
923 |
element.parentNode.removeChild(element); |
---|
924 |
}, |
---|
925 |
|
---|
926 |
update: function(element, html) { |
---|
927 |
$(element).innerHTML = html.stripScripts(); |
---|
928 |
setTimeout(function() {html.evalScripts()}, 10); |
---|
929 |
}, |
---|
930 |
|
---|
931 |
getHeight: function(element) { |
---|
932 |
element = $(element); |
---|
933 |
return element.offsetHeight; |
---|
934 |
}, |
---|
935 |
|
---|
936 |
classNames: function(element) { |
---|
937 |
return new Element.ClassNames(element); |
---|
938 |
}, |
---|
939 |
|
---|
940 |
hasClassName: function(element, className) { |
---|
941 |
if (!(element = $(element))) return; |
---|
942 |
return Element.classNames(element).include(className); |
---|
943 |
}, |
---|
944 |
|
---|
945 |
addClassName: function(element, className) { |
---|
946 |
if (!(element = $(element))) return; |
---|
947 |
return Element.classNames(element).add(className); |
---|
948 |
}, |
---|
949 |
|
---|
950 |
removeClassName: function(element, className) { |
---|
951 |
if (!(element = $(element))) return; |
---|
952 |
return Element.classNames(element).remove(className); |
---|
953 |
}, |
---|
954 |
|
---|
955 |
|
---|
956 |
cleanWhitespace: function(element) { |
---|
957 |
element = $(element); |
---|
958 |
for (var i = 0; i < element.childNodes.length; i++) { |
---|
959 |
var node = element.childNodes[i]; |
---|
960 |
if (node.nodeType == 3 && !/\S/.test(node.nodeValue)) |
---|
961 |
Element.remove(node); |
---|
962 |
} |
---|
963 |
}, |
---|
964 |
|
---|
965 |
empty: function(element) { |
---|
966 |
return $(element).innerHTML.match(/^\s*$/); |
---|
967 |
}, |
---|
968 |
|
---|
969 |
scrollTo: function(element) { |
---|
970 |
element = $(element); |
---|
971 |
var x = element.x ? element.x : element.offsetLeft, |
---|
972 |
y = element.y ? element.y : element.offsetTop; |
---|
973 |
window.scrollTo(x, y); |
---|
974 |
}, |
---|
975 |
|
---|
976 |
getStyle: function(element, style) { |
---|
977 |
element = $(element); |
---|
978 |
var value = element.style[style.camelize()]; |
---|
979 |
if (!value) { |
---|
980 |
if (document.defaultView && document.defaultView.getComputedStyle) { |
---|
981 |
var css = document.defaultView.getComputedStyle(element, null); |
---|
982 |
value = css ? css.getPropertyValue(style) : null; |
---|
983 |
} else if (element.currentStyle) { |
---|
984 |
value = element.currentStyle[style.camelize()]; |
---|
985 |
} |
---|
986 |
} |
---|
987 |
|
---|
988 |
if (window.opera && ['left', 'top', 'right', 'bottom'].include(style)) |
---|
989 |
if (Element.getStyle(element, 'position') == 'static') value = 'auto'; |
---|
990 |
|
---|
991 |
return value == 'auto' ? null : value; |
---|
992 |
}, |
---|
993 |
|
---|
994 |
setStyle: function(element, style) { |
---|
995 |
element = $(element); |
---|
996 |
for (name in style) |
---|
997 |
element.style[name.camelize()] = style[name]; |
---|
998 |
}, |
---|
999 |
|
---|
1000 |
getDimensions: function(element) { |
---|
1001 |
element = $(element); |
---|
1002 |
---|