mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-09-06 18:57:12 +00:00
Create the args and namedArgs objects in Bootstrap.js, pass them along up to CPApplication.
This commit is contained in:
+14
-30
@@ -973,10 +973,9 @@ CPRunContinuesResponse = -1002;
|
||||
[self endSheet:sheet returnCode:0];
|
||||
}
|
||||
|
||||
|
||||
- (CPArray)arguments
|
||||
{
|
||||
if(_fullArgsString != window.location.hash)
|
||||
if(_fullArgsString !== window.location.hash)
|
||||
[self _reloadArguments];
|
||||
|
||||
return _args;
|
||||
@@ -1009,12 +1008,18 @@ CPRunContinuesResponse = -1002;
|
||||
- (void)_reloadArguments
|
||||
{
|
||||
_fullArgsString = window.location.hash;
|
||||
var args = _fullArgsString.replace("#", "").split("/").slice(0);
|
||||
|
||||
for(var i=0, count = args.length; i<count; i++)
|
||||
args[i] = decodeURIComponent(args[i]);
|
||||
|
||||
_args = args;
|
||||
if (_fullArgsString.length)
|
||||
{
|
||||
var args = _fullArgsString.substring(1).split("/");
|
||||
|
||||
for (var i = 0, count = args.length; i < count; i++)
|
||||
args[i] = decodeURIComponent(args[i]);
|
||||
|
||||
_args = args;
|
||||
}
|
||||
else
|
||||
_args = [];
|
||||
}
|
||||
|
||||
- (CPDictionary)namedArguments
|
||||
@@ -1143,29 +1148,8 @@ function CPApplicationMain(args, namedArgs)
|
||||
|
||||
[principalClass sharedApplication];
|
||||
|
||||
//FIXME?
|
||||
if (!args)
|
||||
{
|
||||
var args = [CPApp arguments];
|
||||
|
||||
if([args containsObject:"debug"])
|
||||
CPLogRegister(CPLogPopup);
|
||||
}
|
||||
|
||||
if (!namedArgs)
|
||||
{
|
||||
var searchParams = window.location.search.substring(1).split("&");
|
||||
namedArgs = [CPDictionary dictionary];
|
||||
|
||||
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)];
|
||||
}
|
||||
}
|
||||
if ([args containsObject:"debug"])
|
||||
CPLogRegister(CPLogPopup);
|
||||
|
||||
CPApp._args = args;
|
||||
CPApp._namedArgs = namedArgs;
|
||||
|
||||
@@ -81,7 +81,36 @@ function resolveMainBundleURL()
|
||||
Executable.fileImporterForURL(mainBundleURL)(mainFileURL.lastPathComponent(), YES, function()
|
||||
{
|
||||
disableCFURLCaching();
|
||||
afterDocumentLoad(main);
|
||||
afterDocumentLoad(function()
|
||||
{
|
||||
var hashString = window.location.hash.substring(1),
|
||||
args = [];
|
||||
|
||||
if (hashString.length)
|
||||
{
|
||||
args = hashString.split("/");
|
||||
for (var i = 0, count = args.length; i < count; i++)
|
||||
args[i] = decodeURIComponent(args[i]);
|
||||
}
|
||||
|
||||
var namedArgsArray = window.location.search.substring(1).split("&"),
|
||||
namedArgs = new CFMutableDictionary();
|
||||
|
||||
for (var i = 0, count = namedArgsArray.length; i < count; i++)
|
||||
{
|
||||
var thisArg = namedArgsArray[i].split("=");
|
||||
|
||||
if (!thisArg[0])
|
||||
continue;
|
||||
|
||||
if (thisArg[1] == null)
|
||||
thisArg[1] = true;
|
||||
|
||||
namedArgs.setValueForKey(decodeURIComponent(thisArg[0]), decodeURIComponent(thisArg[1]));
|
||||
}
|
||||
|
||||
main(args, namedArgs);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user