Friday, April 27, 2012

JavaScript Object.Join? With this jQuery Plug you can!

I had a need not to long ago to join an object much in the way you use Array.join().  Naturally, I thought it might be easier to convert the object's to array's, but then I thought, "Why not make a jQuery plug for this?  After all, how hard can it be?"  As it turned out, it was a little bit harder than I thought.  Although, I did finally figure it out and have been successfully using this plug for most of this year.  Now, admittedly, it hasn't been tested on every type of object, so if you use this and find an error, PLEASE COMMENT ME ABOUT IT!  After all, I can't "improve" it if I don't know where it is broken.  Also, if you do report a "bug", please be sure to give me some example of how you reached the bug so I can replicate the issue myself.  In this post, I'm simply going to add the jsFiddle (see below) as it has everything you need; the code, example usage, and example output.  Simply copy out the code between the comments in the JS area of the fiddle and paste it anywhere into your page you like, or paste it into a js file to be included in your header.  Perhaps one day soon, I'll make more official files and a better blog site, but for now, most you know what to do.

Wednesday, April 25, 2012

Simple JS Snippet for Adding a .position Function to the window Object

Not a whole lot to explain here.  I'll include a jsFiddle below that will even show you how to put this func on a timer to update value at a certain area (in my case, a pair of table columns) regularly so you can use this func to tell if the window is being moved!

This function is pretty straight forward and simple.  It first checks to see if anything else in the place of `window.position` and if not, it adds the simple function.  The function itself does nothing more than check browser version, then return an object containing an "x" and a "y" reflecting the current browser window's x and y position on your screen.

I forgot to mention, when I first posted this, using this function this way (preferably at the TOP of your JavaScript) not only enables `window.position`, but it actually assigns the function as a "global".  What this means is that you can recall it in most browsers by simply typing `position()`.  Now, just so you know, this is generally advised against for various reason's.  If you don't feel comfortable assigning this as a global function, you can always use a name-spacing ftw.  For more on name-spacing, check out this nice blog here.

The function:

The Example:

Tuesday, April 17, 2012

My Ongoing List of Fiddles (80+ & Counting)

Not sure why i'm doing this, other than to make it easier for ME to find my fiddles quickly, since the dashboard only show a few at a time.  But who knows, someone may find this page useful in finding my fiddles as well!  As you may notice, there is A LOT of "SO Help"(s), these mean they answered a question on
FYI, it takes a minute to load ...

See more @ Spyk3's jsFiddle Dashboard!