forked from 0x2620/pandora
use home api
This commit is contained in:
parent
b50fc23a75
commit
b829faf5d6
1 changed files with 37 additions and 41 deletions
|
@ -317,26 +317,13 @@ pandora.ui.home = function() {
|
|||
sort: [{key: 'position', operator: '+'}]
|
||||
},
|
||||
items, lists, edits, texts;
|
||||
pandora.api.findLists(find, function(result) {
|
||||
lists = result.data.items.length;
|
||||
items = result.data.items.map(function(item) {
|
||||
return Ox.extend(item, {type: 'list'});
|
||||
});
|
||||
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();
|
||||
pandora.api.getHomeItems({active: true}, function(result) {
|
||||
items = result.data.items;
|
||||
lists = 1;
|
||||
edits = 1;
|
||||
texts = 1;
|
||||
show();
|
||||
});
|
||||
});
|
||||
});
|
||||
function show() {
|
||||
var counter = 0, max = 8, mouse = false, position = 0, selected = 0,
|
||||
color = Ox.Theme() == 'oxlight' ? 'rgb(0, 0, 0)'
|
||||
|
@ -593,17 +580,23 @@ pandora.ui.home = function() {
|
|||
}
|
||||
|
||||
function getHTML(item) {
|
||||
if (item.type == 'custom') {
|
||||
return '<b>' + item.title + '</b><br><br>' + item.text;
|
||||
}
|
||||
return '<b>'
|
||||
+ (
|
||||
(lists && edits) || (lists && texts) || (edits && texts)
|
||||
? Ox._(Ox.toTitleCase(item.type)) + ': '
|
||||
: ''
|
||||
)
|
||||
+ Ox.encodeHTMLEntities(item.name) + '</b><br><br>'
|
||||
+ item.description;
|
||||
+ Ox.encodeHTMLEntities(item.content.name) + '</b><br><br>'
|
||||
+ item.content.description;
|
||||
}
|
||||
|
||||
function getImageURL(item) {
|
||||
if (item.type == 'custom') {
|
||||
return item.image;
|
||||
}
|
||||
return '/' + item.type + '/' + item.user
|
||||
+ ':' + encodeURIComponent(item.name) + '/icon256.jpg?' + item.modified;
|
||||
}
|
||||
|
@ -614,6 +607,9 @@ pandora.ui.home = function() {
|
|||
|
||||
function openItem(i) {
|
||||
that.fadeOutScreen();
|
||||
if (items[i].type == 'custom') {
|
||||
pandora.URL.push(items[i].link);
|
||||
} else {
|
||||
pandora.UI.set(Ox.extend({
|
||||
section: items[i].type == 'list' ? 'items' : items[i].type + 's',
|
||||
page: ''
|
||||
|
@ -621,18 +617,19 @@ pandora.ui.home = function() {
|
|||
find: {
|
||||
conditions: [{
|
||||
key: 'list',
|
||||
value: items[i].user + ':'
|
||||
+ items[i].name,
|
||||
value: items[i].content.user + ':'
|
||||
+ items[i].content.name,
|
||||
operator: '=='
|
||||
}],
|
||||
operator: '&'
|
||||
}
|
||||
} : 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) {
|
||||
if (i >= 0 && i <= items.length - max && i != position) {
|
||||
|
@ -689,7 +686,6 @@ pandora.ui.home = function() {
|
|||
);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue