]> git.wh0rd.org Git - tt-rss.git/commitdiff
implement basic auto-reload on some dependent file timestamp changing
authorAndrew Dolgov <fox@madoka.volgo-balt.ru>
Thu, 21 Mar 2013 14:01:42 +0000 (18:01 +0400)
committerAndrew Dolgov <fox@madoka.volgo-balt.ru>
Thu, 21 Mar 2013 14:01:42 +0000 (18:01 +0400)
include/functions.php
js/tt-rss.js

index 3d6b7c89ad16c1e7e7febdfced11d730877920a2..aa5575548f64c431d38b6e38222ce471b0de047d 100644 (file)
                $data['last_article_id'] = getLastArticleId($link);
                $data['cdm_expanded'] = get_pref($link, 'CDM_EXPANDED');
 
+               $data['dep_ts'] = calculate_dep_timestamp();
+
                if (file_exists(LOCK_DIRECTORY . "/update_daemon.lock")) {
 
                        $data['daemon_is_running'] = (int) file_is_locked("update_daemon.lock");
                echo "<script type=\"text/javascript\" charset=\"utf-8\" src=\"$filename?$timestamp\"></script>\n";
        }
 
+       function calculate_dep_timestamp() {
+               $files = array_merge(glob("js/*.js"), glob("*.css"));
+
+               $max_ts = -1;
+
+               foreach ($files as $file) {
+                       if (filemtime($file) > $max_ts) $max_ts = filemtime($file);
+               }
+
+               return $max_ts;
+       }
+
 ?>
index 77bb5117c52be2145653dc781716caa433c2803f..ed5e01d4bdde399cbfe48e7d847c2dc632cbd86a 100644 (file)
@@ -446,6 +446,12 @@ function parse_runtime_info(data) {
                        return;
                }
 
+               if (k == "dep_ts" && parseInt(getInitParam("dep_ts")) > 0) {
+                       if (parseInt(getInitParam("dep_ts")) < parseInt(v)) {
+                               window.location.reload();
+                       }
+               }
+
                if (k == "daemon_is_running" && v != 1) {
                        notify_error("<span onclick=\"javascript:explainError(1)\">Update daemon is not running.</span>", true);
                        return;