cvs: pear /HTML_Progress2/examples/ajax default1.php default2.php default3.php
| From: | Laurent Laville | Date: | Mon, 22 Jan 2007 18:18:45 +0000 |
| Subject: | cvs: pear /HTML_Progress2/examples/ajax default1.php default2.php default3.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-44340@lists.php.net to get a copy of this message | ||
farell Mon Jan 22 18:18:45 2007 UTC
Added files:
/pear/HTML_Progress2/examples/ajax default3.php
Modified files:
/pear/HTML_Progress2/examples/ajax default1.php default2.php
Log:
3 basics example HTML_AJAX usage
default3 is full multi-labels system compatible
http://cvs.php.net/viewvc.cgi/pear/HTML_Progress2/examples/ajax/default1.php?r1=1.3&r2=1.4&diff_format=u Index: pear/HTML_Progress2/examples/ajax/default1.php diff -u pear/HTML_Progress2/examples/ajax/default1.php:1.3 pear/HTML_Progress2/examples/ajax/default1.php:1.4 --- pear/HTML_Progress2/examples/ajax/default1.php:1.3 Wed Jan 17 12:54:33 2007 +++ pear/HTML_Progress2/examples/ajax/default1.php Mon Jan 22 18:18:44 2007 @@ -1,121 +1,99 @@ <?php /** - * Natural horizontal AJAX ProgressBar with blue skin, using default Ajax driver. + * Basic AJAX example that used a PHP callback function + * to handle progress bar responses * - * @version $Id: default1.php,v 1.3 2007/01/17 12:54:33 farell Exp $ + * @version $Id: default1.php,v 1.4 2007/01/22 18:18:44 farell Exp $ * @author Laurent Laville <pear@laurent-laville.org> * @package HTML_Progress2 * @subpackage Examples * @access public - * @example examples/ajax/default1.php - * AJAX bluesand source code - * @link http://www.laurent-laville.org/img/progress/screenshot/bluesand.png - * screenshot (Image PNG, 190x40 pixels) 352 bytes */ + +if (isset($_GET['reload'])) { + session_start(); + unset($_SESSION['progressPercentage']); + session_destroy(); + die('Job is over !'); +} + require_once 'PEAR.php'; +require_once 'HTML/Progress2.php'; PEAR::setErrorHandling(PEAR_ERROR_DIE); -/** - * Simulate a user-task that will take 9 cycles to complete (12% on each cycle) - */ -function processTask() -{ - $_SESSION['progressPercentage'] = $_SESSION['progressPercentage'] + 12; - $percent = min(100, $_SESSION['progressPercentage']); - return $percent; -} +// set this flag to true if you want to reuse a pre-set external style sheet +$reuseCSS = false; +//$reuseCSS = true; -session_start(); - -if (isset($_REQUEST['registerTask'])) { - // Negociate a new task identifier - $_SESSION['taskId'] = mt_rand(); - $_SESSION['progressId'] = $_REQUEST['registerTask']; - $_SESSION['progressPercentage'] = 0; - header("Content-Type: text/xml"); - echo "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>"; -?> -<progress id="<?php echo $_SESSION['progressId']; ?>" taskId="<?php echo $_SESSION['taskId']; ?>" /> -<?php -} elseif (isset($_REQUEST['TaskId'])) { - // Proceed user-task on each polling loop - if ($_REQUEST['TaskId'] != $_SESSION['taskId']) { - die('wrong task id'); - } - header("Content-Type: text/xml"); - echo "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>"; -?> -<progress id="<?php echo $_SESSION['progressId']; ?>" taskId="<?php echo $_SESSION['taskId']; ?>"> - <percentage><?php echo processTask(); ?></percentage> -</progress> -<?php -} else { - // Initialize progress bar render with initial page content - include_once 'HTML/Progress2.php'; +$pb = new HTML_Progress2(); +$pb->addLabel(HTML_PROGRESS2_LABEL_TEXT, 'txt1', 'Basic AJAX Progress2 example 1'); - $pb = new HTML_Progress2(); +if ($reuseCSS) { $pb->setIdent('PB1'); $pb->setBorderAttributes('class=progressBorder'); $pb->setCellAttributes('class=cell'); $pb->setLabelAttributes('pct1', array( - 'class' => 'progressPercentLabel', - 'align' => 'center' - )); + 'class' => 'progressPercentLabel', + 'align' => 'center' + )); $pb->importStyle('bluesand2.css'); +} else { + $pb->setCellCount(20); + $pb->setCellAttributes(array( + 'active-color' => '#000084', + 'inactive-color' => '#3A6EA5', + 'width' => 25, + 'spacing' => 0, + 'background-image' => 'download.gif' + )); + $pb->setBorderPainted(true); + $pb->setBorderAttributes('width=1 style=inset color=white'); + $pb->setLabelAttributes('pct1', array( + 'width' => 60, + 'font-size' => 10, + 'align' => 'center', + 'valign' => 'left' + )); +} - $ae = $pb->registerAjax(); - $ae->setRequestUri(basename(__FILE__)); +$pb->registerAJAX('phpcb_server1.php', array('getpercentage')); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3c.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <head> -<title>BlueSand Ajax Progress2 example</title> -<link rel="stylesheet" type="text/css" href="bluesand2.css" /> +<title>Basic Ajax Progress2 example 1</title> +<?php +if ($reuseCSS) { + echo '<link rel="stylesheet" type="text/css" href="bluesand2.css" />'."\n"; +} +?> <style type="text/css"> <!-- +<?php +if (!$reuseCSS) { + echo $pb->getStyle(); +} +?> + body {background-color: #EEEEEE; } --> </style> -<script type="text/javascript" src="progress2Handler.js"></script> -<script type="text/javascript" src="Poly9UrlParser.js"></script> +<script type="text/javascript" src="HTML_Progress2.js"></script> +<?php +echo $pb->setupAJAX(); +?> <script type="text/javascript"> //<![CDATA[ -<?php echo $ae->getScript(true); ?> -function complete() -{ - // nothing do to at end, when server-side operation complete - // JS function declaration avoid a JS error on javascript console -} +HTML_Progress2.serverCallback = 'getPercentage'; //]]> </script> </head> <body> -<?php -$pb->display(); -?> -<script type="text/javascript"> -//<![CDATA[ -<?php -$m = $ae->getRequestMethod(); -if ($m != 'GET') { - echo "reqMethod = '$m';\n"; -} -$t = $ae->getRequestTimeout(); -if ($t != 2000) { - echo "timeout = $t;\n"; -} -echo "url1 = '". $ae->getRequestUri(1) ."';\n"; -echo "url2 = '". $ae->getRequestUri(2) ."';\n"; -?> -startTask(); -//]]> -</script> +<a href="javascript:HTML_Progress2.start('<?php echo $pb->getIdent(); ?>');">Start</a> +<?php $pb->display(); ?> </body> -</html> -<?php -} -?> \ No newline at end of file +</html> \ No newline at end of file http://cvs.php.net/viewvc.cgi/pear/HTML_Progress2/examples/ajax/default2.php?r1=1.2&r2=1.3&diff_format=u Index: pear/HTML_Progress2/examples/ajax/default2.php diff -u pear/HTML_Progress2/examples/ajax/default2.php:1.2 pear/HTML_Progress2/examples/ajax/default2.php:1.3 --- pear/HTML_Progress2/examples/ajax/default2.php:1.2 Wed Jan 17 12:54:33 2007 +++ pear/HTML_Progress2/examples/ajax/default2.php Mon Jan 22 18:18:44 2007 @@ -1,91 +1,101 @@ <?php /** - * Reverse horizontal AJAX ProgressBar with red skin, using default Ajax driver. - * This example show how to use two separate scripts to build progress bar, - * and handle server side task operations. + * Basic AJAX example that used an auto server to handle progress bar responses * - * @version $Id: default2.php,v 1.2 2007/01/17 12:54:33 farell Exp $ + * @version $Id: default2.php,v 1.3 2007/01/22 18:18:44 farell Exp $ * @author Laurent Laville <pear@laurent-laville.org> * @package HTML_Progress2 * @subpackage Examples * @access public - * @example examples/ajax/default2.php - * AJAX bgimages source code - * @link http://www.laurent-laville.org/img/progress/screenshot/bgimages.png - * screenshot (Image PNG, 310x40 pixels) 501 bytes */ +if (isset($_GET['reload'])) { + session_start(); + unset($_SESSION['progressPercentage']); + session_destroy(); + die('Job is over !'); +} + +require_once 'PEAR.php'; require_once 'HTML/Progress2.php'; +PEAR::setErrorHandling(PEAR_ERROR_DIE); + +// set this flag to true if you want to reuse a pre-set external style sheet +//$reuseCSS = false; +$reuseCSS = true; + $pb = new HTML_Progress2(); -$pb->setIdent('PB1'); -$pb->setCellAttributes(array( - 'active-color' => '#000084', - 'inactive-color' => '#3A6EA5', - 'width' => 25, - 'spacing' => 0, - 'background-image' => 'download.gif' -)); -$pb->setBorderPainted(true); -$pb->setBorderAttributes('width=1 style=inset color=white'); -$pb->setLabelAttributes('pct1', array( - 'width' => 60, - 'font-size' => 10, - 'align' => 'center', - 'valign' => 'left' -)); - -$ae = $pb->registerAjax(); -$ae->setRequestUri('default2task.php'); -$ae->setRequestMethod('POST'); -$ae->setRequestTimeout(1000); +$pb->addLabel(HTML_PROGRESS2_LABEL_TEXT, 'txt1', 'Basic AJAX Progress2 example 2'); +$pb->addLabel(HTML_PROGRESS2_LABEL_TEXT, 'txt2', 'caption ...'); +$pb->setLabelAttributes('txt2', array('valign' => 'bottom')); + +if ($reuseCSS) { + $pb->setIdent('PB1'); + $pb->setBorderAttributes('class=progressBorder'); + $pb->setCellAttributes('class=cell'); + $pb->setLabelAttributes('pct1', array( + 'class' => 'progressPercentLabel', + 'align' => 'center' + )); + $pb->importStyle('bluesand2.css'); +} else { + $pb->setCellCount(20); + $pb->setCellAttributes(array( + 'active-color' => '#000084', + 'inactive-color' => '#3A6EA5', + 'width' => 25, + 'spacing' => 0, + 'background-image' => 'download.gif' + )); + $pb->setBorderPainted(true); + $pb->setBorderAttributes('width=1 style=inset color=white'); + $pb->setLabelAttributes('pct1', array( + 'width' => 60, + 'font-size' => 10, + 'align' => 'center', + 'valign' => 'left' + )); +} + +$pb->registerAJAX('auto_server.php', array('requeststatus')); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3c.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <head> -<title>BgImages Ajax Progress2 example</title> +<title>Basic Ajax Progress2 example 2</title> +<?php +if ($reuseCSS) { + echo '<link rel="stylesheet" type="text/css" href="bluesand2.css" />'."\n"; +} +?> <style type="text/css"> <!-- -<?php echo $pb->getStyle(); ?> +<?php +if (!$reuseCSS) { + echo $pb->getStyle(); +} +?> -body {background-color: #C3C6C3; } +body {background-color: #EEEEEE; } --> </style> -<?php echo $pb->getScript(false); ?> -<script type="text/javascript" src="Poly9UrlParser.js"></script> +<script type="text/javascript" src="HTML_Progress2.js"></script> +<?php +echo $pb->setupAJAX(); +?> <script type="text/javascript"> //<![CDATA[ -<?php echo $ae->getScript(true); ?> -function complete() -{ - hideProgress(progressId); -} +HTML_Progress2.serverClassName = 'RequestStatus'; +HTML_Progress2.serverMethodName = 'updatePercentage'; //]]> </script> </head> <body> -<?php -$pb->display(); -?> -<script type="text/javascript"> -//<![CDATA[ -<?php -$m = $ae->getRequestMethod(); -if ($m != 'GET') { - echo "reqMethod = '$m';\n"; -} -$t = $ae->getRequestTimeout(); -if ($t != 2000) { - echo "timeout = $t;\n"; -} -echo "url1 = '". $ae->getRequestUri(1) ."';\n"; -echo "url2 = '". $ae->getRequestUri(2) ."';\n"; -?> -startTask(); -//]]> -</script> +<a href="javascript:HTML_Progress2.start('<?php echo $pb->getIdent(); ?>');">Start</a> +<?php $pb->display(); ?> </body> </html> \ No newline at end of file http://cvs.php.net/viewvc.cgi/pear/HTML_Progress2/examples/ajax/default3.php?view=markup&rev=1.1 Index: pear/HTML_Progress2/examples/ajax/default3.php +++ pear/HTML_Progress2/examples/ajax/default3.php <?php /** * Basic AJAX example that used an auto server to handle progress bar responses * Same as example default2.php, but its also multiple-labels system compatible. * * @version $Id: default3.php,v 1.1 2007/01/22 18:18:44 farell Exp $ * @author Laurent Laville <pear@laurent-laville.org> * @package HTML_Progress2 * @subpackage Examples * @access public */ if (isset($_GET['reload'])) { session_start(); unset($_SESSION['progressPercentage']); session_destroy(); die('Job is over !'); } require_once 'PEAR.php'; require_once 'HTML/Progress2.php'; PEAR::setErrorHandling(PEAR_ERROR_DIE); // set this flag to true if you want to reuse a pre-set external style sheet $reuseCSS = false; //$reuseCSS = true; $pb = new HTML_Progress2(); $pb->addLabel(HTML_PROGRESS2_LABEL_TEXT, 'txt1', 'Basic AJAX Progress2 example 3'); $pb->addLabel(HTML_PROGRESS2_LABEL_TEXT, 'txt2', 'caption ...'); $pb->setLabelAttributes('txt2', array('valign' => 'bottom')); if ($reuseCSS) { $pb->setIdent('PB1'); $pb->setBorderAttributes('class=progressBorder'); $pb->setCellAttributes('class=cell'); $pb->setLabelAttributes('pct1', array( 'class' => 'progressPercentLabel', 'align' => 'center' )); $pb->importStyle('bluesand2.css'); } else { $pb->setCellCount(20); $pb->setCellAttributes(array( 'active-color' => '#000084', 'inactive-color' => '#3A6EA5', 'width' => 25, 'spacing' => 0, 'background-image' => 'download.gif' )); $pb->setBorderPainted(true); $pb->setBorderAttributes('width=1 style=inset color=white'); $pb->setLabelAttributes('pct1', array( 'width' => 60, 'font-size' => 10, 'align' => 'center', 'valign' => 'left' )); } $pb->registerAJAX('auto_server.php', array('RequestFullStatus')); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3c.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <head> <title>Basic Ajax Progress2 example 3</title> <?php if ($reuseCSS) { echo '<link rel="stylesheet" type="text/css" href="bluesand2.css" />'."\n"; } ?> <style type="text/css"> <!-- <?php if (!$reuseCSS) { echo $pb->getStyle(); } ?> body {background-color: #EEEEEE; } --> </style> <script type="text/javascript" src="HTML_Progress2.js"></script> <?php echo $pb->setupAJAX(); ?> <script type="text/javascript"> //<![CDATA[ HTML_Progress2.serverClassName = 'RequestFullStatus'; HTML_Progress2.serverMethodName = 'updateTask'; //]]> </script> </head> <body> <a href="javascript:HTML_Progress2.start('<?php echo $pb->getIdent(); ?>');">Start</a> <?php $pb->display(); ?> </body> </html>
http://cvs.php.net/viewvc.cgi/pear/HTML_Progress2/examples/ajax/default1.php?r1=1.3&r2=1.4&diff_format=u Index: pear/HTML_Progress2/examples/ajax/default1.php diff -u pear/HTML_Progress2/examples/ajax/default1.php:1.3 pear/HTML_Progress2/examples/ajax/default1.php:1.4 --- pear/HTML_Progress2/examples/ajax/default1.php:1.3 Wed Jan 17 12:54:33 2007 +++ pear/HTML_Progress2/examples/ajax/default1.php Mon Jan 22 18:18:44 2007 @@ -1,121 +1,99 @@ <?php /** - * Natural horizontal AJAX ProgressBar with blue skin, using default Ajax driver. + * Basic AJAX example that used a PHP callback function + * to handle progress bar responses * - * @version $Id: default1.php,v 1.3 2007/01/17 12:54:33 farell Exp $ + * @version $Id: default1.php,v 1.4 2007/01/22 18:18:44 farell Exp $ * @author Laurent Laville <pear@laurent-laville.org> * @package HTML_Progress2 * @subpackage Examples * @access public - * @example examples/ajax/default1.php - * AJAX bluesand source code - * @link http://www.laurent-laville.org/img/progress/screenshot/bluesand.png - * screenshot (Image PNG, 190x40 pixels) 352 bytes */ + +if (isset($_GET['reload'])) { + session_start(); + unset($_SESSION['progressPercentage']); + session_destroy(); + die('Job is over !'); +} + require_once 'PEAR.php'; +require_once 'HTML/Progress2.php'; PEAR::setErrorHandling(PEAR_ERROR_DIE); -/** - * Simulate a user-task that will take 9 cycles to complete (12% on each cycle) - */ -function processTask() -{ - $_SESSION['progressPercentage'] = $_SESSION['progressPercentage'] + 12; - $percent = min(100, $_SESSION['progressPercentage']); - return $percent; -} +// set this flag to true if you want to reuse a pre-set external style sheet +$reuseCSS = false; +//$reuseCSS = true; -session_start(); - -if (isset($_REQUEST['registerTask'])) { - // Negociate a new task identifier - $_SESSION['taskId'] = mt_rand(); - $_SESSION['progressId'] = $_REQUEST['registerTask']; - $_SESSION['progressPercentage'] = 0; - header("Content-Type: text/xml"); - echo "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>"; -?> -<progress id="<?php echo $_SESSION['progressId']; ?>" taskId="<?php echo $_SESSION['taskId']; ?>" /> -<?php -} elseif (isset($_REQUEST['TaskId'])) { - // Proceed user-task on each polling loop - if ($_REQUEST['TaskId'] != $_SESSION['taskId']) { - die('wrong task id'); - } - header("Content-Type: text/xml"); - echo "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>"; -?> -<progress id="<?php echo $_SESSION['progressId']; ?>" taskId="<?php echo $_SESSION['taskId']; ?>"> - <percentage><?php echo processTask(); ?></percentage> -</progress> -<?php -} else { - // Initialize progress bar render with initial page content - include_once 'HTML/Progress2.php'; +$pb = new HTML_Progress2(); +$pb->addLabel(HTML_PROGRESS2_LABEL_TEXT, 'txt1', 'Basic AJAX Progress2 example 1'); - $pb = new HTML_Progress2(); +if ($reuseCSS) { $pb->setIdent('PB1'); $pb->setBorderAttributes('class=progressBorder'); $pb->setCellAttributes('class=cell'); $pb->setLabelAttributes('pct1', array( - 'class' => 'progressPercentLabel', - 'align' => 'center' - )); + 'class' => 'progressPercentLabel', + 'align' => 'center' + )); $pb->importStyle('bluesand2.css'); +} else { + $pb->setCellCount(20); + $pb->setCellAttributes(array( + 'active-color' => '#000084', + 'inactive-color' => '#3A6EA5', + 'width' => 25, + 'spacing' => 0, + 'background-image' => 'download.gif' + )); + $pb->setBorderPainted(true); + $pb->setBorderAttributes('width=1 style=inset color=white'); + $pb->setLabelAttributes('pct1', array( + 'width' => 60, + 'font-size' => 10, + 'align' => 'center', + 'valign' => 'left' + )); +} - $ae = $pb->registerAjax(); - $ae->setRequestUri(basename(__FILE__)); +$pb->registerAJAX('phpcb_server1.php', array('getpercentage')); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3c.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <head> -<title>BlueSand Ajax Progress2 example</title> -<link rel="stylesheet" type="text/css" href="bluesand2.css" /> +<title>Basic Ajax Progress2 example 1</title> +<?php +if ($reuseCSS) { + echo '<link rel="stylesheet" type="text/css" href="bluesand2.css" />'."\n"; +} +?> <style type="text/css"> <!-- +<?php +if (!$reuseCSS) { + echo $pb->getStyle(); +} +?> + body {background-color: #EEEEEE; } --> </style> -<script type="text/javascript" src="progress2Handler.js"></script> -<script type="text/javascript" src="Poly9UrlParser.js"></script> +<script type="text/javascript" src="HTML_Progress2.js"></script> +<?php +echo $pb->setupAJAX(); +?> <script type="text/javascript"> //<![CDATA[ -<?php echo $ae->getScript(true); ?> -function complete() -{ - // nothing do to at end, when server-side operation complete - // JS function declaration avoid a JS error on javascript console -} +HTML_Progress2.serverCallback = 'getPercentage'; //]]> </script> </head> <body> -<?php -$pb->display(); -?> -<script type="text/javascript"> -//<![CDATA[ -<?php -$m = $ae->getRequestMethod(); -if ($m != 'GET') { - echo "reqMethod = '$m';\n"; -} -$t = $ae->getRequestTimeout(); -if ($t != 2000) { - echo "timeout = $t;\n"; -} -echo "url1 = '". $ae->getRequestUri(1) ."';\n"; -echo "url2 = '". $ae->getRequestUri(2) ."';\n"; -?> -startTask(); -//]]> -</script> +<a href="javascript:HTML_Progress2.start('<?php echo $pb->getIdent(); ?>');">Start</a> +<?php $pb->display(); ?> </body> -</html> -<?php -} -?> \ No newline at end of file +</html> \ No newline at end of file http://cvs.php.net/viewvc.cgi/pear/HTML_Progress2/examples/ajax/default2.php?r1=1.2&r2=1.3&diff_format=u Index: pear/HTML_Progress2/examples/ajax/default2.php diff -u pear/HTML_Progress2/examples/ajax/default2.php:1.2 pear/HTML_Progress2/examples/ajax/default2.php:1.3 --- pear/HTML_Progress2/examples/ajax/default2.php:1.2 Wed Jan 17 12:54:33 2007 +++ pear/HTML_Progress2/examples/ajax/default2.php Mon Jan 22 18:18:44 2007 @@ -1,91 +1,101 @@ <?php /** - * Reverse horizontal AJAX ProgressBar with red skin, using default Ajax driver. - * This example show how to use two separate scripts to build progress bar, - * and handle server side task operations. + * Basic AJAX example that used an auto server to handle progress bar responses * - * @version $Id: default2.php,v 1.2 2007/01/17 12:54:33 farell Exp $ + * @version $Id: default2.php,v 1.3 2007/01/22 18:18:44 farell Exp $ * @author Laurent Laville <pear@laurent-laville.org> * @package HTML_Progress2 * @subpackage Examples * @access public - * @example examples/ajax/default2.php - * AJAX bgimages source code - * @link http://www.laurent-laville.org/img/progress/screenshot/bgimages.png - * screenshot (Image PNG, 310x40 pixels) 501 bytes */ +if (isset($_GET['reload'])) { + session_start(); + unset($_SESSION['progressPercentage']); + session_destroy(); + die('Job is over !'); +} + +require_once 'PEAR.php'; require_once 'HTML/Progress2.php'; +PEAR::setErrorHandling(PEAR_ERROR_DIE); + +// set this flag to true if you want to reuse a pre-set external style sheet +//$reuseCSS = false; +$reuseCSS = true; + $pb = new HTML_Progress2(); -$pb->setIdent('PB1'); -$pb->setCellAttributes(array( - 'active-color' => '#000084', - 'inactive-color' => '#3A6EA5', - 'width' => 25, - 'spacing' => 0, - 'background-image' => 'download.gif' -)); -$pb->setBorderPainted(true); -$pb->setBorderAttributes('width=1 style=inset color=white'); -$pb->setLabelAttributes('pct1', array( - 'width' => 60, - 'font-size' => 10, - 'align' => 'center', - 'valign' => 'left' -)); - -$ae = $pb->registerAjax(); -$ae->setRequestUri('default2task.php'); -$ae->setRequestMethod('POST'); -$ae->setRequestTimeout(1000); +$pb->addLabel(HTML_PROGRESS2_LABEL_TEXT, 'txt1', 'Basic AJAX Progress2 example 2'); +$pb->addLabel(HTML_PROGRESS2_LABEL_TEXT, 'txt2', 'caption ...'); +$pb->setLabelAttributes('txt2', array('valign' => 'bottom')); + +if ($reuseCSS) { + $pb->setIdent('PB1'); + $pb->setBorderAttributes('class=progressBorder'); + $pb->setCellAttributes('class=cell'); + $pb->setLabelAttributes('pct1', array( + 'class' => 'progressPercentLabel', + 'align' => 'center' + )); + $pb->importStyle('bluesand2.css'); +} else { + $pb->setCellCount(20); + $pb->setCellAttributes(array( + 'active-color' => '#000084', + 'inactive-color' => '#3A6EA5', + 'width' => 25, + 'spacing' => 0, + 'background-image' => 'download.gif' + )); + $pb->setBorderPainted(true); + $pb->setBorderAttributes('width=1 style=inset color=white'); + $pb->setLabelAttributes('pct1', array( + 'width' => 60, + 'font-size' => 10, + 'align' => 'center', + 'valign' => 'left' + )); +} + +$pb->registerAJAX('auto_server.php', array('requeststatus')); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3c.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <head> -<title>BgImages Ajax Progress2 example</title> +<title>Basic Ajax Progress2 example 2</title> +<?php +if ($reuseCSS) { + echo '<link rel="stylesheet" type="text/css" href="bluesand2.css" />'."\n"; +} +?> <style type="text/css"> <!-- -<?php echo $pb->getStyle(); ?> +<?php +if (!$reuseCSS) { + echo $pb->getStyle(); +} +?> -body {background-color: #C3C6C3; } +body {background-color: #EEEEEE; } --> </style> -<?php echo $pb->getScript(false); ?> -<script type="text/javascript" src="Poly9UrlParser.js"></script> +<script type="text/javascript" src="HTML_Progress2.js"></script> +<?php +echo $pb->setupAJAX(); +?> <script type="text/javascript"> //<![CDATA[ -<?php echo $ae->getScript(true); ?> -function complete() -{ - hideProgress(progressId); -} +HTML_Progress2.serverClassName = 'RequestStatus'; +HTML_Progress2.serverMethodName = 'updatePercentage'; //]]> </script> </head> <body> -<?php -$pb->display(); -?> -<script type="text/javascript"> -//<![CDATA[ -<?php -$m = $ae->getRequestMethod(); -if ($m != 'GET') { - echo "reqMethod = '$m';\n"; -} -$t = $ae->getRequestTimeout(); -if ($t != 2000) { - echo "timeout = $t;\n"; -} -echo "url1 = '". $ae->getRequestUri(1) ."';\n"; -echo "url2 = '". $ae->getRequestUri(2) ."';\n"; -?> -startTask(); -//]]> -</script> +<a href="javascript:HTML_Progress2.start('<?php echo $pb->getIdent(); ?>');">Start</a> +<?php $pb->display(); ?> </body> </html> \ No newline at end of file http://cvs.php.net/viewvc.cgi/pear/HTML_Progress2/examples/ajax/default3.php?view=markup&rev=1.1 Index: pear/HTML_Progress2/examples/ajax/default3.php +++ pear/HTML_Progress2/examples/ajax/default3.php <?php /** * Basic AJAX example that used an auto server to handle progress bar responses * Same as example default2.php, but its also multiple-labels system compatible. * * @version $Id: default3.php,v 1.1 2007/01/22 18:18:44 farell Exp $ * @author Laurent Laville <pear@laurent-laville.org> * @package HTML_Progress2 * @subpackage Examples * @access public */ if (isset($_GET['reload'])) { session_start(); unset($_SESSION['progressPercentage']); session_destroy(); die('Job is over !'); } require_once 'PEAR.php'; require_once 'HTML/Progress2.php'; PEAR::setErrorHandling(PEAR_ERROR_DIE); // set this flag to true if you want to reuse a pre-set external style sheet $reuseCSS = false; //$reuseCSS = true; $pb = new HTML_Progress2(); $pb->addLabel(HTML_PROGRESS2_LABEL_TEXT, 'txt1', 'Basic AJAX Progress2 example 3'); $pb->addLabel(HTML_PROGRESS2_LABEL_TEXT, 'txt2', 'caption ...'); $pb->setLabelAttributes('txt2', array('valign' => 'bottom')); if ($reuseCSS) { $pb->setIdent('PB1'); $pb->setBorderAttributes('class=progressBorder'); $pb->setCellAttributes('class=cell'); $pb->setLabelAttributes('pct1', array( 'class' => 'progressPercentLabel', 'align' => 'center' )); $pb->importStyle('bluesand2.css'); } else { $pb->setCellCount(20); $pb->setCellAttributes(array( 'active-color' => '#000084', 'inactive-color' => '#3A6EA5', 'width' => 25, 'spacing' => 0, 'background-image' => 'download.gif' )); $pb->setBorderPainted(true); $pb->setBorderAttributes('width=1 style=inset color=white'); $pb->setLabelAttributes('pct1', array( 'width' => 60, 'font-size' => 10, 'align' => 'center', 'valign' => 'left' )); } $pb->registerAJAX('auto_server.php', array('RequestFullStatus')); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3c.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <head> <title>Basic Ajax Progress2 example 3</title> <?php if ($reuseCSS) { echo '<link rel="stylesheet" type="text/css" href="bluesand2.css" />'."\n"; } ?> <style type="text/css"> <!-- <?php if (!$reuseCSS) { echo $pb->getStyle(); } ?> body {background-color: #EEEEEE; } --> </style> <script type="text/javascript" src="HTML_Progress2.js"></script> <?php echo $pb->setupAJAX(); ?> <script type="text/javascript"> //<![CDATA[ HTML_Progress2.serverClassName = 'RequestFullStatus'; HTML_Progress2.serverMethodName = 'updateTask'; //]]> </script> </head> <body> <a href="javascript:HTML_Progress2.start('<?php echo $pb->getIdent(); ?>');">Start</a> <?php $pb->display(); ?> </body> </html>