Author Archives: stuporglue

EnterAsTab.js

I was creating a mobile website and pressing enter on my iPad keyboard kept submitting the form.

Here’s the short script I wrote to avoid that problem It’s EnterAsTab.js. It’s pure JavaScript (no jQuery or anything) so there’s no dependencies, although you could use jQuery to refine which elements have the function applied.

EnterAsTab is on GitHub

function enterAsTab(e){
if ( e.which == 13 ) {
        // We’re on a submit, so click it
        if(this.getAttribute(‘type’).toLowerCase() == ‘submit’){
            return; // let default bubble up
        }
        var n,t;
        n = this;
        do {
            n = n.nextSibling;
            if(n === null){ return; }// no next sibling. Do default behavior
            if(n.tagName != “INPUT”){ continue; }
            // don’t deal with things without a type (such as labels or text nodes) or which are hidden
            t = n.getAttribute(‘type’);
            if(t === null || t.toLowerCase() == ‘hidden’){
                continue;
            }
            if(t.toLowerCase() == ‘submit’){
                return; // bubble up to default
            }else{
                n.focus(); // Found one. Focus,prevent default and done
                e.preventDefault();
                return;
            }
        } while(n !== null);
}
}
function applyEnterAsTab(){
    var inputs = document.getElementsByTagName(‘input’);
    for(var i = 0;i<inputs.length;i++){
        inputs[i].onkeypress=enterAsTab;
    }
}

Usage

You can apply it to all <input> field by simply running:

applyEnterAsTab(); // all input elements are now set to use EnterAsTab

If you’ve got jQuery or Zepto already you can do something like:

$('input.enterastab').on('keypress',enterAsTab); // Only the inputs with enterastab class

$("#oneform input").on('keypress',enterAsTab);   // All inputs within a specific form
Posted in Computers, GitHub, Programming | Tagged , , | Leave a comment

I’m the Happy Owner of a Lathe

I’ve been the happy owner of lathe since some time last summer or fall, but now I’m the happy owner of a functioning lathe. My aunt gave me a lathe her friend had. It’s a 1950s or 1960s PowerKraft from Montgomery Ward. It is in really good condition. The paint is a little worn in some places, but there’s no rust, and all the screws turned pretty easily. I oiled it up and it works like a champ.

I’ve wanted a lathe for a long time. You might remember that about 18 months ago I turned my drill press into a lathe. That worked well enough, but I couldn’t turn anything bigger than a fishing lure on it and I didn’t have the right tools.

This lathe doesn’t have a motor, and I don’t have a lot of space. I already had a motor mounted on my work bench to power my (also antique!) grinder so I added some braces where the lathe should go. Now I can slide the lathe in securely and pin it in place.

My aunt also gave me the body of an an old avacado-green juicer or stand mixer. It’s got a 1/3 HP motor in it, which is twice as powerful as the 1/6 HP motor I have mounted here. The mixer motor doesn’t have a table mount though, so I’m going to have to figure out how to mount it one of these days.

The lathe on my bench
The lathe on my bench

Today I went and bought a $60 set of High Speed Steel lathe chisels from Harbor Freight, and picked a straightish piece of wood from the wood pile.

It was pretty fun to see it get rounded out just like the YouTube videos I’ve been watching. I got through the bark and got it nice and smooth.

A Birch Log
A Birch Log

For my first project I decided to do something simple — a kids size rolling pin. It ended up slightly tapered, and the grooves on the handles aren’t symmetrical, and the grooves aren’t as smooth as I would’ve liked, but I thought it went alright for a first project.

A Rolling Pin
“What is this? A rolling pin for ants?”

The final test will be in the morning when the snoozy wakes up  decides if she’s excited about it or not.

Snoozy with a Rolling Pin
Snoozy with a Rolling Pin

 

Posted in Projects, Woodworking | Tagged , , | Leave a comment

Migrate from Google Reader to SelfOSS

Google Reader is closing, leaving those of us with hundreds of feeds in the lurch.

If you’d like to get out of the lurch, and don’t like the looks of the magazine-style RSS readers, I’d like to recommend SelfOSS.

It’s a self-hosted option, so you’ll need your own server, but it’s simple to set up, it looks good, and last night I added OPML support so you can import your Google Reader list.

You can see a demo here. The demo is automatically reset every hour.

SelfOSS Demo
SelfOSS Demo

 

Posted in Computers, Programming | Tagged , , | Leave a comment