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