Sha256: c419a37aced459f03379a55f6c3a6a8385e3aed8265a11fcb3de8a4872ca286e

Contents?: true

Size: 888 Bytes

Versions: 2

Compression:

Stored size: 888 Bytes

Contents

;(function() {
	const table = document.getElementsByTagName('table')[0]
	const input = document.getElementsByClassName('filter')[0]
	const rows = {}
	const filterKeys = Array.from(document.querySelectorAll('tr[data-filter-key]')).map(el => {
		key = el.dataset.filterKey
		rows[key] = el
		return key
	})
	const scores = {}
	const computeScores = () => {
		const searchString = input.value
		filterKeys.forEach(filterKey => scores[filterKey] = stringScore(filterKey, searchString))
	}

	const redrawTable = (sorted) => {
		const newBody = document.createElement('tbody')
		sorted.forEach(key => newBody.appendChild(rows[key]))
		table.removeChild(table.getElementsByTagName('tbody')[0])
		table.appendChild(newBody)
	}

	input.addEventListener('input', () => {
		computeScores()
		redrawTable(
			filterKeys.filter(k => scores[k] !== 0).sort((a, b) => scores[b] - scores[a])
		)
	})
})()

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
stackprof-webnav-1.0.4 lib/stackprof-webnav/public/overview.js
stackprof-webnav-1.0.3 lib/stackprof-webnav/public/overview.js