Here is the link to the sample project: http://www.harveyspoint.mobi/app/GG-Test.zip
Also the other thing is not working for me is the NKOpenURLInSafari on the twitter.html page.
Thanks again.
function reloadPage()
{
//in this case we do not use the reload method because it would reload the current visible page on the webview and not return to the main one
loadedFirst = 0;
toolBar.removeButtonAtIndex(2);//remove the back button
backButtonIsVisible = false;
webView.loadURL("http://harveyspoint.mobi/app/breaks/");
}
statusHTML.push('<li><span>'+status+'</span> <a style="font-size:85%" href="#" onclick=NKOpenURLInSafari("http://twitter.com/'+username+'/statuses/'+twitters[i].id_str+'">'+relative_time(twitters[i].created_at)+'</a></li>');
/'+twitters[i].id_str+'">
/'+twitters[i].id_str+'")>
<html>
<head>
<meta name = "viewport" content = "initial-scale = 1.0, user-scalable = no" />
<script type="text/javascript" src="NKit.js"></script>
<script type="text/javascript">
var webView = new NKWebView;
webView.init(0,43,320,380);
webView.loadURL("http://harveyspoint.mobi/app/breaks/");
webView.setScalesToFit("yes");
webView.show();
var toolBar = new NKToolBar();
toolBar.init(0);
toolBar.insertButtonAtIndex(1,"Update",'','reloadPage');
toolBar.insertButtonAtIndex(2,"Tweets",'','twitter');
toolBar.setTintColor(01, 44, 18);
toolBar.show();
var loadedFirst = 0;//nothing loaded yet
var backButtonIsVisible = false;
function closeModalWindow()
{
modal.dismiss();
loadedFirst++;//increment it the control
//add the button once this is second time it show (meaning a second page loaded) and increment the loadedFirst
if(loadedFirst > 1 && backButtonIsVisible == false)
{
toolBar.insertButtonAtIndex(2,"Back",'','webViewBack');
backButtonIsVisible = true;
}
}
function webViewBack()
{
webView.goBack();
loadedFirst = loadedFirst- 2;
//Remove the button if the counter reaches 0, meaning it has no page to go back in the history
if(loadedFirst <= 1)
{
toolBar.removeButtonAtIndex(2);//remove the back button
backButtonIsVisible = false;
}
}
function reloadPage()
{
//in this case we do not use the reload method because it would reload the current visible page on the webview and not return to the main one
loadedFirst = 0;
toolBar.removeButtonAtIndex(2);//remove the back button
backButtonIsVisible = false;
webView.loadURL("http://harveyspoint.mobi/app/breaks/");
}
function twitter(){
NKMoveToPageAnimated("twitter.html", 'slideup')
}
modal = new NKModalWindow();
modal.show();
var indicator = new NKActivityIndicator();
indicator.init(90, 165, 30, "white");
indicator.show();
indicator.spin();
modal.addControl(indicator);
var label = new NKLabel();
label.init(140, 158, 140, 40, "Please wait...");
modal.addControl(label);
label.show();
var button = new NKButton();
button.init(120, 210, 100, 40, "buttonClick");
button.setTitle("Dismiss");
modal.addControl(button);
button.show();
function buttonClick(){
modal.dismiss();
}
webView.setOnFinishCallback("closeModalWindow");
// check for internet connectivity
function checkForConnection(){
if(NKIsInternetAvailableViaWifi() == 0 && NKIsInternetAvailableViaCellularNetwork() == 0){
NKAlert("Cannot Connect to Internet", "An internet connection is required to update information.");
}
}
checkForConnection();
</script>
</head>
<body>
</body>
</html>
function reloadPage(){
//in this case we do not use the reload method because it would reload the current visible page on the webview and not return to the main one
modal.show();
loadedFirst = 0;
if(backButtonIsVisible)
{
toolBar.removeButtonAtIndex(2);//remove the back button
}
backButtonIsVisible = false;
webView.loadURL("http://harveyspoint.mobi/app/breaks/");
}
Sorry, just one more last thing: If a user is not connected to the internet and update the page, the alert is not triggered. Will Apple or the user be ok with this?
Users browsing this forum: No registered users and 1 guest