summaryrefslogtreecommitdiffstats
path: root/application
diff options
context:
space:
mode:
authorFlorian Pritz <bluewind@xinu.at>2013-05-23 17:55:12 +0200
committerFlorian Pritz <bluewind@xinu.at>2013-05-23 18:19:55 +0200
commitb7ff91d8e34e1d9f04ad0b153e94441efd312f78 (patch)
treef4f50a1615a102e08bbcc70b8332afb7fefad678 /application
parentd575e1bcb35dc228f3851fbf1f9d4a1de0bdecc4 (diff)
Rework javascript inclusion
Signed-off-by: Florian Pritz <bluewind@xinu.at>
Diffstat (limited to 'application')
-rw-r--r--application/helpers/filebin_helper.php24
-rw-r--r--application/views/footer.php10
-rw-r--r--application/views/header.php1
3 files changed, 29 insertions, 6 deletions
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 "<script src=\"".link_with_mtime($file)."\"></script>\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)) {
}
?>
</div>
-
- <script src="<?php echo link_with_mtime("/data/js/jquery-1.8.2.min.js"); ?>"></script>
- <script src="<?php echo link_with_mtime("/data/js/jquery-ui-1.8.23.custom.min.js"); ?>"></script>
- <script src="<?php echo link_with_mtime("/data/js/bootstrap-2.1.1.min.js"); ?>"></script>
- <script src="<?php echo link_with_mtime("/data/js/script.js"); ?>"></script>
+<?php echo include_js("/data/js/jquery-1.8.2.min.js"); ?>
+<?php echo include_js("/data/js/jquery-ui-1.8.23.custom.min.js"); ?>
+<?php echo include_js("/data/js/bootstrap-2.1.1.min.js"); ?>
+<?php echo include_js("/data/js/script.js"); ?>
+<?php echo include_registered_js(); ?>
</body>
</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 '<link href="'.link_with_mtime("/data/local/style.css").'" rel="stylesheet">';
}
?>
-
</head>
<body>