diff options
author | Andrew Dolgov <[email protected]> | 2018-12-02 18:38:27 +0300 |
---|---|---|
committer | Andrew Dolgov <[email protected]> | 2018-12-02 18:38:27 +0300 |
commit | f89924f7a19871e26d5805a6c1863903c6e474bf (patch) | |
tree | 8e7e26aa987d809c6a217319af79479c0006a260 | |
parent | 807ff074540575e6ef8f99ad32b098a816091171 (diff) |
set use strict on JS modules; remove some mostly useless stuff like get_minified_js()
-rwxr-xr-x | include/functions.php | 49 | ||||
-rw-r--r-- | include/login_form.php | 2 | ||||
-rw-r--r-- | index.php | 9 | ||||
-rw-r--r-- | js/Article.js | 2 | ||||
-rw-r--r-- | js/ArticleCache.js | 2 | ||||
-rw-r--r-- | js/CommonDialogs.js | 2 | ||||
-rw-r--r-- | js/CommonFilters.js | 2 | ||||
-rw-r--r-- | js/Feeds.js | 2 | ||||
-rwxr-xr-x | js/Headlines.js | 4 | ||||
-rw-r--r-- | js/PluginHost.js | 4 | ||||
-rw-r--r-- | js/PrefUsers.js | 2 | ||||
-rw-r--r-- | js/Utils.js | 8 | ||||
-rwxr-xr-x | js/common.js (renamed from js/functions.js) | 1 | ||||
-rwxr-xr-x | js/prefs.js | 1 | ||||
-rw-r--r-- | js/tt-rss.js | 1 | ||||
-rw-r--r-- | prefs.php | 11 | ||||
-rw-r--r-- | register.php | 2 |
17 files changed, 32 insertions, 72 deletions
diff --git a/include/functions.php b/include/functions.php index 2ec42c7ee..baed6fb20 100755 --- a/include/functions.php +++ b/include/functions.php @@ -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); diff --git a/include/login_form.php b/include/login_form.php index bb142f6c5..9c3a9b375 100644 --- a/include/login_form.php +++ b/include/login_form.php @@ -10,7 +10,7 @@ foreach (array("lib/prototype.js", "lib/dojo/dojo.js", "lib/dojo/tt-rss-layer.js", - "js/functions.js", + "js/common.js", "errors.php?mode=js") as $jsfile) { echo javascript_tag($jsfile); @@ -103,6 +103,9 @@ "lib/scriptaculous/scriptaculous.js?load=effects,controls", "lib/dojo/dojo.js", "lib/dojo/tt-rss-layer.js", + "js/tt-rss.js", + "js/common.js", + "js/PluginHost.js", "errors.php?mode=js") as $jsfile) { echo javascript_tag($jsfile); @@ -110,13 +113,9 @@ } ?> <script type="text/javascript"> - 'use strict'; require({cache:{}}); - <?php - print get_minified_js(["tt-rss.js", - "functions.js", "PluginHost.js"]); - ?> </script> + <script type="text/javascript"> <?php foreach (PluginHost::getInstance()->get_plugins() as $n => $p) { diff --git a/js/Article.js b/js/Article.js index 89bb3b3af..0e1318948 100644 --- a/js/Article.js +++ b/js/Article.js @@ -1,3 +1,5 @@ +'use strict' +/* global __, ngettext */ define(["dojo/_base/declare"], function (declare) { return declare("fox.Article", null, { _active_article_id: 0, diff --git a/js/ArticleCache.js b/js/ArticleCache.js index fbba1f679..a4e8e091f 100644 --- a/js/ArticleCache.js +++ b/js/ArticleCache.js @@ -1,3 +1,5 @@ +'use strict' +/* global __, ngettext */ define(["dojo/_base/declare"], function (declare) { return declare("fox.ArticleCache", null, { has_storage: 'sessionStorage' in window && window['sessionStorage'] !== null, diff --git a/js/CommonDialogs.js b/js/CommonDialogs.js index 757f84f81..d8733e1c2 100644 --- a/js/CommonDialogs.js +++ b/js/CommonDialogs.js @@ -1,3 +1,5 @@ +'use strict' +/* global __, ngettext */ define(["dojo/_base/declare"], function (declare) { return declare("fox.CommonDialogs", null, { quickAddFeed: function() { diff --git a/js/CommonFilters.js b/js/CommonFilters.js index 28a151690..3f508ef71 100644 --- a/js/CommonFilters.js +++ b/js/CommonFilters.js @@ -1,3 +1,5 @@ +'use strict' +/* global __, ngettext */ define(["dojo/_base/declare"], function (declare) { return declare("fox.CommonFilters", null, { filterDlgCheckAction: function(sender) { diff --git a/js/Feeds.js b/js/Feeds.js index a461ab7d2..c7db1aee5 100644 --- a/js/Feeds.js +++ b/js/Feeds.js @@ -1,3 +1,5 @@ +'use strict' +/* global __, ngettext */ define(["dojo/_base/declare"], function (declare) { return declare("fox.Feeds", null, { counters_last_request: 0, diff --git a/js/Headlines.js b/js/Headlines.js index 32bf222a7..d5f680f85 100755 --- a/js/Headlines.js +++ b/js/Headlines.js @@ -1,5 +1,5 @@ -/* global dijit, __, ngettext, notify */ - +'use strict'; +/* global __, ngettext */ define(["dojo/_base/declare"], function (declare) { return declare("fox.Headlines", null, { vgroup_last_feed: undefined, diff --git a/js/PluginHost.js b/js/PluginHost.js index a41694f34..9dbd91756 100644 --- a/js/PluginHost.js +++ b/js/PluginHost.js @@ -19,10 +19,10 @@ const PluginHost = { this.hooks[name].push(callback); }, run: function (name, args) { - console.warn('PluginHost::run ' + name); + //console.warn('PluginHost::run ' + name); if (typeof(this.hooks[name]) != 'undefined') - for (var i = 0; i < this.hooks[name].length; i++) + for (let i = 0; i < this.hooks[name].length; i++) if (!this.hooks[name][i](args)) break; } }; diff --git a/js/PrefUsers.js b/js/PrefUsers.js index aa3c2826d..891af8ddb 100644 --- a/js/PrefUsers.js +++ b/js/PrefUsers.js @@ -1,3 +1,5 @@ +'use strict' +/* global __, ngettext */ define(["dojo/_base/declare"], function (declare) { return declare("fox.PrefUsers", null, { diff --git a/js/Utils.js b/js/Utils.js index 204b3189c..8778143f2 100644 --- a/js/Utils.js +++ b/js/Utils.js @@ -1,3 +1,5 @@ +'use strict' +/* global __, ngettext */ define(["dojo/_base/declare"], function (declare) { return declare("fox.Utils", null, { _rpc_seq: 0, @@ -235,12 +237,6 @@ define(["dojo/_base/declare"], function (declare) { console.log("RI:", k, "=>", v); - if (k == "dep_ts" && parseInt(getInitParam("dep_ts")) > 0) { - if (parseInt(getInitParam("dep_ts")) < parseInt(v) && getInitParam("reload_on_ts_change")) { - window.location.reload(); - } - } - if (k == "daemon_is_running" && v != 1) { notify_error("<span onclick=\"Utils.explainError(1)\">Update daemon is not running.</span>", true); return; diff --git a/js/functions.js b/js/common.js index 0d52358ec..b63257099 100755 --- a/js/functions.js +++ b/js/common.js @@ -1,3 +1,4 @@ +'use strict' /* global dijit, __ */ let init_params = {}; diff --git a/js/prefs.js b/js/prefs.js index 637bc7905..7c4021201 100755 --- a/js/prefs.js +++ b/js/prefs.js @@ -1,3 +1,4 @@ +'use strict' /* global dijit, __ */ let Utils; diff --git a/js/tt-rss.js b/js/tt-rss.js index cbae4db4c..74b8403f8 100644 --- a/js/tt-rss.js +++ b/js/tt-rss.js @@ -1,3 +1,4 @@ +'use strict' /* global dijit,__ */ let Utils; @@ -70,19 +70,18 @@ "lib/scriptaculous/scriptaculous.js?load=effects,controls", "lib/dojo/dojo.js", "lib/dojo/tt-rss-layer.js", + "js/common.js", + "js/prefs.js", "errors.php?mode=js") as $jsfile) { echo javascript_tag($jsfile); } ?> - <script type="text/javascript"> - 'use strict'; + <script type="text/javascript"> require({cache:{}}); - <?php - print get_minified_js(["functions.js", "prefs.js"]); - ?> - </script> + </script> + <script type="text/javascript"> <?php foreach (PluginHost::getInstance()->get_plugins() as $n => $p) { diff --git a/register.php b/register.php index 8bbce9932..6e66d7ea6 100644 --- a/register.php +++ b/register.php @@ -95,7 +95,7 @@ <title>Create new account</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <?php echo stylesheet_tag("css/default.css") ?> -<?php echo javascript_tag("js/functions.js") ?> +<?php echo javascript_tag("js/common.js") ?> <?php echo javascript_tag("lib/prototype.js") ?> <?php echo javascript_tag("lib/scriptaculous/scriptaculous.js?load=effects,controls") ?> </head> |