cvs: pear /HTML_Progress2/examples/ajax phpcb_server2.php scriptaculous2.php

From: Date: Tue, 23 Jan 2007 08:48:03 +0000
Subject: cvs: pear /HTML_Progress2/examples/ajax phpcb_server2.php scriptaculous2.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-44351@lists.php.net to get a copy of this message
farell Tue Jan 23 08:48:03 2007 UTC Added files: /pear/HTML_Progress2/examples/ajax phpcb_server2.php scriptaculous2.php Log: alternative to example scriptaculous1.php that seems to have a problem with register JS libraries with registerClass() function. Until answer of Joshua Eichorn, I will publish both examples with version 2.3.0 alpha 2 http://cvs.php.net/viewvc.cgi/pear/HTML_Progress2/examples/ajax/phpcb_server2.php?view=markup&rev=1.1 Index: pear/HTML_Progress2/examples/ajax/phpcb_server2.php +++ pear/HTML_Progress2/examples/ajax/phpcb_server2.php <?php /** * Simple server with PHP callback function, that will serve user task script responder * and used scriptaculous effects libraries * * @version $Id: phpcb_server2.php,v 1.1 2007/01/23 08:48:03 farell Exp $ * @author Laurent Laville <pear@laurent-laville.org> * @package HTML_Progress2 * @subpackage Examples * @access public */ session_start(); function getPercentage() { $newVal = $_SESSION['progressPercentage'] + mt_rand(1, 25); $_SESSION['progressPercentage'] = min(100, $newVal); // should return at least an array with one key ('percentage') and its value $status = array('percentage' => $_SESSION['progressPercentage']); return $status; } require_once 'HTML/AJAX/Server.php'; // register normal function $callback = 'getPercentage'; $server = new HTML_AJAX_Server(); $server->registerPhpCallback($callback); $server->registerJsLibrary('scriptaculous', array('prototype.js', 'scriptaculous.js', 'effects.js'), dirname(__FILE__) . DIRECTORY_SEPARATOR. 'scriptaculous-js-1.7.0' . DIRECTORY_SEPARATOR); $server->handleRequest(); ?> http://cvs.php.net/viewvc.cgi/pear/HTML_Progress2/examples/ajax/scriptaculous2.php?view=markup&rev=1.1 Index: pear/HTML_Progress2/examples/ajax/scriptaculous2.php +++ pear/HTML_Progress2/examples/ajax/scriptaculous2.php <?php /** * Custom AJAX example that used Scriptaculous effect at end of user-task process. * Alternative to scriptaculous1.php that seems to be break (HTML_AJAX bug ?) * * @version $Id: scriptaculous2.php,v 1.1 2007/01/23 08:48:03 farell Exp $ * @author Laurent Laville <pear@laurent-laville.org> * @package HTML_Progress2 * @subpackage Examples * @access public */ require_once 'PEAR.php'; require_once 'HTML/Progress2.php'; PEAR::setErrorHandling(PEAR_ERROR_DIE); $pb = new HTML_Progress2(); $pb->addLabel(HTML_PROGRESS2_LABEL_TEXT, 'txt1', 'Scriptaculous AJAX Progress2 example 2'); $pb->addLabel(HTML_PROGRESS2_LABEL_TEXT, 'txt2', 'caption ...'); $pb->setLabelAttributes('txt2', array('valign' => 'bottom')); $pb->setIdent('PB1'); $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('phpcb_server2.php', array('getPercentage'), array('all', 'scriptaculous')); ?> <!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>Scriptaculous Ajax Progress2 example 2</title> <style type="text/css"> <!-- <?php 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.serverCallback = 'getPercentage'; HTML_Progress2.onComplete = 'fadeIn'; function fadeIn() { new Effect.Opacity(HTML_Progress2.widgetId, {duration:0.5, from:1.0, to:0.4}); } //]]> </script> </head> <body> <a href="javascript:HTML_Progress2.start('<?php echo $pb->getIdent(); ?>');">Start</a> <?php $pb->display(); ?> </body> </html>

« previous php.pear.cvs (#44351) next »