aboutsummaryrefslogtreecommitdiffstats
path: root/Source/SPBundleHTMLOutputController.m
diff options
context:
space:
mode:
Diffstat (limited to 'Source/SPBundleHTMLOutputController.m')
-rw-r--r--Source/SPBundleHTMLOutputController.m71
1 files changed, 56 insertions, 15 deletions
diff --git a/Source/SPBundleHTMLOutputController.m b/Source/SPBundleHTMLOutputController.m
index 365c15a3..a632a51a 100644
--- a/Source/SPBundleHTMLOutputController.m
+++ b/Source/SPBundleHTMLOutputController.m
@@ -304,19 +304,28 @@
- (void)webView:(WebView *)sender runJavaScriptAlertPanelWithMessage:(NSString *)message initiatedByFrame:(WebFrame *)frame
{
- SPBeginAlertSheet(NSLocalizedString(@"JavaScript Alert", @"javascript alert"), NSLocalizedString(@"OK", @"OK button"), nil, nil, [self window], self, nil, nil,
- [message description]);
+ NSAlert *alert = [[NSAlert alloc] init];
+ [alert addButtonWithTitle:NSLocalizedString(@"OK", @"OK button")];
+ [alert setInformativeText:(message)?:@""];
+ [alert setMessageText:@"JavaScript"];
+ [alert runModal];
+ [alert release];
}
- (BOOL)webView:(WebView *)sender runJavaScriptConfirmPanelWithMessage:(NSString *)message initiatedByFrame:(WebFrame *)frame
{
- NSLog(@"confirm");
- return NO;
-}
+ NSAlert *alert = [[NSAlert alloc] init];
+ [alert addButtonWithTitle:NSLocalizedString(@"OK", @"OK button")];
+ [alert addButtonWithTitle:NSLocalizedString(@"Cancel", @"cancel button")];
+ [alert setInformativeText:(message)?:@""];
+ [alert setMessageText:@"JavaScript"];
-- (NSString *)webView:(WebView *)sender runJavaScriptTextInputPanelWithPrompt:(NSString *)prompt defaultText:(NSString *)defaultText initiatedByFrame:(WebFrame *)frame
-{
- return @"be patient";
+ NSUInteger returnCode = [alert runModal];
+
+ [alert release];
+
+ if(returnCode == NSAlertFirstButtonReturn) return YES;
+ return NO;
}
- (void)webView:(WebView *)sender windowScriptObjectAvailable: (WebScriptObject *)windowScriptObject
@@ -328,6 +337,10 @@
{
if (aSelector == @selector(run:))
return @"run";
+ if (aSelector == @selector(getShellEnvironmentForName:))
+ return @"getShellEnvironmentForName";
+ if (aSelector == @selector(makeHTMLOutputWindowKeyWindow))
+ return @"makeHTMLOutputWindowKeyWindow";
return @"";
}
@@ -335,6 +348,12 @@
if (selector == @selector(run:)) {
return NO;
}
+ if (selector == @selector(getShellEnvironmentForName:)) {
+ return NO;
+ }
+ if (selector == @selector(makeHTMLOutputWindowKeyWindow)) {
+ return NO;
+ }
return YES;
}
@@ -342,13 +361,41 @@
if (strcmp(property, "run") == 0) {
return NO;
}
+ if (strcmp(property, "getShellEnvironmentForName") == 0) {
+ return NO;
+ }
+ if (strcmp(property, "makeHTMLOutputWindowKeyWindow") == 0) {
+ return NO;
+ }
return YES;
}
-- (void) windowScriptObjectAvailable:(WebScriptObject*)webScriptObject {
+- (void)windowScriptObjectAvailable:(WebScriptObject*)webScriptObject {
[webScriptObject setValue:self forKey:@"system"];
}
+/**
+ * JavaScript window.system.getShellEnvironmentForName('a_key') function to
+ * return the value for key keyName
+ */
+- (NSString *)getShellEnvironmentForName:(NSString*)keyName
+{
+ return [[[NSApp delegate] shellEnvironment] objectForKey:keyName];
+}
+
+/**
+ * JavaScript window.system.makeHTMLOutputWindowKeyWindow() function
+ * to make the HTML output window the first responder
+ */
+- (void)makeHTMLOutputWindowKeyWindow
+{
+ [[self window] makeKeyAndOrderFront:nil];
+}
+
+/**
+ * JavaScript window.system.run('a_command'|new Array('a_command', 'uuid')) function
+ * to return the result of the BASH command a_command
+ */
- (NSString *)run:(id)call
{
@@ -376,12 +423,6 @@
if(!command) return @"No JavaScript command found.";
- // Check for internal commands passed via JavaScript
- if([command isEqualToString:@"_SP_self_makeKeyWindow"]) {
- [[self window] makeKeyAndOrderFront:nil];
- return @"";
- }
-
NSString *output = nil;
if(uuid == nil)
output = [command runBashCommandWithEnvironment:nil atCurrentDirectoryPath:nil error:&err];