Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Compress JS

  • Loading branch information...
commit 9adae1232076e618726fd95c0e83415f8a5b58e8 1 parent 9e53e3d
Jakub Vrána authored
Showing with 13 additions and 8 deletions.
  1. +1 −1  adminer/file.inc.php
  2. +12 −7 compile.php
2  adminer/file.inc.php
View
@@ -9,7 +9,7 @@
echo lzw_decompress("compile_file('../adminer/static/default.css', 'minify_css');");
} elseif ($_GET["file"] == "functions.js") {
header("Content-Type: text/javascript; charset=utf-8");
- ?>compile_file('../adminer/static/functions.js', 'jsShrink');compile_file('static/editing.js', 'jsShrink');<?php
+ echo lzw_decompress("compile_file('../adminer/static/functions.js;static/editing.js', 'minify_js');");
} else {
header("Content-Type: image/gif");
switch ($_GET["file"]) {
19 compile.php
View
@@ -4,12 +4,6 @@
include dirname(__FILE__) . "/adminer/include/version.inc.php";
include dirname(__FILE__) . "/externals/JsShrink/jsShrink.php";
-if (!function_exists('jsShrink')) {
- function jsShrink($code) {
- return $code;
- }
-}
-
function add_apo_slashes($s) {
return addcslashes($s, "\\'");
}
@@ -257,9 +251,20 @@ function minify_css($file) {
return add_quo_slashes(lzw_compress(preg_replace('~\\s*([:;{},])\\s*~', '\\1', preg_replace('~/\\*.*\\*/~sU', '', $file))));
}
+function minify_js($file) {
+ if (function_exists('jsShrink')) {
+ $file = jsShrink($file);
+ }
+ return add_quo_slashes(lzw_compress($file));
+}
+
function compile_file($match) {
global $project;
- return call_user_func($match[2], file_get_contents(dirname(__FILE__) . "/$project/$match[1]"));
+ $file = "";
+ foreach (explode(";", $match[1]) as $filename) {
+ $file .= file_get_contents(dirname(__FILE__) . "/$project/$filename");
+ }
+ return call_user_func($match[2], $file);
}
$driver = "";
Please sign in to comment.
Something went wrong with that request. Please try again.