44Name : Messenger
55GitHub :
66Roll20 Contact : timmaugh
7- Version : 1.0.1
8- Last Update : 5/4/2023
7+ Version : 1.0.2
8+ Last Update : 20 MAY 2025
99=========================================================
1010*/
1111var API_Meta = API_Meta || { } ;
@@ -15,10 +15,10 @@ API_Meta.Messenger = { offset: Number.MAX_SAFE_INTEGER, lineCount: -1 };
1515const Messenger = ( ( ) => { // eslint-disable-line no-unused-vars
1616 const apiproject = 'Messenger' ;
1717 const apilogo = `https://i.imgur.com/DEkWTak.png` ;
18- const version = '1.0.1 ' ;
18+ const version = '1.0.2 ' ;
1919 const schemaVersion = 0.1 ;
2020 API_Meta [ apiproject ] . version = version ;
21- const vd = new Date ( 1683234644321 ) ;
21+ const vd = new Date ( 1747744062840 ) ;
2222 const versionInfo = ( ) => {
2323 log ( `\u0166\u0166 ${ apiproject } v${ API_Meta [ apiproject ] . version } , ${ vd . getFullYear ( ) } /${ vd . getMonth ( ) + 1 } /${ vd . getDate ( ) } \u0166\u0166 -- offset ${ API_Meta [ apiproject ] . offset } ` ) ;
2424 } ;
@@ -285,7 +285,9 @@ const Messenger = (() => { // eslint-disable-line no-unused-vars
285285 Teal : `#008080` ,
286286 Thistle : `#D8BFD8` ,
287287 Tomato : `#FF6347` ,
288+ Transparent : 'transparent' ,
288289 Turquoise : `#40E0D0` ,
290+ Unset : 'unset' ,
289291 Violet : `#EE82EE` ,
290292 Wheat : `#F5DEB3` ,
291293 White : `#FFFFFF` ,
@@ -323,14 +325,19 @@ const Messenger = (() => { // eslint-disable-line no-unused-vars
323325 'border-collapse' : 'collapse' ,
324326 'font-size' : '12px' ,
325327 } ,
326- p : { } ,
328+ p : {
329+ 'font-family' : 'inherit'
330+ } ,
327331 a : { } ,
328332 img : { } ,
329333 h1 : { } ,
330334 h2 : { } ,
331335 h3 : { } ,
332336 h4 : { } ,
333337 h5 : { } ,
338+ ol : { } ,
339+ ul : { } ,
340+ li : { } ,
334341 th : {
335342 'border-bottom' : `1px solid #000000` ,
336343 'font-weight' : `bold` ,
@@ -376,12 +383,12 @@ const Messenger = (() => { // eslint-disable-line no-unused-vars
376383 } ,
377384 messageButtons : {
378385 'text-align' : `right` ,
379- 'margin' : `4px 4px 8px` ,
386+ 'margin' : `4px 0px 8px` ,
380387 'padding' : '8px'
381388 } ,
382389 messageFooterContent : {
383- margin : '0px 8px' ,
384- width : '98%'
390+ // margin: '0px 8px',
391+ // width: '98%'
385392 } ,
386393 button : {
387394 'background-color' : defaultThemeColor1 ,
@@ -411,28 +418,37 @@ const Messenger = (() => { // eslint-disable-line no-unused-vars
411418 const assembleCSS = ( css ) => {
412419 return `"${ Object . keys ( css ) . map ( ( key ) => { return `${ key } :${ css [ key ] } ;` } ) . join ( '' ) } "` ;
413420 } ;
421+ const processCSS = ( ...css ) => {
422+ return assembleCSS ( combineCSS ( ...css ) ) ;
423+ } ;
414424
415425 // HTML =======================================
416426 const html = {
417- div : ( content , ...CSS ) => `<div style=${ assembleCSS ( combineCSS ( css . div , ...CSS ) ) } >${ content } </div>` ,
418- h1 : ( content , ...CSS ) => `<h1 style=${ assembleCSS ( combineCSS ( css . h1 , ...CSS ) ) } >${ content } </h1>` ,
419- h2 : ( content , ...CSS ) => `<h2 style=${ assembleCSS ( combineCSS ( css . h2 , ...CSS ) ) } >${ content } </h2>` ,
420- h3 : ( content , ...CSS ) => `<h3 style=${ assembleCSS ( combineCSS ( css . h3 , ...CSS ) ) } >${ content } </h3>` ,
421- h4 : ( content , ...CSS ) => `<h4 style=${ assembleCSS ( combineCSS ( css . h4 , ...CSS ) ) } >${ content } </h4>` ,
422- h5 : ( content , ...CSS ) => `<h5 style=${ assembleCSS ( combineCSS ( css . h5 , ...CSS ) ) } >${ content } </h5>` ,
423- p : ( content , ...CSS ) => `<p style=${ assembleCSS ( combineCSS ( css . p , ...CSS ) ) } >${ content } </p>` ,
424- table : ( content , ...CSS ) => `<table style=${ assembleCSS ( combineCSS ( css . tb , ...CSS ) ) } >${ content } </table>` ,
425- th : ( content , ...CSS ) => `<th style=${ assembleCSS ( combineCSS ( css . th , ...CSS ) ) } >${ content } </th>` ,
426- tr : ( content , ...CSS ) => `<tr style=${ assembleCSS ( combineCSS ( css . tr , ...CSS ) ) } >${ content } </tr>` ,
427- td : ( content , ...CSS ) => `<td style=${ assembleCSS ( combineCSS ( css . td , ...CSS ) ) } >${ content } </td>` ,
428- td2 : ( content , ...CSS ) => `<td colspan="2" style=${ assembleCSS ( combineCSS ( css . td , ...CSS ) ) } >${ content } </td>` ,
429- tdcs : ( content , colspan , ...CSS ) => `<td colspan="${ colspan } " style=${ assembleCSS ( combineCSS ( css . td , ...CSS ) ) } >${ content } </td>` ,
430- code : ( content , ...CSS ) => `<code style=${ assembleCSS ( combineCSS ( css . code , ...CSS ) ) } >${ content } </code>` ,
431- pre : ( content , ...CSS ) => `<pre style=${ assembleCSS ( combineCSS ( css . pre , ...CSS ) ) } >${ content } </pre>` ,
432- span : ( content , ...CSS ) => `<span style=${ assembleCSS ( combineCSS ( css . span , ...CSS ) ) } >${ content } </span>` ,
433- a : ( content , link , ...CSS ) => `<a href="${ link } " style=${ assembleCSS ( combineCSS ( css . a , ...CSS ) ) } >${ content } </a>` ,
434- img : ( content , altText , ...CSS ) => `<img src="${ content } " alt="${ altText } " style=${ assembleCSS ( combineCSS ( css . img , ...CSS ) ) } >` ,
435- tip : ( content , tipText , ...CSS ) => `<span class="showtip tipsy-n-right" title="${ HE ( HE ( tipText ) ) } "style=${ assembleCSS ( combineCSS ( css . span , ...CSS ) ) } >${ content } </span>`
427+ div : ( content , ...CSS ) => `<div style=${ processCSS ( css . div , ...CSS ) } >${ content } </div>` ,
428+ h1 : ( content , ...CSS ) => `<h1 style=${ processCSS ( css . h1 , ...CSS ) } >${ content } </h1>` ,
429+ h2 : ( content , ...CSS ) => `<h2 style=${ processCSS ( css . h2 , ...CSS ) } >${ content } </h2>` ,
430+ h3 : ( content , ...CSS ) => `<h3 style=${ processCSS ( css . h3 , ...CSS ) } >${ content } </h3>` ,
431+ h4 : ( content , ...CSS ) => `<h4 style=${ processCSS ( css . h4 , ...CSS ) } >${ content } </h4>` ,
432+ h5 : ( content , ...CSS ) => `<h5 style=${ processCSS ( css . h5 , ...CSS ) } >${ content } </h5>` ,
433+ p : ( content , ...CSS ) => `<p style=${ processCSS ( css . p , ...CSS ) } >${ content } </p>` ,
434+ table : ( content , ...CSS ) => `<table style=${ processCSS ( css . tb , ...CSS ) } >${ content } </table>` ,
435+ th : ( content , ...CSS ) => `<th style=${ processCSS ( css . th , ...CSS ) } >${ content } </th>` ,
436+ tr : ( content , ...CSS ) => `<tr style=${ processCSS ( css . tr , ...CSS ) } >${ content } </tr>` ,
437+ td : ( content , ...CSS ) => `<td style=${ processCSS ( css . td , ...CSS ) } >${ content } </td>` ,
438+ td2 : ( content , ...CSS ) => `<td colspan="2" style=${ processCSS ( css . td , ...CSS ) } >${ content } </td>` ,
439+ tdcs : ( content , colspan , ...CSS ) => `<td colspan="${ colspan } " style=${ processCSS ( css . td , ...CSS ) } >${ content } </td>` ,
440+ tdrs : ( content , rowspan , ...CSS ) => `<td rowspan="${ rowspan } " style=${ processCSS ( css . td , ...CSS ) } >${ content } </td>` ,
441+ tdcrs : ( content , colspan , rowspan , ...CSS ) => `<td rowspan="${ rowspan } colspan="${ colspan } " style=${ processCSS ( css . td , ...CSS ) } >${ content } </td>` ,
442+ code : ( content , ...CSS ) => `<code style=${ processCSS ( css . code , ...CSS ) } >${ content } </code>` ,
443+ pre : ( content , ...CSS ) => `<pre style=${ processCSS ( css . pre , ...CSS ) } >${ content } </pre>` ,
444+ span : ( content , ...CSS ) => `<span style=${ processCSS ( css . span , ...CSS ) } >${ content } </span>` ,
445+ a : ( content , link , ...CSS ) => `<a href="${ link } " style=${ processCSS ( css . a , ...CSS ) } >${ content } </a>` ,
446+ img : ( content , altText , ...CSS ) => `<img src="${ content } " alt="${ altText } " style=${ processCSS ( css . img , ...CSS ) } >` ,
447+ tip : ( content , tipText , ...CSS ) => `<span class="showtip tipsy-n-right" title="${ HE ( HE ( tipText ) ) } "style=${ processCSS ( css . span , ...CSS ) } >${ content } </span>` ,
448+ tag : ( tag , content , ...CSS ) => `<${ tag } style=${ processCSS ( css . div , ...CSS ) } >${ content } </${ tag } >` ,
449+ ol : ( content , ...CSS ) => `<ol style=${ processCSS ( css . ol , ...CSS ) } >${ content } </ol>` ,
450+ ul : ( content , ...CSS ) => `<ul style=${ processCSS ( css . ul , ...CSS ) } >${ content } </ul>` ,
451+ li : ( content , ...CSS ) => `<li style=${ processCSS ( css . li , ...CSS ) } >${ content } </li>` ,
436452 } ;
437453
438454 // HTML Escaping function
@@ -467,7 +483,7 @@ const Messenger = (() => { // eslint-disable-line no-unused-vars
467483 } ;
468484 type = htmlTable [ type ] ;
469485 if ( ! type ) return '' ;
470- let btnCSS = confirmReadability ( css ) ;
486+ let btnCSS = confirmReadability ( Array . isArray ( css ) ? combineCSS ( ... css ) : css ) ;
471487 let api = '' ;
472488 switch ( type ) {
473489 case '#' : // macro
@@ -498,7 +514,7 @@ const Messenger = (() => { // eslint-disable-line no-unused-vars
498514 } ;
499515 type = htmlTable [ type ] ;
500516 if ( ! type ) return '' ;
501- let btnCSS = confirmReadability ( css ) ;
517+ let btnCSS = confirmReadability ( Array . isArray ( css ) ? combineCSS ( ... css ) : css ) ;
502518 let api = '' ;
503519 switch ( type ) {
504520 case '#' : // macro
@@ -528,17 +544,19 @@ const Messenger = (() => { // eslint-disable-line no-unused-vars
528544 boundingcss : boundingcss = { } ,
529545 headercss : headercss = { } ,
530546 bodycss : bodycss = { } ,
547+ contentcss : contentcss = { } ,
531548 footercss : footercss = { } ,
532549 noarchive : noarchive = false
533550 } = { } ) => {
534- let containerCSS = confirmReadability ( combineCSS ( css . divContainer , containercss ) ) ;
535- let boundingCSS = confirmReadability ( combineCSS ( css . div , css . rounded , boundingcss ) ) ;
536- let hdrCSS = confirmReadability ( combineCSS ( css . messageHeader , headercss ) ) ;
537- let bodyCSS = confirmReadability ( combineCSS ( css . messageBody , bodycss ) ) ;
538- let footerCSS = confirmReadability ( combineCSS ( css . messageFooterContent , footercss ) ) ;
551+ let containerCSS = confirmReadability ( combineCSS ( css . divContainer , Array . isArray ( containercss ) ? combineCSS ( ...containercss ) : containercss ) ) ;
552+ let boundingCSS = confirmReadability ( combineCSS ( css . div , css . rounded , Array . isArray ( boundingcss ) ? combineCSS ( ...boundingcss ) : boundingcss ) ) ;
553+ let hdrCSS = confirmReadability ( combineCSS ( css . messageHeader , Array . isArray ( headercss ) ? combineCSS ( ...headercss ) : headercss ) ) ;
554+ let bodyCSS = confirmReadability ( combineCSS ( css . messageBody , Array . isArray ( bodycss ) ? combineCSS ( ...bodycss ) : bodycss ) ) ;
555+ let footerCSS = confirmReadability ( combineCSS ( css . messageFooterContent , Array . isArray ( footercss ) ? combineCSS ( ...footercss ) : footercss ) ) ;
556+ let contentCSS = confirmReadability ( combineCSS ( css . messageBodyContent , Array . isArray ( contentcss ) ? combineCSS ( ...contentcss ) : contentcss ) ) ;
539557
540558 let hdr = title !== '' ? html . div ( html . div ( title , css . messageHeaderContent ) , hdrCSS ) : '' ;
541- let body = html . div ( html . div ( msg , css . messageBodyContent ) , bodyCSS ) ;
559+ let body = html . div ( html . div ( msg , contentCSS ) , bodyCSS ) ;
542560 let buttons = btn !== '' ? html . div ( btn , css . messageButtons ) : '' ;
543561 if ( footer ) footer = html . div ( footer ) ;
544562 if ( footer || buttons ) {
@@ -631,10 +649,12 @@ const Messenger = (() => { // eslint-disable-line no-unused-vars
631649 Button : button ,
632650 HOButton : hobutton ,
633651 MsgBox : msgbox ,
652+ ProcessCSS : processCSS ,
634653 Html : ( ) => _ . clone ( html ) ,
635654 Css : ( ) => _ . clone ( css ) ,
636655 HE : HE ,
637- version : version
656+ version : version ,
657+ ValidateHexColor : validateHexColor
638658 } ;
639659} ) ( ) ;
640660
0 commit comments