Home > Javascript AJAX CSS > JS Code Archive

JS Code Archive

Javascript Code prettifier - Highlight Syntax (JS Code Pro.)

this gadget (upgrade version of code prettifier) highlights syntax code of javascript just copy and paste, and RegExp in a code will be highlighted by midnight Blue. font-size, font-family are changeable. As additional option, text view and print view button will highlight and show source code to new window. print view is for color print. it's not necessary to set up js file. it's easy to use and very accurate.

ガジェットの貼り付けコード


このガジェットは前回紹介した Javascript の Syntax Highlighter ガジェット(JS Code)に機能を追加したものです。

このツールの特徴は、外部 js ファイルなどのセッティングなどを必要とせず、Javascript のコードをコピーして貼り付けるだけです。グローバル変数、ファンクション名、CSSのクラス名なども毎回違う名前になるようにしてますので、ブログなどに何ヶ所もソースコードを貼り付けても名前がかぶることがありません。

正規表現(RegExp)の部分が青(midnightBlue)でハイライトされます。他にあまり見られないものです。

追加機能は、Text view ボタンを追加しています。IE7, FireFox3, Safari, Google Chrome でテストしています。 Opera でテキストエリアの表示(text view)がうまくいきません。Operaはとても優秀なブラウザなので文字化け等への対応がされているためだと思います。文字コードは、現時点ではUnicode のみになります。ガジェットの charset は UTF-8 で設定してます。print view でソースコードをそのままカラープリントが出来ます。

font (font-family)は前のガジェットと変わらず以下の4種類のタイプに変更できます。
  1. "Arial,Helvetica,sans-serif"
  2. "Comic Sans MS"
  3. "Trebuchet MS,sans-serif"
  4. "Georgia,Times,sans-serif"


Last Modified : 26 Sep. 2008

1    /****************************************************************
2    
3     23 Sep. 2008 (C)samurai-logic.com
4    
5    
6     Code Prettifier
7    
8     Modified on 26 Sep. 2008
9    
10   /****************************************************************/
11   
12   function $code(str,rnd){
13   
14   /*--------------------------------------------------------------
15    str = string of javascript code
16    rnd = random 5 digits number for
17    name of temporary var, class,id and function name
18   /*---------------------------------------------------------------*/
19   
20   js_key=/\b(?=(alert|array|arguments|Boolean|break|caller|callee|case|catch|class|confirm|const|constructor|continue|Date|default|delete|do|else|eval|false|final|finally|for|function|if|isFinite|isNaN|Math|NaN|new|null|Number|Object|parseFloat|parseInt|prompt|prototype|return|String|switch|this|throw|throws|toString|toExponential|toFixed|toPrecision|true|try|typeof|value|valueOf|var|void|while|with)(\W))/g;
21   
22   var key="";
23   
24   //replace \b to key()just before keywords of javascript 
25   
26   str=str.replace(/\t/g,"      ").replace(js_key,key).replace(/&/g,"&")+"\n";
27   
28   var CODE  = '';            //CODE is string to modify code 
29   var arg   = -1;            //arg is selectors of key 
30   var pos = end = 0;      //pos = end = position of slice str 
31   var last=" ";            //last is char. before pos 
32   var temp="";            //temp 
33   var LEN=str.length;      //LEN is for end of ' and " 
34   
35   var spn ="<span style='color:";
36   var spn_c="<span class='";
37   var _col = "green;'>";
38   
39   var code_e='<br /></span>';
40   
41   var retrn = false; // for regexp "return /pat/.test()" 
42   
43   chr=/(\(|\=|\[|\:|\||\&|\!|\,)/; // RegExp in front of /pattern/ 
44   
45   d_q=/([^\\]\"[^\"]*[^\:]|[^\"]\"[\s]*[\:\,\}\]\)\;\.])/;  //RegExp of double quot. case "\\"", "\":,;.)}] 
46   s_q=/([^\\]\'[^\']*[^\:]|[^\']\'[\s]*[\:\,\}\]\)\;\.])/;  //RegExp of single quot 
47   
48   Exp=/\/[^\/]*([\s\,\;]*)((\,\s*(\"|\')|(e|h|t)\s*\(\s*\/)[\s\S]+|\/\/[\s\S]+|\/\*[\s\S]+|\s{2,}[\s\S]+|\s)\n*/;
49   
50       while (pos >= 0){
51         var cls = "</span>";
52         var key_q = str.charAt(pos);
53         var key_c = str.substr(pos,2);
54         var key_r = last + key_c;
55         var key_w = str.substr(pos,7);
56         
57         if (key_q=="'")            { arg = 0; pos++; }     //find pos of keyword ' 
58         elseif (key_q=='"')  { arg = 1; pos++; }     //find pos of keyword " 
59         elseif ((key_q=='/') && (key_c!="//") && (key_c!="/*") && ((chr.test(last) || (retrn))))
60                           { arg = 4; pos++; }     //find pos of keyword / 
61         elseif (key_c=="//") { arg = 2; pos+=2; }    //find pos of keyword // 
62         elseif (key_c=="/*") { arg = 3; pos+=2; }    //find pos of keyword /* 
63         elseif (key_w==key)  { arg = 5; pos+=8; }    // find pos of js_key (//.test(key_w)) 
64         else                   { arg =-1; pos++; }
65   
66         if (arg>=0){      //if keyword is found 
67            if (arg==0)      { temp=(str.substring(pos-1, LEN)); 
68                           end = temp.search(s_q)+pos; _col = spn+"#DC143C;'>";}//s_q=2char 
69   
70            elseif (arg==1) { temp=(str.substring(pos-1, LEN)); 
71                           end = temp.search(d_q)+pos; _col = spn+"#DC143C;'>";}
72   
73            elseif (arg==4) { end = str.indexOf("\n", pos);      // find end of line 
74                           temp=(str.substring(pos,end+2));      //temp start from pos to EOL(\n) or use LEN 
75                           end = temp.search(Exp)+pos;  _col = spn+"#0000CD;'>"; //midnightblue 
76                           retrn=false;      //set retrn false 
77                          }
78            elseif (arg==2) { end = str.indexOf("\n", pos); pos--; 
79                          _col = spn+"green;'><small>";
80                            cls+="</small>\n";
81                         }
82            else      if (arg==3) { end = str.indexOf("*/", pos); pos--; end++; _col = spn+"green;'><small>";
83                           /*if(end==0)*/ cls+="</small>";
84                         }
85            else/*if(arg==5)*/{ end = str.indexOf("\n", pos);            //find EOL 
86                            temp=str.substring(pos,end+2);            //+"\n"; 
87                            end = eval(temp.search(/[^\w\d]/)+pos-1); //search \W 
88                           _col = spn_c+"c5"+rnd+"'>"; 
89                            retrn = ((/return/.test(str.substring(pos-1,end+1))))? true:false;      
90                          } //if found keyword "return" then retrn is true 
91            temp=null; // release memory  
92   
93            if (end <= 0) end=str.length-1;  end++; //in case end=-1 : end is length of str 
94   
95            var tmp=str.charAt(end-1); // store last char if code is not comments (except comments from code) 
96   
97            if((/[^\s\n]/.test(tmp)) && (arg>=5 || arg<=1)) { last=tmp;}
98   
99            if ((arg==3)) CODE+=_col + (str.substring(pos-1,end).replace(//g,"").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/\n/g,"</small></span>\n<span style='color:green;'><small>"))+cls;
100  
101           else CODE += _col + (str.substring(pos-1,end).replace(//g,"").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/\s/g,"&ensp;")) + cls;
102  
103           pos=end; cmt=false;  //at last, end up with pos=0 
104  
105        }else{ // else keyword is not found  
106  
107            if      (/\n/.test(key_q)) CODE += "\n"; 
108            elseif (/\s/.test(key_q)) CODE += "&ensp;";
109            elseif (/\t/.test(key_q)) CODE += "&ensp;&ensp;&ensp;&ensp;";
110            elseif (/</.test(key_q))  CODE += "&lt;";
111            elseif (/>/.test(key_q))  CODE += "&gt;";
112            else CODE += key_q; 
113  
114            if(/[^\s\n]/.test(key_q))last=key_q; //if key_q isn't \s nor \n then last=key_q 
115  
116            if(pos>=str.length) pos=-1; //if pos rearch eof 
117        }
118     }
119  
120    delete str;
121  
122    return(CODE);
123  }
124  

Javascript Code Prettifier (Google Gadget)

this gadget highlights syntax code of javascript just copy and paste. no necessary to set up js file. it's easy to use.

ガジェットの貼り付けコード(Upgraded version)


Javascript の Syntax Highlighter ガジェットが完成しました。

このツールの特徴は、外部 js ファイルなどのセッティングなどを必要とせず、Javascript のコードをコピーして貼り付けるだけです。グローバル変数、ファンクション名、CSSのクラス名なども毎回違う名前になるようにしてますので、ブログなどに何ヶ所もソースコードを貼り付けても名前がかぶることがありません。

正規表現がなければ大きな問題もなくソースコードはもっとコンパクトで解りやすく書けたのですが、複雑で少々粗めになってしまいました。いろんなタイプの正規表現が見られる prototype.js , jQuery.js でテストしてクリアしましたので綺麗に使えると思います。(下にサンプルページのリンクがあります)

Scroll Width & Height の初期設定値は600px、250px になっています。これはスクロールさせる範囲の大きさです。ページのサイズに合わせて変更できます。使用できる単位は、px, in, %, cm, mm, pc, pt です。

font ボタンで以下のfont-family に変更できます。
  1. "Arial,Helvetica,sans-serif"
  2. "Comic Sans MS"
  3. "Trebuchet MS,sans-serif"
  4. "Georgia,Times,sans-serif"


prototype.js(1.5.1)

jQuery.js(1.2.6)

ソースコードは「CONTINUE READING」の下に紹介しています。このソースコードはこのガジェットで作ったものです。スクロールサイズは、Scroll Width = 850px Height = 400px で設定しています。

Continue reading

Javascript code prettify - Highlight Syntax (JS Code)

Next google gadget project is Highlight Syntax of JavaScript and etc.

次に公開予定のガジェットは "JS Code" (仮名)です。現在このブログで使っているのがSyntaxHighlighter 1.5.1なんですが、コードの行数が1000行を超えるとかなり読み込み処理に時間がかかります。prototype.js 1.5.1 はファイルを3分割して見れるようにしてますが、IEでの読み込みは少しきついです。

それをガジェットという便利なツールを使って、簡単にコードをブログに貼り付けられるようにしようとしています。コードをコピーしてガジェットのテキストエリアに貼り付けて、ボタンを押すだけでコードをすべて作ってしまえるようにします。javascript ファイル等の のセットアップする必要はありません。グローバル変数、function 名はすべて変えるように設定します。 Javascript の部分はだいたい仕上がってきてます。

また、Javascript Compressor の性能もアップさせる予定です。

jQuery.js をガジェットに貼り付けてコピペするだけでこんな感じになります。3500行以上ありますので、フォントサイズ size(小), SIZE(大), F(フォント), 等を変更する際は処理時間がかかる場合があります。i (italic) は、Class で設定してるので今のところボタンをクリックしても反映されません。

こちらはウェブページです。jQuery.js

1    (function(){
2    /*
3     * jQuery 1.2.6 - New Wave Javascript
4     *
5     * Copyright (c) 2008 John Resig (jquery.com)
6     * Dual licensed under the MIT (MIT-LICENSE.txt)
7     * and GPL (GPL-LICENSE.txt) licenses.
8     *
9     * $Date: 2008-05-24 14:22:17 -0400 (Sat, 24 May 2008) $
10    * $Rev: 5685 $
11    */
12   
13   
14   // Map over jQuery in case of overwrite 
15   var _jQuery = window.jQuery,
16   // Map over the $ in case of overwrite 
17    _$ = window.$;
18   
19   var jQuery = window.jQuery = window.$ = function( selector, context ) {
20    // The jQuery object is actually just the init constructor 'enhanced' 
21    returnnew jQuery.fn.init( selector, context );
22   };
23   
24   // A simple way to check for HTML strings or ID strings 
25   // (both of which we optimize for) 
26   var quickExpr = /^[^<]*(<(.|\s)+>)[^>]*$|^#(\w+)$/,
27   
28   // Is it a simple selector 
29    isSimple = /^.[^:#\[\.]*$/,
30   
31   // Will speed up references to undefined, and allows munging its name. 
32    undefined;
33   
34   jQuery.fn = jQuery.prototype = {
35    init: function( selector, context ) {
36     // Make sure that a selection was provided 
37     selector = selector || document;
38   
39     // Handle $(DOMElement) 
40     if ( selector.nodeType ) {
41      this[0] = selector;
42      this.length = 1;
43      returnthis;
44     }
45     // Handle HTML strings 
46     if ( typeof selector == "string" ) {
47      // Are we dealing with HTML string or an ID? 
48      var match = quickExpr.exec( selector );
49   
50      // Verify a match, and that no context was specified for #id 
51      if ( match && (match[1] || !context) ) {
52   
53       // HANDLE: $(html) -> $(array) 
54       if ( match[1] )
55        selector = jQuery.clean( [ match[1] ], context );
56   
57       // HANDLE: $("#id") 
58       else {
59        var elem = document.getElementById( match[3] );
60   
61        // Make sure an element was located 
62        if ( elem ){
63         // Handle the case where IE and Opera return items 
64         // by name instead of ID 
65         if ( elem.id != match[3] )
66          return jQuery().find( selector );
67   
68         // Otherwise, we inject the element directly into the jQuery object 
69         return jQuery( elem );
70        }
71        selector = [];
72       }
73   
74      // HANDLE: $(expr, [context]) 
75      // (which is just equivalent to: $(content).find(expr) 
76      } else
77       return jQuery( context ).find( selector );
78   
79     // HANDLE: $(function) 
80     // Shortcut for document ready 
81     } elseif ( jQuery.isFunction( selector ) )
82      return jQuery( document )[ jQuery.fn.ready ? "ready" : "load" ]( selector );
83   
84     returnthis.setArray(jQuery.makeArray(selector));
85    },
86   
87    // The current version of jQuery being used 
88    jquery: "1.2.6",
89   
90    // The number of elements contained in the matched element set 
91    size: function() {
92     returnthis.length;
93    },
94   
95    // The number of elements contained in the matched element set 
96    length: 0,
97   
98    // Get the Nth element in the matched element set OR 
99    // Get the whole matched element set as a clean array 
100   get: function( num ) {
101    return num == undefined ?
102  
103     // Return a 'clean' array 
104     jQuery.makeArray( this ) :
105  
106     // Return just the object 
107     this[ num ];
108   },
109  
110   // Take an array of elements and push it onto the stack 
111   // (returning the new matched element set) 
112   pushStack: function( elems ) {
113    // Build a new jQuery matched element set 
114    var ret = jQuery( elems );
115  
116    // Add the old object onto the stack (as a reference) 
117    ret.prevObject = this;
118  
119    // Return the newly-formed element set 
120    return ret;
121   },
122  
123   // Force the current matched set of elements to become 
124   // the specified array of elements (destroying the stack in the process) 
125   // You should use pushStack() in order to do this, but maintain the stack 
126   setArray: function( elems ) {
127    // Resetting the length to 0, then using the native Array push 
128    // is a super-fast way to populate an object with array-like properties 
129    this.length = 0;
130    Array.prototype.push.apply( this, elems );
131  
132    returnthis;
133   },
134  
135   // Execute a callback for every element in the matched set. 
136   // (You can seed the arguments with an array of args, but this is 
137   // only used internally.) 
138   each: function( callback, args ) {
139    return jQuery.each( this, callback, args );
140   },
141  
142   // Determine the position of an element within 
143   // the matched set of elements 
144   index: function( elem ) {
145    var ret = -1;
146  
147    // Locate the position of the desired element 
148    return jQuery.inArray(
149     // If it receives a jQuery object, the first element is used 
150     elem && elem.jquery ? elem[0] : elem
151    , this );
152   },
153  
154   attr: function( name, value, type ) {
155    var options = name;
156  
157    // Look for the case where we're accessing a style value 
158    if ( name.constructor == String )
159     if ( value === undefined )
160      returnthis[0] && jQuery[ type || "attr" ]( this[0], name );
161  
162     else {
163      options = {};
164      options[ name ] = value;
165     }
166  
167    // Check to see if we're setting style values 
168    returnthis.each(function(i){
169     // Set all the styles 
170     for ( name in options )
171      jQuery.attr(
172       type ?
173        this.style :
174        this,
175       name, jQuery.prop( this, options[ name ], type, i, name )
176      );
177    });
178   },
179  
180   css: function( key, value ) {
181    // ignore negative width and height values 
182    if ( (key == 'width' || key == 'height') && parseFloat(value) < 0 )
183     value = undefined;
184    returnthis.attr( key, value, "curCSS" );
185   },
186  
187   text: function( text ) {
188    if ( typeof text != "object" && text != null )
189     returnthis.empty().append( (this[0] && this[0].ownerDocument || document).createTextNode( text ) );
190  
191    var ret = "";
192  
193    jQuery.each( text || this, function(){
194     jQuery.each( this.childNodes, function(){
195      if ( this.nodeType != 8 )
196       ret += this.nodeType != 1 ?
197        this.nodeValue :
198        jQuery.fn.text( [ this ] );
199     });
200    });
201  
202    return ret;
203   },
204  
205   wrapAll: function( html ) {
206    if ( this[0] )
207     // The elements to wrap the target around 
208     jQuery( html, this[0].ownerDocument )
209      .clone()
210      .insertBefore( this[0] )
211      .map(function(){
212       var elem = this;
213  
214       while ( elem.firstChild )
215        elem = elem.firstChild;
216  
217       return elem;
218      })
219      .append(this);
220  
221    returnthis;
222   },
223  
224   wrapInner: function( html ) {
225    returnthis.each(function(){
226     jQuery( this ).contents().wrapAll( html );
227    });
228   },
229  
230   wrap: function( html ) {
231    returnthis.each(function(){
232     jQuery( this ).wrapAll( html );
233    });
234   },
235  
236   append: function() {
237    returnthis.domManip(arguments, true, false, function(elem){
238     if (this.nodeType == 1)
239      this.appendChild( elem );
240    });
241   },
242  
243   prepend: function() {
244    returnthis.domManip(arguments, true, true, function(elem){
245     if (this.nodeType == 1)
246      this.insertBefore( elem, this.firstChild );
247    });
248   },
249  
250   before: function() {
251    returnthis.domManip(arguments, false, false, function(elem){
252     this.parentNode.insertBefore( elem, this );
253    });
254   },
255  
256   after: function() {
257    returnthis.domManip(arguments, false, true, function(elem){
258     this.parentNode.insertBefore( elem, this.nextSibling );
259    });
260   },
261  
262   end: function() {
263    returnthis.prevObject || jQuery( [] );
264   },
265  
266   find: function( selector ) {
267    var elems = jQuery.map(this, function(elem){
268     return jQuery.find( selector, elem );
269    });
270  
271    returnthis.pushStack( /[^+>] [^+>]/.test( selector ) || selector.indexOf("..") > -1 ?
272     jQuery.unique( elems ) :
273     elems );
274   },
275  
276   clone: function( events ) {
277    // Do the clone 
278    var ret = this.map(function(){
279     if ( jQuery.browser.msie && !jQuery.isXMLDoc(this) ) {
280      // IE copies events bound via attachEvent when 
281      // using cloneNode. Calling detachEvent on the 
282      // clone will also remove the events from the orignal 
283      // In order to get around this, we use innerHTML. 
284      // Unfortunately, this means some modifications to 
285      // attributes in IE that are actually only stored 
286      // as properties will not be copied (such as the 
287      // the name attribute on an input). 
288      var clone = this.cloneNode(true),
289       container = document.createElement("div");
290      container.appendChild(clone);
291      return jQuery.clean([container.innerHTML])[0];
292     } else
293      returnthis.cloneNode(true);
294    });
295  
296    // Need to set the expando to null on the cloned set if it exists 
297    // removeData doesn't work here, IE removes it from the original as well 
298    // this is primarily for IE but the data expando shouldn't be copied over in any browser 
299    var clone = ret.find("*").andSelf().each(function(){
300     if ( this[ expando ] != undefined )
301      this[ expando ] = null;
302    });
303  
304    // Copy the events from the original to the clone 
305    if ( events === true )
306     this.find("*").andSelf().each(function(i){
307      if (this.nodeType == 3)
308       return;
309      var events = jQuery.data( this, "events" );
310  
311      for ( var type in events )
312       for ( var handler in events[ type ] )
313        jQuery.event.add( clone[ i ], type, events[ type ][ handler ], events[ type ][ handler ].data );
314     });
315  
316    // Return the cloned set 
317    return ret;
318   },
319  
320   filter: function( selector ) {
321    returnthis.pushStack(
322     jQuery.isFunction( selector ) &&
323     jQuery.grep(this, function(elem, i){
324      return selector.call( elem, i );
325     }) ||
326  
327     jQuery.multiFilter( selector, this ) );
328   },
329  
330   not: function( selector ) {
331    if ( selector.constructor == String )
332     // test special case where just one selector is passed in 
333     if ( isSimple.test( selector ) )
334      returnthis.pushStack( jQuery.multiFilter( selector, this, true ) );
335     else
336      selector = jQuery.multiFilter( selector, this );
337  
338    var isArrayLike = selector.length && selector[selector.length - 1] !== undefined && !selector.nodeType;
339    returnthis.filter(function() {
340     return isArrayLike ? jQuery.inArray( this, selector ) < 0 : this != selector;
341    });
342   },
343  
344   add: function( selector ) {
345    returnthis.pushStack( jQuery.unique( jQuery.merge(
346     this.get(),
347     typeof selector == 'string' ?
348      jQuery( selector ) :
349      jQuery.makeArray( selector )
350    )));
351   },
352  
353   is: function( selector ) {
354    return !!selector && jQuery.multiFilter( selector, this ).length > 0;
355   },
356  
357   hasClass: function( selector ) {
358    returnthis.is( "." + selector );
359   },
360  
361   val: function( value ) {
362    if ( value == undefined ) {
363  
364     if ( this.length ) {
365      var elem = this[0];
366  
367      // We need to handle select boxes special 
368      if ( jQuery.nodeName( elem, "select" ) ) {
369       var index = elem.selectedIndex,
370        values = [],
371        options = elem.options,
372        one = elem.type == "select-one";
373  
374       // Nothing was selected 
375       if ( index < 0 )
376        returnnull;
377  
378       // Loop through all the selected options 
379       for ( var i = one ? index : 0, max = one ? index + 1 : options.length; i < max; i++ ) {
380        var option = options[ i ];
381  
382        if ( option.selected ) {
383         // Get the specifc value for the option 
384         value = jQuery.browser.msie && !option.attributes.value.specified ? option.text : option.value;
385  
386         // We don't need an array for one selects 
387         if ( one )
388          returnvalue;
389  
390         // Multi-Selects return an array 
391         values.push( value );
392        }
393       }
394  
395       return values;
396  
397      // Everything else, we just grab the value 
398      } else
399       return (this[0].value || "").replace(/\r/g, "");
400  
401     }
402  
403     return undefined;
404    }
405  
406    if( value.constructor == Number )
407     value += '';
408  
409    returnthis.each(function(){
410     if ( this.nodeType != 1 )
411      return;
412  
413     if ( value.constructor == Array && /radio|checkbox/.test( this.type ) )
414      this.checked = (jQuery.inArray(this.value, value) >= 0 ||
415       jQuery.inArray(this.name, value) >= 0);
416  
417     elseif ( jQuery.nodeName( this, "select" ) ) {
418      var values = jQuery.makeArray(value);
419  
420      jQuery( "option", this ).each(function(){
421       this.selected = (jQuery.inArray( this.value, values ) >= 0 ||
422        jQuery.inArray( this.text, values ) >= 0);
423      });
424  
425      if ( !values.length )
426       this.selectedIndex = -1;
427  
428     } else
429      this.value = value;
430    });
431   },
432  
433   html: function( value ) {
434    returnvalue == undefined ?
435     (this[0] ?
436      this[0].innerHTML :
437      null) :
438     this.empty().append( value );
439   },
440  
441   replaceWith: function( value ) {
442    returnthis.after( value ).remove();
443   },
444  
445   eq: function( i ) {
446    returnthis.slice( i, i + 1 );
447   },
448  
449   slice: function() {
450    returnthis.pushStack( Array.prototype.slice.apply( this, arguments ) );
451   },
452  
453   map: function( callback ) {
454    returnthis.pushStack( jQuery.map(this, function(elem, i){
455     return callback.call( elem, i, elem );
456    }));
457   },
458  
459   andSelf: function() {
460    returnthis.add( this.prevObject );
461   },
462  
463   data: function( key, value ){
464    var parts = key.split(".");
465    parts[1] = parts[1] ? "." + parts[1] : "";
466  
467    if ( value === undefined ) {
468     var data = this.triggerHandler("getData" + parts[1] + "!", [parts[0]]);
469  
470     if ( data === undefined && this.length )
471      data = jQuery.data( this[0], key );
472  
473     return data === undefined && parts[1] ?
474      this.data( parts[0] ) :
475      data;
476    } else
477     returnthis.trigger("setData" + parts[1] + "!", [parts[0], value]).each(function(){
478      jQuery.data( this, key, value );
479     });
480   },
481  
482   removeData: function( key ){
483    returnthis.each(function(){
484     jQuery.removeData( this, key );
485    });
486   },
487  
488   domManip: function( args, table, reverse, callback ) {
489    var clone = this.length > 1, elems;
490  
491    returnthis.each(function(){
492     if ( !elems ) {
493      elems = jQuery.clean( args, this.ownerDocument );
494  
495      if ( reverse )
496       elems.reverse();
497     }
498  
499     var obj = this;
500  
501     if ( table && jQuery.nodeName( this, "table" ) && jQuery.nodeName( elems[0], "tr" ) )
502      obj = this.getElementsByTagName("tbody")[0] || this.appendChild( this.ownerDocument.createElement("tbody") );
503  
504     var scripts = jQuery( [] );
505  
506     jQuery.each(elems, function(){
507      var elem = clone ?
508       jQuery( this ).clone( true )[0] :
509       this;
510  
511      // execute all scripts after the elements have been injected 
512      if ( jQuery.nodeName( elem, "script" ) )
513       scripts = scripts.add( elem );
514      else {
515       // Remove any inner scripts for later evaluation 
516       if ( elem.nodeType == 1 )
517        scripts = scripts.add( jQuery( "script", elem ).remove() );
518  
519       // Inject the elements into the document 
520       callback.call( obj, elem );
521      }
522     });
523  
524     scripts.each( evalScript );
525    });
526   }
527  };
528  
529  // Give the init function the jQuery prototype for later instantiation 
530  jQuery.fn.init.prototype = jQuery.fn;
531  
532  function evalScript( i, elem ) {
533   if ( elem.src )
534    jQuery.ajax({
535     url: elem.src,
536     async: false,
537     dataType: "script"
538    });
539  
540   else
541    jQuery.globalEval( elem.text || elem.textContent || elem.innerHTML || "" );
542  
543   if ( elem.parentNode )
544    elem.parentNode.removeChild( elem );
545  }
546  
547  function now(){
548   return +newDate;
549  }
550  
551  jQuery.extend = jQuery.fn.extend = function() {
552   // copy reference to target object 
553   var target = arguments[0] || {}, i = 1, length = arguments.length, deep = false, options;
554  
555   // Handle a deep copy situation 
556   if ( target.constructor&e