function updateList(filter) {
	// productUrl and productNumbers are defined in pages.js
	var template = '<a href="' + productUrl + '" target="_blank">{{value}}</a>'
	
	var html = ""
	$.each(productNumbers, function (_, p) {
		if (p.includes(filter)) {
			if (html.length) {
				html += "<br>"
			}
			
			
			var value = p.replace(/^(\d{4})(\d{4})(\d{2})$/, "$1 $2 $3")
			if (productUrl && productUrl.length) {
				html += template.replace(/{{product-number}}/g, p).replace(/{{value}}/g, value)
			}
			else {
				html += value
			}
		}
	})
	$(".product-numbers-list").html(html)
}

$(function () {
	updateList("")
	$('#product-numbers-filter').keyup(function () {
		updateList(this.value.replace(/\s/g, ""))
	})	
})