Browzor says

Browser versions and type

June 9th, 2009 . by Sajeev

check your browser version and type with below javascript. Browzor.versoion will give the version of the browser used.

JavaScript:
  1. Browzor = {
  2.     version: (navigator.userAgent.match(/.+(?:rv|it|ra|ie|me)[\/: ]([\d.]+)/i) || [])[1],
  3.     IE : !!(window.attachEvent && !window.opera),
  4.     Mozilla: /mozilla/i.test(navigator.userAgent) && !/(compatible|webkit)/i.test( navigator.userAgent),
  5.     Netscape : !!document.layers,
  6.     Opera : !!window.opera,
  7.     WebKit : /AppleWebKit/i.test(navigator.userAgent),
  8.     Gecko : /gecko/i.test(navigator.userAgent) && ! /KHTML/i.test(navigator.userAgent),
  9.     Chrome: /chrome/i.test(navigator.userAgent),
  10.     MobileSafari : !!navigator.userAgent.match(/Apple.*Mobile.*Safari/),
  11.     Safari: /webkit/i.test( navigator.userAgent) && !/chrome/i.test(navigator.userAgent)
  12. }

skyfire

June 8th, 2009 . by Sajeev

This is really happy news of flash/flex developers. Skyfire says it can play both Flash 10 and Silverlight 2.0. Not sure how happy Adobe will be though, they’ve always resisted full Flash on mobile for “performance” reasons.

check for more details..

Project Natal, fully hands-free control system

June 3rd, 2009 . by Sajeev

This is some pretty impressive interactive technology:

Project Natal

Mr Spielberg said he had always stated that "the main barrier stopping people getting into video games was the complexity of a games controller," and that Natal was "a whole new world".

This is really true, I am not at all interested in playing game because of the same reason. And this technology seems to be really impressive. Hope to experience this in near future.

Pattu Padi

May 28th, 2009 . by Sajeev

Movie Name: Seetha (1960)
Singer: Susheela P
Music Director: Dakshina Murthy
Lyrics: Abhaya Dev
Year: 1960
Director: Kunjako M
Actors: Kushala Kumari, Latheef PA, Prem Nazir

Pattu padi urakam njan thamarappo paithale
Kettu kettu nee urangen karalinte kaathale
Karalinte kaathale

Ninnalee pulmadam poomeda yayeda (2)
Kanna nee enikku samraajyam kai vanneda
Vanneda (pattu padi)

Rajavaayi theerum nee oru kalam omane (2)
Marakkathe annu samjatham sree ramane
Ramane (pattu padi)

Rari raro rariro rariraro rariro

window.setTimeout to JavaScript.doLater

April 6th, 2009 . by Sajeev

Check the syntax for window.setTimeout for mozilla and IE, u can see that it is different in both the browzor. Below is the one method, which will help in unifying this for both browzors.

Syntax
timeoutID = JavaScript.doLater(thisArg, func, delay, [, arg1[, arg2[, ...]]]);

JavaScript:
  1. JavaScript = {
  2.      /*
  3.      * queue for later call
  4.      * target - target type object where method exist
  5.      * method - method to execute after delay milliseconds
  6.      * delay - is the number of milliseconds that the function call should be delayed by (default 0)
  7.      * use - JavaScript.doLater(this, method);
  8.      */
  9.     doLater : function(target, method, delay)
  10.     {
  11.         delay = delay || 0;
  12.         var parameters = (Browzor.IE) ? [target, method] : [JavaScript.createProxy(target, method), delay];
  13.         for(var i = 3; i <arguments.length; i++) {
  14.             parameters.push(arguments[i]);
  15.         } 
  16.         if(Browzor.IE) return window.setTimeout(JavaScript.createProxy.apply(JavaScript, parameters), delay);
  17.         else return window.setTimeout.apply(window, parameters);
  18.     }
  19. }

Javascript Delegate and Proxy methods

February 11th, 2009 . by

Below method can solve the problem of scoping issues with methods and passing parameters for a Delegated events

JavaScript:
  1. JavaScript = {
  2.      /*
  3.      * delegate proxy method.
  4.      * target - target type object where method exist
  5.      * method - method to execute
  6.      * use - JavaScript.createProxy(this, method, [parameter,[...]]);
  7.      */
  8.     createProxy : function(target, method)
  9.     {
  10.         if(!method || !target)return;
  11.         //array of all parameters if any
  12.         var parameters = [];
  13.         for(var i = 2; i <arguments.length; i++) {
  14.             parameters.push(arguments[i]);
  15.         }
  16.         // delegate method which will be executed
  17.         var proxy = function()
  18.         {
  19.             var actualParameters = [];
  20.             for(var i = 0; i <arguments.length; i++) {
  21.                 actualParameters.push(arguments[i]);
  22.             }
  23.             return method.apply(target, actualParameters.concat(parameters));
  24.         };
  25.         return proxy;
  26.     }
  27. }

Find function name in javascript

December 16th, 2008 . by Sajeev

This will help u get the name of the function in javascript but won’t work for anonyms functions

JavaScript:
  1. Function.prototype.getName = function(){
  2.     var m = this.toString().match(/^\s*function\s+([^\s\(]+)/);
  3.     return  m ? m[1].trim() : null;
  4. };

String utilities

December 16th, 2008 . by Sajeev
JavaScript:
  1. /*
  2. * String trim
  3. */
  4. String.prototype.trim = function (chars){
  5.     return this.rtrim(chars).ltrim(chars);    
  6. };
  7. /*
  8. * String left trim
  9. */
  10. String.prototype.ltrim = function (chars){
  11.     chars = chars || "\\s";
  12.     return this.replace(new RegExp("^[" + chars + "]+", "g"), "");
  13. };
  14. /*
  15. * String right trim
  16. */
  17. String.prototype.rtrim = function rtrim(chars){
  18.     chars = chars || "\\s";
  19.     return this.replace(new RegExp("[" + chars + "]+$", "g"), "");
  20. };

Igonre Whitespace in the DOM

December 16th, 2008 . by Sajeev

The presence of whitespace in DOM will become a problem in Mozilla. This will occurs in cases like, when u create html in server side like jsp and injecting the output as string into DOM node. IE will automatically ignore all the whitespace but not Mozilla!. This method can do this for you.

JavaScript:
  1. function ignoreWhiteSpace(stringXml) {
  2.     if(typeof stringXml != 'string')return;   
  3.     stringXml = stringXml.trim("\\t\\n\\r\\s");
  4.     stringXml = stringXml.replace(/<!--[\S\s]*?-->/g,"");       
  5.     /*
  6.      * \s includes non-breaking spaces (and also some other characters).
  7.      */
  8.      //stringXml = stringXml.replace(/>[\t\n\r\x20]+</g,"><"); 
  9.     stringXml = stringXml.replace(/>[\t\n\r\x20]*(.*?)[\t\n\r\x20]*</g,">$1<")
  10.     return stringXml;   
  11. }

See: https://developer.mozilla.org/en/Whitespace_in_the_DOM

append class name to DOM node

December 16th, 2008 . by Sajeev

Use this safe method to append class name to an existing node in DOM. This method will append both class and className attribute.

JavaScript:
  1. function appendClass (node, classname){     
  2.     var newClassName;
  3.     var appendName;
  4.     if(typeof classname == "string" && classname.trim().length> 0)
  5.     {
  6.         appendName = classname.trim();
  7.     }else if(typeof classname == 'object' && classname.constructor == Array && classname.length> 0){
  8.         appendName = classname.join(" ");          
  9.     }else
  10.     {
  11.         return;
  12.     }       
  13.     newClassName = node.className ? (node.className + " " + appendName) : (appendName);           
  14.     node.setAttribute("class", newClassName);
  15.     node.setAttribute("className", newClassName);   
  16. }

« Previous Entries