use home api

This commit is contained in:
j 2017-01-25 21:51:31 +01:00
parent b50fc23a75
commit b829faf5d6

View file

@ -317,25 +317,12 @@ pandora.ui.home = function() {
sort: [{key: 'position', operator: '+'}] sort: [{key: 'position', operator: '+'}]
}, },
items, lists, edits, texts; items, lists, edits, texts;
pandora.api.findLists(find, function(result) { pandora.api.getHomeItems({active: true}, function(result) {
lists = result.data.items.length; items = result.data.items;
items = result.data.items.map(function(item) { lists = 1;
return Ox.extend(item, {type: 'list'}); edits = 1;
}); texts = 1;
pandora.api.findEdits(find, function(result) { show();
edits = result.data.items.length;
items = items.concat(result.data.items.map(function(item) {
return Ox.extend(item, {type: 'edit'});
}));
pandora.api.findTexts(find, function(result) {
texts = result.data.items.length;
items = items.concat(result.data.items.map(function(item) {
return Ox.extend(item, {type: 'text'});
}));
$features.empty();
show();
});
});
}); });
function show() { function show() {
var counter = 0, max = 8, mouse = false, position = 0, selected = 0, var counter = 0, max = 8, mouse = false, position = 0, selected = 0,
@ -593,17 +580,23 @@ pandora.ui.home = function() {
} }
function getHTML(item) { function getHTML(item) {
if (item.type == 'custom') {
return '<b>' + item.title + '</b><br><br>' + item.text;
}
return '<b>' return '<b>'
+ ( + (
(lists && edits) || (lists && texts) || (edits && texts) (lists && edits) || (lists && texts) || (edits && texts)
? Ox._(Ox.toTitleCase(item.type)) + ': ' ? Ox._(Ox.toTitleCase(item.type)) + ': '
: '' : ''
) )
+ Ox.encodeHTMLEntities(item.name) + '</b><br><br>' + Ox.encodeHTMLEntities(item.content.name) + '</b><br><br>'
+ item.description; + item.content.description;
} }
function getImageURL(item) { function getImageURL(item) {
if (item.type == 'custom') {
return item.image;
}
return '/' + item.type + '/' + item.user return '/' + item.type + '/' + item.user
+ ':' + encodeURIComponent(item.name) + '/icon256.jpg?' + item.modified; + ':' + encodeURIComponent(item.name) + '/icon256.jpg?' + item.modified;
} }
@ -614,24 +607,28 @@ pandora.ui.home = function() {
function openItem(i) { function openItem(i) {
that.fadeOutScreen(); that.fadeOutScreen();
pandora.UI.set(Ox.extend({ if (items[i].type == 'custom') {
section: items[i].type == 'list' ? 'items' : items[i].type + 's', pandora.URL.push(items[i].link);
page: '' } else {
}, items[i].type == 'list' ? { pandora.UI.set(Ox.extend({
find: { section: items[i].type == 'list' ? 'items' : items[i].type + 's',
conditions: [{ page: ''
key: 'list', }, items[i].type == 'list' ? {
value: items[i].user + ':' find: {
+ items[i].name, conditions: [{
operator: '==' key: 'list',
}], value: items[i].content.user + ':'
operator: '&' + items[i].content.name,
} operator: '=='
} : items[i].type == 'edit' ? { }],
edit: items[i].user + ':' + items[i].name operator: '&'
} : { }
text: items[i].user + ':' + items[i].name } : items[i].type == 'edit' ? {
})); edit: items[i].content.user + ':' + items[i].content.name
} : {
text: items[i].content.user + ':' + items[i].content.name
}));
}
} }
function scrollToPosition(i, animate) { function scrollToPosition(i, animate) {
@ -689,7 +686,6 @@ pandora.ui.home = function() {
); );
} }
} }
} }
} }