logo
EverydayChaos
Everyday Chaos
Too Big to Know
Too Big to Know
Cluetrain 10th Anniversary edition
Cluetrain 10th Anniversary
Everything Is Miscellaneous
Everything Is Miscellaneous
Small Pieces cover
Small Pieces Loosely Joined
Cluetrain cover
Cluetrain Manifesto
My face
Speaker info
Who am I? (Blog Disclosure Form) Copy this link as RSS address Atom Feed

September 8, 2007

Beginner to Beginner: Setting the cursor in a textarea via Javascript, in Firefox

Suppose you want to positing the insertion point in a textarea on an HTML page using javascript. (If you don’t want to suppose that, then stop reading now.) This is basic stuff for real programmers, but it took me longer than it should to figure out exactly how to get this to work, so pardon my step by step instructions. I figure it might save some other clodhopping amateur like me the effort of figuring out what’s so obvious to real programmers that they don’t bother mentioning it.

So, let’s say your HTML page has a textarea element — you know, one of them type-in fields. In fact, let’s say the entire body of your page looks like this at the code level:

<textarea id=”ta”>01234567</textarea>
<input type=”button” value=”Move cursor to after first letter” onclick=”setsel()”>

That’ll make a page that looks like this:


(The button doesn’t work. It’s just for show. But see below.)

In case any of this is unclear, the first line creates a textarea with an identifer that I made up (“ta”), and containing “01234567” as its initial text. The second line creates the button, gives it a label, and says that when a user clicks it, the function “setsel()” should be executed. But you already knew that.

Here’s the operative part of the function “setsel()”:

var tarea=document.getElementById(“ta”);
tarea.focus();
tarea.setSelectionRange(1,1);

The first line creates a variable called “tarea” and assigns it the textarea that has the identifier “ta.”

The second line tells it that that’s the element on the page that is going to receive the user interaction. (I lost a couple of hours not realizing the textarea had lost the focus. You may not always need this line. But what could it hurt?)

The third contains the command that works in Firefox (but not IE) for selecting a range of text. It takes two parameters: The position of the character where the selection should start and the position of the character where it should end. (Note: The second value does not say how many characters should be selected.) This is a zero-based system: The spot before the first character is 0. So, if you tell setSelectionRange (and capitalization counts!) to begin at 0 and end at 1, it will select the first character. If you tell it to begin and end at, say, 1, nothing will be selected, and the insertion point will be between the “0” and the “1” in this particular example.

Because I am such a fun guy, fill in the values you want in the following two boxes and click away to select the text in the same textarea. (Remember, only Firefoxers can play this exciting game!)


You’d better read any comments before taking this seriously because I’m guaranteed to have gotten it wrong, possibly in destructive and certainly in embarrassing ways. [Tags: javascript amateurs setSelectionRange mozilla firefox tutorial wrong_in_public_again]

Tweet
Follow me

Categories: Uncategorized Tagged with: tech Date: September 8th, 2007 dw

5 Comments »

August 2, 2007

Meta FAQ

QueryCat is a new site that indexes FAQs and makes them searchable via ordinary language queries. It claims to have indexed over 4 million FAQ questions.

Cool idea. FAQs have enough predictable structure that the questions can probably be pretty cleanly separated from the answers. (For one thing, them question thingies tend to end with curly marks.) And, of course, the info in FAQs is, by definition (well, if FAQs actually compiled questions that were frequently asked) frequently requested and thus valuable.

I did a little poking around. “Where can I get a free blog?” got 664 results. ” “How do I tune up a bicycle?” got 11 hits. Where can I get vegetarian omega 3?” pulled up three answers, all pretty relevant. “Should I reply to spam?” got 372 hits, some generic and some specific to particular mail programs or sites. “Does putting in a new hard drive invalidate the warranty on my thinkpad” and “What’s a normal triglycerides result?” got zero hits. So did “What movies has Lily Tomlin starred in?” because that’s unlikely to be asked in a FAQ.

As is common for sites that let you type in questions, “How do I tune up a bicycle” gets exactly the same results as “tune up bicycle” (all without quotes). Natural language = no stop words. Who cares, if it works? It’s also not very forgiving of misspellings and variants; remove the space in “omega 3” and you get zero results. “Fix a dent in my car” gets zero hits, “Repair a dent in my car” gets six, and just “dent in my car” gets 12.

I wonder if QueryCat keeps track of the context of the questions it indexes. So, if 9 out of 10 of the Q’s at the Acme TNT FAQ use the phrase “Acme TNT” in their replies, but the tenth Q&A — “Q: Does this blow up coyotes real good? A: Yup. Real good.” — does not, will that tenth Q&A show up at the top of the list when some queries “Can I blow up coyotes with Acme TNT?”? Just curious.

I did run into one anomaly, or maybe I’m just confused by the site’s UI. The results are listed in the usual search engine format, with a link to the URL, a description, and then some more links. But in my limited poking, the links led to the home page of the sites, even when the anchor text said it linked to the FAQ.

Anyway, it’s a nice idea for a site and could quite possibly be helpful, especially when your question uses terms that would open up the floodgates of normal search engines .

[Tags: querycat faq metadata everything_is_miscellaneous ]

Tweet
Follow me

Categories: Uncategorized Tagged with: everythingIsMiscellaneous • for_everythingismisc • tech Date: August 2nd, 2007 dw

1 Comment »

July 4, 2007

Moving Thunderbird from Windows to Mac

Here’s how I moved all (?) my Thunderbird data from my Windows machine to my Mac, replacing the contents on my Mac.

First step: Make a back up of your Mac Thunderbird settings. You’ll find them in [yourname]/Library/Thunderbird/Profiles and then in a folder that’s a meaningless string of letters and numbers. Save all those contents to a new folder, just in case. And keep in mind the most important thing throughout this entire process: I am not responsible. In any sense of the word.

Now copy your Tbird settings from your Windows machine to your Mac, using whatever transfer mechanism you want. The Windows settings are in: Documents and Settings/[yourname]/Application Data/Thunderbird/Profiles and then some other folder with a different meaningless string of letters and numbers.

Delete the current contents of your meaninglessly-named Thunderbird folder on your Mac. (Remember, you’ve already backed it up. Right?) Copy in the contents from your Windows meaningless folder. Now the contents of your meaningless folder on the Mac are identical to the contents of that other meaningless folder on your Windows ,achine.

Start up Thunderbird. It should display the contents from your Windows machine.

If Thunderbird now refuses to download mail, check the account settings, of course. Mine still wouldn’t download. But then I looked in the pop.gmail.com folder in the Mail folder in the meaninglessly-named folder on the Mac and found a file called “popstate.dat”. I renamed it to “popstate.dat.bak” and restarted Thunderbird. It worked. Unless you use gmail as your pop server, however, the appropriate folder will have a different name. I have confidence you can figure it out. I believe in you.

Good luck. And remember: I am not responsible. [Tags: thunderbird macintosh gmail ]

Tweet
Follow me

Categories: Uncategorized Tagged with: tech Date: July 4th, 2007 dw

8 Comments »

June 23, 2007

“An error was detected on device \Device\Harddisk4\D during a paging operation.”

I have been getting this error for a few weeks. The error shows up in the XP Event Viewer, which you can get to by choosing Run off the Start menu, entering “cmd” and then typing “%SystemRoot%\system32\eventvwr.msc /s” into the Command Prompt box (omitting the quotation marks). Choose “System” to see the errors. I was getting the error message about every 40 seconds.

Harddisk 4 is in my case an external, USB hard drive. The problem turned out not to be the hard drive. Check your USB cable. Mine was ok, so I got a new enclosure for the drive — the macally PHR 100AC — and hooked it up to a firewire port. So far, it seems to be working perfectly. And the case is a solid piece of work. [Tags: errors]

Tweet
Follow me

Categories: Uncategorized Tagged with: tech Date: June 23rd, 2007 dw

1 Comment »

May 24, 2007

Setting up Google Talk in Pidgin

Pidgin (nee Gaim) is an instant messaging client that lets you combine AIM, Yahoo and Google messages. I spent too long this morning trying to get it to recognize Gtalk.

Google has a page describing how to do it. That may work for you. It doesn’t work for everyone, including me.

Next step: Read the “troubleshooting” paragraph at Manast’s post on the topic.

At this point I started getting SSL error messages. But, after installing OpenSSL, it’s now working.

Yay for Open Source! [Tags: pidgin gtalk instant_messaging googletalk]

Tweet
Follow me

Categories: Uncategorized Tagged with: tech Date: May 24th, 2007 dw

3 Comments »

May 21, 2007

Thunderbird not saving preferences

Thunderbird v.2.0.0.0 has decided to stop storing preferences such as which columns I want displayed and what I want shown in the tool bar. I have tried changing the permissions on the files in Docs & Settings > App Data > Thunderbird (in XP), but that does not seem to be the problem.

Any suggestions?


Got an answer at MozillaZine. Window display preferences seem to be stored in localstore.rdf, which is in the particular profile folder (e.g., in Windows, it’d be C:\Documents and Settings\USERNAME\
Application Data\Thunderbird\Profiles\WEIRDNUMBEREDPROFILE\localstore.rdf. (Adjust the all caps parts to your particular environment.) Close Thunderbird and delete (or rename) localstore.rdf. Open Thunderbird, and make your changes. A new copy of localstore.rdf will be automatically generated. Ta-da!

Tweet
Follow me

Categories: Uncategorized Tagged with: tech Date: May 21st, 2007 dw

Be the first to comment »

May 19, 2007

Word Press 2.2 caveats from the Free Range Librarian

Karen Schneider, the Free Range Librarian, has intensely practical notes on how to get your Word Press 2.2 upgrade to go relatively smoothly.

Number one on her list: “If your ISP offers “one-click upgrade,” STOP. Don’t just press that button! Read the WordPress upgrade instructions end-to-end and then proceed with caution.”

Thank you, Karen.

[Tags: wordpress karen_schneider]

Tweet
Follow me

Categories: Uncategorized Tagged with: tech Date: May 19th, 2007 dw

2 Comments »

April 26, 2007

XXClone: Software that works

My boot drive was 99% full so, I got myself a shiny new hard drive. My experience with Windows is that whenever you swap a drive, either the old or the new one dies, making the experience as painful as possible. But this time I used XXClone, a free program that clones disks. It also lets you set the new disk as your boot device (although you also need to set that in your BIOS) and swaps the drive letters so your new disk can be, for example, Drive C. For $40/year/computer, you can get the pro version that does incremental backup and can do unattended operations.

It took it something under 2 hours to clone a 120G disk. When it was done, my computer booted right up. I am having some little problems — Google Desktop can’t get a connection to localhost — but I doubt they are XXClone’s fault.

Software that works! [Tags: xxclone clone utilities]

Tweet
Follow me

Categories: Uncategorized Tagged with: tech Date: April 26th, 2007 dw

2 Comments »

April 16, 2007

Replacing Powerpoint with Flash?

Anyone have any recommendations for a Windows or Linux package that will let me create Flash presentations so I can stop using Powerpoint? Note that I am not trying to import Powerpoint into Flash. I want software that will make it easy-ish to create presentations in Flash, so that I can play them back at 1024×768, complete with snazzy path animation (a must) and special effects. A plain old Flash editor that has a template for presentations would be a start, but I’d like something with effects built in. I’m playing around with Swish (but can’t find a presentation template and so far don’t see how to run it as Flash instead of Shockwave, but I haven’t looked hard.)

My preferences: The editor either works in Linux or works in Linux via Wine or CrossOffice (or some other DLL-runner). And I don’t want to pay a million dollars for this, since it’s likely to be a failed experiment on my part. But if it works, I could switch to Linux on my laptop.

Any thoughts? [Tags: powerpoint flash linux presentation_software]

Tweet
Follow me

Categories: Uncategorized Tagged with: tech Date: April 16th, 2007 dw

11 Comments »

April 9, 2007

WordPress question: Date dividers

I’ve googled around but can’t find a way of putting a date divider between posts using WordPress. That is, I’d like to put in a divider demarking one day’s posts from anothers, as I do on this blog using MovableType . I’d also like to do it at EverythingIsMiscellaneous.com, which uses WordPress. (I posted about it in the support forum here.) Is there really no baked-in way to do that? [Tags: wordpress]

Tweet
Follow me

Categories: Uncategorized Tagged with: tech Date: April 9th, 2007 dw

9 Comments »

« Previous Page | Next Page »


Creative Commons License
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.
TL;DR: Share this post freely, but attribute it to me (name (David Weinberger) and link to it), and don't use it commercially without my permission.

Joho the Blog uses WordPress blogging software.
Thank you, WordPress!