From 479b8450994e5a47eff744c623b3ae14afcee19c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Gro=C3=9Fe?= <grosse@cosmocode.de> Date: Mon, 11 Dec 2017 13:30:52 +0100 Subject: [PATCH] feat: canonically provide $ACT to javascript It would be helpful if there were a reliable way to determine the current mode in javascript, for example if we only want to execute some javascript in `show` or `preview` modes. This writes the final mode to the JSINFO object right before it is written out as header, so we can hopefully capture the actual mode without an plugin changing it later on. --- inc/template.php | 1 + 1 file changed, 1 insertion(+) diff --git a/inc/template.php b/inc/template.php index c44cd064c..bc1c7dea6 100644 --- a/inc/template.php +++ b/inc/template.php @@ -330,6 +330,7 @@ function tpl_metaheaders($alt = true) { if($conf['useacl'] && $INPUT->server->str('REMOTE_USER')) { $script .= "var SIG='".toolbar_signature()."';"; } + $JSINFO['ACT'] = act_clean($ACT); $script .= 'var JSINFO = '.$json->encode($JSINFO).';'; $head['script'][] = array('type'=> 'text/javascript', '_data'=> $script); -- GitLab