javascript

13 posts under this tag.

Star
Why are far things small? 2
0
0
8
May
30

Where, but the web, would you find someone like Oliver Steele? This ain’t no metaphor. That name was a link. I’m not talking about Oliver Steele the person, I haven’t met him (though I apparently am 1-degree of separation from him; weird, that). I’m not talking about the sweating, walking, pinchable, space-and-time-and-flesh-bound avatar, I’m talking about his online persona. And either I’ve gotten crazy enough or technology has advanced enough that I’m ready to treat Oliver Steele —the link, his blog, words, diagrams, code, and further media— as a person by its own merits.

And, boy, is he an interesting guy:

jQuery is the first truly great JS app 2
0
0
7
Jul
12

A JS library JS’s first great app? Indeed. jQuery is the shit. It makes JavaScript, and particularly the intersection between JS and HTML, more fun than you thought it could be. It is one big lump of syntactic sugar, sweet as only truly elegant thinking can be. It is crossbrowser, lightweight (~20kb, compressed), and it leverages your CSS knowledge. jQuery + FireBug is raw sex. You’ll find yourself traversing the DOM just to feel the wind on your face.

Star
HyperScript 2
0
0
7
Jul
06

A 16-line hack to make the JS DOM API a tad more humane.


...absolutely amazing. I’ve yet to find a smaller and yet more astounding example of how you can encapsulate functionality within JavaScript and create brand new APIs on the fly.


Web pages are written in HTMLWP but as they have become more and more complex, they now tend to be written, clientside, through JavascriptWP, which can manipulate and insert HTML. Google Images, for instance, uses Javascript to write the HTML that displays your image results.

Yes, it’s roundabout, but it’s due to the nature of the languages: Javascript does stuff, HTML displays stuff. When you want the browser to do things (instead of merely displaying dumbly what it receives) and when these things themselves involve a lot of displaying, you end up writing HTML through Javascript.

It’s a little like writing French through English (André went to Marie and said: ”Bonjour! Ça va, ma chérie?”) and just as frustrating, particularly because you sometimes have to narrate whole scenes in French (pidgin tends to be painfully verbose) and your English self is left completely in the dark—so you end up naming things in both French and English and it gets as ugly as you can imagine.

HyperScript is a bizarre and quixotic attempt to write French in English; that is, HTML in Javascript. Basically, you do what went on in the Norman conquest of EnglandWP: you anglicize as many French words as you can; that is, you turn into Javascript as many HTML words as you can.

The lark itself takes gratefully (and rather surpisingly) only 16 paltry lines of Javascript code (highlighting thanks to Mark “Tarquin” Wilton-Jones.):


function each(a, f) { for(var i=0, l=a.length; i<l; i++) f(a[i]) };
each('a big blockquote br b center code div em form h1 h2 h3 h4 h5 h6 hr img iframe input i li ol option pre p script select small span strong style sub sup table tbody td textarea tr ul u'.split(' '),
    function(label){
        window[label]=function(){
            var tag=document.createElement(label);
            each(arguments, function(arg){
                if(arg.nodeType) tag.appendChild(arg);
else if(typeof arg=='string' || typeof arg=='number') tag.innerHTML+=arg;
else for(var attr in arg){
if(attr=='style') for(var sty in arg[attr]) tag[attr][sty]=arg[attr][sty];
else tag[attr]=arg[attr];
};
            });
            return tag;
        };
    });


and you can play with it right here, right now:




Test Area:

The translation between HTML and Hyperscript is straightforward, where you would have written
<b>Hello world!</b>,
you now write,

b(‘Hello World!’).

Instead of

<em style=”background-color:yellow”>Hello world!</em>,

now it’s,

em({style:{backgroundColor:’yellow’}},’Hello World!’).

And so on.

HTML in a Javascript syntax. Enjoy!

Never Ending Flickr 2
0
0
7
Jun
20

Flickr AutoPagination has got to be the coolest Greasemonkey script I’ve seen yet, and, to judge by its code, a really intricate labor of love. It works flawlessly and does exactly what you’d guess: it makes every Flickr page (where it would make sense) “infinitely scrollable”. A cool, handy, and surprisingly stable script.

Improv'd Daily! (domburi, notreality) 2
0
0
7
May
11

Encroachment is what makes Life interesting.
Daniel C. DennettWP, EDGE, Freedom Evolves AM

Can’t believe what a coward I’ve been. I guess it wasn’t until I read recently about how Jon Lech Johansen humilliated Hollywood by releasing a program to easily break DVD’s much vaunted DRM (when he was 15 years old), or about “the college droputs that run >youTVpc.com for millions of people on just two low-end desktop computers that I realized how big a wuss I am.

Take Imagery. In a way, I never wanted it to be very popular because I knew I was doing something maybe-legal by scraping Google. I wanted to scrape Flickr and Yahoo! but feared they would be even less likely to see my scraping in a good light. I wanted to create a picture cache to make Imagery much faster and reliable (and to lessen the leech on independent websites) but fretted about bandwidth costs and about whether people would get angry about my caching.

Or take the Spanish dictionary of the Spanish Language Academy. It’s a tremendously useful, gratis dictionary and yet it has a butt-ugly, nonhumane interface. I’ve been bitching about it for years. And I’ve been thinking about giving it a new interface for that long, but, again, what if they don’t like my scraping? (In all probability they won’t. They’re the quintessential staid, monolithic organization.)

A lot of what ifs. But most importantly, so what? So sue me. Well, actually, most important is that I think these scrapings are an overwhelmingly good thing. I see them as a lot of fun—for me, for the scrapees (who’ll get to see how it’s done, ehem), and for the people who will enjoy just how much they never imagined missing. I see them as criticism by example.

So here’s Domburi and here’s NotReality. The idea of Domburi has changed somewhat from its inception (oh, the shame, so many goals not accomplished), it shall now be a collection of search superpowers instead of limiting itself to imagesearching. I believe, with an arrogance that I can’t believe but that I’ve missed, that I have a thing or two to teach Google in its own turf, not just in forgotten backwaters like imagesearching (where Imagery still kicks Google’s ass easily). So I’m starting really tiny now with only a simple redesign of Google search results (there isn’t even imagesearching yet). I’ll be fleshing it out in the coming days, daily, with the daylog here below.

Not Reality, otoh, is still what I’ve always wanted it to be: my webfront for my interface experiments. It’s really simple now but I’ll be improving it daily too.

So please visit the websites, leave your feedback in this post’s comments, and come back often to check out the daylogs—there are loads of interesting things in the pipeline! Thanks for reading.

12-14/May/07

Endless fiddling on Domburi. Collapse of the incrementalism. Obsession with pipe dreams.

15/May/07

Not Reality

Still no attention…

Domburi

Big changes!

  1. Ajaxed requests. Loading icon. Everything happens on the same page. Title changes. Very lightweight script behind the scenes: the now deprecated but still unsurpassed moo.ajax.
  2. New one-column format with even results shaded. Results turn yellow on mouse over, which is silly interactivity, but surprisingly pleasant. Entire result is a link. No numbers anymore showing order.
  3. Displayed URL is now a link that shows results only within the website. This idea from SearchMash, of which I just found out yesterday, and which is a website run by Google where it tries out new interface ideas without the Google brand skewing perception. Very intriguing.
  4. Displayed URL is now cased smartly. So instead of greysanatomyinsider.com you get GreysAnatomyInsider.com. It extracts the case from the result’s title, uses some general heuristics (like upcasing after a ), and if all fails, it simply capitalizes.
  5. Results displayed in-page. This had been the idea ever since I decided to expand Domburi from image searching. I wanted to make the whole searching experience feel faster and more like what Ben Schneiderman calls direct manipulation. It has been much harder than I thought and it was this point where I spent most of my fiddling (I also played for hours with the two-columns layout…). Here’s what I ended up with.
    1. Results seem to open in the entire page, with only the result entry on top. They really open in a full-screen iframe but the effect is surprising. To return to the results you can simply scroll out of the iframe, click the result entry, or…
    2. Pixelside. This is a strange but crucial feature that even if invisible and initially nonintuitive I find very, very promising: it’s simply a 1px-wide, 100%-height leftmost line. Right now you can click on it when on a full-screen result and return to the resultlist (and from there you can click again on it to return to your full-screen result). It is incredibly fast (in Fitt’s lawWP terms, it has “infinite size”), handy, and habituating—and I imagine lots of cool ways to enhance the feature. The only problem is that crappy IE doesn’t allow leftmost pixels! So I’ll have to make up for it with JS. I cringe with only the thought.
    3. The title (but not the entire result, which is JS triggered) is a normal link so if you want to open results in a separate tab just middle-click or CTRL-click it.
  6. Strange cool script used. More details to follow. If you’re interested, check out $.
  7. Works in Firefox, IE, and Opera. Not tested yet on Safari. Some weird bugs on Safari but it broadly works.

16/May/07—20/Jun/07

10-day trip to the US (haven’t told you about that!) with days way too happily busy. Too many books afterwards (63!) to do anything but read for several wonderful, obsessed days until all the stress and overcrowding of the house finally bring me down. Languishment in captivity.

21/Jun/07

Not Reality

Complete Redesign!

I gotta say, I really, really like it. The new eye-candy screenshots are tremendous improvements but the crucial difference is the new text—sort of modeled on ancient book covers—and how it explains infinitely better what it is that I want to accomplish with Domburi and now PLBRS. Please do read it—it’s extremely short and heavily formatted—and tell me what you think.

Added a Not Reality link to Imagery, btw (and finally dropped publicly the promise of more browsers to come for it, it’s all Domburi from now on). Added Google Analytics tracking.


Domburi
Simple changes.

# Fixed logo to point correctly at home. Thanks volve!
# CSS fiddling for greater clarity, minor improvements, and cross-broswser compatibility.
# Added Google Analytics tracking.
# Height adjustment menu. A simple (though surprisingly troublesome) addition that makes Domburi much more useful, you can now adjust the height of the embedded windows and so can view  and compare two or three results at the same time! Imagine this with dragging and width-adjustment…

22 and 23/jun/07

Bad time management. Sorry. :)

24/jun/07

Domburi
Still nothing!

Not Reality # New Book Section! With great quotes and cool photocovers.

Remember to hard refresh (Ctrl-R) to see the most recent changes!

Improv'd Daily! (elzr) 2
0
0
7
May
09

In computing, the second-system syndrome is a form of sophomore slump that describes the tendency to design the successor to a relatively small, elegant, and successful system as an elephantine, feature-laden monstrosity. The term was first used by Fred BrooksWP in his classic The Mythical Man-MonthWP, AM.

Y’know, I remember reading about the syndrome in Brooks’s book with a smug confidence that it would never happen to me. It did. Imagery was by many accounts a pretty cool thing, but then I tried to outdo myself with its successor, Domburi, and, many, many ineffectual months later, I must admit that I’ve only weird sketches and weirder code to show for my time.

Which doesn’t mean that I’ve given up. It means that we need a new strategy. The all-or-nothing, hail-mary, next-big-thing, under-wraps-until-perfect approach was doomed since the beginning. (I really should have known better.) So the new strategy is to get it all out. As rough and soon as possible.

I’m calling it ”Improv’d Daily!” and it is akin to beta-hoodWP—in that it indicates that the website is still under developement—but it carries the all important mantra of radical incrementalism: every single day there will be at least one new, stand-alone, non-trivial improvement for the website. It won’t be earth shattering every day but it shall always be interesting.

I’m starting the meme with this very blog, which is supposed to be my online self and yet still lags far, far behind of what I want from it. (Domburi will be up in a couple of hours. Domburi up.) This very post will be updated daily with each day’s changes starting now and I have several new goodies to kickstart the kaizen:

8/May/07

# Related Posts section added (when viewing an individual post). Posts are related the more tags they have in common and the more rare those tags are.
# List of comments (accessible from the right sidebar, at the bottom of the Recent Comments header)
# New URLs: http://elzr.com/articles/YEAR/MONTH/DAY/TITLE becomes http://elzr.com/posts/TITLE, which is shorter and sweeter. You don’t need to remember a post’s date now and, what’s more, if there’s no post found with that TITLE, Google comes automagically to the rescue.
# Left sidebar redesign: new headshot, shorter description, just email (putting my phone # up there was always a bad idea, that phone-call confirmed it), new format for the archives.
# Collapsed “for:” tags in a post’s tag list. Much clearer. Tags are also now ordered alphabetically.
# Lots of tiny improvements all over. Like the orange bar atop a single post—neat, huh?—or icons for search (a magnifying glass in the searchbox) and for favorites (a star in favorite articles).


9/May/07

# Crappy day: a minor, bureaucratic improvement to the website became a nightmare. Blog crashing on and off. Domburi will have to wait until tomorrow.


10/May/07

# Blog back!
# Section Cache!: the recent list (favorites, posts, comments), the tags list, and the archive are now cached, making the website much, much faster.
# List of all posts (accessible from the left sidebar, below the Archives header)

11/May/07

# Save to Del.icio.us, Reddit, Digg, and Stumble Upon when viewing an individual post.
# Tag Cloud!
# js-less Improv’d Daily! Ok, this may not sound like much but it’s important and cool. I use ALA’s CSS Sprites technique.

12-14/May/07

Obsessed Domburi fiddling. Sorry.

15/May/07

# Fixed broken Tag Cloud links (Thanks Aaron!)

16/May/07—20/Jun/07

Big, humongous gap—or vacations—or depression bout. Or all of them together. See chronicle on Domburi’s Improv’d Daily.

21/Jun/07

  1. Old URLs redirect to URLs to keep with the migration announced May 8. http://elzr.com/articles/YEAR/MONTH/DAY/TITLE now really becomes http://elzr.com/posts/TITLE.>
  2. Sidebar Redesign: new picture, new welcome copy bared down to its barest Basic EnglishWP essentials, new webapps added to webapp section, new, much better descriptions for most items in the sidebar.
  3. Daily Improves section in the sidebar for you to keep handy track of my progress—or lack thereof.
  4. Minor CSS fiddling—like a new, bigger size for small caps type (it could be hard to read at some resolutions and some platforms).
  5. New 404 page, that is, a new page to aid you when you type in an address that can’t be found. Try it now with http://elzr.com/this-address-is-wrong/. Thanks Aaron!


  6. New title for homepage. Since the delta thing is already obscure conceit enough, I decided to convert seconds into more humane time units. 8,321,231s delta is now 96 day delta.

    Delta, btw, means something like the divergence (the difference) that has come to pass between two different times, one of which is usually the present—so when I say in this blog’s homepage title that there’s a 96 day delta I mean that I haven’t updated it in 96 days, i.e., me and my digital self have had 96 days to go our own separate ways. This wonderful sense of the word comes from Charles Stross’s Accelerando.

  7. Unified search into a simple URL, http://elzr.com/search/QUERY, which currently carries a personalized Google search of elzr.com but will eventually change to Domburi. This new unified interface allowed me to finally create a YubNub command for the blog: try elzr (see its man page) at every input box that speaks YubNub.

Wikipedia Popups 2
0
0
7
Apr
19

My Wikipedia investigations of late (I want to propose a major new feature and I’m feeling out the “deep” WIkipedia) uncovered the little known fact that as a registered user you can have a personal stylesheet and javascript file—which means that with a little know-how you can have Wikipedia looking and feeling exactly how you want it—and have this look-and-feel follow you around with your account. If you use the default skin, MonobookWP, your personal stylesheet and js file are monobook.css and monobook.js. There’s help here.

This opens the door to all sorts of customizing galore—skins, plugins, new features…—and while I still have to dig into it properly, so far I’ve found the amazing Navigation popups script, which pops up a small, smart (meaning it does interesting stuff depending on context) preview of any Wikipedia link you hover onto. Its slightly annoying until you get used to it, but once you do get it into your “work”-flow it’s very sweet—blazingly fast and with tons of handy extra options. Installing it is a snap too, just add one line to your monobook.js.

Guard & Default 2
0
0
6
Aug
14

This is from Douglas Crockford’s Survey of Javascript (never program JS without your Crockford!). I thought it quirky at first, surprisingly helpful later. (Emphases added.)

The && operator is commonly called logical and. It can also be called guard. If the first operand is false, null, undefined, ”” (the empty string), or the number 0 then it returns the first operand. Otherwise, it returns the second operand. This provides a convenient way to write a null-check:

var value = p && p.name; /* The name value will
only be retrieved from p if p has a value, avoiding an error. */

The || operator is commonly called logical or. It can also be called default. If the first operand is false, null, undefined, ”” (the empty string), or the number 0, then it returns the second operand. Otherwise, it returns the first operand. This provides a convenient way to specify default values:

value = v || 10; /* Use the value of v, but if v
doesn't have a value, use 10 instead. */

Short-circuit logical operators are a well-known, simple idiom in several languages, but they can sometimes be confusing to read, specially when nested. What I want to point out here is that next time you have to go through code that uses them, try reading them as guard or default, as the case may be. You’ll grokEE them immediately, trust me.

Isn’t it striking, the power of names?

Whoosh 2
0
0
6
Aug
13

I love deadlines. I love the whooshing noise they make as they go by…
— Douglas AdamsWP

Oh boy, can you hear the whoosh yet again? For the first deadline (August 5) my excuse was mostly several huge, polished posts (1, 2, 3) that I just started pouring out possessedly one afternoon after another. For the second deadline (August 12—yesterday!), well, no excuse other than that I’m in thrall with Domburi, and despite sleepless nights (day? night? they’ve lost all meaning to me), I’m happily obsessing with details and trying all sorts of innovative things. I’ve reached a strange state of scripting satori: I’m writing HTML through Javascript like no one has before. I swear it’s so weird and powerful that in a way it’s funny. It’s big stuff.

So yes, it’s better to think of my previous Road Map as broad guidelines for what’s to come. Just trust me, when Domburi’s finally out (August 31), it’ll be heart-breakingly beautiful. Till then and thanks for keeping in touch.

Star
Gmail Matrix 2
0
0
6
Aug
11

I don’t know exactly when or how the thought came into my mind but this morning the epiphany was there: wouldn’t it be cool to see Gmail’s half MB Javascript source1 a la matrix code viewIY? Indeed it would, and so for the next half hour I became a man posessed. It was amazingly easy (“ya sabiendo es facil”) to hack it up in JS and it makes for an interesting screensaver.




When I finished I realized it would be really easy to make my makeshift Matrix code generic and so here’s a quick stab at it. Type whatever text you want matrixified and a new window will (hopefully) popup with it. (Though be warned, it’s pretty rough, unpolished code and it’ll surely be too slow if you don’t have a fast computer.) Anyway, enjoy.



Next time you see Gmail,


think,


fn1. Which I downloaded thanks to Firefox’s wonderful Webdeveloper extension.