Month: February 2014

Javascript – HTML Table as string – Cordova

Hello Guys,

Hope you are doing great !

I’ve found some strange aspects which I never expected while creating HTML table with javascript. I’ve used multiline string to construct the table using “\”. I was completely unaware of the consequences. While accessing the table through DOM, number of children present in each row were being shown as more than what it is originally. I suppose the problem is changing innerHTML as a string which has HTML elements is resulting in wrong interpretation of “\” and white spaces by the browser.

Eg:

table = table + “<tr class=\”note\”>\
<td>”+res.rows.item(i).id + “</td>\
<td>”+res.rows.item(i).title + “</td>\
<td>”+pretext.substr(0,20)+ “…</td>\
</tr>”;

Here each row has 3 columns but in reality, accessing the children of
element will show the length as 6 i.e., threeand three “\”.

Conclusion is just be cautious while using “\” and updating innerHTML with HTML elements.

Advertisements

Cordova Vs Phonegap

Hello Guys,

Hope you are doing great !

I have gone through tough times learning what exactly is cordova and phonegap are. I have finally found a blog which revealed all the suspense. One of the mistake which took me on goose chase was Docs. In short, cordova is an open source project which was born from Adobe’s phonegap. Adobe donated phonegap to open source community through Apache Foundation. Name was changed just to differentiate them and to overcome few issues.

Cordova Problems

Hello Guys,

Hope you are doing great !

I have started working on cordova to build an app for android. Initially I found it hard to understand but after some time, I felt this is a great way to build apps faster. At present, I can see the aspects that are missing in cordova. It has great application but still in need of improvements. Debugging application is one of the most irritating process. Javascript errors are not evaluated as initial check which makes the developers check for such errors separately through browsers. I might be totally wrong, not being able to see the light around me. Only time will unwrap my ignorance 🙂

Cordova Initial Setup

Hello Guys,

Hope you are doing great !

Below are the steps in getting started with cordova API. I need to read around many posts to gather this information. I hope this post will help people learn faster 🙂

Installing cordova:

Install Node.js:

Download Node from http://nodejs.org/

Download and follow below steps just as present in README file –

Prerequisites (Unix only):

* GCC 4.2 or newer
* Python 2.6 or 2.7
* GNU Make 3.81 or newer
* libexecinfo (FreeBSD and OpenBSD only)

Unix/Macintosh:

./configure
make
make install

If your python binary is in a non-standard location or has a
non-standard name, run the following instead:

export PYTHON=/path/to/python
$PYTHON ./configure
make
make install

Install Cordova:

Cordova can be installed through npm which comes with node.js.

sudo npm install -g cardova

Creating App:

cordova create <Folder Name> <Reverse Domain Name> <App Name>

Eg: cordova create hello com.hello.world HelloWorld

App Name is optional. It can be later changed in config.xml file.

Adding Platforms:

Platforms SDK must be already present on your system to add them to cordova. Make sure your platform SDK files are on your file system’s PATH.

cordova platform add <Platform Name>

Eg: cordova platform add android

Adding Plugins:

cordova plugin add <Plugin Link>

Eg: cordova plugin add org.apache.cordova.camera

OR

Eg: cordova plugin add https://github.com/lite4cordova/Cordova-SQLitePlugin

Plugins can also be installed directly through git repository link

Run Application:

cordova run <Platform Name>

Eg: cordova run android

“run” option allows cordova to build, install and run application on device (if device is not connected to the system you are working on, emulator will be started and used automatically)