From a0c407e39d1e189124be77c3c56d46471aa66412 Mon Sep 17 00:00:00 2001 From: Marcin Kurczewski Date: Mon, 3 Nov 2014 12:06:53 +0100 Subject: [PATCH] Fixed handling too long sources in pasted URLs --- public_html/js/Presenters/PostUploadPresenter.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/public_html/js/Presenters/PostUploadPresenter.js b/public_html/js/Presenters/PostUploadPresenter.js index 5fd4df39..cf4782c5 100644 --- a/public_html/js/Presenters/PostUploadPresenter.js +++ b/public_html/js/Presenters/PostUploadPresenter.js @@ -262,8 +262,9 @@ App.Presenters.PostUploadPresenter = function( } function addPostFromUrl(url) { - var post = _.extend({}, getDefaultPost(), {url: url, source: url, fileName: url}); + var post = _.extend({}, getDefaultPost(), {url: url, fileName: url}); postAdded(post); + setPostsSource([post], url); var matches = url.match(/watch.*?=([a-zA-Z0-9_-]+)/); if (matches) { @@ -431,7 +432,11 @@ App.Presenters.PostUploadPresenter = function( function setPostsSource(posts, newSource) { _.each(posts, function(post) { - //todo: take care of max source length + var maxSourceLength = 200; + console.log(newSource); + if (newSource.length > maxSourceLength) { + newSource = newSource.substring(0, maxSourceLength - 5) + '(...)'; + } post.source = newSource; postChanged(post); });