1
0
mirror of https://git.tt-rss.org/git/tt-rss.git synced 2025-12-19 03:31:29 +00:00

set use strict on JS modules; remove some mostly useless stuff like get_minified_js()

This commit is contained in:
Andrew Dolgov
2018-12-02 18:38:27 +03:00
parent 807ff07454
commit f89924f7a1
17 changed files with 32 additions and 72 deletions

View File

@@ -1310,9 +1310,6 @@
$data['last_article_id'] = Article::getLastArticleId();
$data['cdm_expanded'] = get_pref('CDM_EXPANDED');
$data['dep_ts'] = calculate_dep_timestamp();
$data['reload_on_ts_change'] = !defined('_NO_RELOAD_ON_TS_CHANGE');
$data["labels"] = Labels::get_all_labels($_SESSION["uid"]);
if (CHECK_FOR_UPDATES && !$disable_update_check && $_SESSION["last_version_check"] + 86400 + rand(-1000, 1000) < time()) {
@@ -2379,52 +2376,6 @@
return in_array($interface, class_implements($class));
}
function get_minified_js($files) {
$rv = '';
foreach ($files as $js) {
if (!isset($_GET['debug'])) {
$cached_file = CACHE_DIR . "/js/".basename($js);
if (file_exists($cached_file) && is_readable($cached_file) && filemtime($cached_file) >= filemtime("js/$js")) {
list($header, $contents) = explode("\n", file_get_contents($cached_file), 2);
if ($header && $contents) {
list($htag, $hversion) = explode(":", $header);
if ($htag == "tt-rss" && $hversion == VERSION) {
$rv .= $contents;
continue;
}
}
}
$minified = JShrink\Minifier::minify(file_get_contents("js/$js"));
file_put_contents($cached_file, "tt-rss:" . VERSION . "\n" . $minified);
$rv .= $minified;
} else {
$rv .= file_get_contents("js/$js"); // no cache in debug mode
}
}
return $rv;
}
function calculate_dep_timestamp() {
$files = array_merge(glob("js/*.js"), glob("css/*.css"));
$max_ts = -1;
foreach ($files as $file) {
if (filemtime($file) > $max_ts) $max_ts = filemtime($file);
}
return $max_ts;
}
function T_js_decl($s1, $s2) {
if ($s1 && $s2) {
$s1 = preg_replace("/\n/", "", $s1);