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 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'application/helpers') 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); -- cgit v1.2.3-24-g4f1b