added audio

hash-command-arbitrary
Avril 6 years ago
parent 0e3b24a641
commit 88e302226e
Signed by untrusted user: flanchan
GPG Key ID: 284488987C31F630

@ -10,9 +10,14 @@ function queue_roll(bit) {
info.bit = bit; info.bit = bit;
info.$tag = $(this.callback(safe('<strong>'))); info.$tag = $(this.callback(safe('<strong>')));
this.strong = true; this.strong = true;
var audio = undefined;
if(bit =='#loli' && info.dice) { if(bit =='#loli' && info.dice) {
this.callback(safe("<a href='"+info.dice[0]+"' target='_blank' rel='noopener noreferrer'><img src='"+info.dice[1]+"'></img></a>")); this.callback(safe("<a href='"+info.dice[0]+"' target='_blank' rel='noopener noreferrer'><img src='"+info.dice[1]+"'></img></a>"));
} }
else if (info.dice && (audio = readable_audio(bit, info.dice))) {
this.callback(safe("<a style='text-decoration:none;' href='javascript:void(0);' onclick='this.nextSibling.play();'>"+bit+"</a>"));
this.callback(safe("<audio src='"+audio_root+"/"+audio+"'></audio>"));
}
else this.callback(info.dice ? readable_dice(bit, info.dice) : bit); else this.callback(info.dice ? readable_dice(bit, info.dice) : bit);
this.strong = false; this.strong = false;
this.callback(safe('</strong>')); this.callback(safe('</strong>'));
@ -35,7 +40,19 @@ oneeSama.hook('insertOwnPost', function (extra) {
info = rolls[n] = {}; info = rolls[n] = {};
info.dice = extra.dice[i]; info.dice = extra.dice[i];
if (info.$tag) { if (info.$tag) {
if(info.bit == "#loli") var audio = readable_audio(info.bit, info.dice);
if (audio)
{
var $audio = $("<a style='text-decoration:none;' href='javascript:void(0);' onclick='this.nextSibling.play();'>"+info.bit+"</a>");
var $aaudio = $("<audio src='"+audio_root+"/"+audio+"'></audio>");
info.$tag.text('');
info.$tag.append($audio);
info.$tag.append($aaudio);
if(info.$tag.children && info.$tag.children[0]) //wha? works for chakai
info.$tag.children[0].text(info.bit);
}
else if(info.bit == "#loli")
info.$tag.html("<a href='"+info.dice[0]+"' target='_blank' ref='noopener noreferrer'><img src='"+info.dice[1]+"'></img></a>"); info.$tag.html("<a href='"+info.dice[0]+"' target='_blank' ref='noopener noreferrer'><img src='"+info.dice[1]+"'></img></a>");
else info.$tag.text(readable_dice(info.bit, info.dice)); else info.$tag.text(readable_dice(info.bit, info.dice));
} }

@ -388,7 +388,7 @@ OS.karada = function (body) {
return output; return output;
} }
var dice_re = /(#flip|#when|#du|#pyu|#pcount|#test|#sleep|#janken|#8ball|#imfey|#\?(?:\[(?:\w,*)+\])?|#\d{0,2}d\d{1,4}(?:[+-]\d{1,4})?)/i; var dice_re = /(#dame|#muri|#flip|#when|#du|#pyu|#pcount|#test|#sleep|#janken|#8ball|#imfey|#\?(?:\[(?:\w,*)+\])?|#\d{0,2}d\d{1,4}(?:[+-]\d{1,4})?)/i;
exports.dice_re = dice_re; exports.dice_re = dice_re;
var WHEN = [ var WHEN = [
@ -444,7 +444,10 @@ var IMFEY = [
'elwind!', 'elwind!',
]; ];
function parse_dice(frag) { function parse_dice(frag)
{
if(/^#(dame|muri)$/i.test(frag))
return {n:1, faces:2};
if(frag == '#loli') { if(frag == '#loli') {
return {n:1, faces:3}; return {n:1, faces:3};
} }
@ -492,6 +495,15 @@ function parse_dice(frag) {
} }
exports.parse_dice = parse_dice; exports.parse_dice = parse_dice;
const audio_root = "/s/audio";
function readable_audio(bit, d) {
if (bit=='#dame')
return "dame.wav";
else if (bit=='#muri')
return "muri.wav";
}
function readable_dice(bit, d) { function readable_dice(bit, d) {
if(bit == '#loli') { if(bit == '#loli') {
return "you should not see this"; return "you should not see this";
@ -591,7 +603,13 @@ OS.geimu = function (text) {
var d = this.dice.shift(); var d = this.dice.shift();
this.callback(safe('<strong>')); this.callback(safe('<strong>'));
this.strong = true; // for client DOM insertion this.strong = true; // for client DOM insertion
if(bit == "#loli") { var audio = readable_audio(bit,d);
if(audio)
{
this.callback(safe("<a style='text-decoration:none;' href='javascript:void(0);' onclick='this.nextSibling.play();'>"+bit+"</a>"));
this.callback(safe("<audio src='"+audio_root+"/"+audio+"'></audio>"));
}
else if(bit == "#loli") {
this.callback(safe("<a href='"+d[0]+"' target='_blank' rel='noopener noreferrer'><img src='"+d[1]+"'></img></a>")); this.callback(safe("<a href='"+d[0]+"' target='_blank' rel='noopener noreferrer'><img src='"+d[1]+"'></img></a>"));
} }
else else

Loading…
Cancel
Save