aboutsummaryrefslogtreecommitdiffstats
path: root/async.php
diff options
context:
space:
mode:
authorThomas Lange <code@nerdmind.de>2016-06-23 13:10:24 +0200
committerThomas Lange <code@nerdmind.de>2016-06-23 13:16:30 +0200
commitc5637489e603c588fca41e2b7bd4345b67914f33 (patch)
tree5a1e8cc8f9558105422c24ddf8c1b8067df0a081 /async.php
parent102d2dc24505f4ce7fe6601b21a7e2e414f613cb (diff)
downloadbigpipe-c5637489e603c588fca41e2b7bd4345b67914f33.tar.gz
bigpipe-c5637489e603c588fca41e2b7bd4345b67914f33.tar.xz
bigpipe-c5637489e603c588fca41e2b7bd4345b67914f33.zip
Pagelets executed immediately; Dependency feature; Several improvements
+ All pagelets are now executed immediately on arrive. + A "Display Dependency" feature was added. If you give a pagelet an dependency, it will first be executed if all pagelets, who registered as dependency, are displayed. + If BigPipe.reset() is called, the function loops through each Resource and executes Resource.abortLoading(). This removes the <link> or <script> element from DOM and removes the onload callbacks. This is to prevent that an onload callback from a previous page are executed while the user has already changes the page asynchronously and a resource from the previous page wasn't already loaded.
Diffstat (limited to 'async.php')
-rwxr-xr-xasync.php29
1 files changed, 2 insertions, 27 deletions
diff --git a/async.php b/async.php
index 9093c87..bd67865 100755
--- a/async.php
+++ b/async.php
@@ -31,32 +31,8 @@ if(isset($_GET['bigpipe']) AND (int) $_GET['bigpipe'] === 0) {
BigPipe\BigPipe::enablePipeline(FALSE);
}
-#===============================================================================
-# Pagelet with red background color
-#===============================================================================
-$PageletRed = new BigPipe\DemoPagelet();
-$PageletRed->addHTML('<section id="red" class="text">['.time().'] I AM A PAGELET WITH RED BACKGROUND</section>');
-$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('<section id="blue" class="text">['.time().'] I AM A PAGELET WITH BLUE BACKGROUND</section>');
-$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('<section id="green" class="text">['.time().'] I AM A PAGELET WITH GREEN BACKGROUND</section>');
-$PageletGreen->addCSS('static/green.php');
-$PageletGreen->addJS('static/delayJS.php');
-$PageletGreen->addJSCode("document.getElementById('green').innerHTML += ' [JS executed]';document.getElementById('green').style.borderRadius = '30px';");
+// Outsourced to avoid duplicate code in index.php and async.php
+require_once 'include/pagelets.php';
?>
<!DOCTYPE html>
<html lang="de">
@@ -134,7 +110,6 @@ $PageletGreen->addJSCode("document.getElementById('green').innerHTML += ' [JS ex
if(isAsyncRequest()) {
$BUFFER = removeLineBreaksAndTabs(ob_get_clean());
echo '<script>["Application","BigPipe"].forEach(function(name){window[name] = parent[name];});</script>'."\n";
- echo '<script>["BigPipe", "Application"].forEach(function(name){window[name] = parent[name];});</script>'."\n";
echo '<script>Application.placeholderHTML('.json_encode($BUFFER).');</script>'."\n\n";
}