Tuesday, 3 June 2014

Mobile number format(111-111-1111) and maxlength=12(check)using javascript in Jquery mobile in phonegap applied for both Android and IOS.

Mobile number format(111-111-1111) and maxlength=12(check)using javascript in Jquery mobile in phonegap applied for both Android and IOS.

here i used keyup() and onblur() functions


keyup()function
 $('.mobilenumber111').keyup(function() {
                                this.value = this.value
                                .match(/\d*/g).join('')
                                .match(/(\d{0,3})(\d{0,3})(\d{0,4})/).slice(1).join('-').replace(/-*$/g, '');
                                });

onblur() function
function checkno1()
    {
        
        var x=document.getElementById("mobilenumber").value;
        //alert(x.length);
        if(x.length < 12)
        {
            navigator.notification.alert(
                                         'Enter valid number'// message
                                         alertDismissed,         // callback
                                         'Sign in',            // title
                                         'Ok'                  // buttonName
                                         );

            $("#mobilenumber").val("");
        }
        
    }

 <input type="tel" name="number" class="mobilenumber111"  value=""  onblur="checkno1()"  placeholder="Mobile Number" maxlength="12" data-role="none" required/>

Change youtube url to embedded url using javascript in phonegap. Applied for both IOS and Android

Change youtube url to embedded url using javascript in phonegap. Applied for both IOS and Android

here i used iframes to play videos ;


var myId = getId(myUrl);
function getId(url) {
        var regExp = /^.*(youtu.be\/|v\/|u\/\w\/|embed\/|watch\?v=|\&v=)([^#\&\?]*).*/;
        var match = url.match(regExp);
        
        if (match && match[2].length == 11) {
            return match[2];
        } else {
            return 'error';
        }
    }


<iframe class='framlist' width='100%' height='250' id='+VideoID+'src='https://www.youtube.com/embed/" + myId + "' seamless></iframe>

Check for Internet connection periodically in phonegap using java script

Check for Internet connection periodically in phonegap using java script

i used here time intervel it will check for every 10sec if connection is lost it will show alert that connection is deactivatedand if connection is gained it will show alert that connection is activated.

for this u have to include internet connection plugins and this is for both ios and android.


<script>
            var internetAvailableCount = 1;
            var internetUnavailableCount = 0 ;
            var conn=false;
            setInterval(function(){
                        var isConnected = checknetconnection(); // checkConnection() comes from above code
                        if(conn == false)
                        {
                        if(internetUnavailableCount == 0)
                        {
                        navigator.notification.alert(
                                                     'internet connection is deactivated'// message
                                                     alertDismissed,         // callback
                                                     'Internet',            // title
                                                     'Ok'                  // buttonName
                                                     );
                        internetUnavailableCount = internetUnavailableCount +1;
                        internetAvailableCount = 0;
                        }
                        return false;
                        }
                        else
                        {
                        if(internetAvailableCount == 0)
                        {
                        navigator.notification.alert(
                                                     'internet connection is activated'// message
                                                     alertDismissed,         // callback
                                                     'Internet',            // title
                                                     'Ok'                  // buttonName
                                                     );
                        internetUnavailableCount = 0;
                        internetAvailableCount = 1;
                        
                        }
                        
                        }
                        }, 10000);

            </script>


  

function checknetconnection()
{

if(navigator.network.connection.type == Connection.NONE)
{
   
    conn = false;
}
    
else
{
    conn = true;
    return true;
}

}


Setting Up Multiple App Targets in Xcode from a Single Codebase

 To create two different apps (like "Light" and "Regular") from the same codebase in Xcode, you can follow these steps b...