Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alex-zige/6fc35271cb170d20d10858abbfd319c9 to your computer and use it in GitHub Desktop.
Save alex-zige/6fc35271cb170d20d10858abbfd319c9 to your computer and use it in GitHub Desktop.
cocoascirpt
@import 'helpers/Utils.js';
@import 'libraries/View.js';
var onRun = function(context) {
utils.init(context);
dialog.showSuccessExportMessage();
var app = [NSApplication sharedApplication];
[app displayDialog:"Anything selected <img src='http://www.thinkandbuild.it/wp-includes/images/smilies/icon_sad.gif'/> " withTitle:"Exportabler"];
utils.openURL(utils.website)
COScript.currentCOScript().setShouldKeepAround_(true);
var webView = UIWebView.new();
var delegate = new MochaJSDelegate()
var delegate = new MochaJSDelegate({
"webView:didFinishLoadForFrame:": (function(webView, webFrame){
var app = [NSApplication sharedApplication];
[app displayDialog:"Call back works!" withTitle:"Success!"];
dialog.uploadSuccessMessage()
})
});
delegate.setHandlerForSelector("webView:didStartProvisionalLoadForFrame:", function(webView, webFrame){
// var app = [NSApplication sharedApplication];
log("webView:didStartProvisionalLoadForFrame:")
// COScript.currentCOScript().setShouldKeepAround_(false);
});
delegate.setHandlerForSelector("webView:didFinishLoadForFrame:", function(webView, webFrame){
// var app = [NSApplication sharedApplication];
log("webView:didFinishLoadForFrame:")
log(webView.loading);
// log(webFrame.width)
// var resp = [[NSURLCache sharedURLCache] cachedResponseForRequest: webView.request];
// NSLog(webView.request)
// log([resp.response statusCode]);
// var urlResponse = [[NSURLCache sharedURLCache] cachedResponseForRequest:webView.request];
// log(urlResponse)
// var httpResponse = [urlResponse response];
// var statusCode = [httpResponse statusCode];
// log(statusCode);
// COScript.currentCOScript().setShouldKeepAround_(false);
});
delegate.setHandlerForSelector("webView:didCommitLoadForFrame:", function(webView, webFrame){
// var app = [NSApplication sharedApplication];
log("webView:didCommitLoadForFrame:")
// COScript.currentCOScript().setShouldKeepAround_(false);
});
delegate.setHandlerForSelector("webView:willCloseFrame:", function(webView, webFrame){
// var app = [NSApplication sharedApplication];
log("webView:willCloseFrame:")
// COScript.currentCOScript().setShouldKeepAround_(false);
});
delegate.setHandlerForSelector("webView:didFailProvisionalLoadWithError:forFrame:", function(){
// var app = [NSApplication sharedApplication];
log("webView:didFailProvisionalLoadWithError:")
var app = [NSApplication sharedApplication];
[app displayDialog:"Errror!!!" withTitle:"wow!"];
// COScript.currentCOScript().setShouldKeepAround_(false);
});
delegate.setHandlerForSelector("webView:didFailLoadWithError:forFrame:", function(){
// var app = [NSApplication sharedApplication];
log("webView:didFailLoadWithError:forFrame:")
COScript.currentCOScript().setShouldKeepAround_(false);
});
delegate.setHandlerForSelector("webView:didFailLoadWithError:", function(){
// var app = [NSApplication sharedApplication];
log("webView:didFailLoadWithError:forFrame:")
COScript.currentCOScript().setShouldKeepAround_(false);
});
delegate.setHandlerForSelector("webView:didFailLoadWithError:", function(){
// var app = [NSApplication sharedApplication];
var app = [NSApplication sharedApplication];
[app displayDialog:"Errror!!!" withTitle:"wow!"];
// dialog.showRemoteProcessingError()
// COScript.currentCOScript().setShouldKeepAround_(false);
});
webView.setFrameLoadDelegate_(delegate.getClassInstance());
webView.setMainFrameURL_("http://localhost:8000/upload-progress");
log(webView)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment