MCPcopy Create free account
hub / github.com/FSGModding/FSG_Mod_Assistant / #addMod

Method #addMod

renderer/renderJS/main_ui_lib.js:688–770  ·  view source on GitHub ↗
(thisMod, overBadges = null, isHolding = false)

Source from the content-addressed store, hash-verified

686 // MARK: addMod
687 /* eslint-disable-next-line complexity */
688 async #addMod(thisMod, overBadges = null, isHolding = false) {
689 const mod = {
690 filters : new Set(thisMod?.displayBadges?.map?.((x) => x.name) || []),
691 node : document.createElement('tr'),
692 scroll : document.createElement('scroller-item'),
693 search : {
694 find_author : DATA.escapeSpecial(thisMod.modDesc.author).toLowerCase(),
695 find_brand : this.#findExtraInfo(thisMod.has_brands),
696 find_cats : this.#findExtraInfo(thisMod.has_cats),
697 find_name : thisMod.fileDetail.shortName.toLowerCase(),
698 find_title : this.doL10N(thisMod.l10n.title, true),
699 find_version : this.doL10N(thisMod.modDesc.version, true),
700 },
701 }
702 mod.search.find_all = Object.values(mod.search).join(' ')
703
704 mod.scroll.id = `${thisMod.colUUID}--scroller`
705
706 mod.node.classList.add(...[
707 'mod-row',
708 'border-bottom',
709 this.extSites[thisMod.fileDetail.shortName] ? 'has-ext-site' : null,
710 thisMod.modHub.id ? 'has-hash' : null,
711 ...( thisMod.canNotUse === true || this.flag.currentVersion !== thisMod.gameVersion ) ?
712 ['mod-disabled', 'bg-secondary-subtle', 'bg-opacity-25'] :
713 []
714 ].filter((x) => x !== null))
715
716 mod.node.id = thisMod.colUUID
717 // mod.node.setAttribute('draggable', true)
718
719 mod.node.addEventListener('contextmenu', () => { this.modContext(thisMod.colUUID) })
720 // mod.node.addEventListener('dragstart', (e) => { this.modDrag(e, thisMod.colUUID) })
721 mod.node.addEventListener('click', (e) => { this.modClick(e, thisMod.colUUID) })
722
723 if ( ! thisMod.badgeArray.includes('notmod') && ! thisMod.badgeArray.includes('savegame') ) {
724 mod.node.addEventListener('dblclick', () => {
725 if ( thisMod.badgeArray.includes('log') ) {
726 window.main_IPC.dispatchLog(thisMod.fileDetail.fullPath)
727 } else {
728 window.main_IPC.dispatchDetail(thisMod.colUUID)
729 }
730 })
731 }
732
733 const fixCat = [...new Set(thisMod.has_cats.map((x) => x.split(' ')).flat())].sort()
734 const fixBrand = [...new Set(thisMod.has_brands.map((x) => x.split(' ')).flat())].sort()
735
736 const brandTitle = [
737 fixBrand.length !== 0 ? `<strong>${this.#addExtraInfo(fixBrand)}</strong>` : null,
738 fixBrand.length !== 0 ? '--' : null,
739 this.doL10N(thisMod.l10n.title)
740 ]
741 const authorCat = [
742 DATA.escapeSpecial(thisMod.modDesc.author),
743 fixCat.length !== 0 ? '--' : null,
744 fixCat.length !== 0 ? `<em>${this.#addExtraInfo(fixCat)}</em>` : null,
745 ]

Callers 1

updateFromDataMethod · 0.95

Calls 7

#findExtraInfoMethod · 0.95
doL10NMethod · 0.95
modContextMethod · 0.95
modClickMethod · 0.95
#addExtraInfoMethod · 0.95
addMethod · 0.45
addEventListenerMethod · 0.45

Tested by

no test coverage detected