This repository has been archived by the owner on Oct 23, 2020. It is now read-only.
forked from pixelspring/NKBlueprint-Obj-C-Mix-Edition
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.html
165 lines (128 loc) · 5.6 KB
/
main.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
<html>
<head>
<meta name = "viewport" content = "initial-scale = 1.0, user-scalable = no" />
<link rel="stylesheet" href="style.css" type="text/css">
</head>
<body>
<script type="text/javascript" src="NKit.js"></script>
<script>
NKSetPageOpaque('main.html', 'NO');
var navController = new NKNavigationController();
navController.setTitle("Obj-C Tests");
navController.setTintColor(0, 0, 0);
var tabController = new NKTabBarController();
tabController.setTabBarForPage("main.html", "Main", "book32.png");
tabController.setTabBarForPage("pickerview.html", "Picker", "book32.png");
tabController.setTabBarForPage("prompt.html", "Prompt", "book32.png");
tabController.setTabBarForPage("table.html", "Table", "book32.png");
tabController.setTabBarForPage("search.html", "Search", "book32.png");
// NKRegisterClass's
NKRegisterClass("CustomAlert");
NKRegisterClass("ActivityIndicator");
NKRegisterClass("webViewController");
NKRegisterClass("battery");
NKRegisterClass("leftButton");
NKRegisterClass("locale");
NKRegisterClass("deShadow");
NKRegisterClass("flashLight");
NKRegisterClass("buttonlessAlert");
NKRegisterClass("navSpinner");
NKRegisterClass("screenShot");
NKRegisterClass("getFreeSpace");
NKRegisterClass("checkJailbreak");
// Battery Status
function alertPower()
{
var batteryLevel = CallNKitAction('getBatteryLevel?className=battery&sync=yes');
batteryLevel = batteryLevel.slice(1, -9);
NKAlert("Battery at:", batteryLevel+"%");
}
// Get Currency Symbol
function getLocale()
{
var locale = CallNKitAction('getLocale?className=locale&sync=yes');
NKAlert("Your Currency Symbol Is:", locale);
}
// Get Device Country Code
function getLocation()
{
var locale = CallNKitAction('getLocation?className=locale&sync=yes');
NKAlert("Your Device Country Code Is:", locale);
}
// Get Left Button Tap
function leftButtonClicked()
{
NKLog("Left Button Clicked");
NKAlert("Your Left Button Has...", "Been Clicked!");
}
// Show a buttonless alert...
function showButtonlessAlert()
{
CallNKitAction('showButtonless?className=buttonlessAlert');
setTimeout( "hideButtonlessAlert();", 5000);
}
// ... and then hide it as we don't have any buttons(!)
function hideButtonlessAlert()
{
NKLog("hideButtonlessAlert Called");
CallNKitAction('hideButtonless?className=buttonlessAlert');
}
function getSpace()
{
var freeSpace = CallNKitAction('getDeviceFreeSpace?className=getFreeSpace&sync=yes');
// Dirty method to convert bytes to GB. You might want to refine this to use MB etc.
freeSpace = freeSpace/(1024*1024*1024); // Convert Bytes to Gigabytes
gigVal=Math.round(freeSpace*10)/10; // Round to 1 decimal place
NKAlert("You have:", gigVal+" GB of free space remaining on your iDevice");
}
// ************************************************************************
// Is the device jailbroken?
//
// This is a very rudimentary method:
// If Cydia is present, then the device has obviously been jailbroken but..
// .. a jailbroken phone dosen't necessarily have Cydia installed!
// ************************************************************************
function isJailbroken()
{
NKAlert("Cydia Detected", "This device has been jailbroken");
}
function notJailbroken()
{
NKAlert("Cydia Not Found", "Device probably not jailbroken");
}
// ************************************************************************
</script>
<ul>
<!--<li><a onClick="CallNKitAction('showAlert?className=MyObjective')">Show Alert</a></li>-->
<!--<li><a onClick="CallNKitAction('CustomAlert?className=CustomAlert')">Show Custom</a></li>-->
<li><a onClick="CallNKitAction('showActivityIndicator?className=ActivityIndicator')">Show Status Bar Activity Indicator</a></li>
<li><a onClick="CallNKitAction('hideActivityIndicator?className=ActivityIndicator')">Hide Status Bar Activity Indicator</a></li>
<li><a onClick="alertPower()">Get Battery Level</a></li>
<li><a onClick="CallNKitAction('addLeftButton?className=leftButton')">Show Left Button</a></li>
<li><a onClick="CallNKitAction('removeLeftButton?className=leftButton')">Hide Left Button</a></li>
<li><a onClick="getLocale()">Get Locale</a></li>
<li><a onClick="getLocation()">Get Location</a></li>
<li><a onClick="CallNKitAction('dummy?className=deShadow')">Remove UIWebView Shadow</a></li>
<!-- ********************************************************
<--- NEED TO ADD CHECK FOR OS VERSION & DEVICE CAPABILITY
<--- This will ONLY run on device and will crash simulator!
<--- ******************************************************** -->
<li><a onClick="CallNKitAction('flashOn?className=flashLight')">Flashlight On</a></li>
<li><a onClick="CallNKitAction('flashOff?className=flashLight')">Flashlight Off</a></li>
<!--- ******************************************************* -->
<li><a onClick="navController.gotoPage('segmentedcontrol.html')">Segmented Control</a></li>
<li><a onClick="navController.gotoPage('listfiles.html')">Get Files In Documents Folder</a></li>
<li><a onClick="getSpace()">Get Free Space</a></li>
<li><a onClick="CallNKitAction('checkForJailbreak?className=checkJailbreak')">Check For Jailbreak</a></li>
<!-- ********************************************************
<--- NOT YET WORKING and/or CRASHY
<--- Please feel free to fix ;)
<--- ********************************************************
<li><a onClick="showButtonlessAlert()">Show Buttonless Alert</a></li>
<li><a onClick="CallNKitAction('showSpinner?className=navSpinner')">Show NavBar Spinner</a></li>
<li><a onClick="CallNKitAction('stopSpinner?className=navSpinner')">Remove NavBar Spinner</a></li>
<li><a onClick="CallNKitAction('saveScreenshot?className=screenShot')">Take ScreenShot</a></li>
-->
</ul>
</body>
</html>