Something I’ve run into on multiple occasions is the desire to be able to trap the change event of text fields and textareas – not just on blur but when their value actually changes. I will assume some basic understanding of how DOM elements behave and that, while the input and textarea nodes have change events, they don’t actually fire in all browsers until you move away from them. This led me to thinking that there has to be a somewhat optimal way to trigger an event on those fields only when their value changes. If you’ve ever tried something like this before, you may have settled for a combination of listening to keypress and keyup events to get your desired behavior across all browsers, but once again, you have to attach this to all. elements on which you wish it to behave. jQuery once again allows us to develop a very simplistic solution in a relatively tiny bit of code:
(more…)
-
Triggering True onChange Event for Text Fields
27 Mar 2013 by obsidianCategory: JavaScript, Uncategorized, Web DevelopmentTags: events, JavaScript, jQuery, onchange | Comments (0)
-
WordPress Plugin: Ajax and WYSIWYG Comments
21 Nov 2012 by obsidianI spent a good bit of time on Google and the WordPress Codex trying to figure out the best way to customize comments to use Ajax for posting. I finally decided to write my own plugin to solve the issue, since there are a lot of ideas but no real concise nor comprehensive solutions that worked across the board. Additionally, I wanted to offer the capability of using a custom version of the built-in WYSIWYG editor (TinyMCE) to users for comment modification as well. If you have some time to check it out and leave me some feedback, I would appreciate the input!
Category: JavaScript, Programming, Web DevelopmentTags: AJAX, comments, plugins, tinymce, WordPress, wysiwyg | Comments (0)
-
Custom Google Voice Widget Creation
4 Nov 2012 by obsidianIf you use Google Voice, you may be familiar with the option of creating widgets that you can place on your website which allow people to enter their phone number and request to be connected to your Google Voice number. There are several benefits to this type of behavior, but the best of these is that you can offer people the opportunity to call you without ever publicly displaying your phone number. What’s more, each new widget creates a unique buttonId associated with it that allows you to record a custom voicemail response for users of that widget.
Of course, the downside to use of the widget system is that it is not customizable at all, and it is only available in the form of a rather large Flash button to place on your site. After some digging and research, I finally figured out how to post requests to your unique buttonId via standard HTML forms. Taking this to the next level (and much more usable, I might add) lets us create a manual Ajax handler that will make our request to connect the user without ever leaving our page.
(more…)Category: JavaScript, Programming, Web DevelopmentTags: CURL, Google, Google Voice, JavaScript, php, widgets | Comments (0)
-
BackboneJS: Dynamic Override of sync() Method
27 Jun 2012 by obsidianAs with any good solution, there needs to be a valid problem you’re trying to solve. In this case, I ran into a challenge at work and wanted to share the concepts of what I needed to accomplish in case anyone else has run into similar troubles.
I was assigned the task of integrating a new UI with a preexisting backend API, which is really not that big of a deal in and of itself. However, as I wanted to use BackboneJS as our client MVC framework and the API was by no means RESTful nor consistent, I quickly became aware that I would need to manually override the
sync()method of nearly every one of my models in order to have things function properly. Again, in and of itself, this is not a problem, but working in an environment where maintenance and change are the rule, I wanted to figure out a way to extract the customization in such a way as to be extremely easy to manage.
(more…)Category: JavaScript, Programming, Web DevelopmentTags: BackboneJS, JavaScript, MVC | Comments (1)
-
Custom Event Management in JavaScript
27 Sep 2011 by obsidianIf you have used any JavaScript libraries before, you are most likely quite familiar with the concept of binding functions to specific events within an object, but have you ever considered creating your own custom events for your JavaScript classes to allow users even more flexibility in implementing your code? Binding listeners to user events (such as
clickormouseover) is a necessity for robust coding, but what happens when I want to allow developers to execute a specific bit of logic only when my library element has been rendered to the page? I need to build my code in such a way as to give “hooks” to the coder in the form of events for which they can listen.
(more…)Category: JavaScript, Programming, Web DevelopmentComments (15)
-
HTML5 Canvas Layering
26 Sep 2011 by obsidian
I have recently begun to study a couple different ideas to ease the pain of more complex animations using the HTML5 canvas element. Primarily, I have been focusing on layering – stacking individual transparent canvas elements – to achieve a robust effect and help manage individual objects without having to redraw the entire pane with every refresh. In the orbit example above, the center sphere and background are drawn statically on the bottommost layer, while the animation of the satellites is calculated and drawn on a second layer. By clicking on the demo, you can toggle the visibility of the animation layer. If you cannot see the animation at all, you may want to consider picking up a real web browser: Firefox or Chrome are always good options.
(more…)Category: JavaScript, Programming, Web DevelopmentTags: animation, canvas, HTML5, JavaScript, layering | Comments (0)
-
Debug Logging in JavaScript
30 Mar 2011 by obsidianSo, one of the repeat topics I’ve heard in JavaScript discussions both internal and external to work is that of tracing and logging JavaScript activities. What is the best way? How do you know in what order your code is actually completing? These are all valid concerns, and thankfully, there is a fairly easy way to help yourself out. There are back-end libraries to assist with this type of logging such as Apache’s log4j – which has been ported to other popular languages like PHP and C++, but what about seeing under the hood of your browser run scripts?
(more…)Category: JavaScript, Web DevelopmentComments (0)
-
Introducing JSWidgets
9 Mar 2011 by obsidianI have been, for some time, working on a concept that would allow the average JavaScript user to create robust, interactive applications with ease. A daunting task, I know, but having tried to implement so many bloated libraries for simplistic interaction, I wanted to create a way for the beginning or average web developer to create advanced modules quickly. One of the biggest things I have noticed in recent years is the lack of attention given by many to the client side code structure. With this project, I hope to help educate developers a bit more in the necessity of code separation, documentation and reuse of code.
I have been asked if I’m guilty of reinventing the wheel, and it is possible that you may think so, but I feel this offers a level of uniqueness not found in a library this lightweight. In fact, the purpose of this library is not to be a solution to the need in and of itself, but rather it is intended to lay the groundwork for developers to quickly extend their own widgets and have them working in no time. While I am introducing this library in its infancy, I am already in the process of overhauling the template structure to leverage Underscore.js, the most lightweight and robust JavaScript template engine I’ve found to date.
(more…)Category: JavaScript, Web DevelopmentTags: JavaScript, jQuery, JSWidgets, OOP | Comments (0)
-
Zen Coding – HTML Shorthand
4 May 2010 by obsidianIn one of the greatest discoveries of my web development career, I stumbled upon the Zen Coding Project the other day. This is an absolutely amazing project that allows for building robust and — more importantly — valid HTML markup with a fraction of the keystrokes. What’s more, this new method of writing the code uses CSS selectors for an extremely small learning curve. Rather than another language to learn, this little shorthand script is available as a plugin or macro for almost all major IDEs and text editors (Eclipse, NetBeans and even Notepad++ to name a few).
(more…)Category: Web DevelopmentTags: coding, css, html, shorthand, simplification | Comments (2)
-
WordPress Widgets and Flickr RESTful APIs
15 Apr 2010 by obsidianI have done some significant WordPress modifications for friends in the past, be it basic theme manipulations or custom hacking of plugins, but I decided that I wanted to write my own widget to help tie my Flickr account into my blog. I did some searching on the currently hosted WordPress plugin site, and while there were several that tapped the Flickr API, they all seemed too clunky or not quite flexible enough for what I had in mind. Simply listing the most recent thumbnails from my photostream couldn’t be that hard, right? As it turns out, no, it wasn’t.
(more…)Category: Web DevelopmentTags: Flickr, plugin, widget, WordPress | Comments (6)