Pages

Saturday, January 14, 2017

Smooth Scroll for menu in Onepage site

Smooth Scroll for Onepage site


$(function() {
   $('ul li a[href*="#"]:not([href="#"])').click(function() {
   if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
     var target = $(this.hash);
     target = target.length ? target : $('[name=' + this.hash.slice(1) +']');
     if($(window).width()>=768){
       if (target.length) {
         $('html, body').animate({
           scrollTop: target.offset().top - 90
         }, 800);
         return false;
       }
     }
     else{
       if (target.length) {
         $('html, body').animate({
           scrollTop: target.offset().top - 50
         }, 800);
         return false;
       }
     }
   }
   });
 });

Thursday, January 12, 2017

Add Facebook Widget in HTML Website

How are Add Facebook widget Timeline OR Posts in your website

Example here:
Just Change the name of your path in the href attribute like:

href="https%3A%2F%2Fwww.facebook.com%2Fyourpagename

<iframe src="https://www.facebook.com/plugins/page.php?href=https%3A%2F%2Fwww.facebook.com%2Ffacebook&tabs=timeline&width=340&height=500&small_header=false&adapt_container_width=true&hide_cover=false&show_facepile=false&appId=524468484230981" width="340" height="300" style="border:none;overflow:hidden" scrolling="no" frameborder="0" allowTransparency="true"></iframe>


View Posts of your page.



Add Twitter Widget in HTML Website

Add Twitter Widget in HTML Website


<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+"://platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
                                <a class="twitter-timeline" href="https://twitter.com/zakeerio">Tweets by Zahid Ali Keerio</a>
                                <script async src="//platform.twitter.com/widgets.js" charset="utf-8"></script>

Example: 

Tuesday, January 3, 2017

Create Helper function in CodeIgniter

Create Helper function in Codeigniter
------------------------------------------------------------------------
if(!function_exists('sqlRecordsCount')){
function sqlRecordsCount(){
$ci1 =& get_instance();

           // Get Connection of Another Database Defined

   $db2 = $ci1->load->database('otherdb', TRUE);
 

            $query = "SELECT book_id from books";
$query = $db2->query($query);

// echo $db2->last_query();
$result = $query->result_array();
return $result;

}

}

print_r($sqlRecordsCount());

Wednesday, December 7, 2016

Convert 10 OR 9 Digit ISBN Number to 13 Digit ISBN Number in PHP

$isbn = '178629298X';

/**
* Function accepts either 12 or 13 digit number, and either provides or checks the validity of the 13th checksum digit
*    Optionally converts to ISBN 10 as well.
*/
function isbn13checker($input, $convert = FALSE){
$output = FALSE;
if (strlen($input) < 12){
$output = array('error'=>'ISBN too short.');
}
if (strlen($input) > 13){
$output = array('error'=>'ISBN too long.');
}
if (!$output){
$runningTotal = 0;
$r = 1;
$multiplier = 1;
for ($i = 0; $i < 13 ; $i++){
$nums[$r] = substr($input, $i, 1);
$r++;
}
$inputChecksum = array_pop($nums);
foreach($nums as $key => $value){
$runningTotal += $value * $multiplier;
$multiplier = $multiplier == 3 ? 1 : 3;
}
$div = $runningTotal / 10;
$remainder = $runningTotal % 10;

$checksum = $remainder == 0 ? 0 : 10 - substr($div, -1);

$output = array('checksum'=>$checksum);
$output['isbn13'] = substr($input, 0, 12) . $checksum;
if ($convert){
$output['isbn10'] = isbn13to10($output['isbn13']);
}
if (is_numeric($inputChecksum) && $inputChecksum != $checksum){
$output['error'] = 'Input checksum digit incorrect: ISBN not valid';
$output['input_checksum'] = $inputChecksum;
}
}
return $output;
}

/**
* Function accepts either 10 or 9 digit number, and either provides or checks the validity of the 10th checksum digit
*    Optionally converts to ISBN 13 as well.
*/
function isbn10checker($input, $convert = FALSE){
$output = FALSE;
if (strlen($input) < 9){
$output = array('error'=>'ISBN too short.');
}
if (strlen($input) > 10){
$output = array('error'=>'ISBN too long.');
}
if (!$output){
$runningTotal = 0;
$r = 1;
$multiplier = 10;
for ($i = 0; $i < 10 ; $i++){
$nums[$r] = substr($input, $i, 1);
$r++;
}
$inputChecksum = array_pop($nums);
foreach($nums as $key => $value){
$runningTotal += $value * $multiplier;
//echo $value . 'x' . $multiplier . ' + ';
$multiplier --;
if ($multiplier === 1){
break;
}
}
//echo ' = ' . $runningTotal;
$remainder = $runningTotal % 11;
$checksum = $remainder == 1 ? 'X' : 11 - $remainder;
$checksum = $checksum == 11 ? 0 : $checksum;
$output = array('checksum'=>$checksum);
$output['isbn10'] = substr($input, 0, 9) . $checksum;
if ($convert){
$output['isbn13'] = isbn10to13($output['isbn10']);
}
if ((is_numeric($inputChecksum) || $inputChecksum == 'X') && $inputChecksum != $checksum){
$output['error'] = 'Input checksum digit incorrect: ISBN not valid';
$output['input_checksum'] = $inputChecksum;
}
}
return $output;
}

function isbn10to13($isbn10){

$isbnStem = strlen($isbn10) == 10 ? substr($isbn10, 0,9) : $isbn10;
$isbn13data = isbn13checker('978' . $isbnStem);
return $isbn13data['isbn13'];

}

function isbn13to10($isbn13){

$isbnStem = strlen($isbn13) == 13 ? substr($isbn13, 12) : $isbn13;
$isbnStem = substr($isbn13, -10);
$isbn10data = isbn10checker($isbnStem);
return $isbn10data['isbn10'];
}
echo isbn10to13($isbn);

Tuesday, December 6, 2016

Decent CSS Spin Loader

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>

<script type="text/javascript">
  $(document).ready(function(){
    // alert();
    setTimeout(function() {
                $('#divLoader').fadeOut('slow');
                $('#loader_container').fadeOut('slow');
            }, 100);
  });


</script>

 <style type="text/css">

/* CSS LOADER*/

#loader {
    border: 16px solid #f3f3f3;
    border-radius: 50%;
    border-top: 16px solid #3498db;
    width: 120px;
    height: 120px;
    -webkit-animation: spin 2s linear infinite;
    animation: spin 2s linear infinite;
}

#divLoader {
    position: absolute;
    top: 40%;
    left: 45%;
    z-index: 99999;
}

@-webkit-keyframes spin {
    0% {
        -webkit-transform: rotate(0deg);
    }
    100% {
        -webkit-transform: rotate(360deg);
    }
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

  #loader_container {
    width: 100%;
    height: 100%;
    /* border: 5px solid blue; */
    display: inline-block;
    position: absolute;
    background-color: rgba(70, 67, 67, 0.84);
    z-index: 9998;
    /*display: none;*/
}

.pleasewait {
    font-size: 19px;
    color: #3498db !important;
    margin-top: 10px;
    text-align: center;
}
</style>

<div id="loader_container" stylle=""><div id="divLoader" style=""><div id="loader" class="loader">&nbsp;</div><p class="pleasewait">Loading <br> Please wait... </p></div></div>

Wednesday, October 26, 2016

Read CSV file in PHP

CODE HERE

<?php
$csv = array();

// LOAD CSV FILE HERE

$lines = file('files/Flyers.csv', FILE_IGNORE_NEW_LINES);
//$lines = array_filter($lines);
//$lines = array_unique($lines);

foreach($lines as $line)
{
$lines = explode(",",$line);
//echo '<pre>';print_r($lines);

// Columns AND ROWS HERE

$title = mysql_real_escape_string($lines[0]);
$isbn = mysql_real_escape_string($lines[1]);
$exp  = $lines[2];
$price = $lines[3];

echo $title."<br>";
echo $isbn."<br>";
echo         $exp."<br>";
echo         $price.'<br>';
}

?>