Difference between revisions of "User:Prunc"

From Future Of Mankind
(Created page with "==Fairy Dust== <pre> var repeat; function testing(){ if (typeof jQuery != 'undefined'){ clearInterval(repeat); afterLoad(); // console.log("jQuery loaded..."); }else{...")
 
m
Line 26: Line 26:
 
function afterLoad(){
 
function afterLoad(){
  
$("table tr").each(function(){
+
jQuery("table tr").each(function(){
$(this).find("td").eq(1).prependTo($(this))
+
jQuery(this).find("td").eq(1).prependTo(jQuery(this))
 
})
 
})
  
 
var str = "\n\n\n{|\n\n";
 
var str = "\n\n\n{|\n\n";
$("table tr").each(function(){
+
jQuery("table tr").each(function(){
 
str += "|-\n";
 
str += "|-\n";
str += ( "| " + $(this).find("td").eq(0).text().trim().replace(/\n+/gim,"").replace(/\s+/gim, ' ') + "\n" );
+
str += ( "| " + jQuery(this).find("td").eq(0).text().trim().replace(/\n+/gim,"").replace(/\s+/gim, ' ') + "\n" );
str += ( "| " + $(this).find("td").eq(1).text().trim().replace(/\n+/gim,"").replace(/\s+/gim, ' ') + "\n" );
+
str += ( "| " + jQuery(this).find("td").eq(1).text().trim().replace(/\n+/gim,"").replace(/\s+/gim, ' ') + "\n" );
 
str += "\n";
 
str += "\n";
 
});
 
});

Revision as of 16:33, 16 February 2014

Fairy Dust


var repeat;
function testing(){
	if (typeof jQuery != 'undefined'){
		clearInterval(repeat);
		afterLoad();
	//	console.log("jQuery loaded...");
	}else{
		
	};
};
if (typeof jQuery == 'undefined') {
	var newscript = document.createElement('script');
		newscript.type = 'text/javascript';
		newscript.async = true;
		newscript.src = '//code.jquery.com/jquery-2.1.0.min.js';
	(document.getElementsByTagName('head')[0]||document.getElementsByTagName('body')[0]).appendChild(newscript);
	repeat = setInterval(testing,250);
} else {
	afterLoad();
//	console.log("jQuery already present...");
}
function afterLoad(){

	jQuery("table tr").each(function(){
	 jQuery(this).find("td").eq(1).prependTo(jQuery(this))
	})

	var str = "\n\n\n{|\n\n";
	jQuery("table tr").each(function(){
	 str += "|-\n";
	 str += ( "| " + jQuery(this).find("td").eq(0).text().trim().replace(/\n+/gim,"").replace(/\s+/gim, ' ') + "\n" );
	 str += ( "| " + jQuery(this).find("td").eq(1).text().trim().replace(/\n+/gim,"").replace(/\s+/gim, ' ') + "\n" );
	 str += "\n";
	});
	str += "|-\n|}\n";
	console.log(str);

}