more encoding fun

This commit is contained in:
Rolux 2016-01-08 15:29:02 +05:30
parent b94ead03c6
commit 214e6a7e36
2 changed files with 37 additions and 47 deletions

View file

@ -46,10 +46,9 @@ oml.ui.editDialog = function() {
function editMetadata(key, value) {
var edit = {id: ids};
if (Ox.contains(arrayKeys, key)) {
edit[key] = value
? Ox.decodeHTMLEntities(value).split(separator) : [];
edit[key] = value ? value.split(separator) : [];
} else {
edit[key] = Ox.decodeHTMLEntities(value);
edit[key] = value;
}
oml.api.edit(edit, function(result) {
Ox.Request.clearCache();
@ -81,9 +80,7 @@ oml.ui.editDialog = function() {
: key == 'description' ? 'Mixed Description'
: 'mixed'
)) : value ? (Ox.isArray(value) ? value : [value]).map(function(value) {
return Ox.encodeHTMLEntities(
key == 'date' && value ? value.slice(0, 4) : value
);
return key == 'date' && value ? value.slice(0, 4) : value;
}).join(separator) : '';
}
@ -139,7 +136,7 @@ oml.ui.editDialog = function() {
},
placeholder: formatLight(Ox._('No Title')),
tooltip: tooltip,
value: data.title || ''
value: data.title ? Ox.encodeHTMLEntities(data.title) : ''
})
.css({
fontWeight: 'bold',
@ -147,7 +144,7 @@ oml.ui.editDialog = function() {
})
.bindEvent({
submit: function(event) {
editMetadata('title', event.value);
editMetadata('title', Ox.decodeHTMLEntities(event.value));
}
})
)
@ -167,7 +164,7 @@ oml.ui.editDialog = function() {
},
placeholder: formatLight(Ox._('Unknown Author')),
tooltip: tooltip,
value: data.author ? data.author.join(separator) : ''
value: data.author ? Ox.encodeHTMLEntities(data.author.join(separator)) : ''
})
.css({
marginBottom: '-3px',
@ -176,7 +173,7 @@ oml.ui.editDialog = function() {
})
.bindEvent({
submit: function(event) {
editMetadata('author', event.value);
editMetadata('author', Ox.decodeHTMLEntities(event.value));
}
})
)
@ -206,14 +203,14 @@ oml.ui.editDialog = function() {
},
placeholder: formatLight(Ox._('unknown')),
tooltip: tooltip,
value: data[key] ? (
value: data[key] ? Ox.encodeHTMLEntities(
Ox.contains(arrayKeys, key) && Ox.isArray(data[key])
? data[key].join('; ') : data[key]
) : ''
})
.bindEvent({
submit: function(event) {
editMetadata(key, event.value);
editMetadata(key, Ox.decodeHTMLEntities(event.value));
}
})
.appendTo($div);
@ -243,14 +240,14 @@ oml.ui.editDialog = function() {
},
placeholder: formatLight(Ox._('unknown')),
tooltip: tooltip,
value: data[key] ? (
value: data[key] ? Ox.encodeHTMLEntities(
Ox.contains(arrayKeys, key) && Ox.isArray(data[key])
? data[key].join(separator) : data[key]
) : ''
})
.bindEvent({
submit: function(event) {
editMetadata(key, event.value);
editMetadata(key, Ox.decodeHTMLEntities(event.value));
}
})
.appendTo($div);
@ -265,17 +262,17 @@ oml.ui.editDialog = function() {
}).append(
Ox.EditableContent({
editable: true,
format: function(value) {
return formatValue(value, 'description');
},
placeholder: formatLight('No Description'),
tooltip: tooltip,
type: 'textarea',
value: data.description || ''
value: data.description ? Ox.encodeHTMLEntities(data.description) : ''
})
.bindEvent({
submit: function(event) {
editMetadata('description', event.value);
editMetadata(
'description',
Ox.decodeHTMLEntities(event.value).replace(/<br>/g, '\n')
);
}
})
).appendTo($info);

View file

@ -115,7 +115,6 @@ oml.ui.infoView = function(identifyData) {
function formatValue(value, key) {
return value ? (Ox.isArray(value) ? value : [value]).map(function(value) {
value = Ox.encodeHTMLEntities(value);
if (key == 'date' && value) {
value = value.slice(0, 4);
}
@ -460,9 +459,8 @@ oml.ui.infoView = function(identifyData) {
Ox.EditableContent({
clickLink: oml.clickLink,
editable: isEditable,
format: Ox.encodeHTMLEntities,
tooltip: isEditable ? oml.getEditTooltip() : '',
value: data.title || 'No Title'
value: data.title ? Ox.encodeHTMLEntities(data.title) : 'No Title'
})
.css({
fontWeight: 'bold',
@ -470,7 +468,7 @@ oml.ui.infoView = function(identifyData) {
})
.bindEvent({
submit: function(event) {
editMetadata('title', event.value);
editMetadata('title', Ox.decodeHTMLEntities(event.value));
}
})
)
@ -487,11 +485,11 @@ oml.ui.infoView = function(identifyData) {
clickLink: oml.clickLink,
editable: isEditable,
format: function(value) {
return formatValue(splitValue(value), 'author');
return formatValue(value.split('; '), 'author');
},
placeholder: formatLight(Ox._('Unknown Author')),
tooltip: isEditable ? oml.getEditTooltip() : '',
value: data.author ? data.author.join('; ') : ''
value: data.author ? Ox.encodeHTMLEntities(data.author.join('; ')) : ''
})
.css({
marginBottom: '-3px',
@ -500,7 +498,7 @@ oml.ui.infoView = function(identifyData) {
})
.bindEvent({
submit: function(event) {
editMetadata('author', event.value);
editMetadata('author', Ox.decodeHTMLEntities(event.value));
}
})
)
@ -526,20 +524,20 @@ oml.ui.infoView = function(identifyData) {
format: function(value) {
return formatValue(
Ox.contains(arrayKeys, key)
? splitValue(value) : value,
? value.split('; ') : value,
key
);
},
placeholder: formatLight(Ox._('unknown')),
tooltip: isEditable ? oml.getEditTooltip() : '',
value: data[key] ? (
value: data[key] ? Ox.encodeHTMLEntities(
Ox.contains(arrayKeys, key)
? data[key].join('; ') : data[key]
) : ''
})
.bindEvent({
submit: function(event) {
editMetadata(key, event.value);
editMetadata(key, Ox.decodeHTMLEntities(event.value));
}
})
.appendTo($div);
@ -563,20 +561,22 @@ oml.ui.infoView = function(identifyData) {
clickLink: oml.clickLink,
editable: isEditable,
format: function(value) {
return key == 'language'
? formatValue(splitValue(value), key)
: Ox.encodeHTMLEntities(value);
return formatValue(
Ox.contains(arrayKeys, key)
? value.split('; ') : value,
key
);
},
placeholder: formatLight('unknown'),
tooltip: isEditable ? oml.getEditTooltip() : '',
value: data[key] ? (
value: data[key] ? Ox.encodeHTMLEntities(
Ox.contains(arrayKeys, key)
? data[key].join('; ') : data[key]
) : ''
})
.bindEvent({
submit: function(event) {
editMetadata(key, event.value);
editMetadata(key, Ox.decodeHTMLEntities(event.value));
}
})
.appendTo($div);
@ -609,11 +609,11 @@ oml.ui.infoView = function(identifyData) {
editable: isEditable,
placeholder: formatLight('No Classification'),
tooltip: isEditable ? oml.getEditTooltip() : '',
value: data.classification || '',
value: data.classification ? Ox.encodeHTMLEntities(data.classification) : '',
})
.bindEvent({
submit: function(event) {
editMetadata('classification', event.value);
editMetadata('classification', Ox.decodeHTMLEntities(event.value));
}
})
)
@ -631,19 +631,16 @@ oml.ui.infoView = function(identifyData) {
Ox.EditableContent({
clickLink: oml.clickLink,
editable: isEditable,
format: function(value) {
return Ox.encodeHTMLEntities(value);
},
placeholder: formatLight('No Description'),
tooltip: isEditable ? oml.getEditTooltip() : '',
type: 'textarea',
value: data.description || ''
value: data.description ? Ox.encodeHTMLEntities(data.description) : ''
})
.bindEvent({
submit: function(event) {
editMetadata(
'description',
event.value.replace(/<br>/g, '\n')
Ox.decodeHTMLEntities(event.value).replace(/<br>/g, '\n')
);
}
})
@ -730,9 +727,9 @@ oml.ui.infoView = function(identifyData) {
if (value != data[key]) {
var edit = {id: data.id};
if (Ox.contains(arrayKeys, key)) {
edit[key] = value ? splitValue(value) : [];
edit[key] = value ? value.split('; ') : [];
} else {
edit[key] = Ox.decodeHTMLEntities(value);
edit[key] = value;
}
oml.api.edit(edit, function(result) {
Ox.Request.clearCache();
@ -751,10 +748,6 @@ oml.ui.infoView = function(identifyData) {
});
function splitValue(value) {
return Ox.decodeHTMLEntities(value).split('; ');
}
};
if (!identifyData) {