Author Archives: deanoj

Custom event creation in legacy internet explorer

Legacy IE only supports synthetic events of predefined types. It does however allow custom properties to be set on the event object, which allows us to simulate custom events. var ev = document.createEventObject(); ev.eventType = ‘mycustomevent’; ev.data = ‘some string, object or array can go here’; target.fireEvent(’ondataavailable’, ev);

Posted in JavaScript | Tagged , , | Leave a comment

Cross browser javascript event handler

Simple cross browser event handler function, that prevents the default action of the element (not following a link for example) function handler(ev) { var event = ev || window.Event, target = event.currentTarget || event.srcElement;   // do somthing… ev.preventDefault ? ev.preventDefault() : ev.returnValue = false; }

Posted in JavaScript | Tagged | Leave a comment

Eclipse Indigo Software update URLs

Update URLs for the eclipse plugins I need. Subclipse: http://subclipse.tigris.org/update_1.8.x JBoss Tools: http://download.jboss.org/jbosstools/updates/development/indigo/ JBoss VM Arguments: -Xms256m -Xmx512m

Posted in Web Development | Tagged , , | Leave a comment

Fetch a collection by custom filter in Magento

Example of fetching categories in Magento and filtering by a custom attribute: $categories = Mage::getModel(’catalog/category’)->getCollection(); $categories->addAttributeToSelect(’name’); $categories->addAttributeToFilter(’featured_category’, 1);   foreach($categories as $key => $category) { echo $category->getName(); }

Posted in Magento | Tagged | Leave a comment

Javascript Date.format prototype method.

The following code add’s a format function to the Date objects prototype. It simulates the PHP date.format() function. Date.prototype.format = function(format) { var returnStr = ”; var replace = Date.replaceChars; for (var i = 0; i < format.length; i++) { var curChar = format.charAt(i); if (i – 1 >= 0 && format.charAt(i – 1) == [...]

Posted in JavaScript | Tagged , | Leave a comment

WordPress and OSX Lion local install sluggish performance fix

A mirror of a wordpress installlation on my Macbook ran very sluggish. I was using OSX Lion. The fix was to optimise all the MySQL database tables for the installation! Simple!

Posted in Web Development | Tagged , , | Leave a comment

Disable or customise the tap highlight colour on mobile safari.

When you tap a link, button, or other active element with mobile safari, a brief dark grey highlight appears indicating the element was tapped. The colour of the highlight can be customised, or disabled with the following CSS rule. -webkit-tap-highlight-color: rgba(0,0,0,0); // disable

Posted in Mobile Web | Tagged , , , | Leave a comment

Javascript closures within an iteration.

An example of passing in the iteration value to a closure function using a self executing anonymous function. for (var i = 0; i < links.length; i++) { links[i].addEventListener(’click’, (function (n) { return function () { items[n].show(); // do something }; })(i)); }

Posted in JavaScript | Tagged | Leave a comment

GIT clone and private SSL certificates

To allow GIT to use SSL connections with a private certificte env GIT_SSL_NO_VERIFY=true git clone https://www.example.com/private…

Posted in Git | Leave a comment

Custom checkbox and select element styling in webkit browsers.

You can fully customise the style of checkboxes, radio buttons, select elements etc.. in webkit browsers. An example of a custom checkbox is show below. The key CSS rule is -webkit-appearance: none;. This then allows you style the element as a normal block element. Been webkit only, its safari and chrome browsers only at the [...]

Posted in Web Development | Tagged , , | Leave a comment