Archive for the ‘JavaScript’ Category

Javascript: underscore.js nice javascript utilities

Saturday, October 2nd, 2010

JavaScript: Generate UUID and GUID

Thursday, September 16th, 2010
function S4() {

   return (((1+Math.random())*0x10000)|0).toString(16).substring(1);
function guid() {
   return (S4()+S4()+"-"+S4()+"-"+S4()+"-"+S4()+"-"+S4()+S4()+S4());


'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(c) {
    var r = Math.random()*16|0, v = c == 'x' ? r : (r&0x3|0x8);
    return v.toString(16);

Source: Stackoverflow: How to create GUID and UUID in Javascript



Math.uuid() // RFC4122 v4 UUID

Math.uuid(17) // 17 digits, base 62 (0-9,a-Z,A-Z)

Math.uuid(5, 10) // 5 digits, base 10

Math.uuid(8, 16) // 8 digits, base 16

Javascript: Online JSON Formatter & Java JSON Serialization

Sunday, March 7th, 2010

Online Formatter

Java JSON serialization

FlexJSON (nothing to do with Adobe Flex)

javascript: Get parent window location href from an iFrame

Monday, February 22nd, 2010

Assuming the iframe is from the same domain that the top window, use frameElement.ownerDocument to get to the parent document.

var topWindowHref = window.frameElement.ownerDocument.location.href

javascript: Remove items from an array

Monday, February 22nd, 2010

From John Resig Javascript array remove

Array.prototype.remove = function(from, to) {
  var rest = this.slice((to || from) + 1 || this.length);
  this.length = from < 0 ? this.length + from : from;
  return this.push.apply(this, rest);


// Remove the second item from the array
// Remove the second-to-last item from the array
// Remove the second and third items from the array
// Remove the last and second-to-last items from the array

JavaScript: JSONP Quick Ref & Service List

Sunday, January 17th, 2010

JSONP quick sample with Twitter

var tweeturl = "";
  $.getJSON(tweeturl, function(data){
	      $.each(data.results, function(i, item) {
		        .addClass(i%2 ? 'even' : 'odd')
			.prepend("<img src='" + item.profile_image_url + "' />")



         "created_at":"Mon, 08 Mar 2010 02:16:46 +0000",
         "text":"Geaux Haiti! "Far Away" by Lecrae... Powerful song for a honorable cause. Keep praying for Haiti brothers and...",
         "source":"<a href="" rel="nofollow">Facebook</a>"

Twitter JSON Search result

Services supporting JSONP

Feel free too add new one as comment I will update this page

Javascript: Date library datejs

Friday, September 4th, 2009

HTML: AJAX Modal Dialog Box

Wednesday, March 25th, 2009

Here are some JQuery puglins for creating Modal Dialog Box:

  • Facebox: Facebook L&F, does have some images for corners.
  • SimpleModal: Seems simple and lightweight.
  • ThickBox: Seems complete but quite heavy (also, not very well maintained, last change log was from 2007).

Dojo: config settings

Saturday, October 4th, 2008

Add the djConfig to the script tag.

<script type="text/javascript" src="dojo-directory/dojo.js"
djConfig="isDebug: true, parseOnLoad: true"> </script>

For complete list of variables check out the dojo/_base/_loader/bootstrap.js file.
Click here to see the one in trunk.