1<?php
2/**
3 * DokuWiki Plugin wavedrom (Action Component)
4 *
5 * @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html
6 * @author  Raymond Wu <wusixin@gmail.com>
7 */
8
9// must be run within Dokuwiki
10if (!defined('DOKU_INC')) {
11    die();
12}
13
14class action_plugin_wavedrom extends DokuWiki_Action_Plugin
15{
16
17 public function register(Doku_Event_Handler $controller) {
18        $controller->register_hook('TPL_METAHEADER_OUTPUT', 'BEFORE', $this,
19                                   '_loadwavedrom');
20    }
21
22    public function _loadwavedrom(Doku_Event $event, $param) {
23        $event->data['script'][] = array(
24                            'type'    => 'text/javascript',
25                            'charset' => 'utf-8',
26                            '_data'   => '',
27                            'src'     => 'https://cdnjs.cloudflare.com/ajax/libs/wavedrom/1.6.2/skins/default.js');
28        $event->data['script'][] = array(
29                            'type'    => 'text/javascript',
30                            'charset' => 'utf-8',
31                            '_data'   => '',
32                            'src'     => 'https://cdnjs.cloudflare.com/ajax/libs/wavedrom/1.6.2/wavedrom.min.js');
33        $event->data['script'][] = array(
34                            'type'    => 'text/javascript',
35                            'charset' => 'utf-8',
36                            '_data'   => 'jQuery(function(){WaveDrom.ProcessAll()});');
37        }
38
39}
40
41