From b7ff91d8e34e1d9f04ad0b153e94441efd312f78 Mon Sep 17 00:00:00 2001 From: Florian Pritz Date: Thu, 23 May 2013 17:55:12 +0200 Subject: Rework javascript inclusion Signed-off-by: Florian Pritz --- application/helpers/filebin_helper.php | 24 ++++++++++++++++++++++++ application/views/footer.php | 10 +++++----- application/views/header.php | 1 - 3 files changed, 29 insertions(+), 6 deletions(-) (limited to 'application') diff --git a/application/helpers/filebin_helper.php b/application/helpers/filebin_helper.php index 0063b6526..394d55ba5 100644 --- a/application/helpers/filebin_helper.php +++ b/application/helpers/filebin_helper.php @@ -234,6 +234,30 @@ function link_with_mtime($file) return $link; } +function include_js($file) +{ + static $included = array(); + if (in_array($file, $included) || $file === null) { + return ""; + } + return "\n"; +} + +// kind of hacky, but works well enough for now +function register_js_include($file, $return = false) +{ + static $list = ""; + $list .= include_js($file); + if ($return) { + return $list; + } +} + +function include_registered_js() +{ + return register_js_include(null, true); +} + function handle_etag($etag) { $etag = strtolower($etag); diff --git a/application/views/footer.php b/application/views/footer.php index 3d6901748..1e3866ad0 100644 --- a/application/views/footer.php +++ b/application/views/footer.php @@ -4,10 +4,10 @@ if (is_cli_client() && !isset($force_full_html)) { } ?> - - - - - + + + + + diff --git a/application/views/header.php b/application/views/header.php index 40bb6e6a3..6e73003bc 100644 --- a/application/views/header.php +++ b/application/views/header.php @@ -22,7 +22,6 @@ if (is_cli_client() && !isset($force_full_html)) { echo ''; } ?> - -- cgit v1.2.3-24-g4f1b