PKPTemplateManager::addJavaScript PHP Method

addJavaScript() public method

Register a script with the script handler
public addJavaScript ( $name, $script, $args = [] )
$name string Unique name for the script
$script string The script to be included. Should be a URL or, if the `inline` argument is included, script data to be output.
$args array Key/value array defining display details `priority` int The order in which to print this script. Default: STYLE_SEQUENCE_NORMAL `contexts` string|array Where the script should be loaded. Default: array('frontend') `inline` bool Whether the $script value should be output directly as script data. Used to pass backend data to the scripts.
    function addJavaScript($name, $script, $args = array())
    {
        $args = array_merge(array('priority' => STYLE_SEQUENCE_NORMAL, 'contexts' => array('frontend'), 'inline' => false), $args);
        $args['contexts'] = (array) $args['contexts'];
        foreach ($args['contexts'] as $context) {
            $this->_javaScripts[$context][$args['priority']][$name] = array('script' => $script, 'inline' => $args['inline']);
        }
    }