Skip to content

Instantly share code, notes, and snippets.

- (id)init {
self = [super initWithWindowNibName:@"FAMainApp"];
if (self) {
bridge = [[FAMainAppJSBridge alloc] initWithApp:self];
}
return self;
}
+ (BOOL)isSelectorExcludedFromWebScript:(SEL)sel
{
return NO;
}
+ (BOOL)isKeyExcludedFromWebScript:(const char *)name
{
return NO;
}
@interface FAMainAppJSBridge : NSObject<NSURLDownloadDelegate> {
FAMainApp *app;
FAAddInbox *addInbox;
FAWebPopup *popup;
}
- (id)initWithApp:(FAMainApp *)app;
- (void)sendNotification:(NSString *)title message:(NSString *)message link:(NSString *)link;
- (void)openExternalURL:(NSString *)rawURL;
- (void)downloadFile:(NSString *)name atURL:(NSString *)rawUrl;
$window.jsapi = {
refresh: function () {
emitRootScope('refresh');
},
search: function (query) {
$rootScope.$apply(function () {
locations.search(query);
});
},
- (void)runJavaScript:(NSString *)command {
NSLog(@"js: %@", command);
[self.web stringByEvaluatingJavaScriptFromString:[NSString stringWithFormat:@"if (typeof jsapi !== 'undefined') %@;", command]];
}
- (void)toggleArchived {
[self runJavaScript:@"jsapi.toggleArchiveConversation()"];
}
defaults write com.yourcompany.YourApp WebKitDeveloperExtras -bool true
app.directive('faFastScroll', ['$parse', function ($parse) {
var Interval = function(min, max) {
this.min = min || 0;
this.max = max || 0;
};
Interval.prototype.clip = function(min, max) {
if(this.max <= min || this.min >= max) {
this.min = this.max = 0;
frontApp.directive('fastScroll', ['$parse', function ($parse) {
var Interval = function(min, max) {
this.min = min || 0;
this.max = max || 0;
};
Interval.prototype.clip = function(min, max) {
if(this.max <= min || this.min >= max) {
this.min = this.max = 0;
function findAvailablePort(app, done) {
var port = portrange;
portrange += 1;
var server = http.createServer(app);
server.listen(port, function (err) {
done(server, port);
});
@lperrin
lperrin / gist:5934098
Created July 5, 2013 12:04
A quick example of circular dependency with node.js. This code will crash unexpectedly because module A is only partially loaded by C.
// a.js
var moduleB = require('./b');
function ModuleA() {
}
ModuleA.hello = function () {
console.log('hello!');
};