Javascript
Google Analytics - How to manually Track Clicks on Outbound Links
You can use Google Analytics to track clicks on links that lead away from your site. Because links that lead away from your site are not automatically tracked, you will need to manually tag all outbound links you want to track. To do this, you'll add some JavaScript customizations to your page and to the links you want to track.
3 comments for Google Analytics - How to manually Track Clicks on Outbound Links
Drupal - Adding Javascript to your module
When creating your own Drupal module, you may need to add some styling or Javascript to improve the usability of your module. Here is how to do it.
drupal_add_js(drupal_get_path('module', 'MODULE_NAME') . '/common.js');
Similarly you can add CSS to your module as well
drupal_add_css(drupal_get_path('module', 'MODULE_NAME') . '/styles.css');
1 comments for Drupal - Adding Javascript to your module
Prototype JS - Determine if an object exists in the page loaded
I'm so use to using jQuery that I usually don't have to look up documentation on how to use certain functions. They almost come naturally because it's so English-like! Unfortunately Magento uses Prototype as it's native choice of Javascript Frameworks. I sure wish they would have chosen jQuery!
0 comments for Prototype JS - Determine if an object exists in the page loaded
Javascript - Passing Multiple Parameters through setTimeout
One of the problems that I've faced with Javascript is passing multiple parameters through the setTimeout function. I found this little snippet on the internet a few months ago and would like to share it with you. I don't know who the original author is so I could not give him/her proper credit. Thanks!
10 comments for Javascript - Passing Multiple Parameters through setTimeout
How to define your own JavaScript class
There are several ways to define a class in Javascript. I will be listing my favorite method below (JSON Method). It's important to note that there are no real classes in JavaScript. Everything is considered an object. So below is our class definition:
7 comments for How to define your own JavaScript class
J-Crop - the jQuery image cropping plugin
Jcrop is the quick and easy way to add image cropping functionality to your web application. It combines the ease-of-use of a typical jQuery plugin with a powerful cross-platform DHTML cropping engine that is faithful to familiar desktop graphics applications.
0 comments for J-Crop - the jQuery image cropping plugin
MooTools - Free Syntax Highlighting Class
Lighter.js is a free syntax highlighting class developed with MooTools. It was created with the MooTools developer in mind and takes advantage of many of the Framework's features. Using it can be as simple as adding a single script to your web page, selecting the elements you wish to highlight, and Lighter.js takes care of the rest.
2 comments for MooTools - Free Syntax Highlighting Class
Get the filename from upload form using Javascript
I needed a way to access the filename of a file being uploaded or attached using the input file from a form. So, I created a nice little function to achieve this. Hopefully it comes in handy for someone.
<script type="text/javascript">
function getNameFromPath(strFilepath) {
var objRE = new RegExp(/([^\/\\]+)$/);
var strName = objRE.exec(strFilepath);
if (strName == null) {
return null;
}
else {
return strName[0];
}
}
</script>
9 comments for Get the filename from upload form using Javascript
Javascript - Capitalize Each Word in a String
This is a great little function that I whipped up and use to capitalize every word in a string. I can't tell you how many times I've had to use this. Hope you find it useful as I have!
<script type="text/javascript">
function wordToUpper(strSentence) {
return strSentence.toLowerCase().replace(/\b[a-z]/g, convertToUpper);
function convertToUpper() {
return arguments[0].toUpperCase();
}
}
</script>
1 comments for Javascript - Capitalize Each Word in a String
Datejs - An Open-Source JavaScript Date Library
Datejs is an open-source JavaScript Date Library. Comprehensive, yet simple, stealthy and fast. Datejs has passed all trials and is ready to strike. Datejs doesn’t just parse strings, it slices them cleanly in two.