Skip to content

Commit

Permalink
Changed to use json2.js instead toSource() method.
Browse files Browse the repository at this point in the history
  • Loading branch information
kishikawakatsumi committed Jan 16, 2010
1 parent d27b52b commit 48f6126
Show file tree
Hide file tree
Showing 5 changed files with 495 additions and 51 deletions.
2 changes: 1 addition & 1 deletion Classes/RootViewController.m
Expand Up @@ -211,7 +211,7 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
[inputField setReturnKeyType:UIReturnKeyDone]; [inputField setReturnKeyType:UIReturnKeyDone];
[inputField setEnablesReturnKeyAutomatically:YES]; [inputField setEnablesReturnKeyAutomatically:YES];


[inputField setContentVerticalAlignment:UIControlContentVerticalAlignmentCenter]; [inputField setContentVerticalAlignment:UIControlContentVerticalAlignmentBottom];
[inputField setContentHorizontalAlignment:UIControlContentHorizontalAlignmentLeft]; [inputField setContentHorizontalAlignment:UIControlContentHorizontalAlignmentLeft];
} else if (indexPath.section == 1 && indexPath.row == 0) { } else if (indexPath.section == 1 && indexPath.row == 0) {
cell.selectionStyle = UITableViewCellSelectionStyleNone; cell.selectionStyle = UITableViewCellSelectionStyleNone;
Expand Down
5 changes: 2 additions & 3 deletions Classes/UICGoogleMapsAPI.m
Expand Up @@ -32,9 +32,8 @@ - (void)drawRect:(CGRect)rect {
} }


- (void)makeAvailable { - (void)makeAvailable {
NSString *filePath = [[NSBundle mainBundle] pathForResource:@"api" ofType:@"html"]; NSString *path = [[NSBundle mainBundle] pathForResource:@"api" ofType:@"html"];
NSString *fileContents = [NSString stringWithContentsOfFile:filePath encoding:NSUTF8StringEncoding error:nil]; [self loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:path]]];
[self loadHTMLString:fileContents baseURL:[NSURL URLWithString:@"http://iphone.local/"]];
} }


- (void)webView:(UIWebView *)webView runJavaScriptAlertPanelWithMessage:(NSString *)message initiatedByFrame:(id)frame { - (void)webView:(UIWebView *)webView runJavaScriptAlertPanelWithMessage:(NSString *)message initiatedByFrame:(id)frame {
Expand Down
4 changes: 4 additions & 0 deletions MapDirections.xcodeproj/project.pbxproj
Expand Up @@ -34,6 +34,7 @@
14C885E41031D50A00079F9E /* UICGClientGeocoder.m in Sources */ = {isa = PBXBuildFile; fileRef = 14C885E31031D50A00079F9E /* UICGClientGeocoder.m */; }; 14C885E41031D50A00079F9E /* UICGClientGeocoder.m in Sources */ = {isa = PBXBuildFile; fileRef = 14C885E31031D50A00079F9E /* UICGClientGeocoder.m */; };
14C8878F1031EE0800079F9E /* add.png in Resources */ = {isa = PBXBuildFile; fileRef = 14C8878E1031EE0800079F9E /* add.png */; }; 14C8878F1031EE0800079F9E /* add.png in Resources */ = {isa = PBXBuildFile; fileRef = 14C8878E1031EE0800079F9E /* add.png */; };
14C887911031EE4D00079F9E /* remove.png in Resources */ = {isa = PBXBuildFile; fileRef = 14C887901031EE4D00079F9E /* remove.png */; }; 14C887911031EE4D00079F9E /* remove.png in Resources */ = {isa = PBXBuildFile; fileRef = 14C887901031EE4D00079F9E /* remove.png */; };
14F7E03011020DB400D74BF0 /* json2.js in Resources */ = {isa = PBXBuildFile; fileRef = 14F7E02F11020DB400D74BF0 /* json2.js */; };
1D3623260D0F684500981E51 /* MapDirectionsAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 1D3623250D0F684500981E51 /* MapDirectionsAppDelegate.m */; }; 1D3623260D0F684500981E51 /* MapDirectionsAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 1D3623250D0F684500981E51 /* MapDirectionsAppDelegate.m */; };
1D60589B0D05DD56006BFB54 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 29B97316FDCFA39411CA2CEA /* main.m */; }; 1D60589B0D05DD56006BFB54 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 29B97316FDCFA39411CA2CEA /* main.m */; };
1D60589F0D05DD5A006BFB54 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1D30AB110D05D00D00671497 /* Foundation.framework */; }; 1D60589F0D05DD5A006BFB54 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1D30AB110D05D00D00671497 /* Foundation.framework */; };
Expand Down Expand Up @@ -90,6 +91,7 @@
14C885E31031D50A00079F9E /* UICGClientGeocoder.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = UICGClientGeocoder.m; sourceTree = "<group>"; }; 14C885E31031D50A00079F9E /* UICGClientGeocoder.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = UICGClientGeocoder.m; sourceTree = "<group>"; };
14C8878E1031EE0800079F9E /* add.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = add.png; sourceTree = "<group>"; }; 14C8878E1031EE0800079F9E /* add.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = add.png; sourceTree = "<group>"; };
14C887901031EE4D00079F9E /* remove.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = remove.png; sourceTree = "<group>"; }; 14C887901031EE4D00079F9E /* remove.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = remove.png; sourceTree = "<group>"; };
14F7E02F11020DB400D74BF0 /* json2.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = json2.js; sourceTree = "<group>"; };
1D30AB110D05D00D00671497 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; 1D30AB110D05D00D00671497 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; };
1D3623240D0F684500981E51 /* MapDirectionsAppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MapDirectionsAppDelegate.h; sourceTree = "<group>"; }; 1D3623240D0F684500981E51 /* MapDirectionsAppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MapDirectionsAppDelegate.h; sourceTree = "<group>"; };
1D3623250D0F684500981E51 /* MapDirectionsAppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MapDirectionsAppDelegate.m; sourceTree = "<group>"; }; 1D3623250D0F684500981E51 /* MapDirectionsAppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MapDirectionsAppDelegate.m; sourceTree = "<group>"; };
Expand Down Expand Up @@ -242,6 +244,7 @@
28AD735F0D9D9599002E5188 /* MainWindow.xib */, 28AD735F0D9D9599002E5188 /* MainWindow.xib */,
8D1107310486CEB800E47090 /* MapDirections-Info.plist */, 8D1107310486CEB800E47090 /* MapDirections-Info.plist */,
14C87D94102F260A00079F9E /* api.html */, 14C87D94102F260A00079F9E /* api.html */,
14F7E02F11020DB400D74BF0 /* json2.js */,
); );
name = Resources; name = Resources;
sourceTree = "<group>"; sourceTree = "<group>";
Expand Down Expand Up @@ -311,6 +314,7 @@
28AD73600D9D9599002E5188 /* MainWindow.xib in Resources */, 28AD73600D9D9599002E5188 /* MainWindow.xib in Resources */,
2899E5600DE3E45000AC0155 /* RootViewController.xib in Resources */, 2899E5600DE3E45000AC0155 /* RootViewController.xib in Resources */,
14C87D95102F260A00079F9E /* api.html in Resources */, 14C87D95102F260A00079F9E /* api.html in Resources */,
14F7E03011020DB400D74BF0 /* json2.js in Resources */,
14C883A31031A79300079F9E /* Icon.png in Resources */, 14C883A31031A79300079F9E /* Icon.png in Resources */,
14C883DE1031AF7700079F9E /* reticle.png in Resources */, 14C883DE1031AF7700079F9E /* reticle.png in Resources */,
14C883E21031AF9500079F9E /* map_pin.png in Resources */, 14C883E21031AF9500079F9E /* map_pin.png in Resources */,
Expand Down
54 changes: 7 additions & 47 deletions api.html
Expand Up @@ -4,6 +4,7 @@
<meta http-equiv="content-type" content="text/html; charset=utf-8"/> <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<title>Route Map</title> <title>Route Map</title>
<script src="http://maps.google.com/maps?file=api&amp;v=2.x&amp;sensor=false&amp;key=ABQIAAAAHbdppQ3MDhGeECdceHXV_hSdG0_H5fikhlv-IEqZhBC4z1KyBxR12kmbllSrnYs8N7ylVtP59PINPg"></script> <script src="http://maps.google.com/maps?file=api&amp;v=2.x&amp;sensor=false&amp;key=ABQIAAAAHbdppQ3MDhGeECdceHXV_hSdG0_H5fikhlv-IEqZhBC4z1KyBxR12kmbllSrnYs8N7ylVtP59PINPg"></script>
<script type="text/javascript" src="json2.js"></script>
<script type="text/javascript"> <script type="text/javascript">


var map; var map;
Expand Down Expand Up @@ -61,54 +62,13 @@
for (var i = 0; i < numGeocodes; i++) { for (var i = 0; i < numGeocodes; i++) {
geocodes[i] = gdir.getGeocode(i); geocodes[i] = gdir.getGeocode(i);
} }
alert({ "routes": routes, alert(JSON.stringify({"routes": routes,
"geocodes": geocodes, "geocodes": geocodes,
"distance": gdir.getDistance(), "distance": gdir.getDistance(),
"duration": gdir.getDuration(), "duration": gdir.getDuration(),
"polyline": gdir.getPolyline(), "polyline": gdir.getPolyline(),
"status": gdir.getStatus() }.toSource()); "status": gdir.getStatus()}));
} }

(function () {
/* atomic objects */
if (!Boolean.prototype.toSource) Boolean.prototype.toSource = function () {
return this.toString();
};
if (!Number.prototype.toSource) Number.prototype.toSource = function () {
return this.toString();
};
if (!String.prototype.toSource) String.prototype.toSource = function () {
return '\"' + this.toString().replace(/[\\\"\']/g, function (m0) {
return '\\' + m0;
}) + '\"';
};
if (!Date.prototype.toSource) Date.prototype.toSource = function () {
return '(new Date(' + this.valueOf() + '))';
};
if (!RegExp.prototype.toSource) RegExp.prototype.toSource = function () {
return this.toString();
};
/* and built-ins */
if (!Function.prototype.toSource) Function.prototype.toSource = function () {
return this.toString();
}
if (!Array.prototype.toSource) Array.prototype.toSource = function () {
var src = [];
for (var i = 0, l = this.length; i < l; i++) {
src[i] = this[i].toSource();
}
return '[' + src.toString() + ']';
};
if (!Object.prototype.toSource) Object.prototype.toSource = function () {
var src = []; // a-ha!
for (var p in this) {
if (!this.hasOwnProperty(p)) continue;
src[src.length] = p.toSource() + ':' + (this[p] ? this[p].toSource() : this[p] === undefined ? 'undefined' : 'null');
} // parens needed to make eval() happy
return '{' + src.toString() + '}';
};
})();

</script> </script>
</head> </head>
<body onload="initialize()" onunload="GUnload()"> <body onload="initialize()" onunload="GUnload()">
Expand Down

0 comments on commit 48f6126

Please sign in to comment.