Findings and Notes in Web Development

Javascript

Writing jQuery Plugin 101

I often struggle to get my Javascript code organized, and have tried numerous ways to do so. I have tried putting relevant code into classes and instantiate as needed, then abuse jQuery’s data() method to store everything (from scalar values to functions and callbacks). Recently, after knowing (briefly) how a jQuery plugin should be written, it does greatly simplify my code.

Continue reading

  • Post Meta

My Collection of Common Javascript Functions – Part 1

After coded enough Javascript few months back, I found that there are a couple of functions that I kept re-using in different projects. Therefore I took some time to refactor them and re-arrange them into a single file. The common code that I keep reusing even today consists of functions that does prototypical inheritance, scope maintenance, some jquery stuff, google maps api stuff and some general ajax application related code.

Continue reading

  • Post Meta

    • Jeffrey04
    • Javascript
    • No comments
    • 2009-06-4
    • 21:19

Maintaining State with jQuery Event

Maintaining state in Javascript is not too difficult once you catch the idea. However, as I am not a super brilliant programmer, it takes me some time to find a way to maintain state as YUI Event does in jQuery.

Continue reading

  • Post Meta

    • Jeffrey04
    • Javascript
    • No comments
    • 2009-05-4
    • 21:17

Proof of Concept: YQuery

After the last post, I found that it may be fun to write a wrapper for YUI in order to make it behave like jQuery. Therefore, the code below is clearly mainly for self-amusement and is not intended to be used in production projects. However, through coding this, I found that although the difference in design, but YUI is obviously capable to do what jQuery offers (if not more). I will not continue working on this so whoever interested may just copy and paste the code to further developing it.

Continue reading

  • Post Meta

    • Jeffrey04
    • Javascript
    • No comments
    • 2009-05-4
    • 21:01

Random Javascript Notes

I am starting to like programming in Javascript, especially after understanding more about how Javascript handles scopes. Surprisingly this take me like a year to figure out how scope is managed. The result of the findings is that I start doing a lot of experiments and discovered more interesting stuff through them.

Continue reading

  • Post Meta

    • Jeffrey04
    • Javascript
    • 3 Comments
    • 2009-04-11
    • 01:24

Using YUI for DOM Manipulation

After being frustrated of not getting consistent and accurate result via standard DOM methods especially html_element.getAttribute('key'); and html_element.setAttribute('key', 'value');, I came across some YUI library components that provides abstractions to various DOM methods. Some interesting DOM-related tools covered in this post are YAHOO.util.Element, YAHOO.util.DOM and YAHOO.util.Selector.

Continue reading

  • Post Meta

    • Jeffrey04
    • Javascript
    • 3 Comments
    • 2009-01-16
    • 13:07

Random Color Cloud

Just happened to see this post a few months ago, and the author created another cloud that uses almost the same technique to ‘visualize’ a list of countries. The author uses PHP to generate the cloud originally and I thought I may be able to do in javascript. After some quick coding I managed to produce something similar to the first example, source code after the jump.

Continue reading