Examples TOCexamples

Blue Sand Plus

$Date: 2005/07/25 10:25:30 $

 Table of contents

Introduction

This example requires :


This example will run a natural horizontal ProgressBar with blue skin. It will also show you how to print something inside cells with an external javascript (replaced internal code).

Percent text info is centered on a 60 pixels width area, on right side of the progress bar.

[Top]

 Render options

Here are options to build the progress bar cells :
active-color   = #3874B4
inactive-color = #EEEECC
width          = 10
HTML_Progress_UI::setCellAttributes()
Here are options to build the progress bar border :
width = 1
color = navy
HTML_Progress_UI::setBorderAttributes()
Here are options to build the progress bar string (percent text info):
width            = 60
font-size        = 14
background-color = #EEEEEE
align            = center
HTML_Progress_UI::setStringAttributes()
Here is the external javascript source-code which replace internal code :
var isDom = document.getElementById?true:false;
var isIE  = document.all?true:false;
var isNS4 = document.layers?true:false;
var cellCount = 10;

function setprogress(pIdent, pValue, pString, pDeterminate)
{
        if (isDom)
            prog = document.getElementById(pIdent+'installationProgress');
        if (isIE)
            prog = document.all[pIdent+'installationProgress'];
        if (isNS4)
            prog = document.layers[pIdent+'installationProgress'];
        if (prog != null)
            prog.innerHTML = pString;

        if (pValue == pDeterminate) {
            for (i=0; i < cellCount; i++) {
                showCell(i, pIdent, "hidden");
            }
        }
        if ((pDeterminate > 0) && (pValue > 0)) {
            i = (pValue-1) % cellCount;
            showCell(i, pIdent, "visible");
        } else {
            for (i=pValue-1; i >=0; i--) {
                showCell(i, pIdent, "visible");
                if (isDom)
                    document.getElementById(pIdent+'progressCell'+i+'A').innerHTML = i;
                if (isIE)
                    document.all[pIdent+'progressCell'+i+'A'].innerHTML = i;
                if (isNS4)
                    document.layers[pIdent+'progressCell'+i+'A'].innerHTML = i;
            }
    }
}

function showCell(pCell, pIdent, pVisibility)
{
    if (isDom)
        document.getElementById(pIdent+'progressCell'+pCell+'A').style.visibility = pVisibility;
    if (isIE)
        document.all[pIdent+'progressCell'+pCell+'A'].style.visibility = pVisibility;
    if (isNS4)
        document.layers[pIdent+'progressCell'+pCell+'A'].style.visibility = pVisibility;

}
href:  ./progress_number.js

[Top]

 Output

Screenshot

[Top]

 PHP source syntax highlight

  1. <?php
  2. /**
  3.  * Natural Horizontal ProgressBar example with JavaScript customization.
  4.  * See also ProgressMaker usage with pre-set UI model 'BlueSandPlus'.
  5.  *
  6.  * @version    $Id: bluesandplus.php,v 1.2 2005/07/25 10:25:30 farell Exp $
  7.  * @author     Laurent Laville <pear@laurent-laville.org>
  8.  * @package    HTML_Progress
  9.  * @subpackage Examples
  10.  */
  11.  
  12. require_once 'HTML/Progress.php';
  13.  
  14. $bar = new HTML_Progress();
  15. $bar->setAnimSpeed(100);
  16. $bar->setIncrement(10);
  17. $bar->setBorderPainted(true);
  18.  
  19. $ui =& $bar->getUI();
  20. $ui->setTab('    ');
  21. $ui->setCellAttributes('active-color=#3874B4 inactive-color=#EEEECC width=10');
  22. $ui->setBorderAttributes('width=1 color=navy');
  23. $ui->setStringAttributes('width=60 font-size=14 background-color=#EEEEEE align=center');
  24. $ui->setScript('progress_number.js');
  25.  
  26. foreach (range(0,2) as $index) {
  27.     $ui->setCellAttributes('color=silver', $index);
  28. }
  29. foreach (range(3,6) as $index) {
  30.     $ui->setCellAttributes('color=yellow', $index);
  31. }
  32. foreach (range(7,9) as $index) {
  33.     $ui->setCellAttributes('color=orange', $index);
  34. }
  35. ?>
  36. <!DOCTYPE html
  37.     PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  38.     "http://www.w3c.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  39.  
  40. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
  41. <head>
  42. <title>BlueSandPlus Progress example</title>
  43. <style type="text/css">
  44. <!--
  45. <?php echo $bar->getStyle(); ?>
  46.  
  47. body {
  48.     background-color: #EEEEEE;
  49.     color: #000000;
  50.     font-family: Verdana, Arial;
  51. }
  52.  
  53. a:visited, a:active, a:link {
  54.     color: navy;
  55. }
  56. // -->
  57. </style>
  58. <script type="text/javascript" src="<?php echo $bar->getScript(); ?>"></script>
  59. </head>
  60. <body>
  61.  
  62. <?php
  63. echo $bar->toHtml();
  64. $bar->run();
  65. ?>
  66.  
  67. </body>
  68. </html>

[Top]