Javascript

  • warning: Creating default object from empty value in /home1/nate01/public_html/modules/taxonomy/taxonomy.pages.inc on line 33.
  • strict warning: Non-static method view::load() should not be called statically in /home1/nate01/public_html/sites/all/modules/views/views.module on line 1113.
  • strict warning: Declaration of views_handler_field::query() should be compatible with views_handler::query($group_by = false) in /home1/nate01/public_html/sites/all/modules/views/handlers/views_handler_field.inc on line 1147.
  • strict warning: Declaration of views_handler_argument::options_validate() should be compatible with views_handler::options_validate($form, &$form_state) in /home1/nate01/public_html/sites/all/modules/views/handlers/views_handler_argument.inc on line 917.
  • strict warning: Declaration of views_handler_argument::query() should be compatible with views_handler::query($group_by = false) in /home1/nate01/public_html/sites/all/modules/views/handlers/views_handler_argument.inc on line 917.
  • strict warning: Declaration of views_handler_sort::options_validate() should be compatible with views_handler::options_validate($form, &$form_state) in /home1/nate01/public_html/sites/all/modules/views/handlers/views_handler_sort.inc on line 165.
  • strict warning: Declaration of views_handler_sort::options_submit() should be compatible with views_handler::options_submit($form, &$form_state) in /home1/nate01/public_html/sites/all/modules/views/handlers/views_handler_sort.inc on line 165.
  • strict warning: Declaration of views_handler_sort::query() should be compatible with views_handler::query($group_by = false) in /home1/nate01/public_html/sites/all/modules/views/handlers/views_handler_sort.inc on line 165.
  • strict warning: Declaration of views_handler_filter::options_validate() should be compatible with views_handler::options_validate($form, &$form_state) in /home1/nate01/public_html/sites/all/modules/views/handlers/views_handler_filter.inc on line 587.
  • strict warning: Declaration of views_handler_filter::query() should be compatible with views_handler::query($group_by = false) in /home1/nate01/public_html/sites/all/modules/views/handlers/views_handler_filter.inc on line 587.
  • strict warning: Declaration of views_plugin_query::options_submit() should be compatible with views_plugin::options_submit($form, &$form_state) in /home1/nate01/public_html/sites/all/modules/views/plugins/views_plugin_query.inc on line 169.
  • strict warning: Declaration of views_plugin_row::options_validate() should be compatible with views_plugin::options_validate(&$form, &$form_state) in /home1/nate01/public_html/sites/all/modules/views/plugins/views_plugin_row.inc on line 136.
  • strict warning: Non-static method view::load() should not be called statically in /home1/nate01/public_html/sites/all/modules/views/views.module on line 1113.
  • strict warning: Declaration of views_plugin_pager_none::post_execute() should be compatible with views_plugin_pager::post_execute(&$result) in /home1/nate01/public_html/sites/all/modules/views/plugins/views_plugin_pager_none.inc on line 69.

jQuery SlideShow - Short and Sweet

$(function(){
    $('#slides img:gt(0)').hide();
    setInterval(function(){
        $('#slides :first-child').fadeOut().next('img').fadeIn(1000).end().appendTo('#slides');
    },6000);
});

Get the Base URL Javascript Function

function getBaseURL() {
    var url = location.href;  // entire url including querystring - also: window.location.href;
    var baseURL = url.substring(0, url.indexOf('/', 14));
 
 
    if (baseURL.indexOf('http://localhost') != -1) {
        // Base Url for localhost
        var url = location.href;  // window.location.href;
        var pathname = location.pathname;  // window.location.pathname;
        var index1 = url.indexOf(pathname);
        var index2 = url.indexOf("/", index1 + 1);
        var baseLocalUrl = url.substr(0, index2);
 
        return baseLocalUrl

Get URL arguments using Javascript - $_GET Variables

if (location.search != "")
{
	var x = location.search.substr(1).split(";")
	for (var i=0; i<x.length; i++)
	{
		var y = x[i].split("=");
		alert("Key '" + y[0] + "' has the content '" + y[1]+"'")
	}
}

Remove Newline from Text of Element / Convert \n to <br />

I was trying to write an if statement to perform some actions when a certain error message was present. I went round and round trying to figure out why the text of the element wouldn't match in my if statement. Turns out it was because there was a line break before the text which is considered content.

Tooltip Plugin - Cross Browser and Image Map Compatible

I tried several tooltip plugins for use with an image map. The only one that placed the tooltip where it should be placed when hover an area on the map was qTip

qTip is an advanced tooltip plugin for the ever popular jQuery JavaScript framework.

Built from the ground up to be user friendly, yet feature rich, qTip provides you with tonnes of features like rounded corners and speech bubble tips, and best of all... it's completely free under the MIT license!

Javascript Cookies Using jQuery Cookie Plugin

I chose to use the improved version of the jQuery Cookie Plugin with more functions as well as short/easy examples on how to use these functions.
(jQuery Cookie Project Page)

Ask For Confirmation When Leaving a Page

Ask for confirmation when leaving a page in javascript is useful when you have a multistep form or lengthy form that the user may expect to be saved. This code will execute whenever the page is about to be unloaded, to include clicking any links to a new page, using the forward/back buttons of the browser, and when using the address bar to go to a new site or page.

var warning = true;
window.onbeforeunload = function()
{ 
     if (warning) 
     {
    return 'You have made changes on this page that you have not yet confirmed.

Prevent the Enter Key From Submitting a Form: javascript char codes (key codes)

This snippet will prevent the enter key being pressed from submitting a form or clicking the button that is in focus. Replace #foo with the id, class, or element.

Syndicate content