Archive for the ‘phonegap’ Category

I needed to secure my jquery mobile pages. Because it depends on user authentication to the server first.

I use this code for example to prevent the page from loading until user is logged in and redirect it to a login/register page:

$(document).bind(“pagebeforechange”, function (event, data) {

//alert (“trying”);
if (typeof data.toPage == ‘object’ && data.toPage.attr(‘data-needs-auth’) == ‘true’) {
//alert (“token= ” + sessionStorage.getItem(“token”));
if (!sessionStorage.getItem(“token”)) {
pageVars.returnAfterLogin = data;
event.preventDefault();
//alert (“going to login page”);
$.mobile.changePage(“#login”, { changeHash: false });
}
else {
//alert (“going to normal page”);
//sessionStorage.setItem(‘token’, localStorage.getItem(“token”));
}
}
});

and mark the page like this

<div id=”workoutspage” data-role=”page”  data-needs-auth=”true”>

I had the original page init code in the devicereadyevent and I had to move it to the pageshow event. like so:

$(‘#workoutspage’).live(‘pageshow’, function (event) {

… init page stuff …

});

i had to do it like this becuase the devicereadyevent happens anyways no matter what. And i wanted to load the secured page content only if the actual page is loading…  (took it from here http://stackoverflow.com/questions/6126493/jquery-mobile-after-page-is-shown-event)

Advertisements

After SDK upgrade my app kept on failing with errors on launch

FATAL EXCEPTION: main

java.lang.ClassNotFoundException

I spent 2 hours on this bullshit

solution:
under project libs, right click on cordova-2.3.0.jar and click Build Path –> Add to Build Path

After a long romance, we must say goodbye…

We spent lots of time together and it was lovely.

Its not me… its you…. i built you and on some platforms you worked well but most of the time – you just got stuck.

Phonegap has failed me completely. Beside the crappy gui performance, now i also experience functionality anomalities under different os.

I’m going native with android 4. see you in the upcoming bugs 🙂

$.mobile.changePage(“#page2”);

(from this post)

ok. this isn’t working. I’m getting the following error:

02-14 18:20:12.093: E/Web Console(17689): Uncaught TypeError: Cannot call method ‘changePage’ of undefined at file:///android_asset/www/goals.html:112

bad bad bad

need to find something else. so i tried this

$.mobile.back();

still not working i’m getting this error

02-14 18:23:16.082: E/Web Console(17915): Uncaught TypeError: Cannot call method ‘back’ of undefined at file:///android_asset/www/goals.html:112

i’ll try something else… following this site i’m trying

$.mobile.loadPage( pageUrl, { showLoadMsg: false } );

shit. nothing seems to work. now i’m getting this error

02-14 18:27:24.265: E/Web Console(18181): Uncaught TypeError: Cannot call method ‘loadPage’ of undefined at file:///android_asset/www/goals.html:112

tried this:

$.mobile.changePage(“index.html”, null, true, true);

and got

02-14 18:30:33.429: E/Web Console(18465): Uncaught TypeError: Cannot call method ‘changePage’ of undefined at file:///android_asset/www/goals.html:112

it seems like $.mobile is not recognized…. 😦 what to do what to do?

i tried also to change the calling of this code not from deviceReady event of phonegap but with this:

$(document).bind(“pagecreate”, function(){

found it on this link. also not working… not even triggering…damn

also tried to change the calling to this

$(‘#goals-page’).live(“pageinit”, function() {

and failed. I’m getting this error

02-14 18:39:05.158: E/Web Console(19354): Uncaught TypeError: Object [object Object] has no method ‘live’ at file:///android_asset/www/goals.html:103

i’m strating to get pissed off.

OK. FOUND THE ANSWER HERE. I used this:

window.location.href = “index.html”;

I want to show the users progress over time with some charts. So here I am searching google again for some answers.

Found this link:

Create Quick and Easy Progress Bar Charts with HTML5 and CSS3

p1

This isn’t exactly what I was looking for but an easy progress bar can be quite handy. Its worth testing…

Fuck, this article has no demo. This is NOT COOL. But it was easy creating out of the code presented on the page. So I guess I will try.

Ok, got it. Here is the result:

p2

and the code is:

<html>
<body>
<style>
/* Firefox – value portion of progress bar */
progress#bar::-moz-progress-bar {
background-color: red;
-moz-box-shadow: 1px 1px 1px #333333;
}

/* Chrome, Safari – value portion of progress bar */
progress#bar::-webkit-progress-value {
background-color: red;
-webkit-box-shadow: 1px 1px 1px #333333;
}

/* All other attributes */
progress#bar {
background-color: #F0F0F0;
border: solid #808080 2px;
border-radius: 5px;
-moz-box-shadow: 3px 3px 3px #C0C0C0;
-webkit-box-shadow: 3px 3px 3px #C0C0C0;
box-shadow: 3px 3px 3px #C0C0C0;
padding: 3px;
width: 250px;
height: 20px;
}
</style>

<strong>Project Completion Status</strong><br />
<br />
Project #1<br />
<progress id=”bar” value=”6″ max=”9″>
<em>6 of 9 stages completed</em></progress>
<br />
Project #2<br />
<progress id=”bar” value=”20″ max=”100″>
<em>20% complete</em></progress>
<br />
Project #3<br />
<progress id=”bar” value=”12″ max=”20″>
<em>12/20 components completed</em></progress>
<br />
Project #4<br />
<progress id=”bar” value=”4″ max=”8″>
<em>50% complete</em></progress>
<br />
Project #5<br />
<progress id=”bar” value=”9″ max=”10″>
<em>9 out of 10 stages completed</em></progress>
</body>
</html>

This will be handy someday 🙂

The next google search result looks very good. Its specifically about jquery-mobile charting. Exactly what I need.

jQuery Mobile Charts

+ the source code on github

If this will be the result on my end, I will be a happy man indeed. Lets give it a try.

The example works just fine. Now I will try to embed this to my phonegap app. lets see how it goes…

ok. it took me 10 minutes to integrate the sample code to my html5 code. (just the sample, no functionallity yet).

I had one problem with the addition, at first it didn’t work and than I tried to add this code:

<script src=”JQMCharts/scripts/jquery.jqplot.min.js” type=”text/javascript”></script>
<script src=”JQMCharts/scripts/jqplot.pieRenderer.min.js” type=”text/javascript”></script>
<script src=”JQMCharts/scripts/jqplot.barRenderer.min.js” type=”text/javascript”></script>
<script src=”JQMCharts/scripts/jqplot.categoryAxisRenderer.min.js” type=”text/javascript”></script>
<script src=”JQMCharts/scripts/underscore-min.js” type=”text/javascript”></script>
<script src=”JQMCharts/scripts/hideAddressBar.js” type=”text/javascript”></script>
<script src=”JQMCharts/scripts/app.js” type=”text/javascript”></script>

to the end of the file instead of the beginning.

this what fixed my problem.

I have no idea why…

anyways i don’t like this code so much. not very scalable…

So I gonna try this library:

http://www.jqplot.com/

ok so i downloaded jquery.jqplot.1.0.5r1122 and I’m following the basic installation instructions from the jqueryPlot website I hope it will be easy as it looks.

I added two files to my project and added the following lines

<!– jqueryplot –>
<script language=”javascript” type=”text/javascript” src=”jqueryplot/jquery.jqplot.min.js”></script>
<link rel=”stylesheet” type=”text/css” href=”jqueryplot/jquery.jqplot.css” />

I added a chart container:

<div id="chartdiv" style="height:400px;width:300px; "></div>

. and added the graph creation code

$.jqplot('chartdiv',  [[[1, 2],[3,5.12],[5,13.1],[7,33.6],[9,85.9],[11,219.9]]]);

not worknig 😦

I will try to add

<script language=”javascript” type=”text/javascript” src=”jqueryplot/jquery.min.js”></script>

as well.

Still nothing.. the chart isn’t showing…

GOT IT!! The problem was as usual that my code aims for phonegap so the $.jqplot(‘chartdiv’,  [[[1, 2],[3,5.12],[5,13.1],[7,33.6],[9,85.9],[11,219.9]]]); code wasn’t triggered because it was in the deviceReady event function. When I created a window.onLoad function instead – everything worked on Chrome.

 

Now I need to create a vertical bar chart. So I found this link.

Also succeeded to create a BarRender chart with it. and found this pretty awsume link to how add dynamic data to a jqplot chart.

I almost finished my phonegap + native java code for my mobile application.

I decided to take another background task to design it. I guess it will take some time and i’ll iterate over several designs so it about the right time to get started.

I found an interesting post on adobe website, and it links to a video on adobe-tv.

i’m familiar with photoshop, dreamweaver and phonegap so it shouldn’t be too hard on me 🙂

Good day,

I tried for two hours now to figure out how to programically set an option for a selectmenu by mobiscroll. I tried several suggetion found on my google searches and here are my conclusions.

mobiscroll, you need to provide a better api for this. It takes too much time to do this (very very) basic and simple task. WTF.

What i did was to set values with the val() function, than set the mobiscroll functionallity and finally loading the dialog.

$(“#updateDayOfWorkoutPlan”).val(row.dayoftheweek);
$(“#updateTimeOfWorkoutPlan”).val(row.time);
$(“#updateDurationOfWorkoutPlan”).val(row.duration);
$(“#updateAlertOfWorkoutPlan”).val(row.alert);

$(“#updateDayOfWorkoutPlan”).mobiscroll().select();
$(“#updateTimeOfWorkoutPlan”).mobiscroll().time();
$(“#updateDurationOfWorkoutPlan”).mobiscroll().select();
$(“#updateAlertOfWorkoutPlan”).mobiscroll().select();

$.mobile.changePage(“#update-page”);

this is not pretty but got to keep things moving.