blog . taylorbeseda

Archive/RSS/Ask/Submit

blog . taylorbeseda Denver based web-engineer/recovering student into making awesome web things, homebrewing beer, backpacking, running, Jeeping, and most things rad.
Posts tagged with code.

Clear <select> Element with jQuery

This one was tricky. Clearing a select with a unique id using $(‘#mySelectId’).val(”), $(‘#mySelectId’).selected(”), or $(‘#mySelectId’).reset() will fail/break. Even setting the selectedIndex to -1 won’t work… Unless you specify the first object in the array of objects with that unique id (even if there is only one). Example:

$('#mySelectId')[0].selectedIndex = -1

#javascript   #forms   #jquery   #code  

Wade's color picker for Mac OS X developers→

Excellent! Even better than the OS X HexPicker

(via stevenf)

#mac   #code   #color  

Create array with lines of plain text from a textarea.

#javascript   #code  

Is it conceited that I add

// *hiyah* ninja!

to the end of my best lines of jQuery?

#jquery   #ninja   #javascript   #code  
[Flash 9 is required to listen to audio.]

If you write

code
for a living you have to hear Jonathan Coulton’s “Code Monkey”!
#music   #code  

Status bar styles for iPhone web apps

webkitbits:

To change the status bar, the short bar with the time and carrier information, style for full screen web apps, place the following code in the <head> tag:

<meta name="apple-mobile-web-app-status-bar-style" content="black" />

Possible options include default, black, and black-translucent, which overlays the black strip on top of your content.

Note that using black-translucent changes the viewable height of the page and should be accommodated for in your CSS.

Now, that’s slick!

#iphone   #webkit   #code  

jQuery Playground

The code snippet I use to quickly set up a place to play with jQuery:

#jquery   #code  

Quick twitter JSON call

Requires jQuery, and a some HTML.

 
function getTwitter(sn) {
	var url = "http://twitter.com/status/user_timeline/"+sn+".json?count=1&callback=?";
	$.getJSON(url, function(data){
		$.each(data, function(i, item) {
			var image = item.user["profile_image_url"];
			var text = item["text"];
		//changes the image size to 73x73px	
			image = image.replace(/normal/, "bigger");
		});        
	}); 
   //puts the image src in an existing img id=+sn+img
	$("img#"+sn+"img").attr("src", image);
   //puts the latest tweet in an existing span id=+sn+tweet
	$("span#"+sn+"tweet").text(text);
}  
//do it  
getTwitter("tbeseda");

This is mostly to test syntax highlighting on tumblr, but I thought I’d share some code anyway.

#Twitter   #jquery   #javascript   #code   #json   #tumblr