693Changing the Cursor with Events when dragging an HTML5 canvas

With jQuery document ready:

$(function(){
    var canvas = $('#testCanvas')[0];
    canvas.addEventListener('mousedown', function(e){
        e.preventDefault();
        e.stopPropagation();
        e.target.style.cursor = 'move';
    }, false);
    canvas.addEventListener('mouseup', function(e){
        e.target.style.cursor = 'default';
    }, false);
});

And without...

$('#testCanvas')[0].addEventListener('mousedown', function(e){
    e.preventDefault();
    e.stopPropagation();
    e.target.style.cursor = 'move';
}, false);

$('#testCanvas')[0].addEventListener('mouseup', function(e) {
    e.target.style.cursor = 'default';
}, false);

Based on this: http://stackoverflow.com/questions/2659999/html5-canvas-hand-cursor-problems

680javascript:void(0) – the better a href=”#”

Using a href="javascript:void(0)" instead of a href="#" does not jump to the top. Sould have been clear, but still good to know.

677Forcing a Boolean value in Javascript aka ‘The double negative trick’

return !!someValueThatisNotBooleanButShouldBe;

I first encountered it at Mark Pilgrim'sDive Into HTML5. Anyone else remembers his classic Kant Pro Generator from the olden days?

654Find Largest Number in Javascript

Nice way and fast way of finding the largest number in an array.

var arr = [1233, 32, 442];
var largest = Math.max.apply(Math, arr);

http://ejohn.org/blog/fast-javascript-maxmin/

http://stackoverflow.com/questions/1379553/how-might-i-find-the-largest-number-contained-in-a-javascript-array

652PHP Arrays to Javascript Objects via JSON

Moving PHP Associative Array (Dictionaries, whatever..) over for use in Javascript. In JS Associative Array are actually objects, so we might as well make it into one.

echo "var data =" . json_encode($somatic, JSON_FORCE_OBJECT) . ";

233Modifying Quicktags in WordPress

Open:

/wp-includes/js/quicktags.js

Change/Add/Delete tags to your likening.

195UIWebView, Changing filenames with Javascript

Calling JS from webViewDidFinishLoading, modifying paths to local. Before that all the images had to be stored into the local path.

http://iphoneincubator.com/blog/windows-views/uiwebview-dynamically-modify-html-documents

Interesting direction, but still looking for an elegant way to mix external sites (HTML) with local content (images, scripts...)

168Google Translate *New & Improved Bookmarklet

if (page == empty) go to Google Translate else Translate Current Page