WNAS

Previous element selector in javaScript

Jul 22, 2011

In my current project I got it again, an itch for a Previous selector. It will be very helpful when you don't have the freedom to fully control your HTML you are working with.

I mean we have next sibling, general sibling and direct child, why can't we have previous child or while we're at it, direct parent. So I want something to complement these…

foo > bar { }
/* child combinatorsspec*/

foo ~ bar { }
/* general sibling specs*/

foo + bar { }
/* adjacent sibling selector specs*/

/* what I want is a previous selector, like this */
foo - bar { }

/* and a parent selector… */
foo < bar

The problem is browsers now, I've been told that it is really hard to implement. So while we are waiting on something that may never come, we might as well work on a make shift solution. I've build on in javascript and put it on Github. It's pretty simple and I'm sure that somebody can improve upon it.

Update

See this article on extending jQuery's selector capabilities too. / thanks to @eising.

The Challenges of Developing Offline Web Apps

Jun 30, 2011 , and

I just finished reading Toolness » Blog Archive » The Challenges of Developing Offline Web Apps (Via dailynerd.nl which you should all read, every day.) and in it are some things that I don't agree with. Let's go through them one by one, shall we?

  1. Statement : Problem One: Simple Things Aren’t Simple..

    So frigging what I say, who said that developing for different platforms should be easy?

  2. Statement : Problem Two: Your Development Workflow Is Now Broken.

    No, you have to adapt your workflow, period. Different platforms call for different workflows sometimes, deal with it.

  3. Statement : Problem Three: Your App Can’t Access The Network When Online.

    The solution is named in the article, what's the problem? Oke, it's something you have to know and remember, but again, who said thing should be easy?

  4. Statement : Problem Four: Cross-Browser Support Is Hard.

    So?

  5. Statement : Problem Five: There’s Not Much Tooling For This.

    That's right, we are at the beginning of an era where we develop for more platforms and the tools have to catch up.

My two cents

People, we are at a great point in time here. We can make history as we expand beyond the desktop. Yes, there are problems with tooling and support, but there are also new thing to learn each and every day. You can make a name for yourself right now if you work hard and discover something new.

We can complain about it, that it's hard and stuff, but why should we do that. It being hard only makes it more fun in my opinion. We have a very active and social front end community in the world, so use that and have fun.

Links for html5 introduction

Jun 08, 2011 and

Yesterday I gave a presentation and a workshop for a bunch of Java developers in Rotterdam. As I already provided the slides on slideshare, I will give a couple of the links I didn't get to here. For all of the people who frequent this page, no they are not new. But if you are new to front end development, they are worth reading and remembering. So here we go...

I hope you'll get something out of these links and if you feel that I missed some please let me know.

a simple Regular expression explained

May 19, 2011 and

This is just for me, so please ignore this...

I needed a regular expression and as I am NOT good at them, I dissected this one I got from @nickfitz and extended it a tad.

// the expression
^([1-9]\d)+,?\d{0,2}

// start of the line
^
(
// a numerical character 1 to 9 ( no 0)
[1-9]
// any numerical char
\d
)
// the stuff between brackets above this can be repeated. It should be
there one time or more (another possibility would be *, that would
require zero times or more repeating of the above)
+
// an optional comma
,?
// some numbers can be none up to two
\d{0,2}

This should match:
1
15
15,
15,5
15,66

but not:
01
15.
15.55
15,789

Besides the help on twitter from jlix and tijn I used reggy to achieve greatness :).

Different var, same subject

Apr 28, 2011 , and

I recently tried to do something and I don't know if it is all that good. If somebody has an opinion about it, I would love to hear it.

I have been using the $ suffix for variables that are really jQuery objects. But I keep coming across occurrences that need the real variable, aka not the jQuery one.

So what I tend to do now is something like:

collection : {
$foo : $('.bar'),
foo : '.bar'
}

In this way I can use both the jQuery object easily and the normal variable, like this:

// use the jQuery object
collection.$foo.action()// use the normal object
$('body').find(collection.foo)

What do you think, is this too much or do you use this too?

I am trying to get a better last example, 'cause this ain't all that clear I think...