Use '; ' seperator for opening_hours-like tags (closes #2301)

This commit is contained in:
Bryan Housel
2015-04-22 09:52:49 -04:00
parent bfbd1f2d1d
commit 0313064e22
+13 -3
View File
@@ -133,14 +133,24 @@ iD.ui.EntityEditor = function(context) {
}
function clean(o) {
function isOpeningHours(k) {
return _.any(['opening_hours', 'service_times', 'collection_times',
'operating_times', 'smoking_hours', 'happy_hours'], function(s) {
return k.indexOf(s) !== -1;
});
}
function cleanVal(k, v) {
return v.split(';')
.map(function(s) { return s.trim(); })
.join(isOpeningHours(k) ? '; ' : ';');
}
var out = {}, k, v;
/*jshint -W083 */
for (k in o) {
if (k && (v = o[k]) !== undefined) {
out[k] = v.split(';').map(function(s) { return s.trim(); }).join(';');
out[k] = cleanVal(k, v);
}
}
/*jshint +W083 */
return out;
}