FirstClown

firstclown at firstclown.us

Archive for May, 2005

Virgin Mobile and Google SMS

I've been a happy member of Virgin Mobile pre-paid for a while now. Great phones and cheap plans that no one can really compete with. $20 every three months, beat that.

Cingular used to have a similar plan but they have since moved to the dark side and got rid of their good prepaid plan after merging with AT&T. ($25 every three months .. pshaw) I was never too happy with Cingular because their online tools were always hard to use and wouldn't transfer me off of a plan that they acted like they were phasing out. But I 've been very pleased with Virgin. Their online tools are really well done and integrated with the phone service. Everything from usage detail and account information to ordering ringtones is easy and kind of fun.

But I have two gripes.

One, there is no roaming. Nope, sorry, none. Could they charge me a little more for roaming? Hell, could they charge me a lot more for roaming? Um ... no. Sprint PCS network, that's it. It's kind of annoying because I like to go hiking in far off realms, and I can't usually get phone service through the PCS network out there. That could be considered a good thing though. But the coverage isn't that great to begin with.

Gripe two; no Google SMS. Quite frankly, Google SMS rocks. To be out somewhere and be able to quickly find pizza shops around you by the zipcode, nice. Being able to get driving directions on your cell phone, nicer. Getting movie listings because, heck, you're already out and you might as well see what's playing, supra-sweet.

Sadly, I've found out that Virgin doesn't support Google SMS. When I asked the support people whether it's in the future or not I got this:

There is no talk of bringing that feature to future mobile phones offered through Virgin Mobile USA; however, it would ensure the popularity of the service to continue to rise.

Ah... okay. That's a non answer. I'm reading it again an it really makes no sense. Is the person saying that it's not in the plans but Virgin would be stupid to ignore it? "ensure the popularity of the service to continue to rise". Ack... that is some awful corporate speak. Can I get a real answer please? Something like, "That looks really cool. We'll look into it and let you know." Something!

Oi. Where's Fight the Bull when you need them?

Much Better Word Count Implementation

This is much better and not as complicated as I thought. TiddlyWiki's code is so clean.

Anyway.

New Improved Word CountI decided to add the word count as a more integrated solution to TiddlyWiki instead of something that looked like, and was, just a quick hack. So I added it right next to the title, recalculated every time you open the tiddler and edit and save it. You'll need some of the code from the previous word count hack, namely the countWords function.

First, back up your file.

Copy the countWords function from before. We'll need it again.

Find the function createTiddlerSkeleton. Since we're making the word count an integrated component, we'll add it right into the tiddler structure. Add the italicized line below:

var theTitle = createTiddlyElement(theInnerTiddler,"div","title" + title,"title",null);
var theWordCount = createTiddlyElement(theInnerTiddler,"div","count" + title, "count", null);
var theToolbar = createTiddlyElement(theInnerTiddler,"div","toolbar" + title,"toolbar", null);

This adds a count element directly after the title. We'll fill it in with a function called createTiddlerWordCount.

function createTiddlerWordCount(title)
{
var theWordCount = document.getElementById("count" + title);
if(theWordCount){
removeChildren(theWordCount);
var wordCount = countWords(getTiddlerText(title));
var theText = "(" + wordCount + " word" + ((wordCount == 1) ? ")" : "s)");
theWordCount.appendChild(document.createTextNode(theText));
}
}

This will just add the text of our word count right into the element. I have it adding parentheses around it because I like the way it looks. You can do as you wish, of course.

Now the last step is to have this element get filled in with the current word count every time a tiddler is displayed. The key here is that the displayTiddler function is called every time a tiddler is displayed; when opened and after every save. So we add our word count function there:

var theTiddler = createTiddlerSkeleton(place,before,title);
createTiddlerTitle(title,highlightText,highlightCaseSensitive);
createTiddlerWordCount(title);

Voila! Word counts on every tiddler!

The only problem now is that they're ugly. Just add this CSS, or any CSS you want it to use:

.count {
padding: 5px;
font-size: 8pt;
display: inline;
}

New, improved word count.

Fix for TiddlyWiki’s resolveTarget in IE

I noticed the IE 6 wasn't happy when running the resolveTarget code. I found out it was because the Event was null. After some research I found the fix.

You'll need to add:

function resolveTarget(e)
{
var obj;
if (!e) var e = window.event;
if (e.target){

to the beginning of the resolveTarget function. This will get the event ready for IE and not effect the other browsers. Tested in IE6 on Windows 2000 and Firefox on the Mac.

You'll need this to use the spell checker in IE.

Now if only I can get the StyleSheet Tiddly to work in IE...

UPDATE: Stupid me. TiddlyWiki usually calls if (!e) var e = window.event; right before it calls resolveTarget. I kind of like it within the resolveTarget function myself, but this is certainly not a bug in TiddlyWiki.

Fix for IE Mangled Entries in TiddlyWiki

I noticed that IE 6 on Win 2000 (The browser I'm stuck with at work) doesn't like complicated entries with headers and list mixed together. I figured it was a \r problem and it looks like I was right. I found and made a change that fixed it.

You should be able to add the following code without breaking anything else, since it's just ripping out the \r.

Find the newline regexps by searching for "regexpNewLine".

Where the newline regexps are, add:


var regexpNewLine = new RegExp("\n","mg");
var regexpCarriageReturn = new RegExp("\r","mg");

Then below, change:

// Convert newlines to "\n"
function escapeTiddler(text)
{
return( text.replace( regexpDoubleBackSlash,"").replace( regexpNewLine,"\n") );
}

to:

// Convert newlines to "\n"
function escapeTiddler(text)
{
return( text.replace( regexpDoubleBackSlash,"").replace( regexpCarriageReturn,"").replace( regexpNewLine,"\n"));
}

That fixed my problem at least. If you try it and you find it doesn't quite work, please let me know. I'll try and fix it.

Add Word Counts To TiddlyWiki

I'm a writer and like any writer we are really only worried about one thing: word counts. I'm starting to use TiddlyWiki for my writing and I decided I need some good, old-fashoned word counts to help me out. I've added a toolbar button to each tiddler that, when I click it, gives me full word counts on that tiddler. Pretty cool, eh?

First off, back up your wiki page. You don't want to lose everything for a goofy hack.

Sorry for the ugly code below. WordPress doesn't like programmers. Just copy and paste and you should be fine.

Next open the page in an editor and search for:

Show tiddlers that link to this one

You'll see the function where the toolbar is built. Add the lines below under the "references" button:

insertSpacer(theToolbar);
createTiddlyButton(theToolbar,"0","Word Count",onClickToolbarWordCount);

Next we need to add the onClickToolbarWordCount function. Search for onClickToolbarBackLink and undernieth that function add this one:

function onClickToolbarWordCount(e)
{
if(this.parentNode.id){
var wordCount = countWords(getTiddlerText(this.parentNode.id.substr(7)));
//Update button with count
resolveTarget(e).firstChild.nodeValue = wordCount;
}
}

Now we need to add the countWords function. You can really add it anywhere, but keeping it with the onClickToolbarWordCount will help with maintainence and moving it to new versions of TiddlyWiki.

//Do Word Count
function countWords (contents) {
if(contents == null){ return 0; }
contents = contents + ' ';
var nonWordChars = /[^A-Za-z0-9']+/gi;
var cleanedString = contents.replace(nonWordChars, " ");
var words = cleanedString.split(" ");
//Could be empty stuff on beginning and end that mess up count
if(words[0] == "") words.shift();
if(words[words.length-1] == "") words.pop();
var word_count = words.length;
return word_count;
}

Try it out and you should have a new button that will, when pressed, fill in with the latest word count of that tiddler. I haven't put this in the editor view yet because I'm grabbing the content from the tiddler and it's not saved until you hit done. But this works for me. Hopefully it works for you, too.

FirstClown is powered by WordPress
Entries (RSS) and Comments (RSS).