xonecas.io
208
2p

2d-particle-experiements / commit 4e6bc78

added another drawing function, called circle

xonecas2012-07-20 4e6bc78ea8b0ec2094d93834718e8c3b87e2e113 parent dd4b472

5 files changed

This diff is too big to show in full. The first 1000 lines are below, and every file is listed with its counts.

css/style.css+1−0
@@ -8,6 +8,7 @@ html {
88
99 body {
1010 background: transparent;
11+ padding-top: 40px;
1112 }
1213
1314 canvas {
index.html+28−11
@@ -2,18 +2,37 @@
22 <html lang="en">
33 <head charset="utf-8">
44
5- <title></title>
6- <meta name="author" content="">
7- <meta name="description" content="">
5+ <title></title>
6+ <meta name="author" content="">
7+ <meta name="description" content="">
88
9- <meta name="viewport" content="width=device-width, initial-scale=1.0">
10- <link rel="stylesheet" href="css/bootstrap.css">
11- <link rel="stylesheet" href="css/style.css">
9+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
10+ <link rel="stylesheet" href="css/bootstrap.css">
11+ <link rel="stylesheet" href="css/style.css">
1212
1313 </head>
14+<body>
1415 <div class="navbar navbar-fixed-top">
1516 <div class="navbar-inner">
1617 <div class="container">
18+ <ul class="nav pull-right">
19+ <li class="dropdown">
20+ <a href="#" class="dropdown-toggle" data-toggle="dropdown">Functions<b class="caret"></b></a>
21+ <ul class="dropdown-menu">
22+ <li><a data-fn="spiral" class="fn" href="#">Spiral</a></li>
23+ <li><a data-fn="fractal" class="fn" href="#">Fractal</a></li>
24+ <li><a data-fn="rain" class="fn" href="#">Rain</a></li>
25+ <li><a data-fn="tracking" class="fn" href="#">Circle</a></li>
26+ <li class="divider"></li>
27+ <li><a data-fn="stop" class="fn" href="#">Stop</a></li>
28+ </ul>
29+ </li>
30+ </ul>
31+
32+ <p class="navbar-text pull-right">
33+ Open your console for instructions
34+ </p>
35+
1736 <a class="brand" href="//github.com/xonecas/2d-particle-experiements">
1837 Particle Playground
1938 </a>
@@ -21,14 +40,12 @@
2140 <a href="/">
2241 <small class="navbar-text">(click to reset)</small>
2342 </a>
24-
25- <p class="navbar-text pull-right">
26- Open your console for instructions
27- </p>
2843 </div>
2944 </div>
3045 </div>
3146
32- <script src="js/script.js"></script>
47+ <script src="js/jquery-1.7.2.js"></script>
48+ <script src="js/bootstrap-dropdown.js"></script>
49+ <script src="js/script.js"></script>
3350 </body>
3451 </html>
js/bootstrap-dropdown.js+100−0
@@ -0,0 +1,100 @@
1+/* ============================================================
2+ * bootstrap-dropdown.js v2.0.4
3+ * http://twitter.github.com/bootstrap/javascript.html#dropdowns
4+ * ============================================================
5+ * Copyright 2012 Twitter, Inc.
6+ *
7+ * Licensed under the Apache License, Version 2.0 (the "License");
8+ * you may not use this file except in compliance with the License.
9+ * You may obtain a copy of the License at
10+ *
11+ * http://www.apache.org/licenses/LICENSE-2.0
12+ *
13+ * Unless required by applicable law or agreed to in writing, software
14+ * distributed under the License is distributed on an "AS IS" BASIS,
15+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+ * See the License for the specific language governing permissions and
17+ * limitations under the License.
18+ * ============================================================ */
19+
20+
21+!function ($) {
22+
23+ "use strict"; // jshint ;_;
24+
25+
26+ /* DROPDOWN CLASS DEFINITION
27+ * ========================= */
28+
29+ var toggle = '[data-toggle="dropdown"]'
30+ , Dropdown = function (element) {
31+ var $el = $(element).on('click.dropdown.data-api', this.toggle)
32+ $('html').on('click.dropdown.data-api', function () {
33+ $el.parent().removeClass('open')
34+ })
35+ }
36+
37+ Dropdown.prototype = {
38+
39+ constructor: Dropdown
40+
41+ , toggle: function (e) {
42+ var $this = $(this)
43+ , $parent
44+ , selector
45+ , isActive
46+
47+ if ($this.is('.disabled, :disabled')) return
48+
49+ selector = $this.attr('data-target')
50+
51+ if (!selector) {
52+ selector = $this.attr('href')
53+ selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7
54+ }
55+
56+ $parent = $(selector)
57+ $parent.length || ($parent = $this.parent())
58+
59+ isActive = $parent.hasClass('open')
60+
61+ clearMenus()
62+
63+ if (!isActive) $parent.toggleClass('open')
64+
65+ return false
66+ }
67+
68+ }
69+
70+ function clearMenus() {
71+ $(toggle).parent().removeClass('open')
72+ }
73+
74+
75+ /* DROPDOWN PLUGIN DEFINITION
76+ * ========================== */
77+
78+ $.fn.dropdown = function (option) {
79+ return this.each(function () {
80+ var $this = $(this)
81+ , data = $this.data('dropdown')
82+ if (!data) $this.data('dropdown', (data = new Dropdown(this)))
83+ if (typeof option == 'string') data[option].call($this)
84+ })
85+ }
86+
87+ $.fn.dropdown.Constructor = Dropdown
88+
89+
90+ /* APPLY TO STANDARD DROPDOWN ELEMENTS
91+ * =================================== */
92+
93+ $(function () {
94+ $('html').on('click.dropdown.data-api', clearMenus)
95+ $('body')
96+ .on('click.dropdown', '.dropdown form', function (e) { e.stopPropagation() })
97+ .on('click.dropdown.data-api', toggle, Dropdown.prototype.toggle)
98+ })
99+
100+}(window.jQuery);
js/jquery-1.7.2.js+9404−0
@@ -0,0 +1,9404 @@
1+/*!
2+ * jQuery JavaScript Library v1.7.2
3+ * http://jquery.com/
4+ *
5+ * Copyright 2011, John Resig
6+ * Dual licensed under the MIT or GPL Version 2 licenses.
7+ * http://jquery.org/license
8+ *
9+ * Includes Sizzle.js
10+ * http://sizzlejs.com/
11+ * Copyright 2011, The Dojo Foundation
12+ * Released under the MIT, BSD, and GPL Licenses.
13+ *
14+ * Date: Wed Mar 21 12:46:34 2012 -0700
15+ */
16+(function( window, undefined ) {
17+
18+// Use the correct document accordingly with window argument (sandbox)
19+var document = window.document,
20+ navigator = window.navigator,
21+ location = window.location;
22+var jQuery = (function() {
23+
24+// Define a local copy of jQuery
25+var jQuery = function( selector, context ) {
26+ // The jQuery object is actually just the init constructor 'enhanced'
27+ return new jQuery.fn.init( selector, context, rootjQuery );
28+ },
29+
30+ // Map over jQuery in case of overwrite
31+ _jQuery = window.jQuery,
32+
33+ // Map over the $ in case of overwrite
34+ _$ = window.$,
35+
36+ // A central reference to the root jQuery(document)
37+ rootjQuery,
38+
39+ // A simple way to check for HTML strings or ID strings
40+ // Prioritize #id over <tag> to avoid XSS via location.hash (#9521)
41+ quickExpr = /^(?:[^#<]*(<[\w\W]+>)[^>]*$|#([\w\-]*)$)/,
42+
43+ // Check if a string has a non-whitespace character in it
44+ rnotwhite = /\S/,
45+
46+ // Used for trimming whitespace
47+ trimLeft = /^\s+/,
48+ trimRight = /\s+$/,
49+
50+ // Match a standalone tag
51+ rsingleTag = /^<(\w+)\s*\/?>(?:<\/\1>)?$/,
52+
53+ // JSON RegExp
54+ rvalidchars = /^[\],:{}\s]*$/,
55+ rvalidescape = /\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,
56+ rvalidtokens = /"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,
57+ rvalidbraces = /(?:^|:|,)(?:\s*\[)+/g,
58+
59+ // Useragent RegExp
60+ rwebkit = /(webkit)[ \/]([\w.]+)/,
61+ ropera = /(opera)(?:.*version)?[ \/]([\w.]+)/,
62+ rmsie = /(msie) ([\w.]+)/,
63+ rmozilla = /(mozilla)(?:.*? rv:([\w.]+))?/,
64+
65+ // Matches dashed string for camelizing
66+ rdashAlpha = /-([a-z]|[0-9])/ig,
67+ rmsPrefix = /^-ms-/,
68+
69+ // Used by jQuery.camelCase as callback to replace()
70+ fcamelCase = function( all, letter ) {
71+ return ( letter + "" ).toUpperCase();
72+ },
73+
74+ // Keep a UserAgent string for use with jQuery.browser
75+ userAgent = navigator.userAgent,
76+
77+ // For matching the engine and version of the browser
78+ browserMatch,
79+
80+ // The deferred used on DOM ready
81+ readyList,
82+
83+ // The ready event handler
84+ DOMContentLoaded,
85+
86+ // Save a reference to some core methods
87+ toString = Object.prototype.toString,
88+ hasOwn = Object.prototype.hasOwnProperty,
89+ push = Array.prototype.push,
90+ slice = Array.prototype.slice,
91+ trim = String.prototype.trim,
92+ indexOf = Array.prototype.indexOf,
93+
94+ // [[Class]] -> type pairs
95+ class2type = {};
96+
97+jQuery.fn = jQuery.prototype = {
98+ constructor: jQuery,
99+ init: function( selector, context, rootjQuery ) {
100+ var match, elem, ret, doc;
101+
102+ // Handle $(""), $(null), or $(undefined)
103+ if ( !selector ) {
104+ return this;
105+ }
106+
107+ // Handle $(DOMElement)
108+ if ( selector.nodeType ) {
109+ this.context = this[0] = selector;
110+ this.length = 1;
111+ return this;
112+ }
113+
114+ // The body element only exists once, optimize finding it
115+ if ( selector === "body" && !context && document.body ) {
116+ this.context = document;
117+ this[0] = document.body;
118+ this.selector = selector;
119+ this.length = 1;
120+ return this;
121+ }
122+
123+ // Handle HTML strings
124+ if ( typeof selector === "string" ) {
125+ // Are we dealing with HTML string or an ID?
126+ if ( selector.charAt(0) === "<" && selector.charAt( selector.length - 1 ) === ">" && selector.length >= 3 ) {
127+ // Assume that strings that start and end with <> are HTML and skip the regex check
128+ match = [ null, selector, null ];
129+
130+ } else {
131+ match = quickExpr.exec( selector );
132+ }
133+
134+ // Verify a match, and that no context was specified for #id
135+ if ( match && (match[1] || !context) ) {
136+
137+ // HANDLE: $(html) -> $(array)
138+ if ( match[1] ) {
139+ context = context instanceof jQuery ? context[0] : context;
140+ doc = ( context ? context.ownerDocument || context : document );
141+
142+ // If a single string is passed in and it's a single tag
143+ // just do a createElement and skip the rest
144+ ret = rsingleTag.exec( selector );
145+
146+ if ( ret ) {
147+ if ( jQuery.isPlainObject( context ) ) {
148+ selector = [ document.createElement( ret[1] ) ];
149+ jQuery.fn.attr.call( selector, context, true );
150+
151+ } else {
152+ selector = [ doc.createElement( ret[1] ) ];
153+ }
154+
155+ } else {
156+ ret = jQuery.buildFragment( [ match[1] ], [ doc ] );
157+ selector = ( ret.cacheable ? jQuery.clone(ret.fragment) : ret.fragment ).childNodes;
158+ }
159+
160+ return jQuery.merge( this, selector );
161+
162+ // HANDLE: $("#id")
163+ } else {
164+ elem = document.getElementById( match[2] );
165+
166+ // Check parentNode to catch when Blackberry 4.6 returns
167+ // nodes that are no longer in the document #6963
168+ if ( elem && elem.parentNode ) {
169+ // Handle the case where IE and Opera return items
170+ // by name instead of ID
171+ if ( elem.id !== match[2] ) {
172+ return rootjQuery.find( selector );
173+ }
174+
175+ // Otherwise, we inject the element directly into the jQuery object
176+ this.length = 1;
177+ this[0] = elem;
178+ }
179+
180+ this.context = document;
181+ this.selector = selector;
182+ return this;
183+ }
184+
185+ // HANDLE: $(expr, $(...))
186+ } else if ( !context || context.jquery ) {
187+ return ( context || rootjQuery ).find( selector );
188+
189+ // HANDLE: $(expr, context)
190+ // (which is just equivalent to: $(context).find(expr)
191+ } else {
192+ return this.constructor( context ).find( selector );
193+ }
194+
195+ // HANDLE: $(function)
196+ // Shortcut for document ready
197+ } else if ( jQuery.isFunction( selector ) ) {
198+ return rootjQuery.ready( selector );
199+ }
200+
201+ if ( selector.selector !== undefined ) {
202+ this.selector = selector.selector;
203+ this.context = selector.context;
204+ }
205+
206+ return jQuery.makeArray( selector, this );
207+ },
208+
209+ // Start with an empty selector
210+ selector: "",
211+
212+ // The current version of jQuery being used
213+ jquery: "1.7.2",
214+
215+ // The default length of a jQuery object is 0
216+ length: 0,
217+
218+ // The number of elements contained in the matched element set
219+ size: function() {
220+ return this.length;
221+ },
222+
223+ toArray: function() {
224+ return slice.call( this, 0 );
225+ },
226+
227+ // Get the Nth element in the matched element set OR
228+ // Get the whole matched element set as a clean array
229+ get: function( num ) {
230+ return num == null ?
231+
232+ // Return a 'clean' array
233+ this.toArray() :
234+
235+ // Return just the object
236+ ( num < 0 ? this[ this.length + num ] : this[ num ] );
237+ },
238+
239+ // Take an array of elements and push it onto the stack
240+ // (returning the new matched element set)
241+ pushStack: function( elems, name, selector ) {
242+ // Build a new jQuery matched element set
243+ var ret = this.constructor();
244+
245+ if ( jQuery.isArray( elems ) ) {
246+ push.apply( ret, elems );
247+
248+ } else {
249+ jQuery.merge( ret, elems );
250+ }
251+
252+ // Add the old object onto the stack (as a reference)
253+ ret.prevObject = this;
254+
255+ ret.context = this.context;
256+
257+ if ( name === "find" ) {
258+ ret.selector = this.selector + ( this.selector ? " " : "" ) + selector;
259+ } else if ( name ) {
260+ ret.selector = this.selector + "." + name + "(" + selector + ")";
261+ }
262+
263+ // Return the newly-formed element set
264+ return ret;
265+ },
266+
267+ // Execute a callback for every element in the matched set.
268+ // (You can seed the arguments with an array of args, but this is
269+ // only used internally.)
270+ each: function( callback, args ) {
271+ return jQuery.each( this, callback, args );
272+ },
273+
274+ ready: function( fn ) {
275+ // Attach the listeners
276+ jQuery.bindReady();
277+
278+ // Add the callback
279+ readyList.add( fn );
280+
281+ return this;
282+ },
283+
284+ eq: function( i ) {
285+ i = +i;
286+ return i === -1 ?
287+ this.slice( i ) :
288+ this.slice( i, i + 1 );
289+ },
290+
291+ first: function() {
292+ return this.eq( 0 );
293+ },
294+
295+ last: function() {
296+ return this.eq( -1 );
297+ },
298+
299+ slice: function() {
300+ return this.pushStack( slice.apply( this, arguments ),
301+ "slice", slice.call(arguments).join(",") );
302+ },
303+
304+ map: function( callback ) {
305+ return this.pushStack( jQuery.map(this, function( elem, i ) {
306+ return callback.call( elem, i, elem );
307+ }));
308+ },
309+
310+ end: function() {
311+ return this.prevObject || this.constructor(null);
312+ },
313+
314+ // For internal use only.
315+ // Behaves like an Array's method, not like a jQuery method.
316+ push: push,
317+ sort: [].sort,
318+ splice: [].splice
319+};
320+
321+// Give the init function the jQuery prototype for later instantiation
322+jQuery.fn.init.prototype = jQuery.fn;
323+
324+jQuery.extend = jQuery.fn.extend = function() {
325+ var options, name, src, copy, copyIsArray, clone,
326+ target = arguments[0] || {},
327+ i = 1,
328+ length = arguments.length,
329+ deep = false;
330+
331+ // Handle a deep copy situation
332+ if ( typeof target === "boolean" ) {
333+ deep = target;
334+ target = arguments[1] || {};
335+ // skip the boolean and the target
336+ i = 2;
337+ }
338+
339+ // Handle case when target is a string or something (possible in deep copy)
340+ if ( typeof target !== "object" && !jQuery.isFunction(target) ) {
341+ target = {};
342+ }
343+
344+ // extend jQuery itself if only one argument is passed
345+ if ( length === i ) {
346+ target = this;
347+ --i;
348+ }
349+
350+ for ( ; i < length; i++ ) {
351+ // Only deal with non-null/undefined values
352+ if ( (options = arguments[ i ]) != null ) {
353+ // Extend the base object
354+ for ( name in options ) {
355+ src = target[ name ];
356+ copy = options[ name ];
357+
358+ // Prevent never-ending loop
359+ if ( target === copy ) {
360+ continue;
361+ }
362+
363+ // Recurse if we're merging plain objects or arrays
364+ if ( deep && copy && ( jQuery.isPlainObject(copy) || (copyIsArray = jQuery.isArray(copy)) ) ) {
365+ if ( copyIsArray ) {
366+ copyIsArray = false;
367+ clone = src && jQuery.isArray(src) ? src : [];
368+
369+ } else {
370+ clone = src && jQuery.isPlainObject(src) ? src : {};
371+ }
372+
373+ // Never move original objects, clone them
374+ target[ name ] = jQuery.extend( deep, clone, copy );
375+
376+ // Don't bring in undefined values
377+ } else if ( copy !== undefined ) {
378+ target[ name ] = copy;
379+ }
380+ }
381+ }
382+ }
383+
384+ // Return the modified object
385+ return target;
386+};
387+
388+jQuery.extend({
389+ noConflict: function( deep ) {
390+ if ( window.$ === jQuery ) {
391+ window.$ = _$;
392+ }
393+
394+ if ( deep && window.jQuery === jQuery ) {
395+ window.jQuery = _jQuery;
396+ }
397+
398+ return jQuery;
399+ },
400+
401+ // Is the DOM ready to be used? Set to true once it occurs.
402+ isReady: false,
403+
404+ // A counter to track how many items to wait for before
405+ // the ready event fires. See #6781
406+ readyWait: 1,
407+
408+ // Hold (or release) the ready event
409+ holdReady: function( hold ) {
410+ if ( hold ) {
411+ jQuery.readyWait++;
412+ } else {
413+ jQuery.ready( true );
414+ }
415+ },
416+
417+ // Handle when the DOM is ready
418+ ready: function( wait ) {
419+ // Either a released hold or an DOMready/load event and not yet ready
420+ if ( (wait === true && !--jQuery.readyWait) || (wait !== true && !jQuery.isReady) ) {
421+ // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
422+ if ( !document.body ) {
423+ return setTimeout( jQuery.ready, 1 );
424+ }
425+
426+ // Remember that the DOM is ready
427+ jQuery.isReady = true;
428+
429+ // If a normal DOM Ready event fired, decrement, and wait if need be
430+ if ( wait !== true && --jQuery.readyWait > 0 ) {
431+ return;
432+ }
433+
434+ // If there are functions bound, to execute
435+ readyList.fireWith( document, [ jQuery ] );
436+
437+ // Trigger any bound ready events
438+ if ( jQuery.fn.trigger ) {
439+ jQuery( document ).trigger( "ready" ).off( "ready" );
440+ }
441+ }
442+ },
443+
444+ bindReady: function() {
445+ if ( readyList ) {
446+ return;
447+ }
448+
449+ readyList = jQuery.Callbacks( "once memory" );
450+
451+ // Catch cases where $(document).ready() is called after the
452+ // browser event has already occurred.
453+ if ( document.readyState === "complete" ) {
454+ // Handle it asynchronously to allow scripts the opportunity to delay ready
455+ return setTimeout( jQuery.ready, 1 );
456+ }
457+
458+ // Mozilla, Opera and webkit nightlies currently support this event
459+ if ( document.addEventListener ) {
460+ // Use the handy event callback
461+ document.addEventListener( "DOMContentLoaded", DOMContentLoaded, false );
462+
463+ // A fallback to window.onload, that will always work
464+ window.addEventListener( "load", jQuery.ready, false );
465+
466+ // If IE event model is used
467+ } else if ( document.attachEvent ) {
468+ // ensure firing before onload,
469+ // maybe late but safe also for iframes
470+ document.attachEvent( "onreadystatechange", DOMContentLoaded );
471+
472+ // A fallback to window.onload, that will always work
473+ window.attachEvent( "onload", jQuery.ready );
474+
475+ // If IE and not a frame
476+ // continually check to see if the document is ready
477+ var toplevel = false;
478+
479+ try {
480+ toplevel = window.frameElement == null;
481+ } catch(e) {}
482+
483+ if ( document.documentElement.doScroll && toplevel ) {
484+ doScrollCheck();
485+ }
486+ }
487+ },
488+
489+ // See test/unit/core.js for details concerning isFunction.
490+ // Since version 1.3, DOM methods and functions like alert
491+ // aren't supported. They return false on IE (#2968).
492+ isFunction: function( obj ) {
493+ return jQuery.type(obj) === "function";
494+ },
495+
496+ isArray: Array.isArray || function( obj ) {
497+ return jQuery.type(obj) === "array";
498+ },
499+
500+ isWindow: function( obj ) {
501+ return obj != null && obj == obj.window;
502+ },
503+
504+ isNumeric: function( obj ) {
505+ return !isNaN( parseFloat(obj) ) && isFinite( obj );
506+ },
507+
508+ type: function( obj ) {
509+ return obj == null ?
510+ String( obj ) :
511+ class2type[ toString.call(obj) ] || "object";
512+ },
513+
514+ isPlainObject: function( obj ) {
515+ // Must be an Object.
516+ // Because of IE, we also have to check the presence of the constructor property.
517+ // Make sure that DOM nodes and window objects don't pass through, as well
518+ if ( !obj || jQuery.type(obj) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) {
519+ return false;
520+ }
521+
522+ try {
523+ // Not own constructor property must be Object
524+ if ( obj.constructor &&
525+ !hasOwn.call(obj, "constructor") &&
526+ !hasOwn.call(obj.constructor.prototype, "isPrototypeOf") ) {
527+ return false;
528+ }
529+ } catch ( e ) {
530+ // IE8,9 Will throw exceptions on certain host objects #9897
531+ return false;
532+ }
533+
534+ // Own properties are enumerated firstly, so to speed up,
535+ // if last one is own, then all properties are own.
536+
537+ var key;
538+ for ( key in obj ) {}
539+
540+ return key === undefined || hasOwn.call( obj, key );
541+ },
542+
543+ isEmptyObject: function( obj ) {
544+ for ( var name in obj ) {
545+ return false;
546+ }
547+ return true;
548+ },
549+
550+ error: function( msg ) {
551+ throw new Error( msg );
552+ },
553+
554+ parseJSON: function( data ) {
555+ if ( typeof data !== "string" || !data ) {
556+ return null;
557+ }
558+
559+ // Make sure leading/trailing whitespace is removed (IE can't handle it)
560+ data = jQuery.trim( data );
561+
562+ // Attempt to parse using the native JSON parser first
563+ if ( window.JSON && window.JSON.parse ) {
564+ return window.JSON.parse( data );
565+ }
566+
567+ // Make sure the incoming data is actual JSON
568+ // Logic borrowed from http://json.org/json2.js
569+ if ( rvalidchars.test( data.replace( rvalidescape, "@" )
570+ .replace( rvalidtokens, "]" )
571+ .replace( rvalidbraces, "")) ) {
572+
573+ return ( new Function( "return " + data ) )();
574+
575+ }
576+ jQuery.error( "Invalid JSON: " + data );
577+ },
578+
579+ // Cross-browser xml parsing
580+ parseXML: function( data ) {
581+ if ( typeof data !== "string" || !data ) {
582+ return null;
583+ }
584+ var xml, tmp;
585+ try {
586+ if ( window.DOMParser ) { // Standard
587+ tmp = new DOMParser();
588+ xml = tmp.parseFromString( data , "text/xml" );
589+ } else { // IE
590+ xml = new ActiveXObject( "Microsoft.XMLDOM" );
591+ xml.async = "false";
592+ xml.loadXML( data );
593+ }
594+ } catch( e ) {
595+ xml = undefined;
596+ }
597+ if ( !xml || !xml.documentElement || xml.getElementsByTagName( "parsererror" ).length ) {
598+ jQuery.error( "Invalid XML: " + data );
599+ }
600+ return xml;
601+ },
602+
603+ noop: function() {},
604+
605+ // Evaluates a script in a global context
606+ // Workarounds based on findings by Jim Driscoll
607+ // http://weblogs.java.net/blog/driscoll/archive/2009/09/08/eval-javascript-global-context
608+ globalEval: function( data ) {
609+ if ( data && rnotwhite.test( data ) ) {
610+ // We use execScript on Internet Explorer
611+ // We use an anonymous function so that context is window
612+ // rather than jQuery in Firefox
613+ ( window.execScript || function( data ) {
614+ window[ "eval" ].call( window, data );
615+ } )( data );
616+ }
617+ },
618+
619+ // Convert dashed to camelCase; used by the css and data modules
620+ // Microsoft forgot to hump their vendor prefix (#9572)
621+ camelCase: function( string ) {
622+ return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase );
623+ },
624+
625+ nodeName: function( elem, name ) {
626+ return elem.nodeName && elem.nodeName.toUpperCase() === name.toUpperCase();
627+ },
628+
629+ // args is for internal usage only
630+ each: function( object, callback, args ) {
631+ var name, i = 0,
632+ length = object.length,
633+ isObj = length === undefined || jQuery.isFunction( object );
634+
635+ if ( args ) {
636+ if ( isObj ) {
637+ for ( name in object ) {
638+ if ( callback.apply( object[ name ], args ) === false ) {
639+ break;
640+ }
641+ }
642+ } else {
643+ for ( ; i < length; ) {
644+ if ( callback.apply( object[ i++ ], args ) === false ) {
645+ break;
646+ }
647+ }
648+ }
649+
650+ // A special, fast, case for the most common use of each
651+ } else {
652+ if ( isObj ) {
653+ for ( name in object ) {
654+ if ( callback.call( object[ name ], name, object[ name ] ) === false ) {
655+ break;
656+ }
657+ }
658+ } else {
659+ for ( ; i < length; ) {
660+ if ( callback.call( object[ i ], i, object[ i++ ] ) === false ) {
661+ break;
662+ }
663+ }
664+ }
665+ }
666+
667+ return object;
668+ },
669+
670+ // Use native String.trim function wherever possible
671+ trim: trim ?
672+ function( text ) {
673+ return text == null ?
674+ "" :
675+ trim.call( text );
676+ } :
677+
678+ // Otherwise use our own trimming functionality
679+ function( text ) {
680+ return text == null ?
681+ "" :
682+ text.toString().replace( trimLeft, "" ).replace( trimRight, "" );
683+ },
684+
685+ // results is for internal usage only
686+ makeArray: function( array, results ) {
687+ var ret = results || [];
688+
689+ if ( array != null ) {
690+ // The window, strings (and functions) also have 'length'
691+ // Tweaked logic slightly to handle Blackberry 4.7 RegExp issues #6930
692+ var type = jQuery.type( array );
693+
694+ if ( array.length == null || type === "string" || type === "function" || type === "regexp" || jQuery.isWindow( array ) ) {
695+ push.call( ret, array );
696+ } else {
697+ jQuery.merge( ret, array );
698+ }
699+ }
700+
701+ return ret;
702+ },
703+
704+ inArray: function( elem, array, i ) {
705+ var len;
706+
707+ if ( array ) {
708+ if ( indexOf ) {
709+ return indexOf.call( array, elem, i );
710+ }
711+
712+ len = array.length;
713+ i = i ? i < 0 ? Math.max( 0, len + i ) : i : 0;
714+
715+ for ( ; i < len; i++ ) {
716+ // Skip accessing in sparse arrays
717+ if ( i in array && array[ i ] === elem ) {
718+ return i;
719+ }
720+ }
721+ }
722+
723+ return -1;
724+ },
725+
726+ merge: function( first, second ) {
727+ var i = first.length,
728+ j = 0;
729+
730+ if ( typeof second.length === "number" ) {
731+ for ( var l = second.length; j < l; j++ ) {
732+ first[ i++ ] = second[ j ];
733+ }
734+
735+ } else {
736+ while ( second[j] !== undefined ) {
737+ first[ i++ ] = second[ j++ ];
738+ }
739+ }
740+
741+ first.length = i;
742+
743+ return first;
744+ },
745+
746+ grep: function( elems, callback, inv ) {
747+ var ret = [], retVal;
748+ inv = !!inv;
749+
750+ // Go through the array, only saving the items
751+ // that pass the validator function
752+ for ( var i = 0, length = elems.length; i < length; i++ ) {
753+ retVal = !!callback( elems[ i ], i );
754+ if ( inv !== retVal ) {
755+ ret.push( elems[ i ] );
756+ }
757+ }
758+
759+ return ret;
760+ },
761+
762+ // arg is for internal usage only
763+ map: function( elems, callback, arg ) {
764+ var value, key, ret = [],
765+ i = 0,
766+ length = elems.length,
767+ // jquery objects are treated as arrays
768+ isArray = elems instanceof jQuery || length !== undefined && typeof length === "number" && ( ( length > 0 && elems[ 0 ] && elems[ length -1 ] ) || length === 0 || jQuery.isArray( elems ) ) ;
769+
770+ // Go through the array, translating each of the items to their
771+ if ( isArray ) {
772+ for ( ; i < length; i++ ) {
773+ value = callback( elems[ i ], i, arg );
774+
775+ if ( value != null ) {
776+ ret[ ret.length ] = value;
777+ }
778+ }
779+
780+ // Go through every key on the object,
781+ } else {
782+ for ( key in elems ) {
783+ value = callback( elems[ key ], key, arg );
784+
785+ if ( value != null ) {
786+ ret[ ret.length ] = value;
787+ }
788+ }
789+ }
790+
791+ // Flatten any nested arrays
792+ return ret.concat.apply( [], ret );
793+ },
794+
795+ // A global GUID counter for objects
796+ guid: 1,
797+
798+ // Bind a function to a context, optionally partially applying any
799+ // arguments.
800+ proxy: function( fn, context ) {
801+ if ( typeof context === "string" ) {
802+ var tmp = fn[ context ];
803+ context = fn;
804+ fn = tmp;
805+ }
806+
807+ // Quick check to determine if target is callable, in the spec
808+ // this throws a TypeError, but we will just return undefined.
809+ if ( !jQuery.isFunction( fn ) ) {
810+ return undefined;
811+ }
812+
813+ // Simulated bind
814+ var args = slice.call( arguments, 2 ),
815+ proxy = function() {
816+ return fn.apply( context, args.concat( slice.call( arguments ) ) );
817+ };
818+
819+ // Set the guid of unique handler to the same of original handler, so it can be removed
820+ proxy.guid = fn.guid = fn.guid || proxy.guid || jQuery.guid++;
821+
822+ return proxy;
823+ },
824+
825+ // Mutifunctional method to get and set values to a collection
826+ // The value/s can optionally be executed if it's a function
827+ access: function( elems, fn, key, value, chainable, emptyGet, pass ) {
828+ var exec,
Cut short: this commit's diff is over 1000 lines.
js/script.js+73−7
Cut short: this commit's diff is over 1000 lines.