From ec43a38b8672b201c350c6dfce967af9d55fa309 Mon Sep 17 00:00:00 2001 From: jeena Date: Mon, 22 Jul 2013 07:02:26 +0200 Subject: [PATCH] fixed initial mentions --- WebKit/scripts/controller/Mentions.js | 11 ++++---- WebKit/scripts/controller/Sidebar.js | 1 - WebKit/scripts/helper/APICalls.js | 16 ++++++++++- WebKit/scripts/helper/Core.js | 38 +++++++++------------------ 4 files changed, 33 insertions(+), 33 deletions(-) diff --git a/WebKit/scripts/controller/Mentions.js b/WebKit/scripts/controller/Mentions.js index 68fc7ec..dc64952 100644 --- a/WebKit/scripts/controller/Mentions.js +++ b/WebKit/scripts/controller/Mentions.js @@ -10,7 +10,6 @@ function(HostApp, Timeline, URI, APICalls, Core) { function Mentions() { - return // FIXME this.is_not_init = false; this.unread_mentions = 0; @@ -37,7 +36,7 @@ function(HostApp, Timeline, URI, APICalls, Core) { Mentions.prototype.newStatus = function(statuses, append) { Timeline.prototype.newStatus.call(this, statuses, append); - +/* if(this.is_not_init) { for (var i = 0; i < statuses.length; i++) { @@ -52,7 +51,7 @@ function(HostApp, Timeline, URI, APICalls, Core) { if(!append) HostApp.notificateUserAboutMention(status.content.text, name || status.entity, status.id, status.entity); } } - +*/ this.is_not_init = true; } @@ -60,13 +59,13 @@ function(HostApp, Timeline, URI, APICalls, Core) { add_to_search = add_to_search || {}; - if (!add_to_search["mentioned_entity"]) { - add_to_search["mentioned_entity"] = HostApp.stringForKey("entity"); + if (!add_to_search["mentions"]) { + add_to_search["mentions"] = HostApp.stringForKey("entity"); } Timeline.prototype.getNewData.call(this, add_to_search, append); - this.getLatestMentionRead(); + //this.getLatestMentionRead(); } Mentions.prototype.mentionRead = function(id, entity) { diff --git a/WebKit/scripts/controller/Sidebar.js b/WebKit/scripts/controller/Sidebar.js index d32c1e4..845946c 100644 --- a/WebKit/scripts/controller/Sidebar.js +++ b/WebKit/scripts/controller/Sidebar.js @@ -114,7 +114,6 @@ function(HostApp, APICalls) { } } }}); - } Sidebar.prototype.removeEntityAvatar = function() { diff --git a/WebKit/scripts/helper/APICalls.js b/WebKit/scripts/helper/APICalls.js index 9ab43c2..7d97790 100644 --- a/WebKit/scripts/helper/APICalls.js +++ b/WebKit/scripts/helper/APICalls.js @@ -32,7 +32,7 @@ function(jQuery, HostApp, Hmac, Cache) { var content_type = null; - if(options.http_method == "POST" && !options.content_type) { + if((options.http_method == "POST" || options.http_method == "PUT") && !options.content_type) { console.error("No content type for " + options.url); return; } else if(options.content_type != "AAA") { @@ -136,6 +136,20 @@ function(jQuery, HostApp, Hmac, Cache) { APICalls.http_call(settings); } + APICalls.put = function(url, data, options) { + var settings = { + url: url, + http_method: "PUT", + data: data + }; + + for (var key in options) { + settings[key] = options[key]; + } + + APICalls.http_call(settings); + } + APICalls.postMultipart = function(url, callback, data, boundary, accepts) { diff --git a/WebKit/scripts/helper/Core.js b/WebKit/scripts/helper/Core.js index 1f17530..58f54df 100644 --- a/WebKit/scripts/helper/Core.js +++ b/WebKit/scripts/helper/Core.js @@ -3,16 +3,16 @@ define([ "helper/APICalls", "lib/URI", "helper/HostApp", - "helper/Cache", + "lib/Showdown", "lib/Timeago", "lib/SingleDoubleClick" ], -function(jQuery, APICalls, URI, HostApp, Cache) { +function(jQuery, APICalls, URI, HostApp, Showdown) { function Core() { - this.cache = new Cache(); this.saveScrollTop = 0; + this.markdown = new Showdown.converter(); } @@ -279,6 +279,7 @@ function(jQuery, APICalls, URI, HostApp, Cache) { template.message.innerHTML = this.replaceURLWithHTMLLinks(text, entities, template.message); this.afterChangingTextinMessageHTML(template.message) + /* if (status.type == "https://tent.io/types/post/photo/v0.1.0") { for (var i = 0; i < status.attachments.length; i++) { @@ -306,7 +307,7 @@ function(jQuery, APICalls, URI, HostApp, Cache) { })(); } } - + */ this.findMentions(template.message, status.mentions); /* @@ -667,27 +668,14 @@ function(jQuery, APICalls, URI, HostApp, Cache) { } Core.prototype.replaceURLWithHTMLLinks = function(text, entities, message_node) { - - var callback = function(url) { - - var result; - - if (entities && entities.some(function(x) { return x == url })) { - result = url; - } else { - - result = url; - if (url.startsWith("http://") || url.startsWith("https://")) { - result = '' + url + ''; - } - } - - return result; - } - - var hash = /(^|\s)(#)(\w+)/ig; - - return URI.withinString(text, callback).replace(hash, "$1$2$3"); + // FIXME: this has to be done better so one can nest that stuff and escape with \ + return text.replace(/_([^_]+)_/g, "$1 ") + .replace(/\*([^\*]+)\*/g, "$1 ") + .replace(/`([^`]+)`/g, "$1 ") + .replace(/~([^~]+)~/g, "$1 ") + .replace(/\#[^\s]+/, "#$1") + .replace(/[^\^]\[([^\]]+)\]\(([^\)]+)\)/g, "$1 ") + .replace(/\^\[([^\]]+)\]\(([^\)]+)\)/g, "$1 "); } Core.prototype.parseForMedia = function(text, images) {