Javascript: Hijacking document.form.submit()

Earlier this week, I was helping a client of ours interface with a 3rd party widget on a site they work with. What the widget basically does is allow the user to input some information which is then POST’ed to another 3rd party site.

What our clients were looking to do was capture the information in the form before it was submitted, process it before the user left the page, and set any cookies on the user if necessary. Simple enough right? Use jQuery to trap the form’s submit event, do the processing dance, and then allow the form to submit normally.

So I implemented the code as described but for some reason the jQuery submit() handler was never being triggered. Perplexed, I looked through the actual widget code and it turns out that the widget was using a <a> tag with an onclick handler which eventually called document.someForm.submit(). Turns out, the jQuery submit() handler won’t trigger when a form is submitted in this fashion.

Thankfully, it’s relatively straightforward to get around this. You just need to override the form element’s submit() function with one of your own and then eventually call the original function once you’re done.

Well thats about it – As always, questions and comments welcome.

Microsoft & Nokia: Haters Gonna Hate

On the East Coast, most of us woke up from a long weekend to news that Microsoft had purchased Nokia’s mobile hardware manufacturing business. The news didn’t exactly come as a shock, given that the companies had announced a particularly Microsoft friendly operating agreement where Nokia Lumina phones would ship with Windows. What did surprise me was the general skepticism and outright negativity surrounding the deal. From Fred Wilson to the several threads on Hacker News, it seemed like everyone was happy to discount this deal as DOA and go back to arguing about Android and iOS. Personally, I wouldn’t immediately count a combined Microsoft & Nokia team out of the mobile fight for a couple of key reasons.

Consumers are fickle and upgrade cycles are short

This point was brought up on Hacker News and I think it’s one of the key points surrounding this discussion. Consumer attitudes and loyalty surrounding consumer electronics have historically been fairly transient. Six years ago, the iPhone was just hitting store shelves and every teenager was clicking away on a Blackberry. Contrast that with today, where RIM is largely an afterthought and Apple is clearly the dominant player. Discounting that a combined Microsoft/Nokia team could make significant inroads

Along with volatile loyalties, consumer electronics, especially mobile phones have a short upgrade cycle. Compared to desktops or laptops, most American consumers predictable replace their cell phones every 2 years because of free carrier upgrades. Because of this, the mobile phone ecosystem has the potential to change and evolve at a much faster pace than it’s predecessors. This tight upgrade cycle benefits Microsoft/Nokia since it gives them the opportunity to iterate and improve devices much faster than say in the console market where Microsoft has previously used this strategy.

Developers care about install base but it isn’t the only thing

Several comments around the web today pointed to the staggering number of iOS and Android devices already in the wild and made the contention that it doesn’t even make sense for Microsoft to compete. Their primary contention was that since users select a mobile OS based on available apps and developers will only build apps for the biggest platforms there’s a vicious cycle of the less popular platforms not garnering developer attention or user adoption.

The absolute number of available devices is obviously important to developers but it isn’t the only thing they care about. Resource constrained startups are still often building iOS first or iOS only and even larger companies also sometimes focus primarily on their iOS builds. Reasons for this range from everything from the lack of device fragmentation to the engagement and willingness to spend of iOS users.

A combined Microsoft/Nokia should be able to control device fragmentation and also have the software engineering chops to create a best in class toolchain. Visual Studio is generally regarded as a fantastic IDE and if Microsoft can parlay it into creating a true “mobile first” IDE I think they’ll be able to attract developer talent. Another interesting angle is what approach Microsoft takes with HTML5/JS, especially “crossbuild” tools like PhoneGap and Titanium. Playing from third place would give the combined Microsoft/Nokia ample reason to support these crossbuild tools to get more apps onto Windows.

The Living Room and Facebook

It’s becoming clear that the “battle” for consumer living room’s is far from over. With the proliferation of InternetTV devices like the Roku and AppleTV to the announcement of next generation consoles, it’s clear that companies are still very interested in “owning” the living room. The lay of the land is also constantly changing as companies move throughout the value chain. So where does that leave Microsoft? Well its not clear. There’s clearly a lot of XBoxes in living rooms and they’re years away from having any unified mobile + living room experience but that could ultimately serve as a key differentiator and bargaining chip with content owners.

Facebook has always wanted deeper integration on mobile and their Android Home app only solidifies that fact. Microsoft and Facebook also share close ties, Microsoft was a large, pre-IPO investor and Bing is currently powering Facebook’s web search. Given this close relationship, it seems obvious that the two companies would work to tightly integrate Facebook into a phone that was developed in-house. The results could obviously go either way, but there’s no denying that social has helped drive mobile adoption in the past.

However, despite their combined potential the two companies are still facing frighteningly large challenges. With Balmer’s announced departure, the biggest one is certainly who is qualified and willing to lead such a large, multifaceted, corporation down a path that will certainly involve uncomfortable if not downright impossible choices. In any case, consumers and developers shouldn’t count Microsoft out just yet, if nothing else to prevent a Goolge/Apple duopoly in the mobile space.

Fun: Three programming languages I want to experiment with

I spend my days almost entirely developing in PHP and Javascript with the occasional trip to Bash. For the most part, the style of the code ends up looking mostly the same, object oriented PHP and a mix of OO and functional Javascript. Because of this, I’ve been researching a couple of new languages I’d be interested in testing out. Anyway, here is my list – I’d love any feedback or suggestions!

Scala

From Wikipedia:

Scala is an object-functional programming and scripting language for general software applications, statically typed, designed to concisely express solutions in an elegant, type-safe and lightweight (low ceremonial) manner. Scala includes full support for functional programming (including currying, pattern matching, algebraic data types, lazy evaluation, tail recursion, immutability, etc.). It cleans up what are often considered to have been poor design decisions in Java (e.g. type erasure, checked exceptions, the non-unified type system) and adds a number of other features designed to allow cleaner, more concise and more expressive code to be written.

So what makes Scala interesting? Personally, a couple of things stand out. First, the type system looks powerful while also being unobtrusive enough to not offend my dynamic sensibilities. I’ll butcher any explanation of how it works but this presenation does a much better job. Another interesting Scala feature is its rich support for functional programming techniques. I’m excited to try out things like currying and pattern mathing. The last Scala feature that is particularly appealing is that it can be run through the interpreter or compiled to a JAR. Because of this, it would facilitate writing simple “one off” scripts and running them through the interpreter.

Go

Go has been making the rounds on the blogosphere lately so naturally its piqued my interest. From Wikipedia:

Go aims to provide the efficiency of a statically typed compiled language with the ease of programming of a dynamic language. Other goals include:

  • Safety: Type-safe and memory-safe.
  • Intuitive concurrency by providing “goroutines” and channels to communicate between them.
  • Efficient garbage collection “with low enough overhead and no significant latency”.
  • High-speed compilation.

At face value, Go looks familiar and comfortable primarily because of its C inspired syntax and imperative style. The big ticket Go features that look the most interesting are concurrency support and its package and dependency management system. I haven’t written much (or any?) concurrent code and exploring Go’s “goroutines” seems like a great place to start. The official docs provide a great overview of the concurrency features Go exposes. Managing dependencies is painful and nothing is worse than getting stuck in dependency hell. Go has a unique approach to solving these issues, favoring convention over configuration. This post has a great rundown of why Go’s solution looks like a win.

Lua

From Wikipedia:

Lua , from Portuguese: lua meaning moon; explicitly not “LUA”) is a lightweight multi-paradigm programming language designed as a scripting language with “extensible semantics” as a primary goal. Lua is cross-platform since it is written in ISO C.[1] Lua has a relatively simple C API, thus “Lua is especially useful for providing end users with an easy way to program the behavior of a software product without getting too far into its innards.”

Functionally, Lua is a fully featured scripting language written in C which makes it a perfect candidate for embedding places where users need to be able to “script” the behavior of a program. Looking at Wikipedia, Lua has made its way into dozens of projects – including Nginx and Apache. From a language perspective, Lua looks “clean” and somewhat similar to Javascript but the most interesting feature is the possibility of embedding it into a host application. PHP also has out of the box functionality to support embedding Lua.

Anyway, that’s my list – I’d love to hear about any other languages worth checking out.

Thoughts: What is the ultimate brainstorming tool?

Lately, I’ve become interested in the concept and process of structured brainstorming. What makes “structured” brainstorming distinct from its passive cousin is that it has some sort of process and is organized at a specific time. I’d argue that the goal of a structured brainstorming session should be to go in with a loose set of big questions, brainstorm, and then come out with a set of refined questions, themes, and next steps. In our experience, the best way to mentally organize a brainstorm is to group things like ideas, questions, and links under “themes”, continually add to the them, and then sort and prune at the end. Unfortunately, we haven’t really found a software tool that makes this process awesome, let alone easy.

So using this framework, what would make the ultimate brainstorming tool?

Non-linear

One of the most powerful aspects of a brainstorming session is that its non-linear. You easily be able to add “first act” ideas at the same time as adding “late stage” themes without disrupting the flow. In addition to adding, being able to organize information in a non-linear fashion avoids introducing a rigid structure, before the data is really understood.

Organizing data in a non-linear format is one of the primary issues of using a regular text document for a brainstorm. It makes it difficult to add things “out of order” and immediately introduces a rigid structure, since everything is flowing top to bottom.

Collaborative

Successful collaboration is a key point in any team activity and brainstorming is no different. An effective tool should effectively involve all participants by making it easy for everyone to contribute. Since the goal is to eventually prune down anyway, capturing input from everyone involved strengthens the process since it gives a voice to viewpoints that might otherwise go unheard. In our experience, collaborating around a whiteboard works well until 4 people are involved and then it quickly degenerates. By 6 actors, including key stakeholders, some people are hesitant to contribute since they’re afraid of “looking dumb”.

An ideal tool would allow everyone to easily contribute without disrupting active conversations and also without fear of embarrassment.

Linking

Having a ton of great data is awesome but without any way to develop links between the nodes you’re really just left with a massive list. Linking as a feature would let you “chain” pieces of data together, similar to “a href”s in an HTML document, allowing you to develop richer connections within your data.

Current digital tools like Trello or Evernote support linking and I’d imagine an ideal tool supporting it in a similar fashion. The primary concern would be making it easy to visualize the connections between nodes to drive a better understanding of how things fit together.

Ok so we’ve laid out some features, now what does this thing look like? I think ideally this is a SaaS product with a mobile client that looks like a giant table top. The table top would let you add themes, elements within those themes, and also let you create links between anything you’ve added to the table. So does this tool exist? Unfortunately, I don’t think so – or at least I haven’t found it yet.

Anyway, I’d love to hear about your experiences with brainstorming, especially what tools you’ve used.

Tech: If I were Yahoo!, what would I build?

Yahoo’s acquisition of RockMelt last week kicked off another round of armchair quarterbacking questioning the wisdom of aquiring so many startups purely for talent. Only time will ultimately validate the strategy but I think an interesting discussion is given Yahoo!’s position, what would you build given the influx of new talent?

Build a low cost, gaming focused tablet

With the popularity and penetration of tablets accelerating, now would be a great time for Yahoo! to enter the space. In addition to consumer interest, Android 4.3 is rock solid, OEMs are comfortable building “decent” tablets, and Amazon has proved that alternate Android app stores work. So what if Yahoo! built a low cost, gaming focused tablet, with an alternative app store and developer friendly terms? I think they’d be able to successfully capture the low to mid market and then primarily drive revenue via app and in-app purchases.

Double down on Fantasy Sports

One of the few Yahoo! properties that I actually see people visit are it’s Fantasy Sports offerings. Given that, I think it makes sense for Yahoo! to double down on Fantasy and make it an absolutely killer offering. Things like an open API, facilitating playing with real money, and Nate Silver style statistics would set Yahoo! Fantasy apart and ultimately restore the “cool” around the Yahoo! brand.

A killer second screen experience

Remember that tablet Yahoo! just built? Well why not leverage it to put relevant “pop culture” and “celeb gossip” content in front of Yahoo!’s users? It’s not sexy to talk about, but a lot of Yahoo!’s traffic is driven by this type of content and if they can monetize it more effectively than display advertising it should be an easy win. In addition, with the “new” Fantasy Sports available Yahoo! would be able to provide relevant content during live sports and monetize those users as well.

Anyway, whatever Yahoo! ends up building I’m sure it’ll be a bold departure from it’s old path. They have the cash, talent, and hopefully the vision to reinvent a once great Internet giant into a real contender.