Web 2.0 Training
 

Random Header :: Unpredictably Exciting

Rochak.js - Javascript class of common functions

rochakjs-javascript-class-of-common-functions

This class is a collection of basic and commonly used functions in JavaScript. I coded this class just to validate a form in one of my sites. But it turned out to be more than helpful. I hope it will be of some help for all the web developers.

If you want a new function added or face any difficulty, feel free to contact me.

  • Initialize:
    • Just include it at the very top of all the JavaScript file as:
      <script src="rochak.js" type="text/javascript">
      
  • Usage:
    • For example to trim a string:
      var str=rochak.trim(str);
  • Function List:
    1. lTrim(string):
      • Function to trim all the white spacing from the left side of any string.
    2. rTrim(string):
      • Function to trim all the white spacing from the right side of any string.
    3. trim(string):
      • Function to trim all the white spacing from left and right side of the string.
    4. isValidEmail(string):
      • Function to validate a typical email pattern.
    5. getType(variable_name):
      • Function to find the type of the variable. A Clone of PHP\’s “var_dump()” function.
    6. inArray(array, string):
      • Function to find if the sting is in the array. Clone of PHP\’s “in_array()” function.
    7. inArrayI(array, string):
      • Function to find if the sting is in the array. Clone of PHP\’s “in_array()” function. (its case insensitive)
    8. getMouseX(event):
      • Function to find the current X position of the mouse/cursor.
    9. getMouseY(event):
      • Function to find the current Y position of the mouse/cursor.
    10. getMouseXY(event):
      • Function to find the current X and Y positions of the mouse/cursor as an array.
    11. getBrowserName():
      • Function to return the name of the web browser.
    12. isBrowserIe():
      • Function to return “true” if the browser is “Microsoft Internet Explorer” else return “false“.
    13. isBrowserOpera():
      • Function to return “true” if the browser is “Opera” else return “false“.
    14. isBrowserNetscape():
      • Function to return “true” if the browser is “Firefox” or “Netscape” else return “false“.
    15. getTotalImages():
      • Function to return the number of images used in the current page.
    16. explode(delimiter, string):
      • Function to Split a string by a specified delimiter. A Clone of PHP\’s “explode” function.
    17. end(string / array):
      • Function to return the last charactor of a string or the last element of the array. A Clone of PHP\’s “end” function.

    To download right click the link and click on “Save link as” or “Save target as”.

  • rochak-1.0.js


Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • del.icio.us
  • Netvouz
  • DZone
  • ThisNext
  • MisterWong
  • Wists
  • BlinkList
  • Furl
  • IndianPad

If you liked my post, feel free to subscribe to my rss feeds

One Comment

  1. Thanks for this! The class saves me a lot of time! keep up the good work.

    4. Daniel Latter on October 18th, 2007 at 2:25 AM

3 Trackbacks

  1. Kramer auto Pingback[…] http://rochakchauhan.com/blog/2007/10/08/rochakjs-javascript-class-of-common-functions/ October 17, 2007 11:46 AM […]

  2. Kramer auto Pingback[…] There are many required functions which are not available in Native JavaScript.Get trim and more functions like trim() for JavaScript:{Link} […]

  3. By Functions in Javascript » TutorialCode.com on 14 December 2007 at 3:18 AM

    Kramer auto Pingback[…] http://rochakchauhan.com/blog/2007/10/08/rochakjs-javascript-class-of-common-functions/ […]

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*

  Wordpress Themes Protected By Wp Spam Blocker