merge fixes from pandora

This commit is contained in:
j 2025-01-30 08:56:34 +05:30
commit fcf7c24c23
7 changed files with 154 additions and 91 deletions

View file

@ -1,35 +1,4 @@
const getSortValue = function(value) {
var sortValue = value;
function trim(value) {
return value.replace(/^\W+(?=\w)/, '');
}
if (
isEmpty(value)
|| isNull(value)
|| isUndefined(value)
) {
sortValue = null;
} else if (isString(value)) {
// make lowercase and remove leading non-word characters
sortValue = trim(value.toLowerCase());
// move leading articles to the end
// and remove leading non-word characters
['a', 'an', 'the'].forEach(function(article) {
if (new RegExp('^' + article + ' ').test(sortValue)) {
sortValue = trim(sortValue.slice(article.length + 1))
+ ', ' + sortValue.slice(0, article.length);
return false; // break
}
});
// remove thousand separators and pad numbers
sortValue = sortValue.replace(/(\d),(?=(\d{3}))/g, '$1')
.replace(/\d+/g, function(match) {
return match.padStart(64, '0')
});
}
return sortValue;
};
const sortByKey = function(array, by) {
return array.sort(function(a, b) {
@ -122,7 +91,7 @@ async function loadEdit(id, args) {
}
}
data.edit = response['data']
if (data.edit.status !== 'public') {
if (['public', 'featured'].indexOf(data.edit.status) == -1) {
return {
site: data.site,
error: {