added search and logout to Linux

This commit is contained in:
jeena 2013-03-26 13:25:16 +01:00
parent cbc6755791
commit 3d1768540d
7 changed files with 236 additions and 50 deletions

View file

@ -35,6 +35,10 @@ function(HostApp, Core, Paths, URI) {
Core.prototype.hide.call(this, this.container);
}
Profile.prototype.logout = function() {
this.container = "";
}
Profile.prototype.showList = function(list) {
$(this.body).hide();
$(this.followingsBody).hide();

View file

@ -0,0 +1,111 @@
define([
"helper/HostApp",
"helper/Core",
"helper/Paths",
"lib/URI"
],
function(HostApp, Core, Paths, URI) {
function Search() {
Core.call(this);
this.action = "search";
this.container = document.createElement("div");
document.getElementById("content").appendChild(this.container);
this.body = document.createElement("ol");
this.form = document.createElement("form");
this.form.className = this.action;
this.input = document.createElement("input");
this.input.type = "search";
this.input.placeholder = "Search ...";
this.form.appendChild(this.input);
var _this = this;
this.form.onsubmit = function() { _this.doSearch(_this.input.value); return false; };
this.form.action = "#";
this.container.appendChild(this.form);
this.container.appendChild(this.body);
this.hide();
}
Search.prototype = Object.create(Core.prototype);
Search.prototype.show = function() {
Core.prototype.show.call(this, this.container);
this.input.focus();
}
Search.prototype.hide = function() {
Core.prototype.hide.call(this, this.container);
}
Search.prototype.doSearch = function(query) {
this.body.innerHTML = ""; // remove old results
if (query == "") return;
this.input.value = query;
var endpoint = "https://skate.io/api/search";
var api_key = "15cbec6445887eff3408";
var url = URI(endpoint);
url.addSearch("api_key", api_key);
url.addSearch("text", query);
var _this = this;
Paths.getURL(url.toString(), "GET", function(resp) {
var results = JSON.parse(resp.responseText).results;
var statuses = [];
for (var i = 0; i < results.length; i++) {
var result = results[i].source;
var status = {
entity: result.entity,
content: {
text: result.content
},
published_at: result.published_at,
id: result.public_id,
type: result.post_type,
version: result.post_version,
app: {
url: "http://skate.io",
name: "skate.io"
},
mentions: []
}
statuses.push(status);
}
for(var i = 0; i < statuses.length; i++) {
var status = statuses[i];
if (status.type == "https://tent.io/types/post/status/v0.1.0") {
var new_node = _this.getStatusDOMElement(status);
_this.body.appendChild(new_node);
}
}
}, null, false);
}
Search.prototype.searchFor = function(query) {
this.doSearch(query);
bungloo.sidebar.onSearch();
}
return Search;
});

View file

@ -120,6 +120,13 @@ function(HostApp, Paths, Cache) {
}
}
Sidebar.prototype.removeEntityAvatar = function() {
var img = this.menu.user.getElementsByTagName("img")[0];
img.src = "img/sidebar/user.png";
img.src_inactive = img.src;
img.src_active = img.src;
}
Sidebar.prototype.showContentFor = function(active_part, active_li) {
// Show active content
@ -177,6 +184,15 @@ function(HostApp, Paths, Cache) {
this.showContentFor(bungloo.search, this.menu.search);
}
Sidebar.prototype.logout = function() {
this.removeEntityAvatar();
bungloo.timeline.logout();
bungloo.mentions.logout();
bungloo.conversation.logout();
bungloo.entityProfile.logout();
bungloo.search.logout();
}
return Sidebar;
});