Skip to content

Commit 0cbc5a9

Browse files
author
Jakey
committed
commit
1 parent 6156201 commit 0cbc5a9

30 files changed

Lines changed: 1937 additions & 0 deletions

JavaScriptCore-Demo.xcodeproj/project.pbxproj

Lines changed: 513 additions & 0 deletions
Large diffs are not rendered by default.

JavaScriptCore-Demo.xcodeproj/project.xcworkspace/contents.xcworkspacedata

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

JavaScriptCore-Demo/AppDelegate.h

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
//
2+
// AppDelegate.h
3+
// JavaScriptCore-Demo
4+
//
5+
// Created by Jakey on 14/12/26.
6+
// Copyright (c) 2014年 www.skyfox.org. All rights reserved.
7+
//
8+
9+
#import <UIKit/UIKit.h>
10+
11+
@class RootViewController;
12+
13+
@interface AppDelegate : UIResponder <UIApplicationDelegate>
14+
15+
@property (strong, nonatomic) UIWindow *window;
16+
17+
@property (strong, nonatomic) RootViewController *viewController;
18+
19+
@property (strong, nonatomic) UINavigationController *navgationController;
20+
21+
@end

JavaScriptCore-Demo/AppDelegate.m

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
//
2+
// AppDelegate.m
3+
// JavaScriptCore-Demo
4+
//
5+
// Created by Jakey on 14/12/26.
6+
// Copyright (c) 2014年 www.skyfox.org. All rights reserved.
7+
//
8+
9+
#import "AppDelegate.h"
10+
11+
#import "RootViewController.h"
12+
13+
@implementation AppDelegate
14+
15+
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
16+
{
17+
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
18+
// Override point for customization after application launch.
19+
self.window.backgroundColor = [UIColor whiteColor];
20+
self.viewController = [[RootViewController alloc] initWithNibName:@"RootViewController" bundle:nil];
21+
self.navgationController = [[UINavigationController alloc]initWithRootViewController:self.viewController];
22+
self.window.rootViewController = self.navgationController;
23+
[self.window makeKeyAndVisible];
24+
return YES;
25+
}
26+
27+
- (void)applicationWillResignActive:(UIApplication *)application {
28+
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
29+
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
30+
}
31+
32+
- (void)applicationDidEnterBackground:(UIApplication *)application {
33+
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
34+
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
35+
}
36+
37+
- (void)applicationWillEnterForeground:(UIApplication *)application {
38+
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
39+
}
40+
41+
- (void)applicationDidBecomeActive:(UIApplication *)application {
42+
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
43+
}
44+
45+
- (void)applicationWillTerminate:(UIApplication *)application {
46+
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
47+
}
48+
49+
@end
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="6214" systemVersion="14A314h" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES">
3+
<dependencies>
4+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6207"/>
5+
<capability name="Constraints with non-1.0 multipliers" minToolsVersion="5.1"/>
6+
</dependencies>
7+
<objects>
8+
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
9+
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
10+
<view contentMode="scaleToFill" id="iN0-l3-epB">
11+
<rect key="frame" x="0.0" y="0.0" width="480" height="480"/>
12+
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
13+
<subviews>
14+
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text=" Copyright (c) 2014年 www.skyfox.org. All rights reserved." textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" minimumFontSize="9" translatesAutoresizingMaskIntoConstraints="NO" id="8ie-xW-0ye">
15+
<rect key="frame" x="20" y="439" width="441" height="21"/>
16+
<fontDescription key="fontDescription" type="system" pointSize="17"/>
17+
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
18+
<nil key="highlightedColor"/>
19+
</label>
20+
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="JavaScriptCore-Demo" textAlignment="center" lineBreakMode="middleTruncation" baselineAdjustment="alignBaselines" minimumFontSize="18" translatesAutoresizingMaskIntoConstraints="NO" id="kId-c2-rCX">
21+
<rect key="frame" x="20" y="140" width="441" height="43"/>
22+
<fontDescription key="fontDescription" type="boldSystem" pointSize="36"/>
23+
<color key="textColor" cocoaTouchSystemColor="darkTextColor"/>
24+
<nil key="highlightedColor"/>
25+
</label>
26+
</subviews>
27+
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
28+
<constraints>
29+
<constraint firstItem="kId-c2-rCX" firstAttribute="centerY" secondItem="iN0-l3-epB" secondAttribute="bottom" multiplier="1/3" constant="1" id="5cJ-9S-tgC"/>
30+
<constraint firstAttribute="centerX" secondItem="kId-c2-rCX" secondAttribute="centerX" id="Koa-jz-hwk"/>
31+
<constraint firstAttribute="bottom" secondItem="8ie-xW-0ye" secondAttribute="bottom" constant="20" id="Kzo-t9-V3l"/>
32+
<constraint firstItem="8ie-xW-0ye" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" constant="20" symbolic="YES" id="MfP-vx-nX0"/>
33+
<constraint firstAttribute="centerX" secondItem="8ie-xW-0ye" secondAttribute="centerX" id="ZEH-qu-HZ9"/>
34+
<constraint firstItem="kId-c2-rCX" firstAttribute="leading" secondItem="iN0-l3-epB" secondAttribute="leading" constant="20" symbolic="YES" id="fvb-Df-36g"/>
35+
</constraints>
36+
<nil key="simulatedStatusBarMetrics"/>
37+
<freeformSimulatedSizeMetrics key="simulatedDestinationMetrics"/>
38+
<point key="canvasLocation" x="548" y="455"/>
39+
</view>
40+
</objects>
41+
</document>
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
<!doctype html>
2+
3+
<html>
4+
5+
<head>
6+
<meta charset="UTF-8">
7+
8+
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no, target-densitydpi=device-dpi"/>
9+
10+
<title>Highcharts Sample</title>
11+
12+
<style>
13+
*
14+
{
15+
//-webkit-tap-highlight-color: rgba(0,0,0,0);
16+
text-decoration: none;
17+
}
18+
19+
html,body
20+
{
21+
-webkit-touch-callout: none; /* prevent callout to copy image, etc when tap to hold */
22+
-webkit-text-size-adjust: none; /* prevent webkit from resizing text to fit */
23+
-webkit-user-select: none; /* prevent copy paste, to allow, change 'none' to 'text' */
24+
}
25+
26+
body
27+
{
28+
margin: 0;
29+
padding: 0;
30+
}
31+
32+
</style>
33+
34+
<script src="jquery-1.11.0.min.js"></script>
35+
36+
<script type="text/javascript">
37+
38+
function drawChart (seriesArray) {
39+
$('#container').highcharts({
40+
chart: {
41+
type: 'area',
42+
inverted: true
43+
},
44+
title: {
45+
text: '一周网站访问数据图表'
46+
},
47+
xAxis: {
48+
categories: [
49+
'周一',
50+
'周二',
51+
'周三',
52+
'周四',
53+
'周五',
54+
'周六',
55+
'周日'
56+
]
57+
},
58+
yAxis: {
59+
title: {
60+
text: '访问量'
61+
},
62+
labels: {
63+
formatter: function() {
64+
return this.value;
65+
}
66+
},
67+
min: 0
68+
},
69+
plotOptions: {
70+
area: {
71+
fillOpacity: 0.5
72+
}
73+
},
74+
tooltip: {
75+
pointFormat: '{series.name} 被访问了 <b>{point.y:,.0f}</b> 次'
76+
},
77+
series: seriesArray,
78+
79+
// 去掉右下角网址 logo
80+
credits: {
81+
enabled: false
82+
}
83+
});
84+
}
85+
86+
</script>
87+
88+
</head>
89+
90+
<body style="background:#CDE; color:#FFF">
91+
92+
93+
<script src="highcharts.js"></script>
94+
95+
<div id="container" style="min-width: 310px; height: 400px; margin: 10px 5px 10px 5px; padding: 0"></div>
96+
97+
98+
</body>
99+
100+
</html>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
//
2+
// HighchartsWebViewController.h
3+
// JavaScriptCore-Demo
4+
//
5+
// Created by Jakey on 14/12/26.
6+
// Copyright (c) 2014年 www.skyfox.org. All rights reserved.
7+
//
8+
9+
#import <UIKit/UIKit.h>
10+
#import <JavaScriptCore/JavaScriptCore.h>
11+
12+
@interface HighchartsWebViewController : UIViewController<UIWebViewDelegate>
13+
@property (weak, nonatomic) IBOutlet UIWebView *webView;
14+
@property (strong, nonatomic) JSContext *context;
15+
@end
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
//
2+
// HighchartsWebViewController.m
3+
// JavaScriptCore-Demo
4+
//
5+
// Created by Jakey on 14/12/26.
6+
// Copyright (c) 2014年 www.skyfox.org. All rights reserved.
7+
//
8+
9+
#import "HighchartsWebViewController.h"
10+
11+
@interface HighchartsWebViewController ()
12+
13+
@end
14+
15+
@implementation HighchartsWebViewController
16+
17+
- (void)viewDidLoad {
18+
[super viewDidLoad];
19+
// Do any additional setup after loading the view from its nib.
20+
21+
NSString *path = [[[NSBundle mainBundle] bundlePath] stringByAppendingPathComponent:@"HighchartsView.html"];
22+
NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL fileURLWithPath:path]];
23+
24+
[self.webView loadRequest:request];
25+
}
26+
27+
#pragma mark - UIWebViewDelegate
28+
- (void)webViewDidFinishLoad:(UIWebView *)webView
29+
{
30+
// 以 html title 设置 导航栏 title
31+
self.title = [webView stringByEvaluatingJavaScriptFromString:@"document.title"];
32+
33+
// 禁用 页面元素选择
34+
//[webView stringByEvaluatingJavaScriptFromString:@"document.documentElement.style.webkitUserSelect='none';"];
35+
36+
// 禁用 长按弹出ActionSheet
37+
//[webView stringByEvaluatingJavaScriptFromString:@"document.documentElement.style.webkitTouchCallout='none';"];
38+
39+
40+
// 关联 JSContext
41+
self.context = [webView valueForKeyPath:@"documentView.webView.mainFrame.javaScriptContext"];
42+
43+
// 打印异常
44+
self.context.exceptionHandler =
45+
^(JSContext *context, JSValue *exceptionValue)
46+
{
47+
context.exception = exceptionValue;
48+
NSLog(@"%@", exceptionValue);
49+
};
50+
51+
52+
// 装载数据
53+
[self loadChartsData];
54+
}
55+
56+
#pragma mark - Load Charts Data
57+
58+
- (void)loadChartsData
59+
{
60+
// 装载数据
61+
NSArray *the1024Data = @[@33, @41, @32, @51, @42, @103, @136];
62+
NSDictionary *the1024Dict = @{@"name": @"1024", @"data": the1024Data};
63+
64+
NSArray *theCCAVData = @[@8, @11, @21, @13, @20, @52, @43];
65+
NSDictionary *theCCAVDict = @{@"name": @"CCAV", @"data": theCCAVData};
66+
67+
NSArray *seriesArray = @[the1024Dict, theCCAVDict];
68+
69+
[self.context[@"drawChart"] callWithArguments:@[seriesArray]];
70+
}
71+
72+
@end
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="6250" systemVersion="14B25" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none">
3+
<dependencies>
4+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="6244"/>
5+
</dependencies>
6+
<objects>
7+
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner" customClass="HighchartsWebViewController">
8+
<connections>
9+
<outlet property="view" destination="i5M-Pr-FkT" id="sfx-zR-JGt"/>
10+
<outlet property="webView" destination="oVQ-a3-iHJ" id="wdO-Ch-ahh"/>
11+
</connections>
12+
</placeholder>
13+
<placeholder placeholderIdentifier="IBFirstResponder" id="-2" customClass="UIResponder"/>
14+
<view clearsContextBeforeDrawing="NO" contentMode="scaleToFill" id="i5M-Pr-FkT">
15+
<rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
16+
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
17+
<subviews>
18+
<webView contentMode="scaleToFill" id="oVQ-a3-iHJ">
19+
<rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
20+
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
21+
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
22+
<connections>
23+
<outlet property="delegate" destination="-1" id="2La-lB-ZLU"/>
24+
</connections>
25+
</webView>
26+
</subviews>
27+
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
28+
<point key="canvasLocation" x="305" y="364"/>
29+
</view>
30+
</objects>
31+
<simulatedMetricsContainer key="defaultSimulatedMetrics">
32+
<simulatedStatusBarMetrics key="statusBar"/>
33+
<simulatedOrientationMetrics key="orientation"/>
34+
<simulatedScreenMetrics key="destination" type="retina4"/>
35+
</simulatedMetricsContainer>
36+
</document>

0 commit comments

Comments
 (0)