/* * jQuery htmlDoc "fixer" - v0.2pre - 12/15/2010 * http://benalman.com/projects/jquery-misc-plugins/ * * Copyright (c) 2010 "Cowboy" Ben Alman * Dual licensed under the MIT and GPL licenses. * http://benalman.com/about/license/ */ (function(b){var c=/<(\/?)(html|head|body)(\s+[^>]*)?>/ig,a="hd"+ +new Date();b.htmlDoc=function(g){var f=b([]),e,d;e=g.replace(c,function(i,l,k,j){var h=f.length,m={};if(!l){f=f.add("<"+k+"/>");if(j){b.each(b("")[0].attributes,function(o,n){m[n.name]=n.value})}f.eq(h).attr(m)}return"<"+l+"div"+(l?"":' id="'+a+h+'"')+">"});if(f.length){d=b("
").html(e);b.each(f,function(j,h){var k=d.find("#"+a+j).before(f[j]);f.eq(j).html(k.contents());k.remove()});return d.children()}return b(g)}})(jQuery);