-
Notifications
You must be signed in to change notification settings - Fork 3
/
main.html
246 lines (183 loc) · 8.26 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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
<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');
// ************************************************************************
// Customise elements in iOS 5
// This needs to go before the element creation js call.
// Only needs called once on first page to load with custom element
// creation, then will apply globally.
NKRegisterClass("wood");
CallNKitAction('navBar?className=wood'); // Customise navBar
CallNKitAction('tabBar?className=wood'); // Customise tabBar
// ************************************************************************
var tabController = new NKTabBarController();
tabController.setTabBarForPage("main.html", "Main", "home.png");
tabController.setTabBarForPage("pickerview.html", "Picker", "picker.png");
tabController.setTabBarForPage("prompt.html", "Prompt", "prompt.png");
tabController.setTabBarForPage("table.html", "Table", "tblvw.png");
tabController.setTabBarForPage("search.html", "Search", "search.png");
var navController = new NKNavigationController();
navController.setTitle("Obj-C Tests");
navController.setTintColor(0, 0, 0);
// NKRegisterClasses
NKRegisterClass("customUIAlert");
NKRegisterClass("ActivityIndicator");
NKRegisterClass("webViewController");
NKRegisterClass("battery");
NKRegisterClass("leftButton");
NKRegisterClass("locale");
NKRegisterClass("deShadow");
NKRegisterClass("deBounce");
NKRegisterClass("flashLight");
NKRegisterClass("buttonlessAlert");
NKRegisterClass("navSpinner");
NKRegisterClass("screenShot");
NKRegisterClass("getFreeSpace");
NKRegisterClass("checkJailbreak");
NKRegisterClass("TObject");
// 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 Device Country Code
function getLang()
{
var locale = CallNKitAction('getLang?className=locale&sync=yes');
NKAlert("Your ISO 639-1 Language 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");
}
// ************************************************************************
// ************************************************************************
// Send a tweet in iOS 5
//
// Remember to add the Twitter & UIKit frameworks to your project and to
// add a device version check (ie, only for iOS 5+)
//
// Also recommended, "weak link" the Twitter framework: select your target,
// select the "Summary" tab, select the framework in "Linked Frameworks and
// Libraries" and change from "Required" to "Optional"
// ************************************************************************
var tweetMessage = "This is a tweetage sent via a NimbleKit app with Obj-C/js mix";
function sendTweet()
{
CallNKitAction("tweetIt?className=TObject&message="+tweetMessage);
}
// ************************************************************************
// ************************************************************************
// Custom Alert
function showCustomAlert()
{
var customAlert="customAlert?className=customUIAlert&caPage=main.html&title=Custom Alert&message=This is a customised UIAlertView\n\nWoohoo!&cancel=Lovely!&ok=Nice!&jsCAFunction=caButtonPressed()"
CallNKitAction(customAlert);
}
function caButtonPressed() {
NKLog("Custom Alert OK Button Pressed");
// Do Something instead of a boring NKLog :)
}
// ************************************************************************
</script>
<div class="panel">
<ul>
<li><a onClick="showCustomAlert()">Show Custom Alert</a></li>
<li><a onClick="CallNKitAction('dummy?className=deShadow')">Remove UIWebView Shadow</a></li>
<li><a onClick="CallNKitAction('noBounce?className=deBounce')">Prevent WebView Bounce (iOS 5+)</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="CallNKitAction('addLeftButton?className=leftButton')">Show Left Button</a></li>
<li><a onClick="CallNKitAction('removeLeftButton?className=leftButton')">Hide Left Button</a></li>
<li><a onClick="CallNKitAction('showNavSpinner?className=navSpinner')">Show NavBar Spinner</a></li>
<li><a onClick="navController.removeNavigationItem()">Remove NavBar Spinner</a></li>
<li><a onClick="alertPower()">Get Battery Level</a></li>
<li><a onClick="getLocale()">Get Locale</a></li>
<li><a onClick="getLocation()">Get Location</a></li>
<li><a onClick="getLang()">Get Language Code</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>
<li><a onClick="navController.gotoPage('undetecttel.html')">Tel. No. Detection</a></li>
<li><a onClick="navController.gotoPage('urlschemas.html')">URL Schemas</a></li>
<li><a onClick="sendTweet()">Send a Tweet</a></li>
<li><a onClick="navController.gotoPage('compass.html')">Compass</a></li>
<li><a onClick="navController.gotoPage('scrollview.html')">Scroll View</a></li>
<li><a onClick="navController.gotoPage('localnotifications.html')">Local Notifications</a></li>
<li><a onClick="navController.gotoPage('gestures.html')">Gesture Recognizers</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 <i>(Device Only)</i></a></li>
<li><a onClick="CallNKitAction('flashOff?className=flashLight')">Flashlight Off <i>(Device Only)</i></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('saveScreenshot?className=screenShot')">Take ScreenShot</a></li>
-->
</ul>
</div>
</body>
</html>