@@ -45,41 +45,41 @@ emojiMap[ns.schema('EndorseAction')] = '⭐️'
4545emojiMap [ ns . schema ( 'LikeAction' ) ] = '❤️'
4646
4747export function emojiFromActionClass ( action ) {
48- return emojiMap [ action ] || null
48+ return emojiMap [ action ] || null
4949}
5050
5151export function ActionClassFromEmoji ( emoji ) {
52- for ( a in emojiMap ) {
53- if ( emojiMap [ a ] === emoji ) {
54- return $rdf . sym ( a . slice ( 1 , - 1 ) ) // remove < >
55- }
52+ for ( const a in emojiMap ) {
53+ if ( emojiMap [ a ] === emoji ) {
54+ return rdf . sym ( a . slice ( 1 , - 1 ) ) // remove < >
5655 }
57- return null
56+ }
57+ return null
5858}
5959
6060// Allow the qction to give its own emoji as content,
6161// or get the emoji from the class lof action.
6262export function emojiFromAction ( action ) {
63- const content = store . any ( action , ns . sioc ( 'content' ) , null , action . doc ( ) )
64- if ( content ) return content
65- const klass = store . any ( action , ns . rdf ( 'type' ) , null , action . doc ( ) )
66- if ( klass ) {
67- const em = emojiFromActionClass ( klass ) ;
68- if ( em ) return em ;
69- }
70- return '⬜️'
63+ const content = store . any ( action , ns . sioc ( 'content' ) , null , action . doc ( ) )
64+ if ( content ) return content
65+ const klass = store . any ( action , ns . rdf ( 'type' ) , null , action . doc ( ) )
66+ if ( klass ) {
67+ const em = emojiFromActionClass ( klass )
68+ if ( em ) return em
69+ }
70+ return '⬜️'
7171}
7272
7373/**
7474 * Create strip of sentiments expressed
7575 */
7676export async function sentimentStrip ( target , doc ) { // alain seems not used
77- const versions = await allVersions ( target )
78- console . log ( 'sentimentStrip Versions for ' + target , versions )
79- const actions = versions . map ( version => store . each ( null , ns . schema ( 'target' ) , version , doc ) ) . flat ( )
80- console . log ( 'sentimentStrip: Actions for ' + target , actions )
81- const strings = sentiments . map ( action => emojiFromAction ( action ) || '' )
82- return dom . createTextNode ( strings . join ( ' ' ) )
77+ const versions = await allVersions ( target )
78+ debug . log ( 'sentimentStrip Versions for ' + target , versions )
79+ const actions = versions . map ( version => store . each ( null , ns . schema ( 'target' ) , version , doc ) ) . flat ( )
80+ debug . log ( 'sentimentStrip: Actions for ' + target , actions )
81+ const strings = actions . map ( action => emojiFromAction ( action ) || '' )
82+ return dom . createTextNode ( strings . join ( ' ' ) )
8383}
8484/**
8585 * Create strip of sentiments expressed, with hyperlinks
@@ -93,16 +93,16 @@ export async function sentimentStripLinked (target, doc) {
9393 strip . innerHTML = ''
9494 if ( isDeleted ( target ) ) return strip
9595 const versions = await allVersions ( target )
96- console . log ( 'sentimentStripLinked: Versions for ' + target , versions )
96+ debug . log ( 'sentimentStripLinked: Versions for ' + target , versions )
9797 const actions = versions . map ( version => store . each ( null , ns . schema ( 'target' ) , version , doc ) ) . flat ( )
98- console . log ( 'sentimentStripLinked: Actions for ' + target , actions )
99- if ( actions . length == 0 ) return strip
98+ debug . log ( 'sentimentStripLinked: Actions for ' + target , actions )
99+ if ( actions . length === 0 ) return strip
100100 const sentiments = actions . map ( a => [
101101 store . any ( a , ns . rdf ( 'type' ) , null , doc ) ,
102102 store . any ( a , ns . sioc ( 'content' ) , null , doc ) ,
103103 store . any ( a , ns . schema ( 'agent' ) , null , doc )
104104 ] )
105- console . log ( ' Actions sentiments ' , sentiments )
105+ debug . log ( ' Actions sentiments ' , sentiments )
106106 sentiments . sort ( )
107107 sentiments . forEach ( ss => {
108108 const [ theClass , content , agent ] = ss
@@ -116,10 +116,9 @@ export async function sentimentStripLinked (target, doc) {
116116 res . textContent = content || emojiMap [ theClass ] || '⬜️'
117117 strip . appendChild ( res )
118118 } )
119- console . log ( ' Actions strip ' , strip )
120-
119+ debug . log ( ' Actions strip ' , strip )
121120 }
122- refresh ( ) . then ( console . log ( 'sentimentStripLinked: sentimentStripLinked async refreshed' ) )
121+ refresh ( ) . then ( debug . log ( 'sentimentStripLinked: sentimentStripLinked async refreshed' ) )
123122 strip . refresh = refresh
124123 return strip
125124}
0 commit comments