1<?php 2// must be run within Dokuwiki 3if (!defined('DOKU_INC')) die(); 4 5class action_plugin_heatmap extends DokuWiki_Action_Plugin { 6 private static $initialized = false; 7 8 public function register(Doku_Event_Handler $controller) { 9 $controller->register_hook( 'DOKUWIKI_STARTED', 'BEFORE', $this, 'setup_options' ); 10 $controller->register_hook( 'TPL_METAHEADER_OUTPUT', 'BEFORE', $this, 'load_scripts' ); 11 } 12 13 public function setup_options(Doku_Event $event, $param) { 14 if (self::$initialized) return; 15 16 global $JSINFO; 17 if (!isset($JSINFO['plugin']['postHeatmap'])) { 18 $JSINFO['plugin']['postHeatmap'] = []; 19 } 20 21 self::$initialized = true; 22 } 23 24 public function load_scripts(Doku_Event $event, $param) { 25 $event->data['script'][] = array( 26 'defer' => true, 27 'src' => "https://cdn.jsdelivr.net/npm/echarts@5.3.0/dist/echarts.min.js", 28 ); 29 } 30} 31?> 32