From 7a49346f8069d814c51af2e0cefcc6e66fe9826e Mon Sep 17 00:00:00 2001 From: Thomas Lange Date: Fri, 22 Apr 2016 21:17:53 +0200 Subject: Multiple updates with async demo. --- async.php | 144 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 144 insertions(+) create mode 100755 async.php (limited to 'async.php') diff --git a/async.php b/async.php new file mode 100755 index 0000000..9093c87 --- /dev/null +++ b/async.php @@ -0,0 +1,144 @@ +>> [Additional code for the async function] + +#=============================================================================== +# FUNCTION: Return TRUE if the request awaiting a async response +#=============================================================================== +function isAsyncRequest() { + return isset($_GET['response']) AND $_GET['response'] === 'async'; +} + +# <<< + +#=============================================================================== +# Deactivate caching +#=============================================================================== +header('Cache-Control: no-cache, no-store, must-revalidate'); + +#=============================================================================== +# Include classes and functions +#=============================================================================== +require_once 'include/classes/BigPipe/BigPipe.php'; +require_once 'include/classes/BigPipe/Pagelet.php'; +require_once 'include/classes/BigPipe/DemoPagelet.php'; +require_once 'include/functions.php'; + +#=============================================================================== +# Check if BigPipe should be disabled +#=============================================================================== +if(isset($_GET['bigpipe']) AND (int) $_GET['bigpipe'] === 0) { + // You can also check for search spiders and disable the pipeline + BigPipe\BigPipe::enablePipeline(FALSE); +} + +#=============================================================================== +# Pagelet with red background color +#=============================================================================== +$PageletRed = new BigPipe\DemoPagelet(); +$PageletRed->addHTML('
['.time().'] I AM A PAGELET WITH RED BACKGROUND
'); +$PageletRed->addCSS('static/red.php'); +$PageletRed->addJS('static/delayJS.php'); +$PageletRed->addJSCode("document.getElementById('red').innerHTML += ' [JS executed]';document.getElementById('red').style.borderRadius = '30px';"); + +#=============================================================================== +# Pagelet with blue background color +#=============================================================================== +$PageletBlue = new BigPipe\DemoPagelet('customPageletID', BigPipe\Pagelet::PRIORITY_HIGH); +$PageletBlue->addHTML('
['.time().'] I AM A PAGELET WITH BLUE BACKGROUND
'); +$PageletBlue->addCSS('static/blue.php'); +$PageletBlue->addJS('static/delayJS.php'); +$PageletBlue->addJSCode("document.getElementById('blue').innerHTML += ' [JS executed]';document.getElementById('blue').style.borderRadius = '30px';"); + +#=============================================================================== +# Pagelet with green background color +#=============================================================================== +$PageletGreen = new BigPipe\DemoPagelet(); +$PageletGreen->addHTML('
['.time().'] I AM A PAGELET WITH GREEN BACKGROUND
'); +$PageletGreen->addCSS('static/green.php'); +$PageletGreen->addJS('static/delayJS.php'); +$PageletGreen->addJSCode("document.getElementById('green').innerHTML += ' [JS executed]';document.getElementById('green').style.borderRadius = '30px';"); +?> + + + + + + + + + + BigPipe Demo + + + + + + + +

BigPipe Async Demo

+ +

LOAD CONTENT VIA TRANSPORT FRAME [Current Time: – So you can see, that the page does not get completely reloaded]

+

Look at the developer console of your browser to see the debug messages and how the async response from server looks.

+ +
+ + + +
+ + +["Application","BigPipe"].forEach(function(name){window[name] = parent[name];});'."\n"; + echo ''."\n"; + echo ''."\n\n"; +} + +BigPipe\BigPipe::render(); +?> + + \ No newline at end of file -- cgit v1.2.3