Thursday, December 12, 2013

Hybrid vs Native mobile apps

This is an interesting question.
Few years ago, now late Steve Jobs proclaimed that HTML5 is the future of web development. Ok this needs to be viewed in a broader context, at that point in time Apple was waging a war against Flash and HTML 5 was a unlucky winner.
Steve Jobs quote:
They are lazy, Jobs says. They have all this potential to do interesting things but they just refuse to do it. They don’t do anything with the approaches that Apple is taking, like Carbon. Apple does not support Flash because it is so buggy, he says. Whenever a Mac crashes more often than not it’s because of Flash. No one will be using Flash, he says. The world is moving to HTML5.

Tuesday, November 26, 2013

Add Class to Next and Previous links in Wordpress

Write below code in function.php file to add class on next prev links for pagination

add_filter('next_posts_link_attributes', 'posts_next_link_attributes');
add_filter('previous_posts_link_attributes', 'posts_prev_link_attributes');

function posts_next_link_attributes() {
return 'class="nav_next_class"';

function posts_prev_link_attributes() {
return 'class="nav_prev_class"';

above function will add "nav_next_class" to next link and "nav_prev_class" to previous link.

Saturday, November 9, 2013

Get Latitude Longitude using Area Zip in PHP


function getLnt($zip){
$url = "
$result_string = file_get_contents($url);
$result = json_decode($result_string, true);
return $result3[0];

$val = getLnt($zip);
echo "Latitude: ".$val['lat']."<br>";
echo "Longitude: ".$val['lng']."<br>";


Change FromName and FromEmail For Wordpress

Open your theme function.php file to setup new fromname and fromemail for Site emails.


function mail_from()

global $mail_from_opt;

if (empty($mail_from_opt['username'])) : $username = "Bhumika"; endif;
$domainname = strtolower( $_SERVER['SERVER_NAME'] );
if ( substr( $domainname, 0, 4 ) == 'www.' ) {
$domainname = substr( $domainname, 4 );
$emailaddress = $username.'@'.$domainname;

return $emailaddress;

function mail_from_name()

global $mail_from_opt;

if (empty($mail_from_opt['sendername'])) : $sendername = "Bhumika"; endif;

return $sendername;


Friday, August 9, 2013

Create Mathematical Validation in Phone

create input, box and operation div in the html file.
write below code in the js file.
var answer;

var method = ['+', '-', '*'];
var operation;
//var operation='1+2+3';

// load new operation on page laod

Wednesday, July 10, 2013

Get Element Attribute Value using jQuery

Create textarea element to enter html content dynamic

// button click
    var str= $('#html_content').text();
    html = $.parseHTML( str ); // parse text to html
    $.each( html, function( i, el ) {
        var attr = $(el).attr('src'); // attribute name that you want fro the textarea content
        if (typeof attr !== 'undefined' && attr !== false) {
            alert(attr); // attribute value

you can get attribute value in alert dialog.

refer below URL for live example

Thursday, May 16, 2013

Add class to link which contains ".pdf" file

Add pdf icon to whole site pdf URLwhich are in the content_area.

In jQuery a[href*=".pdf"]' syntax contains all the elements which link ref contain .pdf
Add specific class to PDF links.

$('.content_area a[href*=".pdf"]').addClass('pdf_doc');

Apply below css to given class to add PDF icon to link to highlight.

.pdf_doc {
background: url("pdf.png") no-repeat scroll left 0;
padding-left: 20px;
background-size: 18px;

Friday, April 19, 2013

Get File Last Modified Date-Time


$filename = 'somefile.txt';
if (file_exists($filename)) {
    echo "$filename was last modified: " . date ("F d Y H:i:s.", filemtime($filename));


this file modify date is used for the mobile application to get updates are available or not on the server file.

Get County from User Lat Long

In Mobile application how the server knows about the posted device country and response then as per the location.

Get the current location of the device and use google map api to get user location. Get location from the ipaddress is a worth thing now. because all the internet user use proxy network.



$cur_lat =$_REQUEST['lat'];
$cur_lon = $_REQUEST['lon'];

Stop Copy Text from Phonegap Applications


Phonegap application is based on the HTML, CSS and JQuery. So if the user double tap on the app content then it will select the text and give option to copy and select text.

So for the application privacy if app admin does not want to copy application text then here is a way to stop selection of text.

Friday, April 12, 2013

Get Distance Between Two Lat Long

Create function to calculate distance. and pass lat long of first place and second place. and one parameter for the distance type.

function calculateDistance($lat1,$lng1,$lat2,$lng2,$miles = true)
    $pi80 = M_PI / 180;
    $lat1 *= $pi80;
    $lng1 *= $pi80;
    $lat2 *= $pi80;
    $lng2 *= $pi80;

Monday, April 1, 2013

Image store in Database.

Get the image URL that you want to store in the database.

$file= "";

$imgdata = base64_encode(file_get_content($file));

Above syntax give you a image in encoded formate. Store image data as a text in the database.

Use of image data in html app.
Get data from the database and append "data:image/jpeg:base64," before the data string like below:


Use appended string as a source of the image like below:

<img src="data:image/jpeg:base64,skadadjsiweryerjtkHRUWNHDDhASDJKKSDHD=" />

It will display image to the application.. in mobile applications does not need to load image from the server. and its also use for the offline application.

Saturday, March 30, 2013

Phonegap 2.5.0 Splashscreen goes down after load

When my phonegap app starts splash screen goes down 20px..
To resolve this issue I have made below changes in CDVSplashScreen.m. line no 116.

_imageView.frame = CGRectMake(0, 0, _imageView.image.size.width, _imageView.image.size.height);

_imageView.frame = CGRectMake(0, -20, _imageView.image.size.width, _imageView.image.size.height);

I have made this changes for the iphone4 and 5 and i also test this in simulator.

Tuesday, February 19, 2013

Setup Android app to be Movable in SD Card

Open your Android app In eclipse.

And Open menifest.xml file in edit mode.
add below code in manifest tag:


<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android=""
    package=""     android:installLocation="preferExternal"
    android:versionName="1.0" >

Wednesday, February 13, 2013

Disable Page Scroll on jQueryMobile Popup opens

when JQM popup open, and you dont want to scroll page then try this code.

Disable scroll.
$( ".popup").live({
                      popupbeforeposition: function(event, ui) {
                        $("body").on("touchmove", false);

After close popup release scroll.
$( ".popup" ).live({
                      popupafterclose: function(event, ui) {

Thursday, January 31, 2013

Numbers convert to currency formate

Copy below function in your js.

function formatCurrency(num) {
    num = num.toString().replace(/\$|\,/g,'');
    if(isNaN(num)) num = "0";
  // sign = (num == (num = Math.abs(num)));
    num = Math.floor(num*100+0.50000000001);
    cents = num%100;
    num = Math.floor(num/100).toString();
    if(cents<10) cents = "0" + cents;
    for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
        num = num.substring(0,num.length-(4*i+3))+','+num.substring(num.length-(4*i+3));
    return ( num + '.' + cents);

call function to get currency formate:



Friday, January 25, 2013

Access-Control-Allow-Origin. issue on Phonegap JqueryMobile

When i ajax call to get or post some Data from Server, Some times I found error like below.

XMLHttpRequest cannot load file://localhost/Users/bhumika/Documents/phonegap-2.2.0/lib/ios/bin/****/www/js/data.json. Origin null is not allowed by Access-Control-Allow-Origin.

to Solve above error write below syntax in your device ready function.

$.support.cors = true;
$.mobile.allowCrossDomainPages = true;


Write Below syntax in PHP file to the server.
header('Access-Control-Allow-Origin: *');