Thursday 28 August 2014

Array filter with Implode process - PHP

 Array filter with Implode process :

<?php
$chat_list=array(0,1,2,3,4,5,0,4,2,3);  // This array have duplicates

$user=array();

foreach($chat_list as $key=>$chat)
{
 $user[$key]=$chat['UserName'];
}

 print_r(implode(' , ',array_unique($user))); //This will show unique and added comma for each element.

 ?>

PHP Array filter working code


Array filter does not allow duplicate values:

<?php
$array = array(1, "hello", 1, "world", "hello");

$new=array_filter(array_count_values($array),'custom_filter');

print_r($new);

function custom_filter($val)
{
  return $val > 1;
}

?>

HTML Image Zoom Js function

<!doctype html>
<html>

<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>

<script type="text/javascript" src="http://www.dynamicdrive.com/dynamicindex4/jquery.magnifier.js">

/***********************************************
* jQuery Image Magnify- (c) Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for this script and 100s more
***********************************************/

</script>

</head>

<body>
<img src="icon.jpg" class="magnify" style="width:200px; height:150px" />

<img src="logo.jpg" class="magnify" border="0" />
</body>
</html>

HTML video play

HTML Video Play Control : 

<html>
<head>
  </head>
<body>

  <video id="example_video_1" class="video-js vjs-default-skin" controls preload="none"
 width="450" height="264"       data-setup="{}">
   
    <source src="v1.mp4" type='video/mp4' />
   
    <video src="v1.mp4" controls autoplay loop muted preload="auto" poster="demo.jpg" >
HTML5 Video is required for this example
 
  </video>

</body>
</html>

required JS for Phonenumber validation accept + -

Text field validation keep data after submit use required="required"
--------------------------------------------------------------------

Article:2
<input type="text" id="" name="phone" onkeypress="return onlyNos(event,this);" maxlength="15" required="required">

<script language="Javascript" type="text/javascript">

        function onlyNos(e, t) {

            try {

                if (window.event) {

                    var charCode = window.event.keyCode;

                }

                else if (e) {

                    var charCode = e.which;

                }

                else { return true; }

                if (charCode > 31 && (charCode < 48 || charCode > 57) && charCode > 43 && charCode > 45) {

                    return false;

                }

                return true;

            }

            catch (err) {

                alert(err.Description);

            }

        }



    </script>

Image Upload When click on sample image HTML PHP

html:

<input id="profile-image-upload" class="hidden" type="file">
<div id="profile-image">click here to change profile image</div>

js:

$(function() {
    $('#profile-image').on('click', function() {
        $('#profile-image-upload').click();
    });
});

   
css:

input.hidden {
    position: absolute;
    left: -9999px;
}

#profile-image {
    cursor: pointer;
    background: #8adffb;
     width: 80px;
    height: 80px;
}

Ref : jquery1.9.1
REF: http://jsfiddle.net/L8xCb/3/

working code:


<div id="profile-image1"><img  src="<?php echo $image1; ?>" ></div>
 <input id="profile-image-upload1" class="hidden" type="file" name="file1"></input>

We can add more than one image image1,image2 at css,js files.

Footer Fixed at bottom possible without jQuery

Footer fixed bottom position

I have a page with only a couple of lines of content. I want the footer to be pushed to the bottom.

<div id="footer"></div>

I don't want to use #footer{ position:fixed;bottom:0; } AKA Sticky Footer

Is this possible without jQuery?

ThaX for REf link:    http://stackoverflow.com/questions/16679146/force-footer-on-bottom-on-pages-with-little-content
<html>
    <head>
        <link rel="stylesheet" href="layout.css" ... />
    </head>
    <body>
        <div class="wrapper">
            <p>Your website content here.</p>
            <div class="push"></div>
        </div>
        <div class="footer">
            <p>Copyright (c) 2008</p>
        </div>
    </body>
<style>

* {
margin: 0;
}
html, body {
height: 100%;
}
.wrapper {
min-height: 100%;
height: auto !important;
height: 100%;
margin: 0 auto -4em;
}
.footer, .push {
height: 4em;
}
</style>
</html>

Dynamic Text Box add edit and delete and change HTML PHP

Dynamic Text Box add edit and delete and change that values as Array format and store in single column with comma(,) seperator.
Addform.php:
-------------
<?php
<script src="admin/js/jquery-1.11.1.js" ></script>

<form action="adddata.php" method="post" name="addevents"
 <td rowspan="2" style="border:1px solid #ccc;overflow:auto;">
    <div style="overflow:auto;">
    Latitude : <input type="text" name="latitude[]"   />
    Longitude : <input type="text" name="longitude[]"    />
    <input type="button" onclick="addFormField()" value="add" /><br>
   
   
    <div id="MoreFiles">
    </div>
   
<script type="text/javascript" language="javascript">
  var id = 1;
  function addFormField() {
 
      if(id < 100){
        
     
      jQuery("#MoreFiles").append("<div class='spacer'></div><div class='AdmFleft'>
      <div id='row"+id+"'><div class='control-group'>
      <div class='controls'>
      <label class='control-label' for='focusedInput'>Latitude : <input class='input-xlarge focused'  type='text' value='' name='latitude[]'>&nbsp;
      <label class='control-label' for='focusedInput'>Longitude : <input class='input-xlarge focused'  type='text' value='' name='longitude[]'>
      <a href='#' onClick='removeFormField(\"#row"+id+"\"); return false;'>DELETE</a></div></div></div></div>");
      id++;
      //id = (id-1) + 2;
      //document.getElementById('id').value = id;
     // datep();
      }
      else
        alert('Limit Reached');
     
  }
  function removeFormField(id) {
  alert(id);
     
      jQuery(id).remove();
  }

</script>
</td>
</form>
?>

adddata.php:
============
<?php

$lat=$_POST["latitude"];
$long=$_POST["longitude"];
foreach($lat as $latitude)
{
 $item1 .= $latitude.',';
}
foreach($long as $longitude)
{
 $item2 .= $longitude.',';
}
$latitude=substr($item1,0,-1);
$longitude=substr($item2,0,-1);
//$longitude0.','.$longitude1.','.$longitude2.','.$longitude3.','.$longitude4;
//insert  into $latitude......,

?>

================================
editform.php:
-------------


$id = $_GET['id'];
$query=mysql_query("select * from events where eventid=$id");
$res = mysql_fetch_assoc($query);

<td rowspan="2" style="border:1px solid #ccc;">
   
    <?php $latitude=explode(',' ,$res["latitude"]);  $longitude=explode(',' ,$res["longitude"]); ?>
    <?php foreach($latitude as $key => $lat1) { if($latitude[0] == $latitude[$key]) { ?>
   
    Latitude : <input type="text" name="latitude[]" id="latitude0"  value="<?php if(isset($lat1)){ echo $lat1;} else{ echo ''; }; ?>"  />
    Longitude : <input type="text" name="longitude[]" id="longitude0"   value="<?php if(isset($longitude[$key])) { echo $longitude[$key];} else{ echo ''; }; ?>"/>
        <input type="button" onclick="addFormField()" value="add" /><?php }
        else{?> <div id=<?php echo $key; ?>'>
       
    <div id="MoreFile">
    <div class="spacer"></div><div class="AdmFleft"><div id="rows<?php echo $key;?>"><div class="control-group"><div class="controls"><label for="focusedInput" class="control-label">Latitude : <input type="text" name="latitude[]" value="<?php if(isset($lat1)){ echo $lat1;} else{ echo ''; }; ?>" class="input-xlarge focused">&nbsp;<label for="focusedInput" class="control-label">Longitude : <input type="text" name="longitude[]" value="<?php if(isset($longitude[$key])) { echo $longitude[$key];} else{ echo ''; }; ?>" class="input-xlarge focused"><a onclick="removeFormField1(rows<?php echo $key;?>); return false;" href="#">DELETE</a></label></label></div></div></div></div></div>
                <?php } } ?>
       
        <div id="MoreFiles">
    </div>
   
   
<script type="text/javascript" language="javascript">

  var id = 1;
  function addFormField() {
 
      if(id < 100){
     
      jQuery("#MoreFiles").append("<div class='spacer'></div><div class='AdmFleft'><div id='row"+id+"'><div class='control-group'><div class='controls'><label class='control-label' for='focusedInput'>Latitude : <input class='input-xlarge focused'  type='text' value='' name='latitude[]'>&nbsp;<label class='control-label' for='focusedInput'>Longitude : <input class='input-xlarge focused'  type='text' value='' name='longitude[]'><a href='#' onClick='removeFormField(\"#row"+id+"\"); return false;'>DELETE</a></div></div></div></div>");
      id++;
      //id = (id-1) + 2;
      //document.getElementById('id').value = id;
     // datep();
      }
      else
        alert('Limit Reached');
     
  }
  function removeFormField(id) {
  //alert(id);
     
      jQuery(id).remove();
  }
   function removeFormField1(id) {
  alert(id);
     
      jQuery(id).remove();
  }


</script>
    </td>
-----
edit_event_process.php
Same thing follow in add details....

HTML Time Picker

Dowload files link : http://curioussolutions.github.io/DateTimePicker/



HTML TimePicker Example Snippet:

<!DOCTYPE html>

<html>

   
<head>
   

<title>Time Picker</title>

<link rel="stylesheet" type="text/css" href="../src/DateTimePicker.css" />
   


<script type="text/javascript" src="jquery-1.11.0.min.js"></script>
   
<script type="text/javascript" src="../src/DateTimePicker.js"></script>
   

<!--[if lt IE 9]>
           
<link rel="stylesheet" type="text/css" href="../src/DateTimePicker-ltie9.css" />

<script type="text/javascript" src="../src/DateTimePicker-ltie9.js"></script>

<![endif]-->
       


<style type="text/css">

p{
margin-left: 20px;

}


input{
width: 200px;

padding: 10px;

margin-left: 20px;
   
margin-bottom: 20px;

}

</style>
       

</head>
   

<body>
   

<p>Time : </p>
<input type="text" data-field="time" readonly>
   
<div id="timeBox"></div>
   
<input type="text" data-field="date" readonly>

<div id="dateBox"></div>

<script type="text/javascript">
   
$(document).ready(function()
   
{
$("#timeBox").DateTimePicker();
   
$("#dateBox").DateTimePicker();
    });

</script>
   

</body>

s
</html>

Tuesday 26 August 2014

JQM Phonegap Database login , php and home page

login.html:

<!DOCTYPE html> 
<html>
<head>
<meta charset="utf-8">
<title> Mobile Web App</title>
<link href="jquery-mobile/jquery.mobile-1.0.min.css" rel="stylesheet" type="text/css"/>
<script src="jquery-mobile/jquery-1.6.4.min.js" type="text/javascript"></script>

<script src="jquery-mobile/jquery.mobile-1.0.min.js" type="text/javascript"></script>
<script type="text/javascript" src="js/jquery.validate.js"></script>
<link rel="stylesheet" href="css/validate.css" />
<link rel="stylesheet" href="kphome.css" />
<script type="text/javascript" src="cordova-2.6.0.js"></script>

<script type="text/javascript">    

            $(document).bind("mobileinit", function()    // script for page flickering
        {    
                $.mobile.defaultPageTransition = 'none';
                $.mobile.defaultDialogTransition = 'none';
          
        });
            
            </script> 
            
<script type="text/javascript">    
            

var url="http://192.168.1.36:9090/hrms/";


document.addEventListener("deviceready", onDeviceReady, false);

function onDeviceReady()                          // device functionality
{
Dplatform=device.platform;
OSveriosn=device.version;
UUID= device.uuid;
alert('UUID'+UUID+'name'+OSveriosn+'OS'+Dplatform);
deviceinfo='OS: '+Dplatform+'Versionname: '+OSveriosn+'UUID: '+UUID;
alert(deviceinfo);
getDeviceLocation();
//alert("GEO:"+geo);


document.addEventListener("backbutton", Backbutton,false);
//msgloadingimage();
UUID=device.uuid;
//alert(UUID);
   sessionStorage.setItem('uuid',UUID);   
ApplicationVersionName="1.0";

/* if(navigator.network.connection.type==Connection.NONE || navigator.network.connection.type=="unknown" || navigator.network.connection.type==Connection.UNKNOWN)

{
        alert("Check Internet Connectivity");
       
        }
else{ */        
   
 $.ajax({
 url: url+"ANDROID_versionname.php",
 type:"POST",
 data:{"version":ApplicationVersionName}, 
 timeout: 5000,
 success: function(data) {
 if(data==10)
 {
 
 }
 else if(data==20)
 {
 alert("Please update the Current version 1.1");
 navigator.app.exitApp();  
 }
 
   },error:function(x, t, m)                      //notification API
       {   
           if(t==="timeout") {  navigator.notification.alert("Your Data connection is too slow", alertCallback,  "Alert");  
           
           else {  navigator.notification.alert("Check Internet Connectivity", alertCallback,  "Alert");           }
       }

}); 
       // }
 





function alertCallback()
{}

 function Backbutton(){
 if($.mobile.activePage.is("#index")){
  
navigator.notification.confirm('Do you want to exit', onConfirm,'Alert');               
     } 
     
     function onConfirm(button) 
     {
      if(button==1)
      {
       //  e.preventDefault();                  
            navigator.app.exitApp();
      }
      else
      {
      }
     }
 }


function  getDeviceLocation() {                  // geolocation API
//alert('a');
        navigator.geolocation.getCurrentPosition(showPosition, showError, { enableHighAccuracy: true } );
   }

function showPosition(position) {
alert('b');
         alert("Latitude: " + position.coords.latitude + "Longitude: " + position.coords.longitude);    
 geo="Latitude: " + position.coords.latitude + "Longitude: " + position.coords.longitude;
        // geo1=geo.val();
         alert(geo);
        
 }

//5.Create a function to handle the error.

 function showError(error) {

       alert("Errorcode: "    + error.code    + 
                "Errormessage: "+ error.message );
   }
function AlertHandler()
{
       // Codes 
navigator.notification.alert('This is an alert message', AlertHandler, 'Message', 'Exit');
   }
function loginvalidate()
 {
//alert("s");
        
var x=document.forms["loginn"]["username"].value;       
      
      if(x==null || x=="")
      {
navigator.notification.alert("Username cannot be left blank", alertCallback,  "Alert");      
          return false;  
       }

var x=document.forms["loginn"]["password"].value;         
      
      if(x==null || x=="")
      {
navigator.notification.alert("Password cannot be left blank", alertCallback,  "Alert");                                 
          return false;  
       }
    
      else
      {
          
          return true;
      }
 
 }   
 
function help()
{
navigator.notification.alert("Credentials identifies your organization at kp. Your organization may not be on our mobile application support.Please write/check with your Mobile HRMS for your Organization enrolment and the company Details", alertCallback,  "Alert"); 
}

function passingcode()                        // AJAX jquery Database connectivity
    {
//var url="http://http://192.168.1.36:9090//hrms/";
alert("passcode")
// $.mobile.loading( 'show' );

        var validate=loginvalidate();
        if(validate==true){
            
    var username= $("#username").val().toString(); //document.getElementById('compcode').value;
    var password= $("#password").val().toString(); 
    datavalue="username="+username+"&password="+password;
    alert(datavalue)
    $.ajax({
    url: url+"kp_login.php",
    type:"POST",
    data:datavalue,
    timeout: 5000,
    success: function(data) {   
   //  alert('c');
     
  data=jQuery.parseJSON(data);
  alert(data);
 
  if(data.status==1){
 
  / // db maintanance
 
  sessionStorage.clear();  // storage session info clear
  sessionStorage.setItem('dbname',data.dbname);
sessionStorage.setItem('dbserver',data.dbserver);
//sessionStorage.setItem('logo',data.logo);
sessionStorage.setItem('dbuserid',data.dbuserid);        
sessionStorage.setItem('dbpass',data.dbpass);

//sessionStorage.setItem('uid',username);//empcode
sessionStorage.setItem('url',url);
//sessionStorage.setItem('name',data.name);
//sessionStorage.setItem('companyid',compcode);
sessionStorage.setItem('empid',data.empid);
$.mobile.showPageLoadingMsg();
               window.location='kphome.html';
               //sessionStorage.clear(); do not pass data 
               
  navigator.notification.alert("Login success", alertCallback,  "Alert");
  sessionStorage.setItem('url',url);
  // alert("Login success");
  $.mobile.showPageLoadingMsg();
  window.location="kphome.html";
  //$.mobile.pageLoading;
   }
   else if(data==2)
   {
  navigator.notification.alert("Invalid Username", alertCallback,  "Alert");     
  //alert("Invalid username");
  $('#username').val('');
  $('#password').val('');
  }
 
      },error: function(){
  alert('Network activity error');
  }
  });
        }else{
       
        $.mobile.hidePageLoadingMsg();
          //  $.mobile.loading( 'hide' );
        }
   }

</script>

</head> 
<body> 

<div data-role="page" id="index"><!-- index page -->

<div data-role="header"  data-theme="b" style="background: url(images/bg5.png) repeat-x;">
     <div align="center"><img src="images/icon.png" a style="vertical-align:bottom;height:40px;text-align:center;">
  <span>MOBILE HRMS</span></div>
    </div><!-- /header -->

<div data-role="content" class="pagecontent" >
 
            <div class="inset" >
            <div align="center">  <h3 style="color:#08298A;"> MEMBER LOGIN </h3></div>
            <br>
            <hr size="1px" align="left">
            <!-- <form name="kp_login" method="get"  onSubmit="return loginvalidate();" or add to login function function call action="javascipt:kp_login();"> -->
            <form id="Login" method="post" name="loginn" action="javascript:passingcode()">
            
            <p> USER NAME :<img src="images/Help.png" align="right" style="vertical-align:right;" onclick="help()" /> </p>
            <input type="text" name="username" id="username" value="" autocomplete="off" placeholder="User Name" data-clear-btn="true" min="3" maxlength="10"/>
            <p> PASS WORD : </p>
            <input type="password" data-clear-btn="true" name="password" id="password" autocomplete="off" value=""placeholder="Pass Word" min="3" maxlength="8"/>
          
            <div data-role="fieldcontain">
             <input type="submit" name="login" value="Sign In"  /> 
            </div>
        </form>
            <br />
            <hr size="1px">
            <div data-role="fieldcontain" align="justify">
            <a  href="kp_newreg.html" rel="external" data-role="button"  data-inline="true" data-theme="a">New Registration</a>
      <a  href="kp_forgotpass.html" rel="external" data-role="button"  data-inline="true" data-theme="a">Forgot Password?</a>
     
            </div>
            </div>
        </div>
</div><!-- /content -->
    
    <div data-role="footer" data-position="fixed"  style="background: url(images/bg5.png) repeat-x;overflow:hidden;">
    <h4> Tech</h4>
    
</div><!-- /footer -->
</div><!-- /index page -->

</body>
</html>

kp_login.php:

<?php 
//session_start();
$username =$_POST["username"]; //Storing username in $username variable.
$password =$_POST["password"]; //Storing password in $password variable.
include("kp_dbconn.php"); //including config.php in our file
$row=array();
$qry = mysql_query("select firstname from persons where firstname = '$username' and lastname = '$password'") or die (mysql_error());


 if(mysql_affected_rows()>0){


$empdetail =mysql_query("select * from corpratedetails where empid = '$username'") or die(mysql_error());// select here image of emp and amp logo
if($empdetail==true)


//$row = mysql_fetch_array($empdetail);

  //echo $row[];
 $row['status']=1;$row['empid']=$username; $row['dbname']='test'; $row['dbserver']='localhost'; $row['dbuserid']='root';
  $row['dbpass']=' ';

echo json_encode($row);
}
else{

echo 2;
echo "username and password wrong";
}
}
   

?>


kphome.html:

<!DOCTYPE html> 
<html>
<head>
<meta charset="utf-8">
<title> Mobile Web App</title>
<link href="jquery-mobile/jquery.mobile-1.0.min.css" rel="stylesheet" type="text/css"/>
<script src="jquery-mobile/jquery-1.6.4.min.js" type="text/javascript"></script>
<script src="jquery-mobile/jquery.mobile-1.0.min.js" type="text/javascript"></script>
<script src="json2.js" type="text/javascript"></script>

<script type="text/javascript" src="cordova-2.6.0.js"></script>
<link rel="stylesheet" href="kphome.css" />
<script type="text/javascript">    
            $(document).bind("mobileinit", function()
        {    
                $.mobile.defaultPageTransition = 'none';
                $.mobile.defaultDialogTransition = 'none';
          
        });
</script>  
<script>
document.addEventListener("deviceready", onDeviceReady, false);

function onDeviceReady() { 
url=sessionStorage.getItem('url');

document.addEventListener("backbutton", Backbutton , false);
}


function Backbutton() 
{
//alert('a')
$.mobile.showPageLoadingMsg();
window.location="index.html";
$.mobile.hidePageLoadingMsg();
}
function back_button()
{
navigator.notification.alert("Use logout", alertCallback,  "Alert"); 
/* $.mobile.showPageLoadingMsg();
window.location="index.html";
$.mobile.hidePageLoadingMsg(); */
}
function alertCallback()
{}
function logout()
{
navigator.notification.confirm('Do you want to logout', onConfirm,'Alert');

}


function onConfirm(button) 
{
if(button==1)
{
$.mobile.showPageLoadingMsg();
window.location="index.html";
sessionStorage.clear();
}
else
{

}
}

</script>
</head> 
<body> 

<div data-role="page" id="kphomepage">
<div data-role="header"  data-theme="b" style="background: url(images/bg5.png) repeat-x;">
    <h1 style="color:#FFF">Mobile HRMS</h1>
    
    <!--<a href="#" data-icon="gear" class="ui-btn-right">Options</a>-->
   <!-- <div data-role="navbar" >
        <ul>
            <li><a  href="#page3" style="color:#fff;background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#bdbdbd), to(#000));;border-color:#fff;border-left-color:#fff;border-right-color:#fff;" class="ui-btn-active">Attendence System</a></li>
            <li><a href="#page4"style="color:#fff;background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#bdbdbd), to(#000));;border-color:#fff;border-left-color:#fff;border-right-color:#fff;">Corporate Directory</a></li>
            <li><a href="#page5"style="color:#fff;background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#bdbdbd), to(#000));;border-color:#fff;border-left-color:#fff;border-right-color:#fff;">List of Holidays</a></li>
        </ul>
    </div>--><!-- /navbar -->
</div><!-- /header -->

<div data-role="content" class="pagecontent" >
    <div class="backlogobutton" >
    
    
    <!-- <a href="javascript:back_button()" rel="external"  data-theme="b" data-inline="true" style="float:left; margin-top:0px;" >
<img id="home_icon" alt="home"  style="width:20px;  height:20px; " src="images/2.png"> </a> -->

    <img src="images/kp.gif" id='helplogo' >   
 
  <a href="javascript:logout()"  title="Logout" rel="external"  data-theme="b" data-inline="true" style="float:right;margin-top:0px; " >
<img id="logout_icon" alt="logout"  style="width:35px;  height:35px;vertical-align: center " src="images/logout.png"  > </a>
<br>

   
    
    </div>
     <div class="inset" >
<ul data-role="listview" data-inset="true">
        <li><a href="kpattendence.html" rel="external">Attendance Management</a></li>
<li><a href="kp_corp_add.html" rel="external" >Corporate Directory</a></li>
            <li><a href="kp_listofholidays.html" rel="external" >List of Holidays</a></li>
            <li><a href="kp_timsheet.html" rel="external">Time sheet</a></li>
<li><a href="kp_payslip.html" rel="external">Pay slip</a></li>
            <li><a href="kp_helpdesk.html" rel="external">Help Desk</a></li>
            <!--<li><a href="#page8">Help Desk</a></li>
            
<li><a href="#page10">Page ten</a></li>-->
</ul>
</div>
    </div>
<!--<div data-role="footer" data-position="fixed" style="background: url(images/bg5.png) repeat-x;";>
<h4>kp Tech</h4>
</div>-->
    
    <div data-role="footer" data-position="fixed"  style="background: url(images/bg5.png) repeat-x;overflow:hidden;">
    <h3 align="center">@kp</h3>
    <!--<div data-role="navbar">
        <ul>
            <li><a  href="#page3" style="color:#fff;background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#000), to(#bdbdbd));border-color:#fff;border-left-color:#fff;border-right-color:#fff;" class="ui-btn-active">Time Sheet</a></li>
            <li><a  href="#page3" style="color:#fff;background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#000), to(#bdbdbd));border-color:#fff;border-left-color:#fff;border-right-color:#fff;" class="ui-btn-active">Pay Slip</a></li>
            <li><a  href="#page3" style="color:#fff;background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#000), to(#bdbdbd));border-color:#fff;border-left-color:#fff;border-right-color:#fff;" class="ui-btn-active">Help Desk</a></li>
        </ul>-->
    </div><!-- /navbar -->
</div><!-- /footer -->
</div>




</body>

</html>

Friday 22 August 2014

Multiple version of jquery in the same Page

jQuery in no-conflict mode. "No conflict" mode is the typical solution to get jQuery working on a page with other frameworks like prototype, and can be also be used here as it essentially namespaces each version of jQuery which you load.
<script src="jQuery1.3.js"></script>
<script>
    jq13 = jQuery.noConflict(true);
</script>

<!-- original author's jquery version -->
<script src="jQuery1.2.3.js"></script>
<script src="jQuery1.3.js"></script>
<script>
    jq13 = jQuery.noConflict(true);
</script>
<script src="jQuery1.3.1.js"></script>
<script>
    jq131 = jQuery.noConflict(true);
</script>

<!-- original author's jquery version -->
<script src="jQuery1.2.3.js"></script>
The variables jq13 and jq131 would each be used for the version-specific features you require.
It's important that the jQuery used by the original developer is loaded last - the original developer likely wrote their code under the assumption that $() would be using their jQuery version. If you load another version after theirs, the $ will be "grabbed" by the last version you load, which would mean the original developer's code running on the latest library version, rendering the noConflicts somewhat redundant!
Why do conflicts happen? Conflicts typically happen because many JavaScript Libraries/Frameworks use the same shortcut name which is the dollar symbol $. Then if they have the same named functions the browser gets confused!
How do we prevent conflicts? Well, to prevent conflicts i recommend aliasing the jQuery namespace (ie by using example 3 above). Then when you call $.noConflict() to avoid namespace difficulties (as the $ shortcut is no longer available) we are forcing it to wrtie jQuery each time it is required.
1
2
3
4
5
6
7
8
9
10
jQuery.noConflict(); // Reverts '$' variable back to other JS libraries
jQuery(document).ready( function(){
         //do jQuery stuff when DOM is ready with no conflicts
   }); 
 
//or the self executing function way
 jQuery.noConflict();
 (function($) {
    // code using $ as alias to jQuery
})(jQuery);