@@ -19,6 +19,7 @@ import Globals from './globals.mjs'
19
19
const mAvailableMimeTypes = [ ] ,
20
20
mAvailableUploaderTypes = [ 'library' , 'personal-avatar' , 'personal-biographer' , 'resume' , ] ,
21
21
botBar = document . getElementById ( 'bot-bar' ) ,
22
+ mDefaultReliveMemoryButtonText = 'next' ,
22
23
mDefaultTeam = 'memoir' ,
23
24
mGlobals = new Globals ( ) ,
24
25
mLibraries = [ 'entry' , 'experience' , 'file' , 'story' ] , // ['chat', 'conversation']
@@ -397,7 +398,6 @@ async function mMemoryShadow(event){
397
398
throw new Error ( `Unimplemented shadow type: ${ type } ` )
398
399
}
399
400
/* close popup */
400
- // @stub - minimize to header instead?
401
401
const popupClose = document . getElementById ( `popup-close_${ itemId } ` )
402
402
if ( popupClose )
403
403
popupClose . click ( )
@@ -526,6 +526,7 @@ function mCreateCollectionPopup(collectionItem) {
526
526
/* create popup close button */
527
527
const popupClose = document . createElement ( 'button' )
528
528
popupClose . classList . add ( 'fa-solid' , 'fa-close' , 'popup-close' , 'collection-popup-close' )
529
+ popupClose . dataset . isClose = 'true'
529
530
popupClose . id = `popup-close_${ id } `
530
531
popupClose . setAttribute ( 'aria-label' , 'Close' )
531
532
popupClose . addEventListener ( 'click' , mTogglePopup )
@@ -628,108 +629,35 @@ function mCreateCollectionPopup(collectionItem) {
628
629
improveMemory . classList . add ( `collection-popup-${ type } ` )
629
630
improveMemory . id = `popup-${ type } _${ id } `
630
631
improveMemory . name = 'improve-memory-container'
631
- /* shadows, share -memory panel */
632
+ /* shadows, relive -memory panel */
632
633
const improveMemoryLane = document . createElement ( 'div' )
633
634
improveMemoryLane . classList . add ( 'improve-memory-lane' )
634
635
/* story shadows */
635
636
if ( mShadows ?. length )
636
637
improveMemoryLane . appendChild ( mCreateMemoryShadows ( id ) )
637
- /* share memory panel */
638
- const shareMemory = document . createElement ( 'div' )
639
- shareMemory . classList . add ( 'share-memory-container' )
640
- shareMemory . id = `share-memory_${ id } `
641
- shareMemory . name = 'share-memory-container'
642
- const shareMemoryActorSelect = document . createElement ( 'div' )
643
- shareMemoryActorSelect . classList . add ( 'share-memory-select' )
644
- shareMemoryActorSelect . title = `Select the actor or narrator for the story. Who should tell your story? Or who will play "you"?`
645
- /* actor */
646
- const actorList = [ 'Biographer' , 'My Avatar' , 'Member avatar' , 'Q' , 'MyLife Professional Actor' , 'Custom' ]
647
- const actor = document . createElement ( 'select' )
648
- actor . classList . add ( 'share-memory-actor-select' )
649
- actor . dataset . id = id
650
- actor . dataset . type = `actor`
651
- actor . id = `share-memory-actor-select_${ id } `
652
- actor . name = 'share-memory-actor-select'
653
- /* actor/narrator label; **note**: for instance if member has tuned a specific bot of theirs to have an outgoing voice they like */
654
- const actorLabel = document . createElement ( 'label' )
655
- actorLabel . classList . add ( 'share-memory-actor-select-label' )
656
- actorLabel . htmlFor = actor . id
657
- actorLabel . id = `share-memory-actor-select-label_${ id } `
658
- actorLabel . textContent = 'Actor/Narrator:'
659
- shareMemoryActorSelect . appendChild ( actorLabel )
660
- const actorOption = document . createElement ( 'option' )
661
- actorOption . disabled = true
662
- actorOption . selected = true
663
- actorOption . value = ''
664
- actorOption . textContent = 'Select narrator...'
665
- actor . appendChild ( actorOption )
666
- actorList . forEach ( option => {
667
- const actorOption = document . createElement ( 'option' )
668
- actorOption . selected = false
669
- actorOption . textContent = option
670
- actorOption . value = option
671
- actor . appendChild ( actorOption )
672
- } )
673
- actor . addEventListener ( 'change' , mStory )
674
- shareMemoryActorSelect . appendChild ( actor )
675
- shareMemory . appendChild ( shareMemoryActorSelect )
676
- /* pov */
677
- const shareMemoryPovSelect = document . createElement ( 'div' )
678
- shareMemoryPovSelect . classList . add ( 'share-memory-select' )
679
- shareMemoryPovSelect . title = `This refers to the position of the "listener" in the story. Who is the listener? Are they referred to as the protagonist? Antagonist? A particular person or character in your story?`
680
- const povList = [ 'Me' , 'Protagonist' , 'Antagonist' , 'Character' , ]
681
- const pov = document . createElement ( 'select' )
682
- pov . classList . add ( 'share-memory-pov-select' )
683
- pov . dataset . id = id
684
- pov . dataset . type = `pov`
685
- pov . id = `share-memory-pov-select_${ id } `
686
- pov . name = 'share-memory-pov-select'
687
- /* pov label */
688
- const povLabel = document . createElement ( 'label' )
689
- povLabel . classList . add ( 'share-memory-pov-select-label' )
690
- povLabel . htmlFor = pov . id
691
- povLabel . id = `share-memory-pov-select-label_${ id } `
692
- povLabel . textContent = 'Point of View:'
693
- shareMemoryPovSelect . appendChild ( povLabel )
694
- const povOption = document . createElement ( 'option' )
695
- povOption . disabled = true
696
- povOption . selected = true
697
- povOption . value = ''
698
- povOption . textContent = 'Select listener vantage...'
699
- pov . appendChild ( povOption )
700
- povList . forEach ( option => {
701
- const povOption = document . createElement ( 'option' )
702
- povOption . value = option
703
- povOption . textContent = option
704
- pov . appendChild ( povOption )
705
- } )
706
- pov . addEventListener ( 'change' , mStory )
707
- shareMemoryPovSelect . appendChild ( pov )
708
- shareMemory . appendChild ( shareMemoryPovSelect )
709
- /* narrative context */
710
- const narrativeContext = document . createElement ( 'textarea' )
711
- narrativeContext . classList . add ( 'share-memory-context' )
712
- narrativeContext . dataset . id = id
713
- narrativeContext . dataset . previousValue = ''
714
- narrativeContext . dataset . type = `narrative`
715
- narrativeContext . id = `share-memory-context_${ id } `
716
- narrativeContext . name = 'share-memory-context'
717
- narrativeContext . placeholder = 'How should the story be told? Should it be scary? humorous? choose your own adventure?'
718
- narrativeContext . title = `How should the story be told? Should it be scary? humorous? Will it be a choose your own adventure that deviates from the reality of your memory?`
719
- narrativeContext . value = narrativeContext . dataset . previousValue
720
- narrativeContext . addEventListener ( 'blur' , mStoryContext )
721
- shareMemory . appendChild ( narrativeContext )
722
- /* play memory */
723
- const memoryPlay = document . createElement ( 'button' )
724
- memoryPlay . classList . add ( 'relive-memory' )
725
- memoryPlay . dataset . id = id
726
- memoryPlay . id = `relive-memory_${ id } `
727
- memoryPlay . name = 'relive-memory'
728
- memoryPlay . textContent = 'Relive Memory'
729
- memoryPlay . addEventListener ( 'click' , mReliveMemory , { once : true } )
730
- shareMemory . appendChild ( memoryPlay )
731
- improveMemoryLane . appendChild ( shareMemory )
732
- // play memory
638
+ /* relive memory panel */
639
+ const reliveMemory = document . createElement ( 'div' )
640
+ reliveMemory . classList . add ( 'relive-memory-container' )
641
+ reliveMemory . id = `relive-memory_${ id } `
642
+ reliveMemory . name = 'relive-memory-container'
643
+ /* relive memory explanation */
644
+ const reliveExplanation = document . createElement ( 'div' )
645
+ reliveExplanation . classList . add ( 'relive-memory-explanation' )
646
+ reliveExplanation . id = `relive-memory-explanation_${ id } `
647
+ reliveExplanation . name = 'relive-memory-explanation'
648
+ reliveExplanation . textContent = 'Relive a memory by clicking the button below. This will bring up the memory in chat, where you can add to it, or simply enjoy reliving it!'
649
+ /* relive memory button */
650
+ const reliveButton = document . createElement ( 'button' )
651
+ reliveButton . classList . add ( 'relive-memory-button' , 'button' )
652
+ reliveButton . dataset . id = id /* required for triggering PATCH */
653
+ reliveButton . id = `relive-memory-button_${ id } `
654
+ reliveButton . name = 'relive-memory-button'
655
+ reliveButton . textContent = 'Relive Memory'
656
+ reliveButton . addEventListener ( 'click' , mReliveMemory , { once : true } )
657
+ /* append elements */
658
+ reliveMemory . appendChild ( reliveExplanation )
659
+ reliveMemory . appendChild ( reliveButton )
660
+ improveMemoryLane . appendChild ( reliveMemory )
733
661
/* memory media-carousel */
734
662
const memoryCarousel = document . createElement ( 'div' )
735
663
memoryCarousel . classList . add ( 'memory-carousel' )
@@ -1121,31 +1049,34 @@ async function mReliveMemory(event){
1121
1049
event . preventDefault ( )
1122
1050
event . stopPropagation ( )
1123
1051
const { id, inputContent, } = this . dataset
1052
+ const previousInstance = document . getElementById ( `relive-memory-input-container_${ id } ` )
1053
+ if ( previousInstance )
1054
+ previousInstance . remove ( )
1124
1055
const popupClose = document . getElementById ( `popup-close_${ id } ` )
1125
1056
if ( popupClose )
1126
1057
popupClose . click ( )
1127
1058
const { command, parameters, messages, success, } = await mReliveMemoryRequest ( id , inputContent )
1128
1059
if ( success ) {
1129
1060
addMessages ( messages )
1130
- // @todo - create this function in member, as it will display it in chat and pipe it back here as below
1131
1061
const input = document . createElement ( 'div' )
1132
- // id alone is not unique!; input.id = `input_${ id }`
1133
- input . name = `input_${ id } `
1134
1062
input . classList . add ( 'memory-input-container' )
1063
+ input . id = `relive-memory-input-container_${ id } `
1064
+ input . name = `input_${ id } `
1135
1065
const inputContent = document . createElement ( 'textarea' )
1136
1066
inputContent . classList . add ( 'memory-input' )
1137
1067
inputContent . name = `memory-input_${ id } `
1138
1068
const inputSubmit = document . createElement ( 'button' )
1139
1069
inputSubmit . classList . add ( 'memory-input-button' )
1140
1070
inputSubmit . dataset . id = id
1071
+ inputSubmit . textContent = mDefaultReliveMemoryButtonText
1141
1072
input . appendChild ( inputContent )
1142
1073
input . appendChild ( inputSubmit )
1143
1074
inputContent . addEventListener ( 'input' , event => {
1144
1075
const { value, } = event . target
1145
1076
inputSubmit . dataset . inputContent = value
1146
1077
inputSubmit . textContent = value . length > 2
1147
1078
? 'update'
1148
- : 'next'
1079
+ : mDefaultReliveMemoryButtonText
1149
1080
} )
1150
1081
inputSubmit . addEventListener ( 'click' , mReliveMemory , { once : true } )
1151
1082
addInput ( input )
@@ -1606,8 +1537,8 @@ function mTogglePopup(event){
1606
1537
if ( ! popup )
1607
1538
throw new Error ( `Popup not found: ${ popupId } ` )
1608
1539
const { active, } = popup . dataset
1609
- if ( active === 'true' ) { /* close */
1610
- console . log ( 'mTogglePopup::closing:' , popupId , popup . dataset , active )
1540
+ const isClose = event . target ?. dataset ?. isClose
1541
+ if ( active == 'true' || isClose ) { /* close */
1611
1542
popup . dataset . active = 'false'
1612
1543
hide ( popup )
1613
1544
} else { /* open */
0 commit comments