Permalink
Browse files

Changed to use json2.js instead toSource() method.

  • Loading branch information...
1 parent d27b52b commit 48f61267faaf07a7716202bcabe2c0248a8f6834 @kishikawakatsumi committed Jan 16, 2010
Showing with 495 additions and 51 deletions.
  1. +1 −1 Classes/RootViewController.m
  2. +2 −3 Classes/UICGoogleMapsAPI.m
  3. +4 −0 MapDirections.xcodeproj/project.pbxproj
  4. +7 −47 api.html
  5. +481 −0 json2.js
@@ -211,7 +211,7 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
[inputField setReturnKeyType:UIReturnKeyDone];
[inputField setEnablesReturnKeyAutomatically:YES];
- [inputField setContentVerticalAlignment:UIControlContentVerticalAlignmentCenter];
+ [inputField setContentVerticalAlignment:UIControlContentVerticalAlignmentBottom];
[inputField setContentHorizontalAlignment:UIControlContentHorizontalAlignmentLeft];
} else if (indexPath.section == 1 && indexPath.row == 0) {
cell.selectionStyle = UITableViewCellSelectionStyleNone;
@@ -32,9 +32,8 @@ - (void)drawRect:(CGRect)rect {
}
- (void)makeAvailable {
- NSString *filePath = [[NSBundle mainBundle] pathForResource:@"api" ofType:@"html"];
- NSString *fileContents = [NSString stringWithContentsOfFile:filePath encoding:NSUTF8StringEncoding error:nil];
- [self loadHTMLString:fileContents baseURL:[NSURL URLWithString:@"http://iphone.local/"]];
+ NSString *path = [[NSBundle mainBundle] pathForResource:@"api" ofType:@"html"];
+ [self loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:path]]];
}
- (void)webView:(UIWebView *)webView runJavaScriptAlertPanelWithMessage:(NSString *)message initiatedByFrame:(id)frame {
@@ -34,6 +34,7 @@
14C885E41031D50A00079F9E /* UICGClientGeocoder.m in Sources */ = {isa = PBXBuildFile; fileRef = 14C885E31031D50A00079F9E /* UICGClientGeocoder.m */; };
14C8878F1031EE0800079F9E /* add.png in Resources */ = {isa = PBXBuildFile; fileRef = 14C8878E1031EE0800079F9E /* add.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 */; };
1D60589B0D05DD56006BFB54 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 29B97316FDCFA39411CA2CEA /* main.m */; };
1D60589F0D05DD5A006BFB54 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1D30AB110D05D00D00671497 /* Foundation.framework */; };
@@ -90,6 +91,7 @@
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>"; };
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; };
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>"; };
@@ -242,6 +244,7 @@
28AD735F0D9D9599002E5188 /* MainWindow.xib */,
8D1107310486CEB800E47090 /* MapDirections-Info.plist */,
14C87D94102F260A00079F9E /* api.html */,
+ 14F7E02F11020DB400D74BF0 /* json2.js */,
);
name = Resources;
sourceTree = "<group>";
@@ -311,6 +314,7 @@
28AD73600D9D9599002E5188 /* MainWindow.xib in Resources */,
2899E5600DE3E45000AC0155 /* RootViewController.xib in Resources */,
14C87D95102F260A00079F9E /* api.html in Resources */,
+ 14F7E03011020DB400D74BF0 /* json2.js in Resources */,
14C883A31031A79300079F9E /* Icon.png in Resources */,
14C883DE1031AF7700079F9E /* reticle.png in Resources */,
14C883E21031AF9500079F9E /* map_pin.png in Resources */,
View
@@ -4,6 +4,7 @@
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<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 type="text/javascript" src="json2.js"></script>
<script type="text/javascript">
var map;
@@ -61,54 +62,13 @@
for (var i = 0; i < numGeocodes; i++) {
geocodes[i] = gdir.getGeocode(i);
}
- alert({ "routes": routes,
- "geocodes": geocodes,
- "distance": gdir.getDistance(),
- "duration": gdir.getDuration(),
- "polyline": gdir.getPolyline(),
- "status": gdir.getStatus() }.toSource());
+ alert(JSON.stringify({"routes": routes,
+ "geocodes": geocodes,
+ "distance": gdir.getDistance(),
+ "duration": gdir.getDuration(),
+ "polyline": gdir.getPolyline(),
+ "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>
</head>
<body onload="initialize()" onunload="GUnload()">
Oops, something went wrong.

0 comments on commit 48f6126

Please sign in to comment.