Wednesday, May 16, 2012

building tables in IE7 with JavaScript

The documentation on this is a little old and hard to find, since IE7 is old and on rapid decline. But, for those still plagued with a significant percentage of IE7 users, please note that building tables in IE7 can require a step not required by other browsers.

We can normally build tables using HTML and omit the tbody tag without issue. Browsers are supposed to assume a single tbody when none is explicitly given. So, we may naturally assume we can do the same using the DOM methods:

var table = document.createElement('table');
var tr = document.createElement('tr');
var td = document.createElement('td');
td.innerHTML = "oh hi.";
tr.appendChild(td);
table.appendChild(tr);
document.body.appendChild(table);

And indeed, this works perfectly in Chrome, Safari, Firefox, and IE8+. However, IE7 silently adds the table to the body, but refuses to draw anything. IE7 fails to assume the tbody in this case. You need to explicitly add it, like so:

var table = document.createElement('table');
var tbody = document.createElement('tbody');
var tr = document.createElement('tr');
var td = document.createElement('td');
td.innerHTML = "oh hi.";
tr.appendChild(td);
tbody.appendChild(tr);
table.appendChild(tbody);
document.body.appendChild(table);

This will correct the issue in IE7 in without impacting other browsers. And, it'll provide a more accurate representation of the table in your script, which does include a tbody, even when not explicitly given.

Friday, March 16, 2012

javascript namespaces

Well, I lied already: JavaScript doesn't really have namespaces — at least not exactly. But, we can fake it quite easily using objects, which readily serve the same purposes:

var com = {};
com.google = {};
com.google.www = {};
com.google.www.search = function(s) {

  // since we're actually working in the context of an object,
  // we can refer to "this" to set static-ish variables, like a search history:
  if (!this.search_history) {
    this.search_history = [];
  }
  this.search_history.push(s);

  // perform the actual "search" ...
  alert("No results for " + s + "! Try searching with svidgen.com instead!");

} // com.google.www.search()


// you can then use "with"
// even though you shouldn't generally be using "with" ...
with (com.google.www) {
  search("for something");
  search("for something else");
}

// we should be able to see the search history in the
// namespace now
alert(com.google.www.search_history.length);

And there you have it. Namespaces in JavaScript.

Saturday, May 21, 2011

small updates

We've made a few small changes in the past few days. Some of them are invisible to most users, backend changes. A few of them are stylistic changes that we feel are steps in the transition to a prettier bookmarking tool.

First, we cleaned up our bookmarks lists a little bit:


As you can see, we added some space between bookmarks, floated the info and edit/save links to the right, and replaced the single-color english links with colorful icon-based links.

  • Green links with pencil icons have already been saved by you: click the pencil to edit the link.
  • Click a heart to add the link. 
  • Click the pencil to add or view comments.
We also simplified our add bookmark dialogue (and fixed a unicode bug):


The top action bar, search bar, and lower action links have been removed. And a cancel link has been added. Much less cluttered than before.

We've got plenty of other updates in queue. But, we're certainly not opposed to taking a detour if you find any bugs or have any great suggestions. And if you like what we've done so far, we'd like to hear about it!

Wednesday, December 15, 2010

thepointless.com: beginning facebook integration

I've been taking time recently to work on thepointless.com. Frankly, it generates significantly more traffic than Svidgen currently does, and I'd like both reward and harvest those visitors, rather than let the flow of people slowly die off as I have in the past.

On a content level, I've removed a lot of fluff and pushed article-type content out to the angry stickman blog. The site has been trimmed down to a few outbound links and two activities: the clickometer and the dots. Both of these have generated a good deal of traffic in the past and have been featured on other sites, including some youtube videos.

I've also started some facebook integration. So far, this has involved three things:

  1. (re)Creating a facebook page
    This was pretty easy to do. The site is pointless, so the facebook page could be equally pointless. The primary obstacle, which is still an issue, is getting facebook to properly auto-update notes based on the RSS feed of the angry stickman blog.

    In general though, I find this to have been a good investment. The page allows me to instantly remind previous "likers" that the site is still there, and it's still awesomely pointless. Furthermore, because it's social, interactions with the facebook page serve as a free advertisement directly in friends' news feeds.
  2. Adding a Like button to the site
    This was pretty easy to do. It's set to share the count with the corresponding facebook page. It's easy for someone to click if they like what they see. And that subscribes them to future status updates from the site. Good stuff.
  3. and Basic "score" publishing
    The clickometer and dots provide "scores" after the initial interaction. Using the simple JavaScript FB API, these scores can be easily published to a user's FB news feed. And a few folks publish their scores every day, which occasionally leads to an increase in traffic, and more importantly, a really awesome news feed item.
From a marketing perspective, the ROI for reworking the site and starting some basic FB integration has already been great. I'm seeing traffic slowly increase. And I've seeing pages/visit increase drastically. People are engaging more with the site and publishing their interactions, which is turn is drawing more attention.

Since this blog is intended primarily for geeks, I'd be willing to write a little about any of the specifics of the "integration." But, I'm not going to rush on that unless someone voices their interest. The main points are these:
  • thepointless.com has been remade and has my active attention.
  • facebook integration, even on a basic level, is really beneficial.
In any case, keep your eye on thepointless.com for more updates. I'm thinking of recreating the monkey war next, with facebook integration -- but who knows? It's thepointless.com after all, anything could [or couldn't] happen ... 

Monday, November 22, 2010

efficiency concerns

I just wanted to let folks know that I'm aware of some efficiency concerns on Svidgen. Namely, your Heros' Bookmarks list and tag autocompletion for <user x's=""> Bookmarks have the potential to operate very inefficiently. The latter issue deals with the order in which tags are being filtered. And there's actually a two-stage optimization that I'm considering there. I have some ideas for the former issue, but it's less likely to be an issue until the site grows in popularity. You probably haven't even noticed that one.

So, in short, if you're experiencing some particularly high tag autocompletion latency, know that I'm aware of it. And I'll try to have an optimization in place within a week or so.