Documentation

User talk:Djot

From jQuery JavaScript Library

Jump to: navigation, search


djot's place ...

Create a jQuery cheatsheet!!





		jquery_pages = new Array("Ajax", "Attributes", "Core", "CSS", "Effects", "Events", "Manipulation", "Selectors", "Traversing", "Utilities");
		jquery_url = 'http://docs.jquery.com';

		this_col = 1;
		for (var i = 0; i <= jquery_pages.length-1; i++) {
			if (i > 0) {
				this_rest = i % 2;
				if (this_rest == 0) {
					this_col++;
				}
			}

			$("#cheatsheet_"+this_col).append('<div id="' + jquery_pages[i] + '" style="border: 1px solid black; padding: 10px 2px 10px 2px;"></div>');
			$("#cheatsheet_work").append('<div id="' + jquery_pages[i] + '_work" style="visibilty: hidden; display: none;"></div>');
		}
	
		$("#load").bind("click", function() {
			for (var i = 0; i <= jquery_pages.length-1; i++) {
				$('#' + jquery_pages[i] + '_work').load(jquery_url + '/' + jquery_pages[i] + ' #bodyContent');
			}
		});

		$("#parse").bind("click", function() {
			for (var i = 0; i <= jquery_pages.length-1; i++) {
				$("#" + jquery_pages[i] + "_work" + " tr.option").each(
					function(){
						
						this_linktext = $(this).find("a").html();
						this_linktext = this_linktext.replace(/\( /g, "(");
						this_linktext = this_linktext.replace(/ \)/g, ")");
						
						$("#" + jquery_pages[i]).append('<a href="' + jquery_url + $(this).find("a").attr("href") + '" style="font-family: tahoma; font-size: 10px; color: black; text-decoration: none;" target="_blank">' + this_linktext + "</a>");
						this_result="";
						if (!$(this).find("span a").html()) { this_result = $(this).find("span").html(); }
						else { this_result = $(this).find("span a").html(); }
						$("#" + jquery_pages[i]).append('<span style="padding-left: 10px; font-family: tahoma; font-size: 10px; color: dimgray;">Returns: ' + this_result + '</span><br>');
					});
			}

			for (var i = 0; i <= jquery_pages.length-1; i++) {
				$("#" + jquery_pages[i]).prepend('<a style="font-family: tahoma; font-size: 12px; font-weight: bold; color: black;" href="' + jquery_url + '/' + jquery_pages[i] + '" target="_blank">'+ jquery_pages[i] +':</a><br>');
				$("#" + jquery_pages[i] + "_work").hide();
				$("#cheatsheet_work").hide();
			}

		});





<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" 
                    "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
  <script src="http://code.jquery.com/jquery-latest.js"></script>
  
  <script>
  $(document).ready(function(){
    




		jquery_pages = new Array("Ajax", "Attributes", "Core", "CSS", "Effects", "Events", "Manipulation", "Selectors", "Traversing", "Utilities");
		jquery_url = 'http://docs.jquery.com';

		this_col = 1;
		for (var i = 0; i <= jquery_pages.length-1; i++) {
			if (i > 0) {
				this_rest = i % 2;
				if (this_rest == 0) {
					this_col++;
				}
			}

			$("#cheatsheet_"+this_col).append('<div id="' + jquery_pages[i] + '" style="border: 1px solid black; padding: 10px 2px 10px 2px;"></div>');
			$("#cheatsheet_work").append('<div id="' + jquery_pages[i] + '_work" style="visibilty: hidden; display: none;"></div>');
		}
	
		$("#load").bind("click", function() {
			for (var i = 0; i <= jquery_pages.length-1; i++) {
				$('#' + jquery_pages[i] + '_work').load(jquery_url + '/' + jquery_pages[i] + ' #bodyContent');
			}
		});

		$("#parse").bind("click", function() {
			for (var i = 0; i <= jquery_pages.length-1; i++) {
				$("#" + jquery_pages[i] + "_work" + " tr.option").each(
					function(){
						
						this_linktext = $(this).find("a").html();
						this_linktext = this_linktext.replace(/\( /g, "(");
						this_linktext = this_linktext.replace(/ \)/g, ")");
						
						$("#" + jquery_pages[i]).append('<a href="' + jquery_url + $(this).find("a").attr("href") + '" style="font-family: tahoma; font-size: 10px; color: black; text-decoration: none;" target="_blank">' + this_linktext + "</a>");
						this_result="";
						if (!$(this).find("span a").html()) { this_result = $(this).find("span").html(); }
						else { this_result = $(this).find("span a").html(); }
						$("#" + jquery_pages[i]).append('<span style="padding-left: 10px; font-family: tahoma; font-size: 10px; color: dimgray;">Returns: ' + this_result + '</span><br>');
					});
			}

			for (var i = 0; i <= jquery_pages.length-1; i++) {
				$("#" + jquery_pages[i]).prepend('<a style="font-family: tahoma; font-size: 12px; font-weight: bold; color: black;" href="' + jquery_url + '/' + jquery_pages[i] + '" target="_blank">'+ jquery_pages[i] +':</a><br>');
				$("#" + jquery_pages[i] + "_work").hide();
				$("#cheatsheet_work").hide();
			}

		});





  });
  </script>
  
</head>
<body>
  
<button id="load">load</button>Loads all jQuery Reference API pages (wait until loading has finished!)<br>
<button id="parse">parse</button>Parse API pages and create cheatsheet table<br>
<table border="0">
<tr>
<td id="cheatsheet_1" style="vertical-align: top;"></td>
<td id="cheatsheet_2" style="vertical-align: top;"></td>
<td id="cheatsheet_3" style="vertical-align: top;"></td>
<td id="cheatsheet_4" style="vertical-align: top;"></td>
<td id="cheatsheet_5" style="vertical-align: top;"></td>
</tr>
</table>

<div id="cheatsheet_work" style="border: 2px solid red;"></div>


</body>
</html>