fixed problems with mentions

This commit is contained in:
jeena 2013-07-25 16:27:55 +02:00
parent 0bf0324702
commit 1c12e5b375
4 changed files with 36 additions and 28 deletions

View file

@ -277,28 +277,31 @@ function(APICalls, HostApp) {
}; };
var mentions = []; var mentions = [];
if (this.status) { for (var i = 0; i < this.mentions.length; i++) {
var mention = this.mentions[i];
if(this.status && this.status.entity == mention.entity) {
mentions.push({ mentions.push({
entity: this.status.entity, entity: this.status.entity,
post: this.status.id, post: this.status.id,
type: this.status.type type: this.status.type
}); });
} } else {
for (var i = 0; i < this.mentions.length; i++) {
var mention = this.mentions[i];
mentions.push({ mentions.push({
entity: mention.entity entity: mention.entity
}); });
} }
}
data.mentions = mentions; data.mentions = mentions;
debug(data.mentions)
// Make tent flavored markdown mentions // Make tent flavored markdown mentions
for (var i = 0; i < this.mentions.length; i++) { for (var i = 0; i < this.mentions.length; i++) {
var mention = this.mentions[i]; var mention = this.mentions[i];
data.content.text = this.replaceAll(data.content.text, mention.name, "^[" + mention.name + "](" + i + ")") data.content.text = this.replaceAll(data.content.text, mention.name, "^[" + mention.name + "](" + i + ")")
} }
debug(data.content.text)
APICalls.post(HostApp.serverUrl("new_post"), JSON.stringify(data), { APICalls.post(HostApp.serverUrl("new_post"), JSON.stringify(data), {
content_type: data.type, content_type: data.type,

View file

@ -23,8 +23,8 @@ function(HostApp, Core, APICalls, URI) {
this.initProfileTemplate(); this.initProfileTemplate();
this.hide(); this.hide();
var _this = this; //var _this = this;
setTimeout(function() { _this.showProfileForEntity() }, 500); // Load users profile on start //setTimeout(function() { _this.showProfileForEntity() }, 500); // Load users profile on start
} }
Profile.prototype = Object.create(Core.prototype); Profile.prototype = Object.create(Core.prototype);
@ -47,13 +47,19 @@ function(HostApp, Core, APICalls, URI) {
$(this.followingsBody).hide(); $(this.followingsBody).hide();
$(this.followersBody).hide(); $(this.followersBody).hide();
$(list).show(); $(list).show();
}
Profile.prototype.showEntity = function(a, i) {
var entity = $(a).closest("li").get(0).status.mentions[i].entity;
this.showProfileForEntity(entity);
bungloo.sidebar.onEntityProfile();
}; };
Profile.prototype.showProfileForEntity = function(entity) { Profile.prototype.showProfileForEntity = function(entity) {
if (!entity) { if (!entity) {
entity = HostApp.stringForKey("entity"); entity = HostApp.stringForKey("entity");
}; }
this.clear(); this.clear();
this.entity = entity; this.entity = entity;
@ -249,7 +255,6 @@ function(HostApp, Core, APICalls, URI) {
APICalls.get(url, {callback: function(resp) { APICalls.get(url, {callback: function(resp) {
var json = JSON.parse(resp.responseText); var json = JSON.parse(resp.responseText);
debug(json)
var count = json.posts.length; var count = json.posts.length;
if (count > 0) { if (count > 0) {

View file

@ -14,7 +14,7 @@ function(Core, APICalls, HostApp, URI) {
this.action = "timeline"; this.action = "timeline";
this.reload_blocked = false; this.reload_blocked = false;
this.posts_limit = 4; this.posts_limit = 25;
this.max_length = 200; this.max_length = 200;
this.timeout = 10 * 1000; // every 10 seconds this.timeout = 10 * 1000; // every 10 seconds
this.since_id = null; this.since_id = null;

View file

@ -3,16 +3,14 @@ define([
"helper/APICalls", "helper/APICalls",
"lib/URI", "lib/URI",
"helper/HostApp", "helper/HostApp",
"lib/Showdown",
"lib/Timeago", "lib/Timeago",
"lib/SingleDoubleClick" "lib/SingleDoubleClick"
], ],
function(jQuery, APICalls, URI, HostApp, Showdown) { function(jQuery, APICalls, URI, HostApp) {
function Core() { function Core() {
this.saveScrollTop = 0; this.saveScrollTop = 0;
this.markdown = new Showdown.converter();
} }
@ -673,9 +671,9 @@ function(jQuery, APICalls, URI, HostApp, Showdown) {
.replace(/\*([^\*]+)\*/g, "<strong>$1</strong>") .replace(/\*([^\*]+)\*/g, "<strong>$1</strong>")
.replace(/`([^`]+)`/g, "<code>$1</code>") .replace(/`([^`]+)`/g, "<code>$1</code>")
.replace(/~([^~]+)~/g, "<del>$1</del>") .replace(/~([^~]+)~/g, "<del>$1</del>")
.replace(/\#[^\s]+/, "<a href='javascript:controller.search(\'$1\')'>#$1</a>") .replace(/\#([^\s]+)/g, "<a class='hash' href=\"javascript:bungloo.search.searchFor('$1')\">#$1</a>")
.replace(/[^\^]\[([^\]]+)\]\(([^\)]+)\)/g, "<a href='$2'>$1</a> ") .replace(/(^|[^\^])\[([^\]]+)\]\(([^\)]+)\)/g, "<a class='link' href='javascript:controller.openURL(\"$3\");'>$2</a>")
.replace(/\^\[([^\]]+)\]\(([^\)]+)\)/g, "<a class='name' href='javascript:controller.showEntity(this, $2);'>$1</a> "); .replace(/\^\[([^\]]+)\]\(([^\)]+)\)/g, "<a class='name' href='#' onclick='bungloo.entityProfile.showEntity(this, $2); return false;'>$1</a>");
} }
Core.prototype.parseForMedia = function(text, images) { Core.prototype.parseForMedia = function(text, images) {
@ -849,17 +847,19 @@ function(jQuery, APICalls, URI, HostApp, Showdown) {
Core.prototype.afterChangingTextinMessageHTML = function(message_node) { Core.prototype.afterChangingTextinMessageHTML = function(message_node) {
// adding show search on click hash // adding show search on click hash
/*
$(message_node).find("a.hash").click(function(e) { $(message_node).find("a.hash").click(function(e) {
if(bungloo.search) bungloo.search.searchFor(e.target.innerHTML); if(bungloo.search) bungloo.search.searchFor(e.target.innerHTML);
return false; return false;
}); });
*/
// adding show profile on click // adding show profile on click
/*
$(message_node).find("a.name").click(function(e) { $(message_node).find("a.name").click(function(e) {
HostApp.showProfileForEntity(e.target.title); HostApp.showProfileForEntity(e.target.title);
return false; return false;
}); });*/
} }