vapir-firefox 1.7.0.rc1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,1219 @@
1
+ var Prototype = {
2
+ Version: '1.6.1_rc3',
3
+
4
+ ScriptFragment: '<script[^>]*>([\\S\\s]*?)<\/script>',
5
+ //JSONFilter: /^\/\*-secure-([\s\S]*)\*\/\s*$/,
6
+
7
+ emptyFunction: function() { },
8
+ K: function(x) { return x }
9
+ };var Abstract = { };var Try = {
10
+ these: function() {
11
+ var returnValue;
12
+
13
+ for (var i = 0, length = arguments.length; i < length; i++) {
14
+ var lambda = arguments[i];
15
+ try {
16
+ returnValue = lambda();
17
+ break;
18
+ } catch (e) { }
19
+ }
20
+
21
+ return returnValue;
22
+ }
23
+ };var Class = (function() {
24
+ function subclass() {};
25
+ function create() {
26
+ var parent = null, properties = $A(arguments);
27
+ if (Object.isFunction(properties[0]))
28
+ parent = properties.shift();
29
+
30
+ function klass() {
31
+ this.initialize.apply(this, arguments);
32
+ }
33
+
34
+ Object.extend(klass, Class.Methods);
35
+ klass.superclass = parent;
36
+ klass.subclasses = [];
37
+
38
+ if (parent) {
39
+ subclass.prototype = parent.prototype;
40
+ klass.prototype = new subclass;
41
+ parent.subclasses.push(klass);
42
+ }
43
+
44
+ for (var i = 0; i < properties.length; i++)
45
+ klass.addMethods(properties[i]);
46
+
47
+ if (!klass.prototype.initialize)
48
+ klass.prototype.initialize = Prototype.emptyFunction;
49
+
50
+ klass.prototype.constructor = klass;
51
+ return klass;
52
+ }
53
+
54
+ function addMethods(source) {
55
+ var ancestor = this.superclass && this.superclass.prototype;
56
+ var properties = Object.keys(source);
57
+
58
+ if (!Object.keys({ toString: true }).length) {
59
+ if (source.toString != Object.prototype.toString)
60
+ properties.push("toString");
61
+ if (source.valueOf != Object.prototype.valueOf)
62
+ properties.push("valueOf");
63
+ }
64
+
65
+ for (var i = 0, length = properties.length; i < length; i++) {
66
+ var property = properties[i], value = source[property];
67
+ if (ancestor && Object.isFunction(value) &&
68
+ value.argumentNames().first() == "$super") {
69
+ var method = value;
70
+ value = (function(m) {
71
+ return function() { return ancestor[m].apply(this, arguments); };
72
+ })(property).wrap(method);
73
+
74
+ value.valueOf = method.valueOf.bind(method);
75
+ value.toString = method.toString.bind(method);
76
+ }
77
+ this.prototype[property] = value;
78
+ }
79
+
80
+ return this;
81
+ }
82
+
83
+ return {
84
+ create: create,
85
+ Methods: {
86
+ addMethods: addMethods
87
+ }
88
+ };
89
+ })();(function() {
90
+
91
+ function getClass(object) {
92
+ return Object.prototype.toString.call(object)
93
+ .match(/^\[object\s(.*)\]$/)[1];
94
+ }
95
+
96
+ function extend(destination, source) {
97
+ for (var property in source)
98
+ destination[property] = source[property];
99
+ return destination;
100
+ }
101
+
102
+ function inspect(object) {
103
+ try {
104
+ if (isUndefined(object)) return 'undefined';
105
+ if (object === null) return 'null';
106
+ return object.inspect ? object.inspect() : String(object);
107
+ } catch (e) {
108
+ if (e instanceof RangeError) return '...';
109
+ throw e;
110
+ }
111
+ }
112
+ /*
113
+ function toJSON(object) {
114
+ var type = typeof object;
115
+ switch (type) {
116
+ case 'undefined':
117
+ case 'function':
118
+ case 'unknown': return;
119
+ case 'boolean': return object.toString();
120
+ }
121
+
122
+ if (object === null) return 'null';
123
+ if (object.toJSON) return object.toJSON();
124
+ if (isElement(object)) return;
125
+
126
+ var results = [];
127
+ for (var property in object) {
128
+ var value = toJSON(object[property]);
129
+ if (!isUndefined(value))
130
+ results.push(property.toJSON() + ': ' + value);
131
+ }
132
+
133
+ return '{' + results.join(', ') + '}';
134
+ }
135
+ function toJSON_length(object) {
136
+ var result_json=Object.toJSON(object);
137
+ return result_json.length.toString()+"\n"+result_json;
138
+ }*/
139
+
140
+ function toQueryString(object) {
141
+ return $H(object).toQueryString();
142
+ }
143
+
144
+ function toHTML(object) {
145
+ return object && object.toHTML ? object.toHTML() : String.interpret(object);
146
+ }
147
+
148
+ function keys(object) {
149
+ var results = [];
150
+ for (var property in object)
151
+ results.push(property);
152
+ return results;
153
+ }
154
+
155
+ function values(object) {
156
+ var results = [];
157
+ for (var property in object)
158
+ results.push(object[property]);
159
+ return results;
160
+ }
161
+
162
+ function clone(object) {
163
+ return extend({ }, object);
164
+ }
165
+
166
+ function isElement(object) {
167
+ return !!(object && object.nodeType == 1);
168
+ }
169
+
170
+ function isArray(object) {
171
+ return getClass(object) === "Array";
172
+ }
173
+
174
+
175
+ function isHash(object) {
176
+ return object instanceof Hash;
177
+ }
178
+
179
+ function isFunction(object) {
180
+ return typeof object === "function";
181
+ }
182
+
183
+ function isString(object) {
184
+ return getClass(object) === "String";
185
+ }
186
+
187
+ function isNumber(object) {
188
+ return getClass(object) === "Number";
189
+ }
190
+
191
+ function isUndefined(object) {
192
+ return typeof object === "undefined";
193
+ }
194
+
195
+ extend(Object, {
196
+ extend: extend,
197
+ inspect: inspect,
198
+ //toJSON: toJSON,
199
+ //toJSON_length: toJSON_length,
200
+ toQueryString: toQueryString,
201
+ toHTML: toHTML,
202
+ keys: keys,
203
+ values: values,
204
+ clone: clone,
205
+ isElement: isElement,
206
+ isArray: isArray,
207
+ isHash: isHash,
208
+ isFunction: isFunction,
209
+ isString: isString,
210
+ isNumber: isNumber,
211
+ isUndefined: isUndefined
212
+ });
213
+ })();Object.extend(Function.prototype, (function() {
214
+ var slice = Array.prototype.slice;
215
+
216
+ function update(array, args) {
217
+ var arrayLength = array.length, length = args.length;
218
+ while (length--) array[arrayLength + length] = args[length];
219
+ return array;
220
+ }
221
+
222
+ function merge(array, args) {
223
+ array = slice.call(array, 0);
224
+ return update(array, args);
225
+ }
226
+
227
+ function argumentNames() {
228
+ var names = this.toString().match(/^[\s\(]*function[^(]*\(([^)]*)\)/)[1]
229
+ .replace(/\/\/.*?[\r\n]|\/\*(?:.|[\r\n])*?\*\//g, '')
230
+ .replace(/\s+/g, '').split(',');
231
+ return names.length == 1 && !names[0] ? [] : names;
232
+ }
233
+
234
+ function bind(context) {
235
+ if (arguments.length < 2 && Object.isUndefined(arguments[0])) return this;
236
+ var __method = this, args = slice.call(arguments, 1);
237
+ return function() {
238
+ var a = merge(args, arguments);
239
+ return __method.apply(context, a);
240
+ }
241
+ }
242
+
243
+ function bindAsEventListener(context) {
244
+ var __method = this, args = slice.call(arguments, 1);
245
+ return function(event) {
246
+ var a = update([event || window.event], args);
247
+ return __method.apply(context, a);
248
+ }
249
+ }
250
+
251
+ function curry() {
252
+ if (!arguments.length) return this;
253
+ var __method = this, args = slice.call(arguments, 0);
254
+ return function() {
255
+ var a = merge(args, arguments);
256
+ return __method.apply(this, a);
257
+ }
258
+ }
259
+
260
+ function delay(timeout) {
261
+ var __method = this, args = slice.call(arguments, 1);
262
+ timeout = timeout * 1000;
263
+ return window.setTimeout(function() {
264
+ return __method.apply(__method, args);
265
+ }, timeout);
266
+ }
267
+
268
+ function defer() {
269
+ var args = update([0.01], arguments);
270
+ return this.delay.apply(this, args);
271
+ }
272
+
273
+ function wrap(wrapper) {
274
+ var __method = this;
275
+ return function() {
276
+ var a = update([__method.bind(this)], arguments);
277
+ return wrapper.apply(this, a);
278
+ }
279
+ }
280
+
281
+ function methodize() {
282
+ if (this._methodized) return this._methodized;
283
+ var __method = this;
284
+ return this._methodized = function() {
285
+ var a = update([this], arguments);
286
+ return __method.apply(null, a);
287
+ };
288
+ }
289
+
290
+ return {
291
+ argumentNames: argumentNames,
292
+ bind: bind,
293
+ bindAsEventListener: bindAsEventListener,
294
+ curry: curry,
295
+ delay: delay,
296
+ defer: defer,
297
+ wrap: wrap,
298
+ methodize: methodize
299
+ }
300
+ })());/*Date.prototype.toJSON = function() {
301
+ return '"' + this.getUTCFullYear() + '-' +
302
+ (this.getUTCMonth() + 1).toPaddedString(2) + '-' +
303
+ this.getUTCDate().toPaddedString(2) + 'T' +
304
+ this.getUTCHours().toPaddedString(2) + ':' +
305
+ this.getUTCMinutes().toPaddedString(2) + ':' +
306
+ this.getUTCSeconds().toPaddedString(2) + 'Z"';
307
+ };*/RegExp.prototype.match = RegExp.prototype.test;RegExp.escape = function(str) {
308
+ return String(str).replace(/([.*+?^=!:${}()|[\]\/\\])/g, '\\$1');
309
+ };var PeriodicalExecuter = Class.create({
310
+ initialize: function(callback, frequency) {
311
+ this.callback = callback;
312
+ this.frequency = frequency;
313
+ this.currentlyExecuting = false;
314
+
315
+ this.registerCallback();
316
+ },
317
+
318
+ registerCallback: function() {
319
+ this.timer = setInterval(this.onTimerEvent.bind(this), this.frequency * 1000);
320
+ },
321
+
322
+ execute: function() {
323
+ this.callback(this);
324
+ },
325
+
326
+ stop: function() {
327
+ if (!this.timer) return;
328
+ clearInterval(this.timer);
329
+ this.timer = null;
330
+ },
331
+
332
+ onTimerEvent: function() {
333
+ if (!this.currentlyExecuting) {
334
+ try {
335
+ this.currentlyExecuting = true;
336
+ this.execute();
337
+ } catch(e) {
338
+ /* empty catch for clients that don't support try/finally */
339
+ }
340
+ finally {
341
+ this.currentlyExecuting = false;
342
+ }
343
+ }
344
+ }
345
+ });Object.extend(String, {
346
+ interpret: function(value) {
347
+ return value == null ? '' : String(value);
348
+ },
349
+ specialChar: {
350
+ '\b': '\\b',
351
+ '\t': '\\t',
352
+ '\n': '\\n',
353
+ '\f': '\\f',
354
+ '\r': '\\r',
355
+ '\\': '\\\\'
356
+ }
357
+ });Object.extend(String.prototype, (function() {
358
+
359
+ function prepareReplacement(replacement) {
360
+ if (Object.isFunction(replacement)) return replacement;
361
+ var template = new Template(replacement);
362
+ return function(match) { return template.evaluate(match) };
363
+ }
364
+
365
+ function gsub(pattern, replacement) {
366
+ var result = '', source = this, match;
367
+ replacement = prepareReplacement(replacement);
368
+
369
+ if (Object.isString(pattern))
370
+ pattern = RegExp.escape(pattern);
371
+
372
+ if (!(pattern.length || pattern.source)) {
373
+ replacement = replacement('');
374
+ return replacement + source.split('').join(replacement) + replacement;
375
+ }
376
+
377
+ while (source.length > 0) {
378
+ if (match = source.match(pattern)) {
379
+ result += source.slice(0, match.index);
380
+ result += String.interpret(replacement(match));
381
+ source = source.slice(match.index + match[0].length);
382
+ } else {
383
+ result += source, source = '';
384
+ }
385
+ }
386
+ return result;
387
+ }
388
+
389
+ function sub(pattern, replacement, count) {
390
+ replacement = prepareReplacement(replacement);
391
+ count = Object.isUndefined(count) ? 1 : count;
392
+
393
+ return this.gsub(pattern, function(match) {
394
+ if (--count < 0) return match[0];
395
+ return replacement(match);
396
+ });
397
+ }
398
+
399
+ function scan(pattern, iterator) {
400
+ this.gsub(pattern, iterator);
401
+ return String(this);
402
+ }
403
+
404
+ function truncate(length, truncation) {
405
+ length = length || 30;
406
+ truncation = Object.isUndefined(truncation) ? '...' : truncation;
407
+ return this.length > length ?
408
+ this.slice(0, length - truncation.length) + truncation : String(this);
409
+ }
410
+
411
+ function strip() {
412
+ return this.replace(/^\s+/, '').replace(/\s+$/, '');
413
+ }
414
+
415
+ function stripTags() {
416
+ return this.replace(/<\w+(\s+("[^"]*"|'[^']*'|[^>])+)?>|<\/\w+>/gi, '');
417
+ }
418
+
419
+ function stripScripts() {
420
+ return this.replace(new RegExp(Prototype.ScriptFragment, 'img'), '');
421
+ }
422
+
423
+ function extractScripts() {
424
+ var matchAll = new RegExp(Prototype.ScriptFragment, 'img');
425
+ var matchOne = new RegExp(Prototype.ScriptFragment, 'im');
426
+ return (this.match(matchAll) || []).map(function(scriptTag) {
427
+ return (scriptTag.match(matchOne) || ['', ''])[1];
428
+ });
429
+ }
430
+
431
+ function evalScripts() {
432
+ return this.extractScripts().map(function(script) { return eval(script) });
433
+ }
434
+
435
+ function escapeHTML() {
436
+ escapeHTML.text.data = this;
437
+ return escapeHTML.div.innerHTML;
438
+ }
439
+
440
+ /* function unescapeHTML() {
441
+ var div = document.createElement('div');
442
+ div.innerHTML = this.stripTags();
443
+ return div.childNodes[0] ? (div.childNodes.length > 1 ?
444
+ $A(div.childNodes).inject('', function(memo, node) { return memo+node.nodeValue }) :
445
+ div.childNodes[0].nodeValue) : '';
446
+ }*/
447
+
448
+
449
+ function toQueryParams(separator) {
450
+ var match = this.strip().match(/([^?#]*)(#.*)?$/);
451
+ if (!match) return { };
452
+
453
+ return match[1].split(separator || '&').inject({ }, function(hash, pair) {
454
+ if ((pair = pair.split('='))[0]) {
455
+ var key = decodeURIComponent(pair.shift());
456
+ var value = pair.length > 1 ? pair.join('=') : pair[0];
457
+ if (value != undefined) value = decodeURIComponent(value);
458
+
459
+ if (key in hash) {
460
+ if (!Object.isArray(hash[key])) hash[key] = [hash[key]];
461
+ hash[key].push(value);
462
+ }
463
+ else hash[key] = value;
464
+ }
465
+ return hash;
466
+ });
467
+ }
468
+
469
+ function toArray() {
470
+ return this.split('');
471
+ }
472
+
473
+ function succ() {
474
+ return this.slice(0, this.length - 1) +
475
+ String.fromCharCode(this.charCodeAt(this.length - 1) + 1);
476
+ }
477
+
478
+ function times(count) {
479
+ return count < 1 ? '' : new Array(count + 1).join(this);
480
+ }
481
+
482
+ function camelize() {
483
+ var parts = this.split('-'), len = parts.length;
484
+ if (len == 1) return parts[0];
485
+
486
+ var camelized = this.charAt(0) == '-'
487
+ ? parts[0].charAt(0).toUpperCase() + parts[0].substring(1)
488
+ : parts[0];
489
+
490
+ for (var i = 1; i < len; i++)
491
+ camelized += parts[i].charAt(0).toUpperCase() + parts[i].substring(1);
492
+
493
+ return camelized;
494
+ }
495
+
496
+ function capitalize() {
497
+ return this.charAt(0).toUpperCase() + this.substring(1).toLowerCase();
498
+ }
499
+
500
+ function underscore() {
501
+ return this.gsub(/::/, '/').gsub(/([A-Z]+)([A-Z][a-z])/,'#{1}_#{2}').gsub(/([a-z\d])([A-Z])/,'#{1}_#{2}').gsub(/-/,'_').toLowerCase();
502
+ }
503
+
504
+ function dasherize() {
505
+ return this.gsub(/_/,'-');
506
+ }
507
+
508
+ function inspect(useDoubleQuotes) {
509
+ var escapedString = this.gsub(/[\x00-\x1f\\]/, function(match) {
510
+ var character = String.specialChar[match[0]];
511
+ return character ? character : '\\u00' + match[0].charCodeAt().toPaddedString(2, 16);
512
+ });
513
+ if (useDoubleQuotes) return '"' + escapedString.replace(/"/g, '\\"') + '"';
514
+ return "'" + escapedString.replace(/'/g, '\\\'') + "'";
515
+ }
516
+
517
+ /*function toJSON() {
518
+ return this.inspect(true);
519
+ }
520
+
521
+ function unfilterJSON(filter) {
522
+ return this.sub(filter || Prototype.JSONFilter, '#{1}');
523
+ }
524
+
525
+ function isJSON() {
526
+ var str = this;
527
+ if (str.blank()) return false;
528
+ str = this.replace(/\\./g, '@').replace(/"[^"\\\n\r]*"/g, '');
529
+ return (/^[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t]*$/).test(str);
530
+ }
531
+
532
+ function evalJSON(sanitize) {
533
+ var json = this.unfilterJSON();
534
+ try {
535
+ if (!sanitize || json.isJSON()) return eval('(' + json + ')');
536
+ } catch (e) { }
537
+ throw new SyntaxError('Badly formed JSON string: ' + this.inspect());
538
+ }*/
539
+
540
+ function include(pattern) {
541
+ return this.indexOf(pattern) > -1;
542
+ }
543
+
544
+ function startsWith(pattern) {
545
+ return this.indexOf(pattern) === 0;
546
+ }
547
+
548
+ function endsWith(pattern) {
549
+ var d = this.length - pattern.length;
550
+ return d >= 0 && this.lastIndexOf(pattern) === d;
551
+ }
552
+
553
+ function empty() {
554
+ return this == '';
555
+ }
556
+
557
+ function blank() {
558
+ return /^\s*$/.test(this);
559
+ }
560
+
561
+ function interpolate(object, pattern) {
562
+ return new Template(this, pattern).evaluate(object);
563
+ }
564
+
565
+ return {
566
+ gsub: gsub,
567
+ sub: sub,
568
+ scan: scan,
569
+ truncate: truncate,
570
+ strip: String.prototype.trim ? String.prototype.trim : strip,
571
+ stripTags: stripTags,
572
+ stripScripts: stripScripts,
573
+ extractScripts: extractScripts,
574
+ evalScripts: evalScripts,
575
+ escapeHTML: escapeHTML,
576
+ /*unescapeHTML: unescapeHTML,*/
577
+ toQueryParams: toQueryParams,
578
+ parseQuery: toQueryParams,
579
+ toArray: toArray,
580
+ succ: succ,
581
+ times: times,
582
+ camelize: camelize,
583
+ capitalize: capitalize,
584
+ underscore: underscore,
585
+ dasherize: dasherize,
586
+ inspect: inspect,
587
+ //toJSON: toJSON,
588
+ //unfilterJSON: unfilterJSON,
589
+ //isJSON: isJSON,
590
+ //evalJSON: evalJSON,
591
+ include: include,
592
+ startsWith: startsWith,
593
+ endsWith: endsWith,
594
+ empty: empty,
595
+ blank: blank,
596
+ interpolate: interpolate
597
+ };
598
+ })());String.prototype.escapeHTML = function() {
599
+ return this.replace(/&/g,'&amp;').replace(/</g,'&lt;').replace(/>/g,'&gt;');
600
+ }; String.prototype.unescapeHTML = function() {
601
+ return this.stripTags().replace(/&lt;/g,'<').replace(/&gt;/g,'>').replace(/&amp;/g,'&');
602
+ };var Template = Class.create({
603
+ initialize: function(template, pattern) {
604
+ this.template = template.toString();
605
+ this.pattern = pattern || Template.Pattern;
606
+ },
607
+
608
+ evaluate: function(object) {
609
+ if (object && Object.isFunction(object.toTemplateReplacements))
610
+ object = object.toTemplateReplacements();
611
+
612
+ return this.template.gsub(this.pattern, function(match) {
613
+ if (object == null) return (match[1] + '');
614
+
615
+ var before = match[1] || '';
616
+ if (before == '\\') return match[2];
617
+
618
+ var ctx = object, expr = match[3];
619
+ var pattern = /^([^.[]+|\[((?:.*?[^\\])?)\])(\.|\[|$)/;
620
+ match = pattern.exec(expr);
621
+ if (match == null) return before;
622
+
623
+ while (match != null) {
624
+ var comp = match[1].startsWith('[') ? match[2].gsub('\\\\]', ']') : match[1];
625
+ ctx = ctx[comp];
626
+ if (null == ctx || '' == match[3]) break;
627
+ expr = expr.substring('[' == match[3] ? match[1].length : match[0].length);
628
+ match = pattern.exec(expr);
629
+ }
630
+
631
+ return before + String.interpret(ctx);
632
+ });
633
+ }
634
+ });Template.Pattern = /(^|.|\r|\n)(#\{(.*?)\})/;var $break = { };var Enumerable = (function() {
635
+ function each(iterator, context) {
636
+ var index = 0;
637
+ try {
638
+ this._each(function(value) {
639
+ iterator.call(context, value, index++);
640
+ });
641
+ } catch (e) {
642
+ if (e != $break) throw e;
643
+ }
644
+ return this;
645
+ }
646
+
647
+ function eachSlice(number, iterator, context) {
648
+ var index = -number, slices = [], array = this.toArray();
649
+ if (number < 1) return array;
650
+ while ((index += number) < array.length)
651
+ slices.push(array.slice(index, index+number));
652
+ return slices.collect(iterator, context);
653
+ }
654
+
655
+ function all(iterator, context) {
656
+ iterator = iterator || Prototype.K;
657
+ var result = true;
658
+ this.each(function(value, index) {
659
+ result = result && !!iterator.call(context, value, index);
660
+ if (!result) throw $break;
661
+ });
662
+ return result;
663
+ }
664
+
665
+ function any(iterator, context) {
666
+ iterator = iterator || Prototype.K;
667
+ var result = false;
668
+ this.each(function(value, index) {
669
+ if (result = !!iterator.call(context, value, index))
670
+ throw $break;
671
+ });
672
+ return result;
673
+ }
674
+
675
+ function collect(iterator, context) {
676
+ iterator = iterator || Prototype.K;
677
+ var results = [];
678
+ this.each(function(value, index) {
679
+ results.push(iterator.call(context, value, index));
680
+ });
681
+ return results;
682
+ }
683
+
684
+ function detect(iterator, context) {
685
+ var result;
686
+ this.each(function(value, index) {
687
+ if (iterator.call(context, value, index)) {
688
+ result = value;
689
+ throw $break;
690
+ }
691
+ });
692
+ return result;
693
+ }
694
+
695
+ function findAll(iterator, context) {
696
+ var results = [];
697
+ this.each(function(value, index) {
698
+ if (iterator.call(context, value, index))
699
+ results.push(value);
700
+ });
701
+ return results;
702
+ }
703
+
704
+ function grep(filter, iterator, context) {
705
+ iterator = iterator || Prototype.K;
706
+ var results = [];
707
+
708
+ if (Object.isString(filter))
709
+ filter = new RegExp(RegExp.escape(filter));
710
+
711
+ this.each(function(value, index) {
712
+ if (filter.match(value))
713
+ results.push(iterator.call(context, value, index));
714
+ });
715
+ return results;
716
+ }
717
+
718
+ function include(object) {
719
+ if (Object.isFunction(this.indexOf))
720
+ if (this.indexOf(object) != -1) return true;
721
+
722
+ var found = false;
723
+ this.each(function(value) {
724
+ if (value == object) {
725
+ found = true;
726
+ throw $break;
727
+ }
728
+ });
729
+ return found;
730
+ }
731
+
732
+ function inGroupsOf(number, fillWith) {
733
+ fillWith = Object.isUndefined(fillWith) ? null : fillWith;
734
+ return this.eachSlice(number, function(slice) {
735
+ while(slice.length < number) slice.push(fillWith);
736
+ return slice;
737
+ });
738
+ }
739
+
740
+ function inject(memo, iterator, context) {
741
+ this.each(function(value, index) {
742
+ memo = iterator.call(context, memo, value, index);
743
+ });
744
+ return memo;
745
+ }
746
+
747
+ function invoke(method) {
748
+ var args = $A(arguments).slice(1);
749
+ return this.map(function(value) {
750
+ return value[method].apply(value, args);
751
+ });
752
+ }
753
+
754
+ function max(iterator, context) {
755
+ iterator = iterator || Prototype.K;
756
+ var result;
757
+ this.each(function(value, index) {
758
+ value = iterator.call(context, value, index);
759
+ if (result == null || value >= result)
760
+ result = value;
761
+ });
762
+ return result;
763
+ }
764
+
765
+ function min(iterator, context) {
766
+ iterator = iterator || Prototype.K;
767
+ var result;
768
+ this.each(function(value, index) {
769
+ value = iterator.call(context, value, index);
770
+ if (result == null || value < result)
771
+ result = value;
772
+ });
773
+ return result;
774
+ }
775
+
776
+ function partition(iterator, context) {
777
+ iterator = iterator || Prototype.K;
778
+ var trues = [], falses = [];
779
+ this.each(function(value, index) {
780
+ (iterator.call(context, value, index) ?
781
+ trues : falses).push(value);
782
+ });
783
+ return [trues, falses];
784
+ }
785
+
786
+ function pluck(property) {
787
+ var results = [];
788
+ this.each(function(value) {
789
+ results.push(value[property]);
790
+ });
791
+ return results;
792
+ }
793
+
794
+ function reject(iterator, context) {
795
+ var results = [];
796
+ this.each(function(value, index) {
797
+ if (!iterator.call(context, value, index))
798
+ results.push(value);
799
+ });
800
+ return results;
801
+ }
802
+
803
+ function sortBy(iterator, context) {
804
+ return this.map(function(value, index) {
805
+ return {
806
+ value: value,
807
+ criteria: iterator.call(context, value, index)
808
+ };
809
+ }).sort(function(left, right) {
810
+ var a = left.criteria, b = right.criteria;
811
+ return a < b ? -1 : a > b ? 1 : 0;
812
+ }).pluck('value');
813
+ }
814
+
815
+ function toArray() {
816
+ return this.map();
817
+ }
818
+
819
+ function zip() {
820
+ var iterator = Prototype.K, args = $A(arguments);
821
+ if (Object.isFunction(args.last()))
822
+ iterator = args.pop();
823
+
824
+ var collections = [this].concat(args).map($A);
825
+ return this.map(function(value, index) {
826
+ return iterator(collections.pluck(index));
827
+ });
828
+ }
829
+
830
+ function size() {
831
+ return this.toArray().length;
832
+ }
833
+
834
+ function inspect() {
835
+ return '#<Enumerable:' + this.toArray().inspect() + '>';
836
+ }
837
+
838
+ return {
839
+ each: each,
840
+ eachSlice: eachSlice,
841
+ all: all,
842
+ every: all,
843
+ any: any,
844
+ some: any,
845
+ collect: collect,
846
+ map: collect,
847
+ detect: detect,
848
+ findAll: findAll,
849
+ select: findAll,
850
+ filter: findAll,
851
+ grep: grep,
852
+ include: include,
853
+ member: include,
854
+ inGroupsOf: inGroupsOf,
855
+ inject: inject,
856
+ invoke: invoke,
857
+ max: max,
858
+ min: min,
859
+ partition: partition,
860
+ pluck: pluck,
861
+ reject: reject,
862
+ sortBy: sortBy,
863
+ toArray: toArray,
864
+ entries: toArray,
865
+ zip: zip,
866
+ size: size,
867
+ inspect: inspect,
868
+ find: detect
869
+ };
870
+ })();function $A(iterable) {
871
+ if (!iterable) return [];
872
+ if ('toArray' in Object(iterable)) return iterable.toArray();
873
+ var length = iterable.length || 0, results = new Array(length);
874
+ while (length--) results[length] = iterable[length];
875
+ return results;
876
+ }function $w(string) {
877
+ if (!Object.isString(string)) return [];
878
+ string = string.strip();
879
+ return string ? string.split(/\s+/) : [];
880
+ }Array.from = $A;(function() {
881
+ var arrayProto = Array.prototype,
882
+ slice = arrayProto.slice,
883
+ _each = arrayProto.forEach; // use native browser JS 1.6 implementation if available
884
+
885
+ function each(iterator) {
886
+ for (var i = 0, length = this.length; i < length; i++)
887
+ iterator(this[i]);
888
+ }
889
+ if (!_each) _each = each;
890
+
891
+ function clear() {
892
+ this.length = 0;
893
+ return this;
894
+ }
895
+
896
+ function first() {
897
+ return this[0];
898
+ }
899
+
900
+ function last() {
901
+ return this[this.length - 1];
902
+ }
903
+
904
+ function compact() {
905
+ return this.select(function(value) {
906
+ return value != null;
907
+ });
908
+ }
909
+
910
+ function flatten() {
911
+ return this.inject([], function(array, value) {
912
+ if (Object.isArray(value))
913
+ return array.concat(value.flatten());
914
+ array.push(value);
915
+ return array;
916
+ });
917
+ }
918
+
919
+ function without() {
920
+ var values = slice.call(arguments, 0);
921
+ return this.select(function(value) {
922
+ return !values.include(value);
923
+ });
924
+ }
925
+
926
+ function reverse(inline) {
927
+ return (inline !== false ? this : this.toArray())._reverse();
928
+ }
929
+
930
+ function uniq(sorted) {
931
+ return this.inject([], function(array, value, index) {
932
+ if (0 == index || (sorted ? array.last() != value : !array.include(value)))
933
+ array.push(value);
934
+ return array;
935
+ });
936
+ }
937
+
938
+ function intersect(array) {
939
+ return this.uniq().findAll(function(item) {
940
+ return array.detect(function(value) { return item === value });
941
+ });
942
+ }
943
+
944
+
945
+ function clone() {
946
+ return slice.call(this, 0);
947
+ }
948
+
949
+ function size() {
950
+ return this.length;
951
+ }
952
+
953
+ function inspect() {
954
+ return '[' + this.map(Object.inspect).join(', ') + ']';
955
+ }
956
+
957
+ /*function toJSON() {
958
+ var results = [];
959
+ this.each(function(object) {
960
+ var value = Object.toJSON(object );
961
+ if (!Object.isUndefined(value))
962
+ results.push(value);
963
+ else
964
+ results.push('null');
965
+ });
966
+ return '[' + results.join(', ') + ']';
967
+ }*/
968
+
969
+ function indexOf(item, i) {
970
+ i || (i = 0);
971
+ var length = this.length;
972
+ if (i < 0) i = length + i;
973
+ for (; i < length; i++)
974
+ if (this[i] === item) return i;
975
+ return -1;
976
+ }
977
+
978
+ function lastIndexOf(item, i) {
979
+ i = isNaN(i) ? this.length : (i < 0 ? this.length + i : i) + 1;
980
+ var n = this.slice(0, i).reverse().indexOf(item);
981
+ return (n < 0) ? n : i - n - 1;
982
+ }
983
+
984
+ function concat() {
985
+ var array = slice.call(this, 0), item;
986
+ for (var i = 0, length = arguments.length; i < length; i++) {
987
+ item = arguments[i];
988
+ if (Object.isArray(item) && !('callee' in item)) {
989
+ for (var j = 0, arrayLength = item.length; j < arrayLength; j++)
990
+ array.push(item[j]);
991
+ } else {
992
+ array.push(item);
993
+ }
994
+ }
995
+ return array;
996
+ }
997
+
998
+ Object.extend(arrayProto, Enumerable);
999
+
1000
+ if (!arrayProto._reverse)
1001
+ arrayProto._reverse = arrayProto.reverse;
1002
+
1003
+ Object.extend(arrayProto, {
1004
+ _each: _each,
1005
+ clear: clear,
1006
+ first: first,
1007
+ last: last,
1008
+ compact: compact,
1009
+ flatten: flatten,
1010
+ without: without,
1011
+ reverse: reverse,
1012
+ uniq: uniq,
1013
+ intersect: intersect,
1014
+ clone: clone,
1015
+ toArray: clone,
1016
+ size: size,
1017
+ inspect: inspect,
1018
+ //toJSON: toJSON
1019
+ });
1020
+
1021
+ var CONCAT_ARGUMENTS_BUGGY = (function() {
1022
+ return [].concat(arguments)[0][0] !== 1;
1023
+ })(1,2)
1024
+
1025
+ if (CONCAT_ARGUMENTS_BUGGY) arrayProto.concat = concat;
1026
+
1027
+ if (!arrayProto.indexOf) arrayProto.indexOf = indexOf;
1028
+ if (!arrayProto.lastIndexOf) arrayProto.lastIndexOf = lastIndexOf;
1029
+ })();function $H(object) {
1030
+ return new Hash(object);
1031
+ };var Hash = Class.create(Enumerable, (function() {
1032
+ function initialize(object) {
1033
+ this._object = Object.isHash(object) ? object.toObject() : Object.clone(object);
1034
+ }
1035
+
1036
+ function _each(iterator) {
1037
+ for (var key in this._object) {
1038
+ var value = this._object[key], pair = [key, value];
1039
+ pair.key = key;
1040
+ pair.value = value;
1041
+ iterator(pair);
1042
+ }
1043
+ }
1044
+
1045
+ function set(key, value) {
1046
+ return this._object[key] = value;
1047
+ }
1048
+
1049
+ function get(key) {
1050
+ if (this._object[key] !== Object.prototype[key])
1051
+ return this._object[key];
1052
+ }
1053
+
1054
+ function unset(key) {
1055
+ var value = this._object[key];
1056
+ delete this._object[key];
1057
+ return value;
1058
+ }
1059
+
1060
+ function toObject() {
1061
+ return Object.clone(this._object);
1062
+ }
1063
+
1064
+ function keys() {
1065
+ return this.pluck('key');
1066
+ }
1067
+
1068
+ function values() {
1069
+ return this.pluck('value');
1070
+ }
1071
+
1072
+ function index(value) {
1073
+ var match = this.detect(function(pair) {
1074
+ return pair.value === value;
1075
+ });
1076
+ return match && match.key;
1077
+ }
1078
+
1079
+ function merge(object) {
1080
+ return this.clone().update(object);
1081
+ }
1082
+
1083
+ function update(object) {
1084
+ return new Hash(object).inject(this, function(result, pair) {
1085
+ result.set(pair.key, pair.value);
1086
+ return result;
1087
+ });
1088
+ }
1089
+
1090
+ function toQueryPair(key, value) {
1091
+ if (Object.isUndefined(value)) return key;
1092
+ return key + '=' + encodeURIComponent(String.interpret(value));
1093
+ }
1094
+
1095
+ function toQueryString() {
1096
+ return this.inject([], function(results, pair) {
1097
+ var key = encodeURIComponent(pair.key), values = pair.value;
1098
+
1099
+ if (values && typeof values == 'object') {
1100
+ if (Object.isArray(values))
1101
+ return results.concat(values.map(toQueryPair.curry(key)));
1102
+ } else results.push(toQueryPair(key, values));
1103
+ return results;
1104
+ }).join('&');
1105
+ }
1106
+
1107
+ function inspect() {
1108
+ return '#<Hash:{' + this.map(function(pair) {
1109
+ return pair.map(Object.inspect).join(': ');
1110
+ }).join(', ') + '}>';
1111
+ }
1112
+
1113
+ /*function toJSON() {
1114
+ return Object.toJSON(this.toObject());
1115
+ }*/
1116
+
1117
+ function clone() {
1118
+ return new Hash(this);
1119
+ }
1120
+
1121
+ return {
1122
+ initialize: initialize,
1123
+ _each: _each,
1124
+ set: set,
1125
+ get: get,
1126
+ unset: unset,
1127
+ toObject: toObject,
1128
+ toTemplateReplacements: toObject,
1129
+ keys: keys,
1130
+ values: values,
1131
+ index: index,
1132
+ merge: merge,
1133
+ update: update,
1134
+ toQueryString: toQueryString,
1135
+ inspect: inspect,
1136
+ //toJSON: toJSON,
1137
+ clone: clone
1138
+ };
1139
+ })());Hash.from = $H;Object.extend(Number.prototype, (function() {
1140
+ function toColorPart() {
1141
+ return this.toPaddedString(2, 16);
1142
+ }
1143
+
1144
+ function succ() {
1145
+ return this + 1;
1146
+ }
1147
+
1148
+ function times(iterator, context) {
1149
+ $R(0, this, true).each(iterator, context);
1150
+ return this;
1151
+ }
1152
+
1153
+ function toPaddedString(length, radix) {
1154
+ var string = this.toString(radix || 10);
1155
+ return '0'.times(length - string.length) + string;
1156
+ }
1157
+
1158
+ /*function toJSON() {
1159
+ return isFinite(this) ? this.toString() : 'null';
1160
+ }*/
1161
+
1162
+ function abs() {
1163
+ return Math.abs(this);
1164
+ }
1165
+
1166
+ function round() {
1167
+ return Math.round(this);
1168
+ }
1169
+
1170
+ function ceil() {
1171
+ return Math.ceil(this);
1172
+ }
1173
+
1174
+ function floor() {
1175
+ return Math.floor(this);
1176
+ }
1177
+
1178
+ return {
1179
+ toColorPart: toColorPart,
1180
+ succ: succ,
1181
+ times: times,
1182
+ toPaddedString: toPaddedString,
1183
+ //toJSON: toJSON,
1184
+ abs: abs,
1185
+ round: round,
1186
+ ceil: ceil,
1187
+ floor: floor
1188
+ };
1189
+ })());function $R(start, end, exclusive) {
1190
+ return new ObjectRange(start, end, exclusive);
1191
+ }var ObjectRange = Class.create(Enumerable, (function() {
1192
+ function initialize(start, end, exclusive) {
1193
+ this.start = start;
1194
+ this.end = end;
1195
+ this.exclusive = exclusive;
1196
+ }
1197
+
1198
+ function _each(iterator) {
1199
+ var value = this.start;
1200
+ while (this.include(value)) {
1201
+ iterator(value);
1202
+ value = value.succ();
1203
+ }
1204
+ }
1205
+
1206
+ function include(value) {
1207
+ if (value < this.start)
1208
+ return false;
1209
+ if (this.exclusive)
1210
+ return value < this.end;
1211
+ return value <= this.end;
1212
+ }
1213
+
1214
+ return {
1215
+ initialize: initialize,
1216
+ _each: _each,
1217
+ include: include
1218
+ };
1219
+ })());$_H=function(object){var ret=({}); for(var k in object){try{ret[k]=object[k];}catch(e){ret[k]=null;}} return $H(ret);};"done!"