From 3628849c341be85c7aaa9ac0ba3179d34ccfd0db Mon Sep 17 00:00:00 2001 From: Nicolas Boisselier Date: Fri, 17 May 2019 03:19:18 +0100 Subject: [PATCH] www/dbq/html/default.js --- lib/php/page.php | 24 +++++++++++++++++++----- www/dbq/dbq.php | 16 +++++++++------- www/dbq/html/default.js | 23 +++++++++++++++++++++-- 3 files changed, 49 insertions(+), 14 deletions(-) diff --git a/lib/php/page.php b/lib/php/page.php index 6c7c10e9..68e75e3e 100644 --- a/lib/php/page.php +++ b/lib/php/page.php @@ -38,6 +38,8 @@ class Page extends nb { public $js = []; public $js_code = ''; + public $js_code_pre = ''; + public $js_code_post = ''; public $body_class = ''; public $body_id = ''; @@ -319,14 +321,20 @@ class Page extends nb { } - public static function end() { + public function end() { if (self::is('html')) { self::tag_end(); - echo '' - . '' . NB_EOL - . '' . NB_EOL - ; + if ($this->js_code_post) echo '' + . '' . NB_EOL + ; + echo '' . NB_EOL; + echo '' . NB_EOL; } } @@ -409,6 +417,12 @@ class Page extends nb { ; // JS + if ($this->js_code_pre) $head .= '' + . '' . NB_EOL + ; + foreach ((array)($this->js) as $vv) { foreach ($this->path2url($vv) as $v) { $head .= '' . NB_EOL; diff --git a/www/dbq/dbq.php b/www/dbq/dbq.php index c51a04f7..9f90be5c 100644 --- a/www/dbq/dbq.php +++ b/www/dbq/dbq.php @@ -1,5 +1,6 @@ _nopage)) { - $this->page->js_code = 'window._dbq = '.json_encode($this->conf); + #$this->page->js_code_post = 'window._dbq = '.json_encode($this->conf).';dbqLoad();'; + $this->page->js_code_post = 'dbqLoad('.json_encode($this->conf).');'; if ($obj != 'logout') { list($title,$nav) = $this->title_nav(); diff --git a/www/dbq/html/default.js b/www/dbq/html/default.js index d89cd41d..de65ad8e 100644 --- a/www/dbq/html/default.js +++ b/www/dbq/html/default.js @@ -1,4 +1,10 @@ -document.addEventListener("DOMContentLoaded", function() { +/* +if (window._dbq != undefined) +*/ +//document.addEventListener("DOMContentLoaded", function() { +//}); +function dbqLoad(DBQ) { + window._dbq = DBQ; $('.db-rows form.rm').each(function() { }); @@ -181,7 +187,7 @@ document.addEventListener("DOMContentLoaded", function() { }); -}); +} // dbqLoad() function form_clean(form) { var e; @@ -275,3 +281,16 @@ function iframe_embed(href) { console.log(href); return false; } + +/* +//console.log(window._dbq); +if (window._dbq != undefined) { + if (document.readyState === 'loading') { // Loading hasn't finished yet + document.addEventListener('DOMContentLoaded', dbqLoad); + } else { // `DOMContentLoaded` has already fired + dbqLoad; + } +} else { +//console.log('ERR'); +} +*/ -- 2.47.3