Commit 8a4a1edf authored by John Resig's avatar John Resig

Inital Import.

parents
// AJAX Plugin
// Docs Here:
// http://jquery.com/docs/ajax/
if ( typeof XMLHttpRequest == 'undefined' && typeof window.ActiveXObject == 'function') {
var XMLHttpRequest = function() {
return new ActiveXObject((navigator.userAgent.toLowerCase().indexOf('msie 5') >= 0) ?
"Microsoft.XMLHTTP" : "Msxml2.XMLHTTP");
};
}
$.xml = function( type, url, data, ret ) {
var xml = new XMLHttpRequest();
if ( xml ) {
xml.open(type || "GET", url, true);
if ( data )
xml.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
if ( ret )
xml.onreadystatechange = function() {
if ( xml.readyState == 4 ) ret(xml);
};
xml.send(data)
}
};
$.httpData = function(r,type) {
return r.getResponseHeader("content-type").indexOf("xml") > 0 || type == "xml" ?
r.responseXML : r.responseText;
};
$.get = function( url, ret, type ) {
$.xml( "GET", url, null, function(r) {
if ( ret ) ret( $.httpData(r,type) );
});
};
$.getXML = function( url, ret ) {
$.get( url, ret, "xml" );
};
$.post = function( url, data, ret, type ) {
$.xml( "POST", url, $.param(data), function(r) {
if ( ret ) ret( $.httpData(r,type) );
});
};
$.postXML = function( url, data, ret ) {
$.post( url, data, ret, "xml" );
};
$.param = function(a) {
var s = [];
for ( var i in a )
s[s.length] = i + "=" + encodeURIComponent( a[i] );
return s.join("&");
};
$.fn.load = function(a,o,f) {
// Arrrrghhhhhhhh!!
// I overwrote the event plugin's .load
// this won't happen again, I hope -John
if ( a && a.constructor == Function )
return this.bind("load", a);
var t = "GET";
if ( o && o.constructor == Function ) {
f = o; o = null;
}
if (o != null) {
o = $.param(o);
t = "POST";
}
var self = this;
$.xml(t,a,o,function(h){
var h = h.responseText;
self.html(h).find("script").each(function(){
try {
eval( this.text || this.textContent || this.innerHTML );
} catch(e){}
});
if(f)f(h);
});
return this;
};
RewriteEngine On
RewriteRule ^$ /docs/SourceCode/ [L,QSA]
RewriteRule ^([^/]+).js$ browse-new.cgi?v=$1 [L,QSA]
RewriteRule ^([^/]+)/$ browse-new.cgi?v=$1 [L,QSA]
RewriteRule ^([^/]+)/([a-z0-9-]+)/?$ browse-new.cgi?v=$1&custom=$2 [L,QSA]
This diff is collapsed.
#ParseMaster (July 25 2005)
# Based on "ParseMaster.js" by Dean Edwards <http://dean.edwards.name/>
# Ported to Perl by Rob Seiler, ELR Software Pty Ltd <http://www.elr.com.au>
# Copyright 2005. License <http://creativecommons.org/licenses/LGPL/2.1/>
package ParseMaster;
use strict;
use Data::Dumper;
# Package wide variable declarations
use vars qw/$VERSION
@_X_escaped @_X_patterns
/;
$VERSION = '017';
# constants
my $X_EXPRESSION = 0;
my $X_REPLACEMENT = 1;
my $X_LENGTH = 2;
# re's used to determine nesting levels
my $X_GROUPS = qr/\(/o; # NB: Requires g modifier!
my $X_SUB_REPLACE = qr/\$\d/o;
my $X_INDEXED = qr/^\$\d+$/o;
my $XX_ESCAPE = qr/\\./o; # NB: Requires g modifier!
my $XX_DELETED = qr/\001[^\001]*\001/o; # NB: Requires g modifier!
my $DIGIT = qr/[^\D]/o; # Yep - this is a digit - contains no non-digits
# Constructor
sub new {
my $class = shift;
my $self = {};
@_X_escaped = (); # Re-initialize global for each instance
@_X_patterns = (); # Re-initialize global for each instance
# Instance variables - access by similarly named set/get functions
$self->{_ignoreCase_} = 0;
$self->{_escapeChar_} = '';
bless ($self, $class);
return $self;
}
sub ignoreCase {
my ($self, $value) = @_;
if (defined($value)) {
$self->{_ignoreCase_} = $value;
}
return $self->{_ignoreCase_};
}
sub escapeChar{
my ($self, $value) = @_;
if (defined($value)) {
$self->{_escapeChar_} = $value;
}
return $self->{_escapeChar_};
}
#######################
# Public Parsemaster functions
my $X_DELETE = sub(@$) {
my $X_offset = pop;
my @X_match = @_;
return (chr(001) . $X_match[$X_offset] . chr(001));
}; # NB semicolon required for closure!
# create and add a new pattern to the patterns collection
sub add {
my ($self, $expression, $X_replacement) = @_;
if (!$X_replacement) {$X_replacement = $X_DELETE};
# count the number of sub-expressions
my $temp = &_X_internalEscape($expression);
my $length = 1; # Always at least one because each pattern is itself a sub-expression
$length += $temp =~ s/$X_GROUPS//g; # One way to count the left capturing parentheses in the regexp string
# does the pattern deal with sub-expressions?
if ((ref($X_replacement) ne "CODE") && ($X_replacement =~ m/$X_SUB_REPLACE/)) {
if ($X_replacement =~ m/$X_INDEXED/) { # a simple lookup? (eg "$2")
# store the index (used for fast retrieval of matched strings)
$X_replacement = substr($X_replacement,1) - 1;
}
else { # a complicated lookup (eg "Hello $2 $1")
my $i = $length;
while ($i) { # Had difficulty getting Perl to do Dean's splitting and joining of strings containing $'s
my $str = '$a[$o+' . ($i-1) . ']'; # eg $a[$o+1]
$X_replacement =~ s/\$$i/$str/; # eg $2 $3 -> $a[$o+1] $a[$o+2]
$i--;
}
# build a function to do the lookup - returns interpolated string of array lookups
$X_replacement = eval('sub {my $o=pop; my @a=@_; return "' . $X_replacement . '"};');
}
}
else {}
# pass the modified arguments
&_X_add($expression || q/^$/, $X_replacement, $length);
}
# execute the global replacement
sub exec {
#print Dumper(@_X_patterns);
my ($self, $X_string) = @_;
my $escChar = $self->escapeChar();
my $ignoreCase = $self->ignoreCase();
my ($regexp,$captures) = &_getPatterns(); # Concatenated and parenthesized regexp eg '(regex1)|(regex2)|(regex3)' etc
$X_string = &_X_escape($X_string, $escChar);
if ($ignoreCase) {$X_string =~ s/$regexp/{&_X_replacement(&_matchVars($captures,\$X_string))}/gie} # Pass $X_String as a
else {$X_string =~ s/$regexp/{&_X_replacement(&_matchVars($captures,\$X_string))}/ge} # reference for speed
$X_string = &_X_unescape($X_string, $escChar);
$X_string =~ s/$XX_DELETED//g;
return $X_string;
}
sub _X_add {
push (@_X_patterns, [@_]); # Save each argument set as is into an array of arrays
}
# this is the global replace function (it's quite complicated)
sub _X_replacement {
my (@arguments) = @_;
#print Dumper (@arguments);
if ($arguments[0] le '') {return ''}
# Dereference last index (source String) here - faster than in _matchVars (maybe not needed at all?)
$arguments[$#arguments] = ${$arguments[$#arguments]};
my $i = 1;
# loop through the patterns
for (my $j=0; $j<scalar(@_X_patterns); $j++) { # Loop through global all @_X_patterns
my @X_pattern = @{$_X_patterns[$j]};
# do we have a result? NB: "if ($arguments[$i])" as in Dean's Javascript is false for the value 0!!!
if ((defined $arguments[$i]) && ($arguments[$i] gt '')) {
my $X_replacement = $X_pattern[$X_REPLACEMENT];
# switch on type of $replacement
if (ref($X_replacement) eq "CODE") { # function
return &$X_replacement(@arguments,$i);
}
elsif ($X_replacement =~ m/$DIGIT/) { # number (contains no non-digits)
return $arguments[$X_replacement + $i];
}
else { # default
return $X_replacement; # default
}
} # skip over references to sub-expressions
else {$i += $X_pattern[$X_LENGTH]}
}
}
#######################
# Private functions
#######################
# encode escaped characters
sub _X_escape {
my ($X_string, $X_escapeChar) = @_;
if ($X_escapeChar) {
my $re = '\\'.$X_escapeChar.'(.)';
$X_string =~ s/$re/{push(@_X_escaped,$1); $X_escapeChar}/ge;
}
return $X_string;
}
# decode escaped characters
sub _X_unescape {
my ($X_string, $X_escapeChar) = @_;
if ($X_escapeChar) { # We'll only do this if there is an $X_escapeChar!
my $re = '\\'.$X_escapeChar;
$X_string =~ s/$re/{$X_escapeChar . (shift(@_X_escaped))}/ge; # Don't use Dean Edwards as below 'or' here - because zero will return ''!
# $X_string =~ s/$re/{$X_escapeChar . (shift(@_X_escaped) || '')}/ge;
}
return $X_string;
}
sub _X_internalEscape {
my ($string) = shift;
$string =~ s/$XX_ESCAPE//g;
return $string;
}
# Builds an array of match variables to (approximately) emulate that available in Javascript String.replace()
sub _matchVars {
my ($m,$sref) = @_;
my @args = (1..$m); # establish the number potential memory variables
my @mv = map {eval("\$$_")} @args; # matchvarv[1..m] = the memory variables $1 .. $m
unshift (@mv, $&); # matchvar[0] = the substring that matched
push (@mv, length($`)); # matchvar[m+1] = offset within the source string where the match occurred (= length of prematch string)
push (@mv, $sref); # matchvar[m+2] = reference to full source string (dereference in caller if/when needed)
#print Dumper (@mv);
return @mv;
}
sub _getPatterns {
my @Patterns = ();
my $lcp = 0;
for (my $i=0; $i<scalar(@_X_patterns); $i++) { # Loop through global all @_patterns
push (@Patterns, $_X_patterns[$i][$X_EXPRESSION]); # accumulate the expressions
$lcp += $_X_patterns[$i][$X_LENGTH]; # sum the left capturing parenthesis counts
}
my $str = "(" . join(')|(',@Patterns). ")"; # enclose each pattern in () separated by "|"
return ($str, $lcp);
}
##################
# END #
##################
1; # ParseMaster #
##################
#!/usr/bin/perl
use Pack;
use CGI;
use LWP::Simple;
use Digest::MD5 qw(md5_hex);
chdir("/home/jquery/www/src/");
my $cgi = new CGI();
print $cgi->header('text/javascript');
my $c = $cgi->param('c') || 'compressed';
my $v = $cgi->param('v') || 'latest';
my $live = 0;
#$v = "0.10" if ( $v eq 'latest' );
if ( $v eq 'dev' ) {
$live = 1;
$c = 'sane';
$v = 'latest';
} elsif ( $v eq 'debug' ) {
$c = 'sane';
$v = 'latest';
}
my @files = $cgi->param('files') ?
split(',', join(',', $cgi->param('files')) ):
("jquery","fx","event","ajax");
if ($cgi->param('custom') && $cgi->param('custom') !~ /-/) {
$c = $cgi->param('custom');
}
my $md5 = $cgi->param('custom') || join('-',dupe(@files),$v,$c);
my $j = "build/$md5\.js";
my $stamp = "/* Built " . localtime() . " */\n";
if ( !-e $j && !$live ) {
my $f = getf();
open( F, ">$j" );
print F $stamp;
print F $c eq 'compressed' ? &Pack::pack($f, 62, 1, 0) : $f;
close( F );
if ( $c eq 'compressed' ) {
my $tj = $j;
$tj =~ s/$c\.js$/sane\.js/;
open( F, ">$tj" );
print F $stamp;
print F $f;
close( F );
}
}
if ( $cgi->param('files') ) {
print $cgi->redirect("/src/$v/$md5/");
} else {
#print $cgi->header('text/javascript');
if ( $live ) {
print getf();
} else {
my $t = `cat copyright.txt $j`;
$v = $v eq 'latest' ? 'Current' : "Version $v";
$t =~ s/\$VERSION/$v/ig;
$t =~ s/\$MD5/$md5/ig;
my $url = $cgi->param('v') . "/";
$url .= $cgi->param('custom') . "/" if ( $cgi->param('custom') );
$t =~ s/\$URL/$url/ig;
print $t;
}
}
sub getf {
my $f = '';
foreach ( @files ) {
$f .= `cat $_/$_\-$v\.js`;
}
$f =~ s/\r//g;
$f;
}
sub dupe {
my %check;
$check{$_} = 1 foreach (@_);
return sort keys %check;
}
#!/usr/bin/perl
use Pack;
use CGI;
use LWP::Simple;
use Digest::MD5 qw(md5_hex);
chdir("/home/jquery/www/src/");
my $cgi = new CGI();
my $c = $cgi->param('c') || 'compressed';
my $v = $cgi->param('v');
#$v = "0.10" if ( $v eq 'latest' );
my @files = $cgi->param('files') ?
split(',', join(',', $cgi->param('files')) ):
("jquery","minifx","fx","event");
my $md5 = $cgi->param('custom') || join('-',dupe(@files),$v,$c);
my $j = "build/$md5\.js";
if ( !-e $j ) {
my $f = '';
foreach ( @files ) {
$f .= `cat $_/$_\-$v\.js`;
}
$f =~ s/\r//g;
my $o = $c eq 'compressed' ? &Pack::pack($f, 62, 1, 0) : $f;
open( F, ">$j" );
print F $o;
close( F );
}
if ( $cgi->param('files') ) {
print $cgi->redirect("/src/$v/$md5/");
} else {
print $cgi->header('text/javascript');
my $t = `cat copyright.txt $j`;
$v = $v eq 'latest' ? 'Current' : "Version $v";
$t =~ s/\$VERSION/$v/ig;
$t =~ s/\$MD5/$md5/ig;
my $url = $cgi->param('v') . "/";
$url .= $cgi->param('custom') . "/" if ( $cgi->param('custom') );
$t =~ s/\$URL/$url/ig;
print $t;
}
sub dupe {
my %check;
$check{$_} = 1 foreach (@_);
return sort keys %check;
}
/*
* jQuery - $VERSION
* New Wave Javascript
* http://jquery.com/
*
* To use, place this HTML into the <head>...</head> of your web page:
* <script type="text/javascript" src="http://jquery.com/src/$URL"></script>
*
* This licensed under the Creative Commons Attribution-ShareAlike License.
* License Info: http://creativecommons.org/licenses/by-sa/2.5/
*
*** NOTE:
* This code is compressed, for the original code please visit jquery.com.
* If you don't see anything below this comment, it's a bug with Firefox
* the code is there, it's just one long, compressed, line - trust me.
***
*/
This diff is collapsed.
var e = ["blur","focus","contextmenu","load","resize","scroll","unload",
"click","dblclick","mousedown","mouseup","mouseenter","mouseleave",
"mousemove","mouseover","mouseout","change","reset","select","submit",
"keydown","keypress","keyup","abort","error","ready"];
for ( var i = 0; i < e.length; i++ ) {
(function(){
var o = e[i];
$.fn[o] = function(f){ return this.bind(o, f); };
$.fn["un"+o] = function(f){ return this.unbind(o, f); };
$.fn["do"+o] = function(){ return this.trigger(o); };
$.fn["one"+o] = function(f){ return this.bind(o, function(e){
if ( this[o+f] != null ) return true;
this[o+f]++;
return $.apply(this,f,[e]);
}); };
// Deprecated
//$.fn["on"+o] = function(f){ return this.bind(o, f); };
})();
}
$.fn.hover = function(f,g) {
// Check if mouse(over|out) are still within the same parent element
return this.each(function(){
var obj = this;
addEvent(this, "mouseover", function(e) {
var p = ( e.fromElement != null ? e.fromElement : e.relatedTarget );
while ( p && p != obj ) p = p.parentNode;
if ( p == obj ) return false;
return $.apply(obj,f,[e]);
});
addEvent(this, "mouseout", function(e) {
var p = ( e.toElement != null ? e.toElement : e.relatedTarget );
while ( p && p != obj ) p = p.parentNode;
if ( p == obj ) return false;
return $.apply(obj,g,[e]);
});
});
};
// Deprecated
$.fn.onhover = $.fn.hover;
$.fn.ready = function(f) {
return this.each(function(){
if ( this.$$timer ) {
this.$$ready.push( f );
} else {
var obj = this;
this.$$ready = [ f ];
this.$$timer = setInterval( function(){
if ( obj && obj.getElementsByTagName && obj.getElementById && obj.body ) {
clearInterval( obj.$$timer );
obj.$$timer = null;
for ( var i = 0; i < obj.$$ready.length; i++ )
$.apply( obj, obj.$$ready[i] );
obj.$$ready = null;
}
}, 13 );
}
});
};
// Deprecated
$.fn.onready = $.fn.ready;
$.fn.toggle = function(a,b) {
return a && b ? this.click(function(e){
this.$$last = this.$$last == a ? b : a;
e.preventDefault();
return $.apply( this, this.$$last, [e] ) || false;
}) : this._toggle();
};
function fx(el,op,ty,tz){
var z = this;
z.a = function(){z.el.style[ty]=z.now+z.o.unit};
z.max = function(){return z.el["io"+ty]||z.el["natural"+tz]||z.el["scroll"+tz]||z.cur()};
z.cur = function(){return parseInt($.getCSS(z.el,ty))};
z.show = function(){z.ss("block");z.custom(0,z.max())};
z.hide = function(){z.el.$o=$.getCSS(z.el,"overflow");z.el["io"+ty]=this.cur();z.custom(z.cur(),0)};
z.ss = function(a){if(y.display!=a)y.display=a};
z.toggle = function(){if(z.cur()>0)z.hide();else z.show()};
z.modify = function(a){z.custom(z.cur(),z.cur()+a)};
z.clear = function(){clearInterval(z.timer);z.timer=null};
z.el = el.constructor==String?document.getElementById(el):el;
var y = z.el.style;
z.oo = y.overflow;
y.overflow = "hidden";
z.o = {
unit: "px",
duration: (op && op.duration) || 400,
onComplete: (op && op.onComplete) || op
};
z.step = function(f,tt){
var t = (new Date).getTime();
var p = (t - z.s) / z.o.duration;
if (t >= z.o.duration+z.s) {
z.now = tt;
z.clear();
setTimeout(function(){
y.overflow = z.oo;
if(y.height=="0px"||y.width=="0px")z.ss("none");
$.setAuto( z.el, "height" );
$.setAuto( z.el, "width" );
if(z.o.onComplete.constructor == Function){z.el.$_ = z.o.onComplete;z.el.$_();}
},13);
} else
z.now = ((-Math.cos(p*Math.PI)/2) + 0.5) * (tt-f) + f;
z.a();
};
z.custom = function(f,t){
if(z.timer)return;this.now=f;z.a();z.io=z.cur();z.s=(new Date).getTime();
z.timer=setInterval(function(){z.step(f,t);}, 13);
};
}
fx.fn = ["show","hide","toggle"];
fx.ty = ["Height","Width","Left","Top"];
for(var i in fx.ty){(function(){
var c = fx.ty[i];
fx[c] = function(a,b){
return new fx(a,b,c.toLowerCase(),c);};
})()}
fx.Opacity = function(a,b){
var o = new fx(a,b,"opacity");
o.cur = function(){return parseFloat(o.el.style.opacity);};
o.a = function() {
var e = o.el.style;
if (o.now == 1) o.now = 0.9999;
if (window.ActiveXObject)
e.filter = "alpha(opacity=" + o.now*100 + ")";
e.opacity = o.now;
};
o.io = o.now = 1;
o.a();
return o;
};
fx.Resize = function(e,o){
var z = this;
var h = new fx.Height(e,o);
if(o) o.onComplete = null;
var w = new fx.Width(e,o);
function c(a,b,c){return (!a||a==c||b==c);}
for(var i in fx.fn){(function(){
var j = fx.fn[i];
z[j] = function(a,b){
if(c(a,b,"height")) h[j]();
if(c(a,b,"width")) w[j]();
};
})()}
z.modify = function(c,d){
h.modify(c);
w.modify(d);
};
};
fx.FadeSize = function(e,o){
var z = this;
var p = new fx.Opacity(e,o);
if(o) o.onComplete = null;
var r = new fx.Resize(e,o);
for(var i in fx.fn){(function(){
var j = fx.fn[i];
z[j] = function(a,b){p[j]();r[j](a,b);};
})()}
};
$.speed = function(s,o) {
if ( o && o.constructor == Function ) o = { onComplete: o };
o = o || {};
var ss = {"crawl":1200,"xslow":850,"slow":600,"medium":400,"fast":200,"xfast":75,"normal":400};
o.duration = typeof s == "number" ? s : ss[s] || 400;
return o;
};
$.fn.hide = function(a,o) {
o = $.speed(a,o);
return a ? this.each(function(){
new fx.FadeSize(this,o).hide();
}) : this._hide();
};
$.fn.show = function(a,o) {
o = $.speed(a,o);
return a ? this.each(function(){
new fx.FadeSize(this,o).show();
}) : this._show();
};
$.fn.slideDown = function(a,o) {
o = $.speed(a,o);
return this.each(function(){
new fx.Resize(this,o).show("height");
});
};
$.fn.slideUp = function(a,o) {
o = $.speed(a,o);
return this.each(function(){
new fx.Resize(this,o).hide("height");
});
};
$.fn.fadeOut = function(a,o) {
o = $.speed(a,o);
return a ? this.each(function(){
new fx.Opacity(this,o).hide();
}) : this._hide();
};
$.fn.fadeIn = function(a,o) {
o = $.speed(a,o);
return a ? this.each(function(){
new fx.Opacity(this,o).show();
}) : this._show();
};
$.fn.center = function(f) {
return this.each(function(){
if ( !f && this.nodeName == 'IMG' &&
!this.offsetWidth && !this.offsetHeight ) {
var self = this;
setTimeout(function(){
$(self).center(true);
}, 13);
} else {
var s = this.style;
var p = this.parentNode;
if ( $.css(p,"position") == 'static' )
p.style.position = 'relative';
s.position = 'absolute';
s.left = parseInt(($.css(p,"width") - $.css(this,"width"))/2) + "px";
s.top = parseInt(($.css(p,"height") - $.css(this,"height"))/2) + "px";
}
});
};
$.setAuto = function(e,p) {
var a = e.style[p];
var o = $.css(e,p);
e.style[p] = 'auto';
var n = $.css(e,p);
if ( o != n )
e.style[p] = a;
};
$.fn.sort = function(f) {
cur = cur.sort(function(a,b){
if ( typeof f == 'object' )
var ret = f(a,b);
else
var ret = $.fn.genericSort(a,b,f);
if ( a < b )
b.parentNode.insertBefore( a, b );
else if ( a > b )
a.parentNode.insertBefore( b, a );
return ret;
});
return this;
}
$.fn.reverse = function() {
cur[0].parentNode.appendChild( cur[0] );
for ( var i = 1; cur && i < cur.length; i++ )
cur[i-1].parentNode.insertBefore( cur[i], cur[i-1] );
cur = cur.reverse();
return this;
}
$.fn.genericSort = function(a,b,c) {
if ( typeof a == "string" || typeof b == "string" ) {
} else if ( c != null ) {
a = sibling(a.firstChild)[c].innerText;
b = sibling(b.firstChild)[c].innerText;
} else {
a = a.innerText;
b = b.innerText;
}
// Case insensitive
a = a.toLowerCase();
b = b.toLowerCase();
// Figure out if it's an American-style date
var re = new RegExp( "^(\d{2}).(\d{2}).(\d{2,4})$" );
var ma = re.exec(a);
var mb = re.exec(b);
if ( ma.length && mb.length ) {
a = ma.reverse().join('');
b = mb.reverse().join('');
}
// If it contains a number, sort on that only
if ( a.match(/\d/) ) {
var re = new RegExp("[^0-9.-]","ig");
a = parseFloat( a.replace( re, "" ) );
b = parseFloat( b.replace( re, "" ) );
}
return ( a < b ? -1 : ( a > b ? 1 : 0 ) );
}
$.fn.get = function(i) {
return i == null ?
this.$$unclean ? $.sibling(this.$$unclean[0]) : this.cur :
(this.get())[i];
};
$.fn._get = function(i) {
return i == null ? this.cur : this.cur[i];
};
$.fn.set = function(a,b) {
return this.each(function(){
if ( b == null )
for ( var j in a )
this[$.attr(j)] = a[j];
else {
if ( b.constructor != String ) { // TODO: Fix this
for ( var i in b ) {
var c = $.Select(i,this);
for ( var j in c )
c[j][$.attr(a)] = b[i];
}
} else
this[$.attr(a)] = b;
}
});
};
function $C(a) {
if ( a.indexOf('<') >= 0 ) {
if ( a.indexOf('<tr') >= 0 ) {
var r = $C("table").html("<tbody>"+a+"</tbody>");
r.$$unclean = r.get(0).childNodes[0].childNodes;
} else {
var r = $C("div").html(a);
r.$$unclean = r.get(0).childNodes;
}
return r;
} else {
return $(document.createElement(a),document);
}
};
$.fn.appendTo = function() {
var self = this;
var a = arguments;
return this.each(function(){
for ( var i = 0; i < a.length; i++ ) {
if ( self.$$unclean )
$(a[i]).append( self.get() );
else
$(a[i]).append( this );
}
});
};
$.clean = function(a) {
var r = [];
for ( var i = 0; i < a.length; i++ ) {
if ( a[i].constructor == String ) {
// Cool, but has scary side-effects
//a[i] = a[i].replace( /#([a-zA-Z0-9_-]+)/g, " id='$1' " );
//a[i] = a[i].replace( /\.([a-zA-Z0-9_-]+)/g, " class='$1' " );
var div = document.createElement("div");
div.innerHTML = a[i];
for ( var j = 0; j < div.childNodes.length; j++ )
r[r.length] = div.childNodes[j];
} else if ( a[i].length ) {
for ( var j = 0; j < a[i].length; j++ )
r[r.length] = a[i][j];
} else {
r[r.length] = a[i];
}
}
return r;
};
// Frequently-used Accessors
window.cssQuery = $.Select;
document.getElementsByClass = function(a){return $.Select("."+a)};
document.getElementsBySelector = $.Select;
// Make Xpath Axes Sane
//var re = new RegExp( "/?descendant::", "i" );
//t = t.replace( re, " " );
//var re = new RegExp( "/?child::", "i" );
//t = t.replace( re, "/" );
// If only...
//var re = new RegExp( "/?following-sibling::", "i" );
//t = t.replace( re, " + " );
//var re = new RegExp( "/?preceding-sibling::", "i" );
//t = t.replace( re, " ~ " );
//var re = new RegExp( "/?self::", "i" );
//t = t.replace( re, "" );
//var re = new RegExp( "/?parent::", "i" );
//t = t.replace( re, " .. " );
// following
// preceding
// ancestor
// ancestor-or-self
// descendant-or-self
// Deprecated
//style: function(a,b){ return this.css(a,b); },
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment