Skip to content

Instantly share code, notes, and snippets.

@boucher
Created September 4, 2008 18:42
Show Gist options
  • Save boucher/8843 to your computer and use it in GitHub Desktop.
Save boucher/8843 to your computer and use it in GitHub Desktop.
function main(args, namedArgs)
{
// FIXME: This code should be in Objective-J.
var args = window.location.hash.replace("#", "").split("/").slice(0),
searchParams = window.location.search.substring(1).split("&");
namedArgs = [CPDictionary dictionary];
for(var i=0, count = args.length; i<count; i++)
args[i] = decodeURIComponent(args[i]);
if([args containsObject:"debug"])
CPLogRegister(CPLogPopup);
for(var i=0; i<searchParams.length; i++)
{
var index = searchParams[i].indexOf('=');
if(index == -1)
[namedArgs setObject: "" forKey:searchParams[i]];
else
[namedArgs setObject: searchParams[i].substring(index+1) forKey: searchParams[i].substring(0, index)];
}
CPApplicationMain(args, namedArgs);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment