Category Archives: Javascript

HTML 5 Framework for game development

Posted in Featured, HTML5, Javascript

Find actual javascript size of array

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 //find value in associative array for (i in tmpArr) {     console.log(i+’:'+tmpArr[i]+’, ‘); // outputs: one:First, two:Second, three:Third }   … Continue reading

Posted in Javascript

Javascript: checking if a function exists

It’s typeof to the rescue (again)! To check if a function exists before you try and call it (and get a nasty javasscript error), use typeof to check. Heres something I prepared earlier: 1 2 3 4 if(typeof window.myFunction == … Continue reading

Posted in Javascript

Calling a JavaScript function using JavaScript variable

Functions are first-class objects, so they can be properties of an object (in which case they are called methods) or even elements of arrays. If you aren’t choosing the object a function belongs to, it belongs to the global scope. … Continue reading

Posted in Javascript, MooTools

Jquery Live alternate/replacement in MooTools

1 2 3 4 5 6 7 8 9 10 11    $(’base-id’).addEvent(’dblclick:relay(childelement)’, function(event,clicked) {   }   //example   $(’selected_modules’).addEvent(’dblclick:relay(option)’, function(event,clicked) {   }         

Posted in Javascript, MooTools

Dynamic Height using Fx.Slide element with Mootools

this.step_3 = new Fx.Slide(’step_3′, { onComplete: function(){   this.wrapper.setStyle(’height’, null); //or this.wrapper.setStyle(’height’, ‘auto’);   } });

Posted in Javascript, MooTools

Remove style attribute using MooTools

element.setStyle(‘somestyle’, null); element.setStyle(‘border’,”//empty string

Posted in Javascript, MooTools

MooTools AJAX : Preserve javascript/Script tags

There are two ways that I know of with Request.HTML. By default, evalScripts is set to true. If you set the ‘update’ to $(‘refresh-box’, it will work. function ajaxRequest(){ new Request.HTML({ url: ‘post.php’, update: $(’refresh-box’) }).send(); } By default, the … Continue reading

Posted in Javascript, MooTools

Mootools form submit error

Mootools form submit error : %5Bobject%20Object%5D. You should set send before sending, like this: $(’form’).set(’send’,{ onFailure:function(){console.log(’Error’)}, onComplete: function() { console.log(’Data saved sucessfully!’) }   });   $(’form’).send();

Posted in Javascript, MooTools

Check for undefined JavaScript variable

The typeof operator The “typeof” operator in JavaScript allows you to probe the data type of its operand, such as whether a variable is string, numeric, or even undefined. The below simple example alerts the data type of the variable … Continue reading

Posted in Javascript