Monday, May 25, 2015

JavaScript Array Reduce Method

JavaScript loops such as for and while provides a way to do useful work on each array element, i.e code below:
<script>
	var numbers = [5, 2, 15, 7, 9, 3, 8, 25, 3, 10, 11];
	for(var i = 0; i < numbers.length; i++){
		console.log(numbers[i]);
	}
</script>

The for loop goes through each element in the array and logs the value to the browser console.

Another useful JavaScript feature to go through each array element is by using the method reduce built-in on arrays. The method passes through each array element to reduce the values to a single value. This can be used to accumulate the element values into a single value.

The code below takes an array of numbers and uses the reduce method to get the element with the highest value divisible by the first element value:

The array numbers holds integer values for each of its element. The JavaScript code is to take the first element and divide the remaining elements by the value. The code checks if the quotient is divisible (no remainder), and determines which divisible value is the highest.

The array numbers has 5 as the value of the first element. Scanning the remaining elements, we see that there are three element values divisible by 5: 15, 25 and 10.
The variable divisor takes the value of the first array element. This is the value which array elements starting from the second up to the last will be divided by. 
The reduce method of the array has a callback function as its parameter. Callback functions, in turn, can have four parameters: previous value, current value, index and the array calling the reduce method.
In the code provided, only two parameters will be used. The start will hold the previous value passed to the callback, while the current will hold the current element in the callback. 

On the first loop of the reduce method, start parameter is initialized to the first array element value, 5 while the current parameter takes the second array element value, 2:
The current value, 2 is divided by the divisor value, 5. Since divisor was declared outside the callback method, the method can "see" or access the divisor. Since the quotient will return a value, the condition check will return a True value. The True value is reversed, and the condition check is evaluated to false. the first loop of the reduce method will then return the start value of 5.

On the next loop, the reduce method will assign the next element value, 15 to the current parameter. The start parameter takes the returned value of the previous loop, 5. The quotient of the current value 15 over the divisor, 5 will yield a value of zero, corresponding to false, which is then reversed to true. 
The check of current value, 15 greater than start value, 5 will evaluate to true. The current value, 15 is then returned. On the next, loop, the start parameter will now take this value.

On the loop that follows, the reduce method will assign the value of the next array element, 7 to the current parameter. The start parameter takes the returned value from the previous loop, which is 15. The quotient of the current value, 7 over the divisor, 5 will yield a value, corresponding to true, which is reversed to false. The loop will return the start value, 15.
 

The start value of 15 is retained, until the reduce method assigns the current parameter to array value 25. The loop will then return the value 25.
The start value of 25 will be retained even until the reduce method loops through the last array element. When the reduce method reaches the array element value 10, the loop determines that 10 is divisible by 5. However, the check of current value 10 greater than start value will evaluate to false. The loop will still return the value 25.
The full code can be accessed on my GitHib account:

Resources on array reduce method may accessed on the links below:



Saturday, May 16, 2015

Bootstrap Cheat Code for WordPress Thumbnail Mobile Responsiveness

Using the_post_thumbnail() in a WordPress loop displays the post featured image as a thumbnail to the post article. The first parameter size lets setting or customizing the width and height dimensions for the thumbnail. However, I wanted a flexibility for my Bootstrap based WordPress theme wherein the post thumbnail will display in a smaller size in mobile. In short, I wanted a post thumbnail mobile responsiveness on its display. The WordPress loop uses a Media Object to display the title, time posted, excerpt and of course, the thumbnail. A sample loop is shown below:
The Media Object calls the_post_thumbnail() while passing the 'thumbnail' parameter. The 'thumbnail' size is set to 150x150:

When the theme is rendered, WordPress set the width and height attributes to 150. I could have used CSS3's media query, but was not sure is it could have overwritten the width and height attributes. I decided come up with my own cheat code to display the thumbnail in a different size on mobiles:
The cheat involves using two image links. The first image link passes 'thumbnail' as the size parameter. The classes "hidden-xs hidden-sm" makes sure that the image will not display on mobile sized devices. This makes sure that the image is displayed in traditional desktop or laptop computers. The second image link passes array(50,50) as the size parameter. The thumbnail is displayed in 50px width and height. The classes "hidden-md hidden-lg" makes sure that the image will not display on computers with medium or large screens, i.e. desktop or laptop computers. This makes sure that the image is displayed on mobile devices. The WordPress loop code with the Bootstrap cheat is listed below
<?php 
if(have_posts()): 
while (have_posts()): the_post(); 
?>
<div class="media">
 <a href="#" class="pull-left hidden-xs hidden-sm">
  <?php the_post_thumbnail('thumbnail', array( 'class' => 'media-object img-rounded' )); ?>
 </a>
 <a href="#" class="pull-left hidden-md hidden-lg">
  <?php the_post_thumbnail(array(50,50), array( 'class' => 'media-object img-rounded' )); ?>
 </a>
 <div class="media-body">
  <h4 class="media-heading"><?php the_title(); ?> <small>Posted on<?php the_time('F j, Y'); ?></small></h4>
  <p><small><?php echo(get_the_excerpt()); ?></small></p>
  <p><a href="<?php the_permalink(); ?>" class="btn btn-primary">Read More</a>
  </p>
 </div>
</div>
<?php endwhile; ?>
<?php else: ?>
<?php endif; ?>

Tuesday, March 3, 2015

Applying Bootstrap Styles to WordPress Feature Image

For WordPress themes that are based on Bootstrap framework, applying styles such as circled, rounded image or thumbnails provides one way to enhance featured image appearances.

In the screenshot below, a feature image is displayed together with a loop post:

I've used the function the_post_thumbnail() to display the feature image:








Bootstrap circled image style can be applied to the featured image by using the arguments parameter to pass the corresponding class style.


The function the_post_thumbnail() was modified to take 'thumbnail' as the first parameter to define the size and 'array(,,,' to define the attributes. Take note of the Bootstrap image circle style added to the class

The code for the post loop together with the Bootstrap style on the featured image is listed below:

<?php if(have_posts()): while (have_posts()): the_post(); ?>
  <div class="col-lg-6" style="margin-bottom:5px;">
    <div class="media">
      <a href="#" class="pull-left">
        <?php the_post_thumbnail('thumbnail', array( 'class' => 'media-object img-circle' )); ?>
      </a>
    <div class="media-body">
      <h3 class="media-heading"><?php the_title(); ?>. <small><?php echo(get_the_excerpt()); ?></small></h3>
    </div>
    </div>
  </div>
<?php endwhile; ?>

Tuesday, October 7, 2014

Creating scroll up effect on JQuery Pajinate plugin

For website not using Bootstrap, the JQuery Pajinate can be used to organize content into blocks of pages to be displayed one at a time.

More info on the plugin is provided on this link, https://github.com/wesnolte/Pajinate

I've downloaded a copy to give the plugin a try. The demo page contains quite a number of samples on how to use the plugin.:

In instances where a page may display a long list and the navigation panel (see Two Nav Panels in screen shot above) is placed at the bottom, there may be a need to scroll up as the page link is clicked.

By applying some tweaks in the plugin, the desired effect can be achieved.

I've opened the plugin file jquery.pajinate.js to see where I can apply the tweaks. Scrolling down the code, I've chanced upon the event handler for the page links and decided to add a JQuery animate scroll up:

The tweak worked! I've scrolled down the demo page and clicked the page links at the bottom. The display jumped to the next page and the page scrolled to the top.

This is perfect in case the paginate displays a long list with the navigation panel at the bottom. Clicking any of the page links jumps to the next page block and scrolls up to the top.

Need help on some web coding task? Let me know about it. Email me at jun.dolor@gmail.com and I'll be more than happy to blog about it with my thoughts.

Hosting of the sample pages were provided for by the following:

Monday, October 6, 2014

Bootstrap Loading-State Button on AJAX call

The sample code on http://www.tutorialrepublic.com/codelab.php?topic=bootstrap&file=stateful-button shows how to change the state of a button from its normal state to a loading state.

I thought I'd use the use on the code on my previous post to have a button that makes an AJAX request, change the content to 'loading data...' and revert back to its content after the AJAX response.

To see if I can get the effect I've set a five second delay on the backend PHP. If my approach is correct, I should be seeing 'Loading data...during the delay'. The PHP code on the backend is listed below:
    <?php
$time =  array("hr1"=>"1:00", "hr2"=>"2:00", "hr3"=>"3:00", "hr4"=>"4:00", "hr5"=>"5:00", "hr6"=>"6:00", "hr7"=>"7:00", "hr8"=>"8:00", "hr9"=>"9:00", "hr10"=>"10:00", "hr11"=>"11:00", "hr12"=>"12:00", "hr13"=>"13:00", "hr14"=>"14:00", "hr15"=>"15:00", "hr16"=>"16:00", "hr17"=>"17:00", "hr18"=>"18:00", "hr19"=>"19:00", "hr20"=>"20:00", "hr21"=>"21:00", "hr22"=>"22:00", "hr23"=>"23:00", "hr24"=>"00:00");

$action = '';
if(isset($_GET['action'])) $action = $_GET['action'];
$return = array();
switch ($action){
 case "init":
  $length = count($time);
  $return = array("return_param" => $length);
  break;
 case "get-time":
  $return = array("return_param" => ($time));
  break;
 default:
  $return = array("return_param" => "Error");
}
sleep(5);
echo json_encode($return);
?>

On my first attempt, I did not exactly get the effect I wanted. The 'Loading data' on the button reverted back to its initial content before the content was displayed. I realized then that it was the asynchronous part of the AJAX that continued with the execution of the script while it was making a request.

Using anonymous function approach, I was able to sync the change of the button contents during and after AJAX has completed the request and loaded the response.

The button to make the AJAX request has an id of 'loadhrs' and data-loading-text of 'Loading data...'

The adjustments in the code consists of a bind of the button id '#loadhrs' to the click event. The method queue() allows the button to display the loading text while AJAX is pulling the request. To sync with AJAX, I used anonymous function which accepts the button as an object passed as parameter.
The rest of the code is left unchanged.

To test, the html page with the code is loaded.. The button in its initial state displays 'Load Hours'

When the button is clicked, the initial text is replaced with the loading text. The button is likewise in its deactivated state.

After AJAX has pulled the response and displayed the contents, the button is back to its initial state.

The full code is listed below:
<!DOCTYPE html>
<html lang="en">
<head>
 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
 <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="">

    <title>Bootstrap Pagination</title>
 
 <link href="css/bootstrap.min.css" rel="stylesheet">

    <!-- Just for debugging purposes. Don't actually copy these 2 lines! -->
    <!--[if lt IE 9]><script src="../../assets/js/ie8-responsive-file-warning.js"></script><![endif]-->
    <script src="js/ie-emulation-modes-warning.js"></script>

    <!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!--[if lt IE 9]>
      <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
      <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
 <!--nivo stylesheets-->
 <link rel="stylesheet" href="css/nivo-slider.css" type="text/css" />
 <link rel="stylesheet" href="css/default.css" type="text/css" />
 <script src="js/jquery.min.js"></script>
    <script src="js/bootstrap.min.js"></script>
    <script src="js/docs.min.js"></script>
 <script>
  
  $(document).ready(function (){
   var itemsperpage = 5;
   function bindli(itemsperpage, jlength, pages){
    $("ul.pagination li a").bind("click",function(){
      var showPage = this.id;
      if(showPage == 'first') showPage = 1;
      if(showPage == 'last') showPage = pages;
      showli(parseInt(showPage), itemsperpage, jlength)
    });
   }
   function showli(page, itemsperpage, jlength){
    $('ul.pagination li').removeClass('active');
    var offset = page +1;
    var activePage = 'ul.pagination li:nth-child('+offset+')';
    $(activePage).addClass('active');
    $( "div#hours ul li" ).hide();
    var upto = parseInt(page * itemsperpage);
    var start = (upto + 1) - itemsperpage;
    if(upto > jlength) upto = jlength;
    
    for(i = start; i <= upto; i++){
     showitem = 'div#hours li:nth-child('+i+')';
     $(showitem).show();
    }
   }
   function populateli(json, itemsperpage, jlength, pages){
    html = '<ul class="list-group">';
    $.each(json, function (key, data) {
     $.each(data, function (index, data2) {
      html += '<li class="list-group-item">'+data2+'</li>';
     })
    })
    html += '</ul>';
    $('div#hours').html(html);
    showli(1, itemsperpage, jlength);
    bindli(itemsperpage, jlength, pages);
   }
   function displayli(json, itemsperpage){
    var jlength = Object.keys(json.return_param).length;    
    var pages = parseInt(jlength/itemsperpage);
    var remainder = parseInt(jlength % itemsperpage);
    if(remainder > 0) pages++;
    var html = '<li><a href="#" id="first">&laquo;</a></li>';
    for(i = 1; i <= pages; i++) html += '<li><a href="#" id="'+i+'" title="'+i+'">'+i+'</a></li>';
    html += '<li><a href="#" id="last">&raquo;</a></li>';
    $('ul.pagination').html(html);
    populateli(json, itemsperpage, jlength, pages);
   }
   function init(sychit){
    $.ajax({    
     url: 'gethours.php?action=get-time',  
     dataType: 'json',       
     success: function(json) {
      var objButton = $("#loadhrs");
      sychit(objButton);
      displayli(json, itemsperpage);
     },  
     error: function(xhr, ajaxOptions, thrownError) { 
      alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText + "\r\n" + "Err-01");  
     }  
    });    
   }
   $("#loadhrs").bind("click",function(){
    $(this).button('loading').delay(1000).queue(function() {
     init(function(objButton){
      //this just forces a synch to reset/dequeue the button object
      objButton.button('reset');
      objButton.dequeue();
     });
    });
   });
  })
 </script>
</head>
<body>
 <div class="container">
  <div class="row">
   <div class="col-xs-12">
    <ul class="pagination">     
    </ul>
   </div>
  </div>
  <div class="row">
   <div class="col-xs-12">
    <div id="hours">
    hours
    </div>
   </div>
  </div>
   <button id='loadhrs' type="button" class="btn btn-primary" data-loading-text="Loading data...">Load Hours</button>
 </div>
</body>
</html>

Need help on some web coding task? Let me know about it. Email me at jun.dolor@gmail.com and I'll be more than happy to blog about it with my thoughts.

Hosting of the sample pages were provided for by the following:

Sunday, October 5, 2014

Populating Bootstrap Pagination with AJAX response

Bootstrap's built-in pagination control organizes data by dividing them as blocks of pages. These pages are displayed one at a time by means of corresponding links. If the link for the page is clicked, only the block for that page is displayed.

For this post,  the data to be organized is the hours of the day. Instead of displaying all the day hours at the same time, I've organized by grouping them by fives. Each group has their page assignment, i.e. first five hours of the day goes to page 1 and so forth. Only one group is displayed at a time.

Screen shot below shows the first five hours of the day displayed and the pagination control to navigate to the rest of hours. The pagination control for page 1 is highlighted to indicate it is the active page.

If I wanted to navigate to the third group of hours, I click on the link for page 3. The third set of hours is displayed and the page control is highlighted.

The hours of the day will come from an AJAX request to a backend PHP page. The response will be a JSON object holding the hours of the day.

The html will consist of a Bootstrap container for the pagination control and the list of the day hours. All content will come from the AJAX call as we will see later.

The JQuery starts with a variable itemsperpage initialized to five. Functions to populate with returned data and organize them into block of pages are called. The first function to be called is init(), which makes an AJAX request to a backend. The response is a JSON object containing the hours of the day. When the AJAX call is successful, the function displayli() is called, passing the JSON object and number of items to display per page of block.

The function displayli() computes how the number of page blocks based on the number of JSON items and the number of items to display. The HTML for the page links is constructed and displayed on the ul class .pagination. Each link has an ID corresponding to its page number. The function populateli() is called, passing the JSON object, number of items to display per page, total number of items and number of pages computed.

The function populate() contructs the HTML list to display on the container for the content, (div id #hours). All items returned by the JSON respond from the AJAX call goes into this list. The function showli() is called, passing value of 1 (first page to display),  number of items to display per page and number of pages computed. This is followed by a call to function bindli, passing the number of items to display per page,  total number of items and number of pages computed.

The function showli() determines what list item to display. All list belonging to the current page block is displayed. This means that if the active page is 1, only list items one to five are displayed, and so forth.

The function bindli() binds each page link to the click event. The id of the link corresponds to the page number to display. The id is then passed as the page number to display on function showli().

The full code is listed below:
<!DOCTYPE html>
<html lang="en">
<head>
 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
 <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="">

    <title>Bootstrap Pagination</title>
 
 <link href="css/bootstrap.min.css" rel="stylesheet">

    <!-- Just for debugging purposes. Don't actually copy these 2 lines! -->
    <!--[if lt IE 9]><script src="../../assets/js/ie8-responsive-file-warning.js"></script><![endif]-->
    <script src="js/ie-emulation-modes-warning.js"></script>

    <!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!--[if lt IE 9]>
      <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
      <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
 <!--nivo stylesheets-->
 <link rel="stylesheet" href="css/nivo-slider.css" type="text/css" />
 <link rel="stylesheet" href="css/default.css" type="text/css" />
 <script src="js/jquery.min.js"></script>
    <script src="js/bootstrap.min.js"></script>
    <script src="js/docs.min.js"></script>
 <script>
  
  $(document).ready(function (){
   var itemsperpage = 5;
   function bindli(itemsperpage, jlength, pages){
    $("ul.pagination li a").bind("click",function(){
      var showPage = this.id;
      if(showPage == 'first') showPage = 1;
      if(showPage == 'last') showPage = pages;
      showli(parseInt(showPage), itemsperpage, jlength)
    });
   }
   function showli(page, itemsperpage, jlength){
    $('ul.pagination li').removeClass('active');
    var offset = page +1;
    var activePage = 'ul.pagination li:nth-child('+offset+')';
    $(activePage).addClass('active');
    $( "div#hours ul li" ).hide();
    var upto = parseInt(page * itemsperpage);
    var start = (upto + 1) - itemsperpage;
    if(upto > jlength) upto = jlength;
    
    for(i = start; i <= upto; i++){
     showitem = 'div#hours li:nth-child('+i+')';
     $(showitem).show();
    }
   }
   function populateli(json, itemsperpage, jlength, pages){
    html = '<ul class="list-group">';
    $.each(json, function (key, data) {
     $.each(data, function (index, data2) {
      html += '<li class="list-group-item">'+data2+'</li>';
     })
    })
    html += '</ul>';
    $('div#hours').html(html);
    showli(1, itemsperpage, jlength);
    bindli(itemsperpage, jlength, pages);
   }
   function displayli(json, itemsperpage){
    var jlength = Object.keys(json.return_param).length;    
    var pages = parseInt(jlength/itemsperpage);
    var remainder = parseInt(jlength % itemsperpage);
    if(remainder > 0) pages++;
    var html = '<li><a href="#" id="first">&laquo;</a></li>';
    for(i = 1; i <= pages; i++) html += '<li><a href="#" id="'+i+'" title="'+i+'">'+i+'</a></li>';
    html += '<li><a href="#" id="last">&raquo;</a></li>';
    $('ul.pagination').html(html);
    populateli(json, itemsperpage, jlength, pages);
   }
   function init(){
    $.ajax({    
     url: 'gethours.php?action=get-time',  
     dataType: 'json',       
     success: function(json) {
      displayli(json, itemsperpage);
     },  
     error: function(xhr, ajaxOptions, thrownError) { 
      alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText + "\r\n" + "Err-01");  
     }  
    });    
   }
   
   init();
  })
 </script>
</head>
<body>
 <div class="container">
  <div class="row">
   <div class="col-xs-12">
    <ul class="pagination">     
    </ul>
   </div>
  </div>
  <div class="row">
   <div class="col-xs-12">
    <div id="hours">
    hours
    </div>
   </div>
  </div>
 </div>
</body>
</html>

Need help on some web coding task? Let me know about it. Email me at jun.dolor@gmail.com and I'll be more than happy to blog about it with my thoughts.

Hosting of the sample pages were provided for by the following:

Saturday, October 4, 2014

Showing progress on Bootstrap loader during JQuery AJAX download

Taking advantage of XMLHttpRequest2's support for "listening" to progress events, the code from my last post can further be improved by letting the progress bar loader slide up during the progression of its AJAX JSON download response.

The link http://www.dave-bond.com/blog/2010/01/JQuery-ajax-progress-HMTL5/ provided the progress event listener integrated to the code of my previous post.

The first adjustment to the code is to give an ID to the div holding the class .progress-bar and set the CSS style width to 10%. The CSS width will show the status of the progress. When the AJAX has completed the JSON response download, the width should be set to 100%

On the AJAX call, we add the XHR callback for the XMLHttpRequest2 object code from the link above.

Since we are concerned with the progress of the AJAX download, we tweak the corresponding event listener. The idea is to let the AJAX call "listen" how much progress is made on the download and update the progress  bar width.

On success of AJAX download, I've commented out the hiding of the progress bar. On the test run, I would want to retain the bar.

And speaking of test run, I now execute the code. Initially, the progress bar is set to 10%


When AJAX starts to download the JSON response, the progress bar slides up until it hits 100%.

The full code is listed below:
<!DOCTYPE html>
<html lang="en">
<head>
 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
 <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="">

    <title>Loader</title>
 
 <link href="css/bootstrap.min.css" rel="stylesheet">

    <!-- Just for debugging purposes. Don't actually copy these 2 lines! -->
    <!--[if lt IE 9]><script src="../../assets/js/ie8-responsive-file-warning.js"></script><![endif]-->
    <script src="js/ie-emulation-modes-warning.js"></script>

    <!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!--[if lt IE 9]>
      <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
      <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
 <!--nivo stylesheets-->
 <link rel="stylesheet" href="css/nivo-slider.css" type="text/css" />
 <link rel="stylesheet" href="css/default.css" type="text/css" />
 <script src="js/jquery.min.js"></script>
    <script src="js/bootstrap.min.js"></script>
    <script src="js/docs.min.js"></script>
 <script>
  $(document).ready(function (){
   function updateprogress(){
   }
   function init(){
    $.ajax({    
     xhr: function(){
      var xhr = new window.XMLHttpRequest();
      //Upload progress
      xhr.upload.addEventListener("progress", function(evt){
       if (evt.lengthComputable) {
        var percentComplete = evt.loaded / evt.total;
        //Do something with upload progress
        console.log(percentComplete);
       }
      }, false);
      //Download progress
      xhr.addEventListener("progress", function(evt){
       if (evt.lengthComputable) {
        var percentComplete = evt.loaded / evt.total;
        //Do something with download progress
        var value = percentComplete * 100;
        value = value+"%";
        $('#loadingbar').width(value)
        console.log(percentComplete);
       }
      }, false);
      return xhr;
     },
     url: 'gethours.php?action=get-time',  
     dataType: 'json',  
     
     success: function(json) {
      //var jlength = Object.keys(json.return_param).length;
      //alert('parameter1 = '+jlength); 
      //$("#loading").hide();
      
     },  
     error: function(xhr, ajaxOptions, thrownError) { 
      $("#loading").hide();
      alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText + "\r\n" + "Err-01");  
     }  
    });    
   }
   
   init();
  })
 </script>
</head>
<body>
 <div class="container">
  <div class="row">
   <div class="col-xs-12">
    <div id="loading">
    
    <div class="progress progress-striped active">
     <div id="loadingbar" class="progress-bar" style="width:10%;">
      <span class="sr-only">60% Complete</span>
     </div>
    </div>
    
    </div>
   </div>
  </div>
 </div>
</body>
</html>

Need help on some web coding task? Let me know about it. Email me at jun.dolor@gmail.com and I'll be more than happy to blog about it with my thoughts.

Hosting of the sample pages were provided for by the following: