Imported core stuff from Misuzu.

This commit is contained in:
flash 2025-02-20 20:49:09 +00:00
parent 5c71b34c24
commit 9841468f59
35 changed files with 314 additions and 399 deletions
src/mami.js

View file

@ -1,5 +1,3 @@
#include utility.js
if(!Umi.Parser) Umi.Parser = {};
if(!Umi.Parser.SockChatBBcode) Umi.Parser.SockChatBBcode = {};
@ -146,8 +144,9 @@ Umi.Parsing = (function() {
};
};
const motivFrame = function(texts, body) {
return $e({
attrs: {
return $element(
'div',
{
style: {
display: 'inline-block',
textAlign: 'center',
@ -158,48 +157,46 @@ Umi.Parsing = (function() {
lineHeight: '1.4em',
},
},
child: [
$element(
'div',
{
tag: 'div',
attrs: {
style: {
border: '3px double #fff',
maxWidth: '50vw',
maxHeight: '50vh',
marginTop: '30px',
marginLeft: '50px',
marginRight: '50px',
boxSizing: 'content-box',
display: 'inline-block',
},
},
child: body,
},
{
tag: 'h1',
child: texts.top,
attrs: {
style: {
color: '#fff',
textDecoration: 'none !important',
margin: '10px',
textTransform: 'uppercase',
},
style: {
border: '3px double #fff',
maxWidth: '50vw',
maxHeight: '50vh',
marginTop: '30px',
marginLeft: '50px',
marginRight: '50px',
boxSizing: 'content-box',
display: 'inline-block',
},
},
body
),
$element(
'h1',
{
tag: 'p',
child: texts.bottom,
attrs: {
style: {
color: '#fff',
textDecoration: 'none !important',
margin: '10px',
},
style: {
color: '#fff',
textDecoration: 'none !important',
margin: '10px',
textTransform: 'uppercase',
},
},
],
});
texts.top
),
$element(
'p',
{
style: {
color: '#fff',
textDecoration: 'none !important',
margin: '10px',
},
},
texts.bottom
),
);
};
const toggleImage = function(element) {
@ -219,9 +216,9 @@ Umi.Parsing = (function() {
element.dataset.embed = '1';
element.classList.add('markup__link--visited');
let html = $e({
tag: 'img',
attrs: {
let html = $element(
'img',
{
src: url,
alt: url,
style: {
@ -234,7 +231,7 @@ Umi.Parsing = (function() {
container.scrollIntoView({ inline: 'end' });
},
},
});
);
if(mami.settings.get('motivationalImages'))
html = motivFrame(
@ -256,16 +253,16 @@ Umi.Parsing = (function() {
element.dataset.embed = '0';
element.textContent = 'Embed';
container.textContent = '';
container.appendChild($e({
tag: 'a',
attrs: {
container.appendChild($element(
'a',
{
href: url,
target: '_blank',
rel: 'nofollow noreferrer noopener',
className: 'markup__link',
},
child: url,
}));
url,
));
} else {
container.title = 'audio';
element.dataset.embed = '1';
@ -273,9 +270,9 @@ Umi.Parsing = (function() {
container.textContent = '';
element.classList.add('markup__link--visited');
let media = $e({
tag: 'audio',
attrs: {
let media = $element(
'audio',
{
src: url,
controls: true,
onloadedmetadata: () => {
@ -285,7 +282,7 @@ Umi.Parsing = (function() {
media.play();
},
},
});
);
container.appendChild(media);
}
@ -300,25 +297,25 @@ Umi.Parsing = (function() {
element.dataset.embed = '0';
element.textContent = 'Embed';
container.textContent = '';
container.appendChild($e({
tag: 'a',
attrs: {
container.appendChild($element(
'a',
{
href: url,
target: '_blank',
rel: 'nofollow noreferrer noopener',
className: 'markup__link',
},
child: url,
}));
url,
));
} else {
container.title = 'video';
element.dataset.embed = '1';
element.textContent = 'Remove';
element.classList.add('markup__link--visited');
let media = $e({
tag: 'video',
attrs: {
let media = $element(
'video',
{
src: url,
controls: true,
style: {
@ -332,7 +329,7 @@ Umi.Parsing = (function() {
media.play();
},
},
});
);
let html = media;