use home api

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

View file

@ -317,26 +317,13 @@ 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) {
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(); 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,
color = Ox.Theme() == 'oxlight' ? 'rgb(0, 0, 0)' color = Ox.Theme() == 'oxlight' ? 'rgb(0, 0, 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,6 +607,9 @@ pandora.ui.home = function() {
function openItem(i) { function openItem(i) {
that.fadeOutScreen(); that.fadeOutScreen();
if (items[i].type == 'custom') {
pandora.URL.push(items[i].link);
} else {
pandora.UI.set(Ox.extend({ pandora.UI.set(Ox.extend({
section: items[i].type == 'list' ? 'items' : items[i].type + 's', section: items[i].type == 'list' ? 'items' : items[i].type + 's',
page: '' page: ''
@ -621,18 +617,19 @@ pandora.ui.home = function() {
find: { find: {
conditions: [{ conditions: [{
key: 'list', key: 'list',
value: items[i].user + ':' value: items[i].content.user + ':'
+ items[i].name, + items[i].content.name,
operator: '==' operator: '=='
}], }],
operator: '&' operator: '&'
} }
} : items[i].type == 'edit' ? { } : items[i].type == 'edit' ? {
edit: items[i].user + ':' + items[i].name edit: items[i].content.user + ':' + items[i].content.name
} : { } : {
text: items[i].user + ':' + items[i].name text: items[i].content.user + ':' + items[i].content.name
})); }));
} }
}
function scrollToPosition(i, animate) { function scrollToPosition(i, animate) {
if (i >= 0 && i <= items.length - max && i != position) { if (i >= 0 && i <= items.length - max && i != position) {
@ -689,7 +686,6 @@ pandora.ui.home = function() {
); );
} }
} }
} }
} }