Copy To Clipboard

You've probably noticed by now that this blog has lots of snippets that you want to copy into a script before executing. It would be convenient if you didn't have to manually select all of the text to copy it into your clipboard. Up until now I've ignored adding this…

Read this article

Debian/Ubuntu - Install Bower

Bower is a package management service that you can use to install specific versions (or just latest) of web components including HTML, CSS, and javascript. For example you could use the command bower install bootstrap to install the latest version of bootstrap. Steps First Install NodeJS. Then use npm to…

Read this article

PHP - Converting Data for Google Charts

I find it annoying that for a line graph, Google wants the data in this format (javascript): var data = google.visualization.arrayToDataTable([ ['Year', 'Sales', 'Expenses'], ['2004', 1000, 400], ['2005', 1170, 460], ['2006', 660, 1120], ['2007', 1030, 540] ]); In PHP form this is equal to the following (before we run JSON…

Read this article

Javascript Cheatsheet

Check if Element With ID Exists With jquery... if($("#" + name).length == 0) { //it doesn't exist } Get Whether Checkbox Ticked Use jquery .is(':checked') Execute Script When Document Loaded $(document).ready() You can chain these multiple times and all will execute. E.g. $(document).ready(function(){ doSomething(); }) $(document).ready(function(…

Read this article

HTML5 - Context Menus

One of the great additions in HTML5 was the ability to add to the context menu when the user right clicks something. Not all browsers support this (such as Chromium and Opera), but it will work in Firefox. Below is a code example which will use a context menu to…

Read this article

HTML5 - Copy To Clipboard

Below is a code example that you can add to your site to have a code section with a button, that when clicked, will copy the code to the user's clipboard. I have done the same thing below, but with a hyperlink instead of a button. Copy code to clipboard…

Read this article

JavaScript - Object Oriented Form Validation

This tutorial aims to teach you a better way to validate your forms that doesn't rely on naming your forms, or worse, relying heavily on IDs. Wherever possible, ID usage should be removed. Why Bother? By not having to use IDs or naming our forms: we do not have to…

Read this article

Javascript Object Orientation

I've always preferred PHP/Java over Javascript because of the way in which I can structure code in an object-orientated manner, which allows me to build complex systems that are simple to understand. Whenever I have viewed examples of javascript online, it had always looked like a jumbled mess to…

Read this article