I need to map some user generated fields to something the system I'm working on can recognize.
For this we want to provide a certain amount of freedom for users, and offer five or so options for each of our fields.
So far we have a switch which does the job, but now we have to extend the switch, and it's going to be pretty big. This is needless to say not a very dynamic way of doing it. Is there any alternatives?
function findHeader(object) {
var title = object.toString().trim().toLowerCase()
switch (title) {
case 'name':
case 'idea':
case 'ide':
case 'ide navn':
case 'title':
case 'idea name':
title = 'name'
break
case 'beskrivelse':
case 'problemet':
case 'description':
case 'the problem':
case 'ide beskrivelse':
title = 'description'
break
case 'ejer':
case 'owner':
case 'opfinder':
case 'ide person':
case 'idea person':
case 'person':
title = 'owner'
break
case 'duedate':
case 'deadline':
case 'tidsfrist':
case 'sidste dato':
case 'dato':
case 'due date':
title = 'duedate'
break
case 'billede':
case 'billeder':
case 'image':
case 'images':
case 'attachment':
title = 'imageUrl'
break
case "":
title = 'remove'
break
default:
title = 'Unassigned'
break
}
return title
}