Skip to content

Commit

Permalink
Possible changeset for [CPApp setArguments:]. Please review
Browse files Browse the repository at this point in the history
  • Loading branch information
nciagra authored and Ross Boucher committed Jan 29, 2009
1 parent d1977f1 commit 615383e
Showing 1 changed file with 38 additions and 5 deletions.
43 changes: 38 additions & 5 deletions AppKit/CPApplication.j
Expand Up @@ -666,6 +666,40 @@ CPRunContinuesResponse = -1002;
return _args;
}

- (void)setArguments:(CPArray)args
{
if(!args || args.length == 0)
{
_args = [];
window.location.hash = @"#";

return;
}

if([args class] != CPArray)
args = [CPArray arrayWithObject:args];

_args = args;

var toEncode = [_args copy];
for(var i=0, count = toEncode.length; i<count; i++)
toEncode[i] = encodeURIComponent(toEncode[i]);

var hash = [toEncode componentsJoinedByString:@"/"];

window.location.hash = @"#" + hash;
}

- (void)_reloadArguments
{
var args = window.location.hash.replace("#", "").split("/").slice(0);

for(var i=0, count = args.length; i<count; i++)
args[i] = decodeURIComponent(args[i]);

_args = args
}

- (CPDictionary)namedArguments
{
return _namedArgs;
Expand Down Expand Up @@ -715,13 +749,12 @@ function CPApplicationMain(args, namedArgs)
//FIXME?
if (!args && !namedArgs)
{
var args = window.location.hash.replace("#", "").split("/").slice(0),
[CPApp _reloadArguments];

var args = [CPApp arguments],
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);

Expand Down

0 comments on commit 615383e

Please sign in to comment.