We started the process of getting rid of deprecated methods in order to migrate to jQuery 1.9, but the removal of $.browser was a no go for us. I pulled jQuery's browser detection code and packaged it into a closure, with a few minor changes for past encountered bugs, and then simply replaced all instances of "$.browser" in my scripts with "browser". Add this script above the rest of your scrips and make the replace and you'll have your browser detection back. Things like bgiframe() are still necessary for some of us supporting B2B clients on antique browsers, it just isn't possible to use feature detection for some of these cases. I noticed in the comments section on jquery.com for the release of 1.9.1 some people asking for this, hope this helps.
For some reason today, boredom or whatever, I was hell bent on getting the Angry Birds theme song onto my iPhone to replace that stupid Marimba ringtone. First task was to find or make the ringtone, I found one offered up for free here http://www.angrybirdsnest.com/2010/08/angry-birds-theme-song-ringtone/. Not quite sure yet how I was going to manage getting the ringtone on to my phone, I copied the link for the theme song from the web page, http://www.angrybirdsnest.com/wp/wp-content/uploads/2010/08/Angry-Birds-Main-Theme-Song.m4r, and emailed it to myself.
Now that I had the link, through trial and error I figured out the rest. There are a couple of apps you'll need to have in order to download the ringtone and get it to the proper place on your iPhone. The first app you'll need is iDownloader, you can find this app in the appstore. The second app you'll need is iFile, which can be found in Cydia, yes your phone will need to be jailbroken to accomplish this, I know I'll see comments about how you could do this all with iFile, or use iFile and the Safari downloader from Cydia. Well i couldn't get the webserver on iFile to start and I happened to have these apps on my iPhone already so this is what I used to make it happen, if you already knew how to do this you could write your own blog post about it...
- Start by opening iDownloader and pasting the link into the Address bar, you'll be asked if you want to download the file, let the file download.
- Once the download is finished launch iFile, click the gear on the left of the tab bar to open the Preferences page, turn on Hidden Files and Application Names
- In iFile, navigate to /var/mobile/Applications/iDownloader/Documents/Downloads/, you should find the File you downloaded, Angry-Birds-Main-Theme-Song.m4r. Click Edit, Select the File, click the far right action icon on the Tab bar and select Copy
- Now in iFile navigate to /Library/Ringtones/, click Edit, click the same icon as the previous step and select Paste
- Open the settings app, click on Sounds, Ringtone, you should now see the ringtone in the list, select it and enjoy
Sure you can use this technique for any ringtone file you can find on the internet, but I think the Angry Birds theme song makes an excellent ringtone, enjoy.
In your html template or page add a nojs class to your html node and a script tag in the head section below your title changing the className to js:
The tabindex is absolutely necessary for controlling the tab order through a really long form, from a usability and accessibility standpoint. This is probably not the preferred way to do this, you should be setting the tabindex attribute on all of your input elements in your html. Now if you work with lazy developers, that often forget to set the tabindex, you may find this to be an acceptable solution.
Quick walk through:
- The outside function is your document ready function in jQuery (explaining for those new to jQuery)
- The tabindex variable is there to keep track of the index across multiple forms on the page (another reason you may want to use something like this, if your view code is modular and split into a bunch of snippets or includes)
- The select grabs all the input and select elements on the page we then exclude the hidden input boxes
- We then set the tabindex and increment the variable
Another great "little" solution with jQuery. Needed a simple way to protect all the forms on our site from being double submitted. There was an attempted solution in place on our app, that added an onsubmit to every form with a function above it called ignoreDoubleSubmit that tried to trap the event of the button was clicked and not allow it to be clicked again. The problem was the event for the button wasn't present when the form was submitted so it would silently error out with a blink in the Firebug console. After weeks of fighting to have it fixed, I removed the code and reimplemented a working solution with jQuery
I was recently in need of a stock quote web service in order to display quote information and charts for a corporate website I was working on, so I started looking around for something, free of course. I kept reading that the most common example of web as a service is the stock quote example, but I didn't really find any examples that gave me a warm and fuzzy, everyone seemed to be scraping the html from a page. Doesn't seem to be much out there, in the way of quote services for free, but I did come across a yahoo download service and a few half written examples, where you can fetch quote information from Yahoo in .csv format, with a 20 minute delay of course. I've also added a 1-day small chart and a 5-day large chart image by passing the symbol into Yahoo's basic chart image url.
I basically needed the update button to be the default action on clicking enter in the form, but there were multiple submit buttons in my form and they weren't in the order I needed due to UI design. This was a quick and dirty solution to select an html submit button and make it the default when a user clicks enter from certain or all input elements on the form. It could be tweaked to give specific behavior to specific types of input boxes, such as invoking a tab on enter in between required elements, but the general idea is using jQuery to click the default button when the user hits enter.
Ran into some issues on some of our Java sites today and needed a quick fix to protect the sites from malicious Cross Site Scripting (XSS) attempts. If you're not aware of what XSS is and have websites that have sensitive user data, you may want to read up, you're probably vulnerable, which means your users are vulnerable. I'm not claiming this is a perfect solution, but it was easy to implement and corrected the vulnerabilities with form and url injection. We basically have a Servlet Filter that's going to intercept every request sent to the web application and then we use an HttpServletRequestWrapper to wrap and override the getParameter methods and clean any potential script injection.
I'm sure the cleanXSS replacements aren't the most efficient way of doing this, you could replace it StringEscapeUtils.escapeHtml from commons lang to simplify it a little, it's up to you, it all depends on what your site is doing and whether it's going to be a pain having all the html escaped, you could also adjust the url-pattern of the filter to be more specific to your application urls, so that everything under your app isn't running through the filter.
Some things to be aware of with this approach, you'll need to account for what you've encoded or in some cases you'll end up with weird characters in your database and possibly in validation of your input boxes. Some would recommend a more positive validation rather than negative validation and only allow a certain range of characters, it's up to you, but it is something to think about.
Some notes on this approach, it's old, you should checkout the OWASP website for the latest projects to prevent XSS and other exploits.
I'm putting this post out there for Javier, who reads my blog, but doesn't understand a word of it, and the answer to that burning question is, no my wife won't let me date that girl from work ;)