Looping arrays is particularly useful for things like photo galleries and other iterative processes where you want the "next photo" button on a gallery to continue from the beginning of the album after the user passes the last photo.
In my humble opinion, I believe this functionality should be built into the core of Ecmascript ( For example, something like myArray[-2] should really return the second last element in the array) but alas we have to write it ourselves, so here goes...
Showing posts with label js. Show all posts
Showing posts with label js. Show all posts
21 September 2012
Loop Javascript (or Actionscript!) array based on index
Continue Reading >
Labels:
Actionscript,
AS2,
AS3,
functions,
Javascript,
js
11 May 2012
Simple Javascript Pie Chart using HTML5 Canvas tag
I had a look around today for a handy pie chart that I could quickly drop into a new web app I'm working on and it seems there's a lot of bloated solutions out there. I like to keep things short and sweet so I found this one online and edited it to make it a bit more user friendly. Enjoy!
Labels:
functions,
html,
Javascript,
js
26 January 2012
Free Javascript for Rotating Website Banner or Fading Slideshow - standalone
As flash becomes less widespread I've had more and more instances where I need to create website banners in Javascript rather than my old flash approach. Today I've decided to share my method with my adoring public (that's you!).
This method is completely standalone and does not require jQuery or any other plugin or library. It has been tested and works in latest versions of all browsers.
View a demo here (right click to get the whole source at once) or view the step-by-step instructions below...
Continue Reading >
This method is completely standalone and does not require jQuery or any other plugin or library. It has been tested and works in latest versions of all browsers.
View a demo here (right click to get the whole source at once) or view the step-by-step instructions below...
Labels:
functions,
Javascript,
js
05 November 2011
Javascript function for checking a variables type or empty/unset variables - similar to PHP's empty()
I've been building on this one all week and I'm finding it more and more useful for quickly writing variable checks at the top of functions. You can use it to easily check if a var is defined or check if it is of a certain type. It's a work in progress but it's very handy. Check out the commented examples to get an idea of potential uses. Ideas for improvements/additions are welcome!
Continue Reading >
Labels:
functions,
Javascript,
js
14 March 2011
Max/MSP Javascript "find object" - lazy dollar function
The second function in my "Making Max JS less crap" series, this function scans all objects in the patch and all subpatches and returns a reference to the object with the specified scripting name: It's basically a lazy man's version of my dollar function which means you dont need to give every patcher a scripting name. The downside is it (probably) runs a bit slower. Enjoy!
Continue Reading >
Labels:
functions,
Javascript,
js,
Max,
Max/MSP
Max/MSP Javascript: Dollar Function - Returns a reference to a Max Object in a patch/subpatch
I started using Max this month and was simultaneously impressed with its power and simplicity and frustrated by it's cumbersome interface. I quickly checked out it's javascript capabilities and became much more comfortable. JS allows you do simple operations quite quickly that would take a tonne of parsing objects which use up space and lead to a messy patch.
That said, JS in Max is really a slightly ugly cousin of browser based javascript. Calls to objects are long winded and basically everything is a bit head wrecking!
So here we go: the first in my "Making Max JS less crap" series... The infamous dollar function! All you need to do to access a max object is give the object a scripting name in the inspector* and then use: $('scriptingname')
Continue Reading >
That said, JS in Max is really a slightly ugly cousin of browser based javascript. Calls to objects are long winded and basically everything is a bit head wrecking!
So here we go: the first in my "Making Max JS less crap" series... The infamous dollar function! All you need to do to access a max object is give the object a scripting name in the inspector* and then use: $('scriptingname')
Labels:
functions,
Javascript,
js,
Max,
Max/MSP
11 February 2011
Actionscript/Javascript Colour mode conversion functions - convert HSB/HSL/HSV to RGB to web HEX color or to flash matrix
I wrote/found/tweaked these conversion functions today to convert between the most common colour modes. it was very difficult to find a solid source for converting colours online so I thought I'd post them here for the world. They should work in actionscript 2 & 3 and could easily be tweaked to work in php, python or any other language. Here goes...
Continue Reading >
Labels:
Actionscript,
AS2,
AS3,
functions,
Javascript,
js
23 August 2010
Javascript: Simple, Drag & Drop element class - multiple draggable elements on one page.
I found a tonne of these drag & drop functions online but they were all either too big & bloated or relied heavily on external libraries. The one I did find that was small and usable triggers chrome bug 7423 because it captures the mousedown event for the page. So I've written my own and posted here for your convenience.
See Demo (Internet Explorer ain't supported)
Continue Reading >
See Demo (Internet Explorer ain't supported)
Labels:
functions,
Javascript,
js
02 May 2010
Javascript: Auto-Expand a form's select box on hover/mouseover
Productivity is all about cutting down mouse clicks. With this in mind, I've written this function to open/close a html dropdown menu on mouseover/out. It's currently more of an idea than a usable function, so it might need some testing & tweaking to work cross browser in a real web environment but the basic principal is here to get you started.
Try a demo »
Continue Reading >
Try a demo »
Labels:
css,
html,
Javascript,
js,
usability
28 April 2010
Javascript: Set or get URL/URI/src/href of an iframe or frame/frameset function
This function simply targets an iframe or frameset and retrieves or changes it's src or href attribute.
Continue Reading >
Labels:
Javascript,
js,
shortcuts
25 November 2009
Javascript: Get/Set Caret Cursor position in iframe WYSIWYG editor
I've been working on this for 3 months now on and off, using code snippets from the net and asking questions in forums, etc. I'm trying to get a RTE to autosave as the user is typing. I still don't have a viable solution that works cross browser but I will keep this post updated as I progress. The following works in Firefox:
Continue Reading >
Labels:
Javascript,
js
Subscribe to:
Posts (Atom)
