diff --git a/Mac/Controller.h b/Mac/Controller.h
index 24f2e12..c440493 100644
--- a/Mac/Controller.h
+++ b/Mac/Controller.h
@@ -29,6 +29,7 @@
ViewDelegate *viewDelegate;
WebView *oauthView;
AccessToken *accessToken;
+
}
@property (retain, nonatomic) IBOutlet WebView *timelineView;
@@ -46,6 +47,7 @@
@property (retain, nonatomic) WebView *oauthView;
@property (retain, nonatomic) AccessToken *accessToken;
+
- (void)initOauth;
- (void)authentificationSucceded:(id)sender;
- (void)authentificationDidNotSucceed:(NSString *)errorMessage;
diff --git a/Mac/Controller.m b/Mac/Controller.m
index 1143517..d26294b 100644
--- a/Mac/Controller.m
+++ b/Mac/Controller.m
@@ -8,7 +8,7 @@
#import "Controller.h"
#import "NewMessageWindow.h"
-#import "TweetModel.h"
+#import "PostModel.h"
@implementation Controller
@synthesize loginViewWindow;
@@ -74,6 +74,10 @@
}
}
+# pragma mark Init
+
+
+
- (void)initOauth
{
if (!oauthView) {
@@ -280,13 +284,19 @@
- (IBAction)sendTweet:(id)sender
{
- TweetModel *tweet = (TweetModel *)[sender object];
- NSString *text = [[tweet.text stringByReplacingOccurrencesOfString:@"\\" withString:@"\\\\"] stringByReplacingOccurrencesOfString:@"\"" withString:@"\\\""];
+ PostModel *post = (PostModel *)[sender object];
+ NSString *text = [[post.text stringByReplacingOccurrencesOfString:@"\\" withString:@"\\\\"] stringByReplacingOccurrencesOfString:@"\"" withString:@"\\\""];
text = [text stringByReplacingOccurrencesOfString:@"\n" withString:@"\\n"];
- NSString *func = [NSString stringWithFormat:@"tentia_instance.sendNewMessage(\"%@\", \"%@\", \"%@\")",
+
+ NSString *locationObject = @"null";
+ if (post.location) {
+ locationObject = [NSString stringWithFormat:@"[%f, %f]", post.location.coordinate.latitude, post.location.coordinate.longitude];
+ }
+ NSString *func = [NSString stringWithFormat:@"tentia_instance.sendNewMessage(\"%@\", \"%@\", \"%@\", %@)",
text,
- tweet.inReplyTostatusId,
- tweet.inReplyToEntity];
+ post.inReplyTostatusId,
+ post.inReplyToEntity,
+ locationObject];
[timelineView stringByEvaluatingJavaScriptFromString:func];
}
diff --git a/Mac/English.lproj/NewMessageWindow.xib b/Mac/English.lproj/NewMessageWindow.xib
index c258c2f..a845fb8 100644
--- a/Mac/English.lproj/NewMessageWindow.xib
+++ b/Mac/English.lproj/NewMessageWindow.xib
@@ -12,7 +12,11 @@
@@ -173,6 +231,38 @@
100038
+
+
+ addMenu
+
+
+
+ 100048
+
+
+
+ addCurrentLocation:
+
+
+
+ 100049
+
+
+
+ openAddMenu:
+
+
+
+ 100053
+
+
+
+ addMenuButton
+
+
+
+ 100054
+
delegate
@@ -181,6 +271,14 @@
100035
+
+
+ menu
+
+
+
+ 100045
+
@@ -222,6 +320,7 @@
YES
+
@@ -259,6 +358,34 @@
+
+ 100039
+
+
+ YES
+
+
+
+
+
+ 100040
+
+
+
+
+ 100041
+
+
+ YES
+
+
+
+
+
+ 100043
+
+
+
@@ -272,6 +399,10 @@
100029.IBPluginDependency
100036.IBPluginDependency
100037.IBPluginDependency
+ 100039.IBPluginDependency
+ 100040.IBPluginDependency
+ 100041.IBPluginDependency
+ 100043.IBPluginDependency
5.IBPluginDependency
5.IBWindowTemplateEditedContentRect
6.IBPluginDependency
@@ -286,6 +417,10 @@
com.apple.InterfaceBuilder.CocoaPlugin
com.apple.InterfaceBuilder.CocoaPlugin
com.apple.InterfaceBuilder.CocoaPlugin
+ com.apple.InterfaceBuilder.CocoaPlugin
+ com.apple.InterfaceBuilder.CocoaPlugin
+ com.apple.InterfaceBuilder.CocoaPlugin
+ com.apple.InterfaceBuilder.CocoaPlugin
{{127, 736}, {299, 113}}
com.apple.InterfaceBuilder.CocoaPlugin
@@ -302,7 +437,7 @@
- 100038
+ 100054
@@ -311,25 +446,64 @@
NewMessageWindow
NSDocument
- sendTweet:
- NSControl
+ YES
+
+ YES
+ addCurrentLocation:
+ addImage:
+ openAddMenu:
+ sendTweet:
+
+
+ YES
+ id
+ id
+ id
+ NSControl
+
- sendTweet:
-
- sendTweet:
- NSControl
+ YES
+
+ YES
+ addCurrentLocation:
+ addImage:
+ openAddMenu:
+ sendTweet:
+
+
+ YES
+
+ addCurrentLocation:
+ id
+
+
+ addImage:
+ id
+
+
+ openAddMenu:
+ id
+
+
+ sendTweet:
+ NSControl
+
YES
YES
+ addMenu
+ addMenuButton
counter
textField
YES
+ NSMenu
+ NSButton
NSTextField
NSTextField
@@ -338,11 +512,21 @@
YES
YES
+ addMenu
+ addMenuButton
counter
textField
YES
+
+ addMenu
+ NSMenu
+
+
+ addMenuButton
+ NSButton
+
counter
NSTextField
@@ -368,5 +552,20 @@
YES
3
+
+ YES
+
+ YES
+ NSAddTemplate
+ NSMenuCheckmark
+ NSMenuMixedState
+
+
+ YES
+ {8, 8}
+ {11, 11}
+ {10, 3}
+
+
diff --git a/Mac/NewMessageWindow.h b/Mac/NewMessageWindow.h
index 7d993e6..6f49e95 100644
--- a/Mac/NewMessageWindow.h
+++ b/Mac/NewMessageWindow.h
@@ -8,21 +8,34 @@
#import
+#import
-@interface NewMessageWindow : NSDocument
+@interface NewMessageWindow : NSDocument
{
IBOutlet NSTextField *textField;
IBOutlet NSTextField *counter;
+ NSMenu *addMenu;
+ NSButton *addMenuButton;
NSString *inReplyTostatusId;
NSString *inReplyToEntity;
+ NSMenuItem *addImage;
+ CLLocationManager *locationManager;
+ CLLocation *currentLocation;
}
@property (nonatomic, retain) IBOutlet NSTextField *textField;
@property (nonatomic, retain) IBOutlet NSTextField *counter;
+@property (assign) IBOutlet NSMenu *addMenu;
+@property (assign) IBOutlet NSButton *addMenuButton;
+@property (retain, nonatomic) CLLocationManager *locationManager;
+@property (retain, nonatomic) CLLocation *currentLocation;
- (IBAction)sendTweet:(NSControl *)control;
- (void)inReplyTo:(NSString *)userName statusId:(NSString *)statusId withString:(NSString *)string;
- (void)withString:(NSString *)aString;
+- (IBAction)addCurrentLocation:(id)sender;
+- (IBAction)addImage:(id)sender;
+- (IBAction)openAddMenu:(id)sender;
@end
diff --git a/Mac/NewMessageWindow.m b/Mac/NewMessageWindow.m
index 470f270..5806f89 100644
--- a/Mac/NewMessageWindow.m
+++ b/Mac/NewMessageWindow.m
@@ -8,22 +8,34 @@
#import "NewMessageWindow.h"
#import "Constants.h"
-#import "TweetModel.h"
+#import "PostModel.h"
+#import "Controller.h"
@interface NewMessageWindow (private)
- (BOOL)isCommandEnterEvent:(NSEvent *)e;
+- (void)initLocationManager;
@end
@implementation NewMessageWindow
+@synthesize addMenu;
+@synthesize addMenuButton;
@synthesize textField, counter;
+@synthesize locationManager, currentLocation;
+- (void)dealloc
+{
+ [locationManager stopUpdatingLocation];
+ [locationManager release];
+ [currentLocation release];
+ [super dealloc];
+}
- (id)init
{
self = [super init];
- if (self) {
-
+ if (self)
+ {
// Add your subclass-specific initialization here.
// If an error occurs here, send a [self release] message and return nil.
inReplyTostatusId = @"";
@@ -39,7 +51,8 @@
return @"NewMessageWindow";
}
-- (NSString *)displayName {
+- (NSString *)displayName
+{
return @"New Post";
}
@@ -76,13 +89,15 @@
// For applications targeted for Panther or earlier systems, you should use the deprecated API -loadDataRepresentation:ofType. In this case you can also choose to override -readFromFile:ofType: or -loadFileWrapperRepresentation:ofType: instead.
- if ( outError != NULL ) {
+ if ( outError != NULL )
+ {
*outError = [NSError errorWithDomain:NSOSStatusErrorDomain code:unimpErr userInfo:NULL];
}
return YES;
}
-- (void)inReplyTo:(NSString *)entity statusId:(NSString *)statusId withString:(NSString *)string {
+- (void)inReplyTo:(NSString *)entity statusId:(NSString *)statusId withString:(NSString *)string
+{
[textField setStringValue:string];
NSRange range = {[[textField stringValue] length] , 0};
[[textField currentEditor] setSelectedRange:range];
@@ -98,7 +113,8 @@
[self controlTextDidChange:nil];
}
-- (void)withString:(NSString *)aString {
+- (void)withString:(NSString *)aString
+{
[textField setStringValue:aString];
NSRange range = {[[textField stringValue] length] , 0};
[[textField currentEditor] setSelectedRange:range];
@@ -106,6 +122,45 @@
[self controlTextDidChange:nil];
}
+- (IBAction)addCurrentLocation:(id)sender
+{
+ NSMenuItem *menuItem = (NSMenuItem *)sender;
+ if (!self.locationManager)
+ {
+ [menuItem setTitle:@"Current location not available"];
+ [self initLocationManager];
+ }
+ else
+ {
+ [self.locationManager stopUpdatingLocation];
+ self.currentLocation = nil;
+ self.locationManager = nil;
+ [menuItem setTitle:@"Add current location"];
+ }
+}
+
+- (IBAction)addImage:(id)sender
+{
+}
+
+- (IBAction)openAddMenu:(id)sender
+{
+ NSRect frame = [(NSButton *)sender frame];
+ NSPoint menuOrigin = [[(NSButton *)sender superview] convertPoint:NSMakePoint(frame.origin.x, frame.origin.y+frame.size.height) toView:nil];
+
+ NSEvent *event = [NSEvent mouseEventWithType:NSLeftMouseDown
+ location:menuOrigin
+ modifierFlags:NSLeftMouseDownMask // 0x100
+ timestamp:NSTimeIntervalSince1970
+ windowNumber:[[(NSButton *)sender window] windowNumber]
+ context:[[(NSButton *)sender window] graphicsContext]
+ eventNumber:0
+ clickCount:1
+ pressure:1];
+
+ [NSMenu popUpContextMenu:self.addMenu withEvent:event forView:self.addMenuButton];
+}
+
-(void)controlTextDidChange:(NSNotification *)aNotification {
NSInteger c = MESSAGE_MAX_LENGTH - [[textField stringValue] length];
[counter setIntValue:c];
@@ -116,16 +171,39 @@
}
}
+- (void)initLocationManager
+{
+ self.locationManager = [[CLLocationManager alloc] init];
+ [self.locationManager setDelegate:self];
+ [self.locationManager setDesiredAccuracy:kCLLocationAccuracyBest];
+ [self.locationManager setDistanceFilter:kCLDistanceFilterNone];
+ [self.locationManager startUpdatingLocation];
+}
+
+- (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation
+{
+ self.currentLocation = newLocation;
+ NSMenuItem *menuItem = [self.addMenu itemAtIndex:0];
+ [menuItem setTitle:@"Remove current location"];
+}
+
+- (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error{
+ NSLog(@"CLLocationManager Error: %@", error);
+
+ NSMenuItem *menuItem = [self.addMenu itemAtIndex:0];
+ [menuItem setTitle:@"Current location not available"];
+}
#pragma mark Keyboard delegate methods
- (IBAction)sendTweet:(NSControl *)control {
if ([[control stringValue] length] <= MESSAGE_MAX_LENGTH) {
- TweetModel *tweet = [[[TweetModel alloc] init] autorelease];
- tweet.text = [control stringValue];
- tweet.inReplyTostatusId = inReplyTostatusId;
- tweet.inReplyToEntity = inReplyToEntity;
- [[NSNotificationCenter defaultCenter] postNotificationName:@"sendTweet" object:tweet];
+ PostModel *post = [[[PostModel alloc] init] autorelease];
+ post.text = [control stringValue];
+ post.inReplyTostatusId = inReplyTostatusId;
+ post.inReplyToEntity = inReplyToEntity;
+ post.location = self.currentLocation;
+ [[NSNotificationCenter defaultCenter] postNotificationName:@"sendTweet" object:post];
[self close];
} else {
NSBeep();
diff --git a/Mac/TweetModel.h b/Mac/PostModel.h
similarity index 65%
rename from Mac/TweetModel.h
rename to Mac/PostModel.h
index 51f08b9..5130c1b 100644
--- a/Mac/TweetModel.h
+++ b/Mac/PostModel.h
@@ -7,16 +7,20 @@
//
#import
+#import
-
-@interface TweetModel : NSObject {
+@interface PostModel : NSObject {
NSString *text;
NSString *inReplyTostatusId;
NSString *inReplyToEntity;
+ CLLocation *location;
+ NSImage *image;
}
@property (nonatomic, retain) NSString *text;
@property (nonatomic, retain) NSString *inReplyTostatusId;
@property (nonatomic, retain) NSString *inReplyToEntity;
+@property (nonatomic, retain) CLLocation *location;
+@property (nonatomic, retain) NSImage *image;
@end
diff --git a/Mac/TweetModel.m b/Mac/PostModel.m
similarity index 61%
rename from Mac/TweetModel.m
rename to Mac/PostModel.m
index dc917ea..b96ff5d 100644
--- a/Mac/TweetModel.m
+++ b/Mac/PostModel.m
@@ -6,17 +6,19 @@
// Copyright 2011 __MyCompanyName__. All rights reserved.
//
-#import "TweetModel.h"
+#import "PostModel.h"
-@implementation TweetModel
+@implementation PostModel
-@synthesize text, inReplyTostatusId, inReplyToEntity;
+@synthesize text, inReplyTostatusId, inReplyToEntity, location, image;
- (void)dealloc {
[text release];
[inReplyTostatusId release];
[inReplyToEntity release];
+ [location release];
+ [image release];
[super dealloc];
}
diff --git a/Mac/Tentia.xcodeproj/project.pbxproj b/Mac/Tentia.xcodeproj/project.pbxproj
index 16ea905..c044196 100644
--- a/Mac/Tentia.xcodeproj/project.pbxproj
+++ b/Mac/Tentia.xcodeproj/project.pbxproj
@@ -12,8 +12,9 @@
1F122D49118E1DE100E83B77 /* Icon.icns in Resources */ = {isa = PBXBuildFile; fileRef = 1F122D48118E1DE100E83B77 /* Icon.icns */; };
1F1990C6117BCA960049BEA7 /* ApplicationServices.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1F1990C5117BCA960049BEA7 /* ApplicationServices.framework */; };
1F1C80F916482A250010B409 /* WebKit in Resources */ = {isa = PBXBuildFile; fileRef = 1F1C80F816482A250010B409 /* WebKit */; };
+ 1F2D79BD165E8C6B000E8428 /* CoreLocation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1F2D79BC165E8C6B000E8428 /* CoreLocation.framework */; };
1F3F129E164F202000C7C983 /* dsa_pub.pem in Resources */ = {isa = PBXBuildFile; fileRef = 1F3F129D164F202000C7C983 /* dsa_pub.pem */; };
- 1F618ECA12DB5E6100E500D9 /* TweetModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 1F618EC912DB5E6100E500D9 /* TweetModel.m */; };
+ 1F618ECA12DB5E6100E500D9 /* PostModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 1F618EC912DB5E6100E500D9 /* PostModel.m */; };
1F70619F1178FBB300C85707 /* Carbon.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1F70619E1178FBB300C85707 /* Carbon.framework */; };
1F77DB47118C5F1C007C7F1E /* Constants.m in Sources */ = {isa = PBXBuildFile; fileRef = 1F77DB46118C5F1C007C7F1E /* Constants.m */; };
1FA09847144602530079E258 /* libicucore.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 1FA09846144602530079E258 /* libicucore.dylib */; };
@@ -56,9 +57,10 @@
1F122D48118E1DE100E83B77 /* Icon.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = Icon.icns; sourceTree = ""; };
1F1990C5117BCA960049BEA7 /* ApplicationServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ApplicationServices.framework; path = System/Library/Frameworks/ApplicationServices.framework; sourceTree = SDKROOT; };
1F1C80F816482A250010B409 /* WebKit */ = {isa = PBXFileReference; lastKnownFileType = folder; name = WebKit; path = ../WebKit; sourceTree = ""; };
+ 1F2D79BC165E8C6B000E8428 /* CoreLocation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreLocation.framework; path = /System/Library/Frameworks/CoreLocation.framework; sourceTree = ""; };
1F3F129D164F202000C7C983 /* dsa_pub.pem */ = {isa = PBXFileReference; lastKnownFileType = text; name = dsa_pub.pem; path = publish/dsa_pub.pem; sourceTree = ""; };
- 1F618EC812DB5E6100E500D9 /* TweetModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = TweetModel.h; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; };
- 1F618EC912DB5E6100E500D9 /* TweetModel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = TweetModel.m; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objc; };
+ 1F618EC812DB5E6100E500D9 /* PostModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = PostModel.h; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; };
+ 1F618EC912DB5E6100E500D9 /* PostModel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = PostModel.m; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objc; };
1F70619E1178FBB300C85707 /* Carbon.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Carbon.framework; path = System/Library/Frameworks/Carbon.framework; sourceTree = SDKROOT; };
1F77DB45118C5F1C007C7F1E /* Constants.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = Constants.h; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; };
1F77DB46118C5F1C007C7F1E /* Constants.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = Constants.m; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objc; };
@@ -89,6 +91,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
+ 1F2D79BD165E8C6B000E8428 /* CoreLocation.framework in Frameworks */,
1FDEF722164EFE9100F927F3 /* Growl.framework in Frameworks */,
1FA09847144602530079E258 /* libicucore.dylib in Frameworks */,
8D15AC340486D014006FF6A4 /* Cocoa.framework in Frameworks */,
@@ -105,6 +108,7 @@
1058C7A6FEA54F5311CA2CBB /* Linked Frameworks */ = {
isa = PBXGroup;
children = (
+ 1F2D79BC165E8C6B000E8428 /* CoreLocation.framework */,
1FDEF721164EFE9100F927F3 /* Growl.framework */,
1FE2FC92117A818D000504B0 /* Sparkle.framework */,
1058C7A7FEA54F5311CA2CBB /* Cocoa.framework */,
@@ -157,8 +161,8 @@
2A37F4ACFDCFA73011CA2CEA /* NewMessageWindow.m */,
1F77DB45118C5F1C007C7F1E /* Constants.h */,
1F77DB46118C5F1C007C7F1E /* Constants.m */,
- 1F618EC812DB5E6100E500D9 /* TweetModel.h */,
- 1F618EC912DB5E6100E500D9 /* TweetModel.m */,
+ 1F618EC812DB5E6100E500D9 /* PostModel.h */,
+ 1F618EC912DB5E6100E500D9 /* PostModel.m */,
1FC2549A1427D9930035D84B /* AccessToken.h */,
1FC2549B1427D9930035D84B /* AccessToken.m */,
);
@@ -277,7 +281,7 @@
1FFA36D71177D879006C8562 /* Controller.m in Sources */,
1FFA36D81177D879006C8562 /* ViewDelegate.m in Sources */,
1F77DB47118C5F1C007C7F1E /* Constants.m in Sources */,
- 1F618ECA12DB5E6100E500D9 /* TweetModel.m in Sources */,
+ 1F618ECA12DB5E6100E500D9 /* PostModel.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
diff --git a/Mac/ViewDelegate.m b/Mac/ViewDelegate.m
index aa3d466..80bc517 100644
--- a/Mac/ViewDelegate.m
+++ b/Mac/ViewDelegate.m
@@ -56,6 +56,20 @@
- (void)webView:(WebView *)sender didFinishLoadForFrame:(WebFrame *)frame {
+ NSFileManager *fileManager = [NSFileManager defaultManager];
+ NSString *pathToJsPlugin = [@"~/Library/Application Support/Tentia/Plugin.js" stringByExpandingTildeInPath];
+ NSString *pathToCssPlugin = [@"~/Library/Application Support/Tentia/Plugin.css" stringByExpandingTildeInPath];
+
+ if([fileManager fileExistsAtPath:pathToCssPlugin])
+ {
+ [sender stringByEvaluatingJavaScriptFromString:[NSString stringWithFormat:@"setTimeout(function() { loadCssPlugin('file://localhost%@') }, 1000);", pathToCssPlugin]];
+ }
+
+ if([fileManager fileExistsAtPath:pathToJsPlugin])
+ {
+ [sender stringByEvaluatingJavaScriptFromString:[NSString stringWithFormat:@"setTimeout(function() { loadJsPlugin('file://localhost%@') }, 1000);", pathToJsPlugin]];
+ }
+
[sender stringByEvaluatingJavaScriptFromString:@"var OS_TYPE = 'mac';"];
if (sender == oauthView) {
@@ -96,4 +110,16 @@
[mentionsView stringByEvaluatingJavaScriptFromString:@"tentia_instance.getNewData();"];
}
+- (NSString *)pluginURL
+{
+ NSFileManager *fileManager = [NSFileManager defaultManager];
+ NSString *pathToPlugin = [@"~/Library/Application Support/Tentia/Plugin.js" stringByExpandingTildeInPath];
+
+ if([fileManager fileExistsAtPath:pathToPlugin])
+ {
+ return [NSString stringWithFormat:@"%@", [NSURL fileURLWithPath:pathToPlugin]];
+ }
+ return nil;
+}
+
@end
diff --git a/WebKit/scripts/controller/Timeline.js b/WebKit/scripts/controller/Timeline.js
index 6d0d67c..1892422 100644
--- a/WebKit/scripts/controller/Timeline.js
+++ b/WebKit/scripts/controller/Timeline.js
@@ -117,10 +117,10 @@ function(Core, Paths, HostApp, URI) {
}
}
- Timeline.prototype.sendNewMessage = function(content, in_reply_to_status_id, in_reply_to_entity) {
+ Timeline.prototype.sendNewMessage = function(content, in_reply_to_status_id, in_reply_to_entity, location) {
var _this = this;
var callback = function(data) { _this.getNewData(); }
- Core.prototype.sendNewMessage.call(this, content, in_reply_to_status_id, in_reply_to_entity, callback);
+ Core.prototype.sendNewMessage.call(this, content, in_reply_to_status_id, in_reply_to_entity, location, callback);
}
Timeline.prototype.remove = function(id) {
diff --git a/WebKit/scripts/helper/Core.js b/WebKit/scripts/helper/Core.js
index 5ca50d7..2a97e4a 100644
--- a/WebKit/scripts/helper/Core.js
+++ b/WebKit/scripts/helper/Core.js
@@ -237,7 +237,7 @@ function(jQuery, Paths, URI, HostApp, Followings) {
}
// {"type":"Point","coordinates":[57.10803113,12.25854746]}
- if (status.content && status.content.location && status.content.location.type == "Point") {
+ if (status.content && status.content.location && (typeof status.content.location.type == "undefined" || status.content.location.type == "Point")) {
template.geo.href = "http://maps.google.com/maps?q=" + status.content.location.coordinates[0] + "," + status.content.location.coordinates[1];
template.geo.style.display = "";
}
@@ -249,7 +249,7 @@ function(jQuery, Paths, URI, HostApp, Followings) {
return template.item;
}
- Core.prototype.sendNewMessage = function(content, in_reply_to_status_id, in_reply_to_entity, callback) {
+ Core.prototype.sendNewMessage = function(content, in_reply_to_status_id, in_reply_to_entity, location, callback) {
var url = URI(Paths.mkApiRootPath("/posts"));
@@ -266,6 +266,10 @@ function(jQuery, Paths, URI, HostApp, Followings) {
},
};
+ if (location) {
+ data["content"]["location"] = { "type": "Point", "coordinates": location }
+ }
+
var mentions = this.parseMentions(content, in_reply_to_status_id, in_reply_to_entity);
if (mentions.length > 0) {
diff --git a/WebKit/scripts/main.js b/WebKit/scripts/main.js
index daa16cd..8fd074e 100644
--- a/WebKit/scripts/main.js
+++ b/WebKit/scripts/main.js
@@ -105,17 +105,23 @@ var console = {
}
};
-function loadPlugin(js_url, css_url) {
+function loadJsPlugin(js_url) {
if (js_url) {
-
+ var js_plugin = document.createElement("script");
+ js_plugin.type = "text/javascript";
+ js_plugin.src = js_url;
+ document.getElementsByTagName("head")[0].appendChild(js_plugin);
}
- var plugin = document.createElement("script");
- plugin.type = "text/javascript";
- plugin.src = js_url;
- document.getElementsByTagName("head")[0].appendChild(plugin);
+}
- if (css_url != null) {
+function loadCssPlugin(css_url) {
+ if (css_url) {
+ var css_plugin = document.createElement("link");
+ css_plugin.rel = 'stylesheet';
+ css_plugin.type = 'text/css'
+ css_plugin.href = css_url;
+ document.getElementsByTagName("head")[0].appendChild(css_plugin);
}
}