-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.php
33 lines (31 loc) · 1.01 KB
/
init.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<?php
$pluginContainer = ClassRegistry::getObject('PluginContainer');
$pluginContainer->installed('cc_u-nya-', '0.2.0');
App::uses('CakeEventManager', 'Event');
CakeEventManager::instance()->attach(function ($event)
{
$i = 0;
$event->data['text'] = $event->result['text'] = preg_replace_callback("/u-nya-/", function ($matches) use (&$i) {
$i++;
return <<<EOM
<span id="cc-u-nya-$i"></span><script>
(function() {
var aa = [
"(」・ω・)」うー!",
"(/・ω・)/にゃー!",
"(」・ω・)」うー!",
"(/・ω・)/にゃー!",
"(」・ω・)」うー!",
"(/・ω・)/にゃー!",
"Let's\(・ω・)/にゃー!",
"Let's\(・ω・)/にゃー!"
], span = document.getElementById("cc-u-nya-$i"), i = 0;
setInterval(function() {
span.innerHTML = aa[i++];
i = i % aa.length;
}, 500);
})();
</script>
EOM;
}, $event->data['text']);
}, 'Helper.Candy.afterTextilizable');