diff --git a/renderer/renderJS/assist_ui.js b/renderer/renderJS/assist_ui.js
index d58c576b..8828715a 100644
--- a/renderer/renderJS/assist_ui.js
+++ b/renderer/renderJS/assist_ui.js
@@ -82,16 +82,31 @@ window.mods.receive('fromMain_selectOnlyFilter', (selectMod, filterText) => {
})
-let lastLocale = 'en'
-let lastQuickLists = {}
+let lastLocale = 'en'
+let lastQuickLists = {}
+let searchStringMap = {}
+let searchTagMap = {}
window.mods.receive('fromMain_modList', (opts) => {
- lastQuickLists = {}
+ lastQuickLists = {}
+ searchStringMap = {}
+ searchTagMap = {
+ broken : [],
+ folder : [],
+ new : [],
+ nomp : [],
+ notmod : [],
+ pconly : [],
+ problem : [],
+ recent : [],
+ update : [],
+ nonmh : [],
+ }
lastLocale = opts.currentLocale
const lastOpenAcc = document.querySelector('.accordion-collapse.show')
const lastOpenID = (lastOpenAcc !== null) ? lastOpenAcc.id : null
- const lastOpenQ = (lastOpenAcc !== null) ? lastOpenAcc.querySelector('input.mod-row-filter').value : ''
+ const lastOpenQ = (lastOpenAcc !== null) ? fsgUtil.byId('filter_input').value : ''
const scrollStart = window.scrollY
const selectedList = ( opts.activeCollection !== '999' && opts.activeCollection !== '0') ? `collection--${opts.activeCollection}` : opts.activeCollection
@@ -106,45 +121,61 @@ window.mods.receive('fromMain_modList', (opts) => {
opts.modList[collection].mods.forEach((thisMod) => {
try {
- const extraBadges = []
- const modId = opts.modHub.list.mods[thisMod.fileDetail.shortName] || null
- const modVer = opts.modHub.version[modId] || null
+ const displayBadges = thisMod.badgeArray || []
+ const modId = opts.modHub.list.mods[thisMod.fileDetail.shortName] || null
+ const modVer = opts.modHub.version[modId] || null
+ const modColUUID = `${collection}--${thisMod.uuid}`
sizeOfFolder += thisMod.fileDetail.fileSize
if ( Object.keys(thisMod.modDesc.binds).length > 0 ) {
if ( typeof opts.bindConflict[collection][thisMod.fileDetail.shortName] !== 'undefined' ) {
- extraBadges.push(fsgUtil.badge('danger', 'keys_bad'))
+ displayBadges.push('keys_bad')
} else {
- extraBadges.push(fsgUtil.badge('success', 'keys_ok'))
+ displayBadges.push('keys_ok')
}
}
if ( modVer !== null && thisMod.modDesc.version !== modVer) {
- extraBadges.push(fsgUtil.badge('light', 'update'))
+ displayBadges.push('update')
}
if ( opts.newMods.includes(thisMod.md5Sum) && !thisMod.canNotUse ) {
- extraBadges.push(fsgUtil.badge('success', 'new'))
+ displayBadges.push('new')
}
if ( modId !== null && opts.modHub.list.last.includes(modId) ) {
- extraBadges.push(fsgUtil.badge('success', 'recent'))
+ displayBadges.push('recent')
}
if ( modId === null ) {
- extraBadges.push(fsgUtil.badge('dark', 'nonmh'))
+ displayBadges.push('nonmh')
}
- let theseBadges = thisMod.badges + extraBadges.join('')
+ if ( displayBadges.includes('broken') && displayBadges.includes('notmod') ) {
+ const brokenIdx = displayBadges.indexOf('broken')
+ displayBadges.splice(brokenIdx, brokenIdx !== -1 ? 1 : 0)
+ }
- if ( theseBadges.match('mod_badge_broken') && theseBadges.match('mod_badge_notmod') ) {
- theseBadges = theseBadges.replace(fsgUtil.badge('danger', 'broken'), '')
+ if ( ! metDepend(thisMod.modDesc.depend, collection, opts.modList[collection].mods) ) {
+ displayBadges.unshift('depend')
}
+ searchStringMap[modColUUID] = [
+ thisMod.fileDetail.shortName,
+ thisMod.l10n.title,
+ thisMod.modDesc.author
+ ].join(' ').toLowerCase()
+
+ displayBadges.forEach((badge) => {
+ if ( typeof searchTagMap?.[badge]?.push === 'function' ) {
+ searchTagMap[badge].push(modColUUID)
+ }
+ })
+
modRows.push(makeModRow(
- `${collection}--${thisMod.uuid}`,
+ modColUUID,
thisMod,
- theseBadges,
- modId,
- metDepend(thisMod.modDesc.depend, collection, opts.modList[collection].mods)
+ displayBadges,
+ modId
))
+
} catch (e) {
window.log.notice(`Error building mod row: ${e}`, 'main')
}
@@ -152,12 +183,13 @@ window.mods.receive('fromMain_modList', (opts) => {
modTable.push(makeModCollection(
collection,
- `${opts.modList[collection].name}
`,
modRows,
fsgUtil.notesDefault(opts.notes, collection, 'notes_website'),
fsgUtil.notesDefault(opts.notes, collection, 'notes_websiteDL', false),
fsgUtil.notesDefault(opts.notes, collection, 'notes_tagline'),
- fsgUtil.notesDefault(opts.notes, collection, 'notes_admin')
+ fsgUtil.notesDefault(opts.notes, collection, 'notes_admin'),
+ opts.modList[collection].mods.length
))
const selectCollName = `${opts.modList[collection].name}${window.mods.getCollDesc(collection)}`
@@ -200,6 +232,7 @@ window.mods.receive('fromMain_modList', (opts) => {
window.scrollTo(0, scrollStart)
} catch { /* nope */ }
+ select_lib.filter()
processL10N()
})
@@ -238,9 +271,11 @@ function clientMakeListActive() {
}
}
-function makeModCollection(id, name, modsRows, website, dlEnabled, tagLine, adminPass) {
+function makeModCollection(id, name, modsRows, website, dlEnabled, tagLine, adminPass, modCount) {
+ const totCount = modCount > 999 ? '999+' : modCount
return `
`
}
-
-function makeModRow(id, thisMod, badges, modId, metDepend) {
- const theseBadges = ( metDepend ) ? badges : fsgUtil.badge('warning', 'depend') + badges
+function makeModRow(id, thisMod, badges, modId) {
+ const badgeHTML = Array.from(badges, (badge) => fsgUtil.badge(false, badge))
return `
@@ -306,7 +309,7 @@ function makeModRow(id, thisMod, badges, modId, metDepend) {
|
- ${thisMod.fileDetail.shortName} ${fsgUtil.escapeSpecial(thisMod.l10n.title)} - ${fsgUtil.escapeSpecial(thisMod.modDesc.author)}${theseBadges}
+ ${thisMod.fileDetail.shortName} ${fsgUtil.escapeSpecial(thisMod.l10n.title)} - ${fsgUtil.escapeSpecial(thisMod.modDesc.author)}${badgeHTML.join(' ')}
|
${fsgUtil.escapeSpecial(thisMod.modDesc.version)} ${( thisMod.fileDetail.fileSize > 0 ) ? fsgUtil.bytesToHR(thisMod.fileDetail.fileSize, lastLocale) : ''}
@@ -315,10 +318,8 @@ function makeModRow(id, thisMod, badges, modId, metDepend) {
}
-function clientClearInput(id) {
- const filterId = id.replace('__filter', '')
-
- select_lib.filter(filterId, '')
+function clientClearInput() {
+ select_lib.filter(null, '')
}
function clientBatchOperation(mode) {
@@ -368,8 +369,8 @@ function clientOpenFarmSim() {
window.mods.startFarmSim()
}
-window.addEventListener('hide.bs.collapse', () => { select_lib.clear_all() })
-window.addEventListener('show.bs.collapse', () => { select_lib.clear_all() })
+window.addEventListener('hide.bs.collapse', () => { select_lib.click_none() })
+window.addEventListener('show.bs.collapse', () => { select_lib.click_none() })
const giantsLED = { filters : [{ vendorId : fsgUtil.led.vendor, productId : fsgUtil.led.product }] }
diff --git a/renderer/renderJS/detail_ui.js b/renderer/renderJS/detail_ui.js
index c6c40767..37ce5dce 100644
--- a/renderer/renderJS/detail_ui.js
+++ b/renderer/renderJS/detail_ui.js
@@ -106,24 +106,24 @@ window.mods.receive('fromMain_modRecord', (modRecord, modhubRecord, bindConflict
fsgUtil.byId('problems').innerHTML = ``
}
- const extraBadges = []
+ const displayBadges = modRecord.badgeArray || []
if ( Object.keys(modRecord.modDesc.binds).length > 0 ) {
if ( typeof bindConflict[modRecord.currentCollection][modRecord.fileDetail.shortName] !== 'undefined' ) {
- extraBadges.push(fsgUtil.badge('danger', 'keys_bad'))
+ displayBadges.push('keys_bad')
} else {
- extraBadges.push(fsgUtil.badge('success', 'keys_ok'))
+ displayBadges.push('keys_ok')
}
}
if ( modhubRecord[0] !== null && modhubRecord[1] !== null && modRecord.modDesc.version !== modhubRecord[1]) {
- extraBadges.push(fsgUtil.badge('light', 'update'))
+ displayBadges.push('update')
}
if ( modhubRecord[2] ) {
- extraBadges.push(fsgUtil.badge('success', 'recent'))
+ displayBadges.push('recent')
}
if ( modhubRecord[0] === null ) {
- extraBadges.push(fsgUtil.badge('dark', 'nonmh'))
+ displayBadges.push('nonmh')
fsgUtil.byId('modhub_link').classList.add('d-none')
} else {
const modhubLink = `https://www.farming-simulator.com/mod.php?mod_id=${modhubRecord[0]}`
@@ -131,16 +131,16 @@ window.mods.receive('fromMain_modRecord', (modRecord, modhubRecord, bindConflict
}
if ( typeof modRecord.modDesc.depend !== 'undefined' && modRecord.modDesc.depend.length > 0 ) {
- extraBadges.push(fsgUtil.badge('success', 'depend_flag'))
+ displayBadges.push('depend_flag')
}
- extraBadges.push(modRecord.badges)
- let theseBadges = extraBadges.join('')
-
- if ( theseBadges.match('mod_badge_broken') && theseBadges.match('mod_badge_notmod') ) {
- theseBadges = theseBadges.replace(fsgUtil.badge('danger', 'broken'), '')
+ if ( displayBadges.includes('broken') && displayBadges.includes('notmod') ) {
+ const brokenIdx = displayBadges.indexOf('broken')
+ displayBadges.splice(brokenIdx, brokenIdx !== -1 ? 1 : 0)
}
+ const theseBadges = Array.from(displayBadges, (badge) => fsgUtil.badge(false, badge)).join(' ')
+
textOrHide(
'badges',
theseBadges,
diff --git a/renderer/renderJS/fsg_util.js b/renderer/renderJS/fsg_util.js
index b1819f29..c29cc0fe 100644
--- a/renderer/renderJS/fsg_util.js
+++ b/renderer/renderJS/fsg_util.js
@@ -25,7 +25,7 @@ const fsgUtil = {
case 'x':
return ''
case 'folder':
- return ' |