From 9fb767619e903bab6dc20058bbb8683cd807e685 Mon Sep 17 00:00:00 2001 From: Simon Grim Date: Wed, 6 May 2015 21:43:01 +0500 Subject: [PATCH 01/12] fix of twistday reminder doesnt show list if there is less than 2 twisters in it --- js/interface_home.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/js/interface_home.js b/js/interface_home.js index dec022c..291173f 100644 --- a/js/interface_home.js +++ b/js/interface_home.js @@ -273,9 +273,9 @@ function refreshTwistdayReminder() { } } - if (listCurrent.children().length > 1) + if (listCurrent.children().length) listCurrent.parent().show(); - if (listUpcoming.children().length > 1) + if (listUpcoming.children().length) listUpcoming.parent().show(); $module.find('.refresh').show(); $module.find('.loading-roller').hide(); From c60b8ef17e6f2862e03a5d9082ee2f86d92bd546 Mon Sep 17 00:00:00 2001 From: Simon Grim Date: Wed, 6 May 2015 21:52:49 +0500 Subject: [PATCH 02/12] fix of wrong binding of functions on keyup event --- js/tmobile.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/js/tmobile.js b/js/tmobile.js index a5944c4..fd8ff2e 100644 --- a/js/tmobile.js +++ b/js/tmobile.js @@ -24,8 +24,11 @@ function initializeTwister( redirectNetwork, redirectLogin, cbFunc, cbArg ) { $.mobile.silentScroll(0); }); // reply text counter both newmsg and dmchat - var $replyText = $( ".post-area-new textarea" ); - $replyText.off('input keyup').on('keyup', replyTextInput, function() { replyTextUpdateRemaining(this); }); + $('.post-area-new textarea') + .off('input keyup') + .on('keyup', replyTextInput) + .on('keyup', function() { replyTextUpdateRemaining(this); }) + ; handlersInstalled = true; } From 0fc45771a080bd1c8d864fe89a2a4ae57d9925c2 Mon Sep 17 00:00:00 2001 From: Simon Grim Date: Wed, 6 May 2015 22:31:40 +0500 Subject: [PATCH 03/12] fix of #243 Secret gets cut off in nin theme --- theme_nin/css/style.css | 8 +++++--- theme_nin/sass/style.sass | 8 +++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/theme_nin/css/style.css b/theme_nin/css/style.css index 9195763..46ddf43 100644 --- a/theme_nin/css/style.css +++ b/theme_nin/css/style.css @@ -2966,10 +2966,10 @@ ol.toptrends-list a:hover { /********* NEW USER MODAL************* */ /* line 861, ../sass/style.sass */ .new-user .modal-wrapper { - width: 520px; + width: 640px; height: 600px; top: 10%; - margin: 0 0 0 -260px; + margin: 0 0 0 -320px; overflow-x: hidden; overflow-y: hidden; } @@ -2987,13 +2987,15 @@ ol.toptrends-list a:hover { } /* line 874, ../sass/style.sass */ .new-user .emphasis { - font-size: 18px; text-align: center; } /* line 877, ../sass/style.sass */ .new-user .secret-key { + display: block; + margin-top: 8px; color: black; font-weight: bold; + font-size: 110%; } /******** HASHTAG MODAL********** */ diff --git a/theme_nin/sass/style.sass b/theme_nin/sass/style.sass index 070bd84..0d8f1c1 100755 --- a/theme_nin/sass/style.sass +++ b/theme_nin/sass/style.sass @@ -914,10 +914,10 @@ ol.toptrends-list .new-user .modal-wrapper - width: $postboard-modal-width + width: 640px height: 600px top: 10% - margin: 0 0 0 0-($postboard-modal-width/2) + margin: 0 0 0 -320px overflow-x: hidden overflow-y: hidden .modal-content @@ -927,11 +927,13 @@ ol.toptrends-list .text margin: 0 0 15px 0 .emphasis - font-size: 18px text-align: center .secret-key + display: block + margin-top: 8px color: rgba(0.5, 0, 0, 1) font-weight: bold + font-size: 110% /******** HASHTAG MODAL***********/ From ef210732feafb6bad56e9c2f0dba33f6405f22ae Mon Sep 17 00:00:00 2001 From: Simon Grim Date: Sat, 9 May 2015 00:51:13 +0500 Subject: [PATCH 04/12] optimization of postboard showPosts() and preventing of post duplication --- js/twister_timeline.js | 56 ++++++++++++++++++++++++++---------------- 1 file changed, 35 insertions(+), 21 deletions(-) diff --git a/js/twister_timeline.js b/js/twister_timeline.js index 1cba22c..f192aad 100644 --- a/js/twister_timeline.js +++ b/js/twister_timeline.js @@ -188,6 +188,7 @@ function showPosts(req, posts) //console.log(req); //console.log(posts); var streamItemsParent = $.MAL.getStreamPostsParent(); + var streamItems = streamItemsParent.children(); for( var i = 0; i < posts.length; i++ ) { var post = posts[i]; @@ -200,31 +201,44 @@ function showPosts(req, posts) var streamPostAppended = false; // insert the post in timeline ordered by (you guessed) time - // FIXME: lame! searching everything everytime. please optimize! - var streamItems = streamItemsParent.children(); - if( streamItems.length == 0) { - // timeline is empty - streamItemsParent.append( streamPost ); - streamPostAppended = true; - } else { - var j = 0; - for( j = 0; j < streamItems.length; j++) { - var streamItem = streamItems.eq(j); - var timeItem = streamItem.attr("data-time"); - if( timeItem == undefined || - timePost > parseInt(timeItem) ) { - // this post in stream is older, so post must be inserted above - streamItem.before(streamPost); - streamPostAppended = true; - break; + if (streamItems.length) { + // check for duplicate twists + var streamItemsSameTime = streamItemsParent.children('[data-time='+timePost+']'); + if (streamItemsSameTime.length) { + var streamPostInnerHTML = streamPost[0].innerHTML; + for (var j = 0; j < streamItemsSameTime.length; j++) { + var streamItem = streamItemsSameTime.eq(j); + if (streamItem[0].innerHTML === streamPostInnerHTML) { + streamPostAppended = true; + console.log('appending of duplicate twist prevented'); + break; + } + } + } + if (!streamPostAppended) { + for (var j = 0; j < streamItems.length; j++) { + var streamItem = streamItems.eq(j); + var timeItem = streamItem.attr("data-time"); + if( timeItem == undefined || + timePost > parseInt(timeItem) ) { + // this post in stream is older, so post must be inserted above + streamItem.before(streamPost); + streamItems[streamItems.length] = streamPost[0]; + streamItems.length += 1; + streamPostAppended = true; + streamPost.show(); + break; + } } } } - if (!streamPostAppended) + if (!streamPostAppended) { streamItemsParent.append( streamPost ); - - streamPostAppended = true; - streamPost.show(); + streamItems[streamItems.length] = streamPost[0]; + streamItems.length += 1; + streamPostAppended = true; + streamPost.show(); + } req.reportProcessedPost(post["userpost"]["n"],post["userpost"]["k"], streamPostAppended); } } From 4ee5ee0bde760d517168df2846ab68e704105e7e Mon Sep 17 00:00:00 2001 From: Simon Grim Date: Sat, 9 May 2015 10:08:06 +0500 Subject: [PATCH 05/12] fix of ordering in postboard showPosts() --- js/twister_timeline.js | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/js/twister_timeline.js b/js/twister_timeline.js index f192aad..ab7c127 100644 --- a/js/twister_timeline.js +++ b/js/twister_timeline.js @@ -216,20 +216,23 @@ function showPosts(req, posts) } } if (!streamPostAppended) { + var timeClosest = 0; for (var j = 0; j < streamItems.length; j++) { var streamItem = streamItems.eq(j); - var timeItem = streamItem.attr("data-time"); - if( timeItem == undefined || - timePost > parseInt(timeItem) ) { - // this post in stream is older, so post must be inserted above - streamItem.before(streamPost); - streamItems[streamItems.length] = streamPost[0]; - streamItems.length += 1; - streamPostAppended = true; - streamPost.show(); - break; + var timeItem = parseInt(streamItem.attr("data-time")); + if (timePost > timeItem && timeItem > timeClosest) { + timeClosest = timeItem; + var streamItemClosest = streamItem; } } + if (timeClosest) { + // this post in stream is older, so post must be inserted above + streamItemClosest.before(streamPost); + streamItems[streamItems.length] = streamPost[0]; + streamItems.length += 1; + streamPostAppended = true; + streamPost.show(); + } } } if (!streamPostAppended) { From 345966effd08da3607d7993274399df813c96444 Mon Sep 17 00:00:00 2001 From: Simon Grim Date: Sun, 10 May 2015 00:32:54 +0500 Subject: [PATCH 06/12] more optimization of showPosts(), renaming of it to attachPostsToStream() and applying of it in displayHashtagPending() --- js/twister_actions.js | 28 +---------- js/twister_timeline.js | 104 ++++++++++++++++++++--------------------- 2 files changed, 53 insertions(+), 79 deletions(-) diff --git a/js/twister_actions.js b/js/twister_actions.js index 818b4bd..fc63fee 100644 --- a/js/twister_actions.js +++ b/js/twister_actions.js @@ -379,33 +379,7 @@ function processHashtag(postboard, hashtag, data) { } function displayHashtagPending(postboard) { - for( var i = 0; i < _hashtagPendingPosts.length; i++ ) { - var post = _hashtagPendingPosts[i]; - //console.log(post); - var streamPost = postToElem(post, "original"); - var timePost = post["userpost"]["time"]; - streamPost.attr("data-time",timePost); - - var streamItems = postboard.children(); - if( streamItems.length == 0) { - postboard.prepend( streamPost ); - } else { - var j = 0; - for( j = 0; j < streamItems.length; j++) { - var streamItem = streamItems.eq(j); - var timeItem = streamItem.attr("data-time"); - if( timeItem == undefined || - timePost > parseInt(timeItem) ) { - // this post in stream is older, so post must be inserted above - streamItem.before(streamPost); - break; - } - } - if( j == streamItems.length ) { - postboard.append( streamPost ); - } - } - } + attachPostsToStream(postboard, _hashtagPendingPosts, false); $.MAL.postboardLoaded(); _hashtagPendingPosts = []; } diff --git a/js/twister_timeline.js b/js/twister_timeline.js index ab7c127..74a7635 100644 --- a/js/twister_timeline.js +++ b/js/twister_timeline.js @@ -160,7 +160,7 @@ function processReceivedPosts(req, posts) i--; } } - showPosts(req, posts); + updateTimeline(req, posts); req.doneReportProcessing(posts.length); //if the count of recieved posts less or equals to requested then... @@ -182,67 +182,67 @@ function processReceivedPosts(req, posts) } } -function showPosts(req, posts) -{ - //console.log('showPosts:'); - //console.log(req); +function updateTimeline(req, posts) { + attachPostsToStream($.MAL.getStreamPostsParent(), posts, req.getspam); + for (var i = 0; i < posts.length; i++) { + req.reportProcessedPost(posts[i]['userpost']['n'], posts[i]['userpost']['k'], true); + } +} + +function attachPostsToStream(stream, posts, isPromoted) { + //console.log('attachPostsToStream:'); //console.log(posts); - var streamItemsParent = $.MAL.getStreamPostsParent(); - var streamItems = streamItemsParent.children(); + function byTimeInDescendingOrder(a, b) { + return (a.time > b.time) ? -1 : 1; + } - for( var i = 0; i < posts.length; i++ ) { - var post = posts[i]; - //console.log(post); - var streamPost = postToElem(post, "original", req.getspam); - var timePost = post["userpost"]["time"]; - streamPost.attr("data-time",timePost); - - // post will only be shown if appended to the stream list - var streamPostAppended = false; - - // insert the post in timeline ordered by (you guessed) time - if (streamItems.length) { - // check for duplicate twists - var streamItemsSameTime = streamItemsParent.children('[data-time='+timePost+']'); - if (streamItemsSameTime.length) { - var streamPostInnerHTML = streamPost[0].innerHTML; - for (var j = 0; j < streamItemsSameTime.length; j++) { - var streamItem = streamItemsSameTime.eq(j); - if (streamItem[0].innerHTML === streamPostInnerHTML) { - streamPostAppended = true; + var streamItems = stream.children(); + var streamPosts = []; + + for (var i = 0; i < streamItems.length; i++) { + var streamItem = streamItems.eq(i); + streamPosts.push({item: streamItem, time: parseInt(streamItem.attr('data-time'))}); + } + //streamPosts.sort(byTimeInDescendingOrder); // currently there is no reason to sort it yet + + for (var i = 0; i < posts.length; i++) { + //console.log(posts[i]); + var isAttached = false; + var intrantPost = {item: postToElem(posts[i], 'original', isPromoted), time: posts[i]['userpost']['time']}; + intrantPost.item.attr('data-time', intrantPost.time); + + if (streamPosts.length) { + // check to avoid twist duplication + var streamItems = stream.children('[data-time='+intrantPost.time+']'); + if (streamItems.length) { + for (var j = 0; j < streamItems.length; j++) { + var streamItem = streamItems.eq(j); + if (streamItem[0].innerHTML === intrantPost.item[0].innerHTML) { + isAttached = true; console.log('appending of duplicate twist prevented'); break; } } } - if (!streamPostAppended) { - var timeClosest = 0; - for (var j = 0; j < streamItems.length; j++) { - var streamItem = streamItems.eq(j); - var timeItem = parseInt(streamItem.attr("data-time")); - if (timePost > timeItem && timeItem > timeClosest) { - timeClosest = timeItem; - var streamItemClosest = streamItem; + // insert the post in timeline ordered by (you guessed) time + if (!isAttached) { + for (var j = 0; j < streamPosts.length; j++) { + if (intrantPost.time > streamPosts[j].time) { + // this post in stream is older, so post must be inserted above + intrantPost.item.insertBefore(streamPosts[j].item).show(); + streamPosts.push(intrantPost); + streamPosts.sort(byTimeInDescendingOrder); + isAttached = true; + break; } } - if (timeClosest) { - // this post in stream is older, so post must be inserted above - streamItemClosest.before(streamPost); - streamItems[streamItems.length] = streamPost[0]; - streamItems.length += 1; - streamPostAppended = true; - streamPost.show(); - } } } - if (!streamPostAppended) { - streamItemsParent.append( streamPost ); - streamItems[streamItems.length] = streamPost[0]; - streamItems.length += 1; - streamPostAppended = true; - streamPost.show(); + if (!isAttached) { + intrantPost.item.appendTo(stream).show(); + streamPosts.push(intrantPost); + streamPosts.sort(byTimeInDescendingOrder); } - req.reportProcessedPost(post["userpost"]["n"],post["userpost"]["k"], streamPostAppended); } } @@ -258,7 +258,7 @@ function requestTimelineUpdate(mode, count, timelineUsers, getspam) var req = new requestObj(timelineUsers, mode, count, getspam); if (mode === 'pending') { req.mode = 'latest'; - showPosts(req, _newPostsPending); + updateTimeline(req, _newPostsPending); _newPostsPending = []; $.MAL.reportNewPosts(_newPostsPending.length); $.MAL.postboardLoaded(); @@ -340,7 +340,7 @@ function processNewPostsConfirmation(expected, posts) } if ( sendedPostsPending.length > 0 ) { var req = new requestObj([defaultScreenName],'latest',sendedPostsPending.length,promotedPostsOnly); - showPosts(req, sendedPostsPending); + updateTimeline(req, sendedPostsPending); } if( posts.length < expected ) { From 3574c0389ce2899a3df1a438ffedc2ecce1fac16 Mon Sep 17 00:00:00 2001 From: Simon Grim Date: Tue, 12 May 2015 04:29:48 +0500 Subject: [PATCH 07/12] even more optimization for attachPostsToStream() to avoid as much as possible of DOM traversing --- js/twister_timeline.js | 35 +++++++++++++---------------------- 1 file changed, 13 insertions(+), 22 deletions(-) diff --git a/js/twister_timeline.js b/js/twister_timeline.js index 74a7635..0ae2b5c 100644 --- a/js/twister_timeline.js +++ b/js/twister_timeline.js @@ -203,38 +203,29 @@ function attachPostsToStream(stream, posts, isPromoted) { var streamItem = streamItems.eq(i); streamPosts.push({item: streamItem, time: parseInt(streamItem.attr('data-time'))}); } - //streamPosts.sort(byTimeInDescendingOrder); // currently there is no reason to sort it yet + //streamPosts.sort(byTimeInDescendingOrder); // currently here is no reason to sort it, it should be ok for (var i = 0; i < posts.length; i++) { //console.log(posts[i]); var isAttached = false; - var intrantPost = {item: postToElem(posts[i], 'original', isPromoted), time: posts[i]['userpost']['time']}; + var intrantPost = {item: postToElem(posts[i], 'original', isPromoted), time: posts[i].userpost.time}; intrantPost.item.attr('data-time', intrantPost.time); if (streamPosts.length) { - // check to avoid twist duplication - var streamItems = stream.children('[data-time='+intrantPost.time+']'); - if (streamItems.length) { - for (var j = 0; j < streamItems.length; j++) { - var streamItem = streamItems.eq(j); - if (streamItem[0].innerHTML === intrantPost.item[0].innerHTML) { + // check to avoid twist duplication and insert the post in timeline ordered by (you guessed) time + for (var j = 0; j < streamPosts.length; j++) { + if (intrantPost.time === streamPosts[j].time && + intrantPost.item[0].innerHTML === streamPosts[j].item[0].innerHTML) { isAttached = true; console.log('appending of duplicate twist prevented'); break; - } - } - } - // insert the post in timeline ordered by (you guessed) time - if (!isAttached) { - for (var j = 0; j < streamPosts.length; j++) { - if (intrantPost.time > streamPosts[j].time) { - // this post in stream is older, so post must be inserted above - intrantPost.item.insertBefore(streamPosts[j].item).show(); - streamPosts.push(intrantPost); - streamPosts.sort(byTimeInDescendingOrder); - isAttached = true; - break; - } + } else if (intrantPost.time > streamPosts[j].time) { + // this post in stream is older, so post must be inserted above + intrantPost.item.insertBefore(streamPosts[j].item).show(); + streamPosts.push(intrantPost); + streamPosts.sort(byTimeInDescendingOrder); + isAttached = true; + break; } } } From 257aedf61af2f2af94875140b142de3afe888699 Mon Sep 17 00:00:00 2001 From: Simon Grim Date: Tue, 12 May 2015 04:41:32 +0500 Subject: [PATCH 08/12] crazy gonzales optimization of htmlFormatMsg() to avoid AMAP DOM interacting (but with too many RegExps), some minor optimization for postToElem(), introducing of proxyURL() --- js/interface_common.js | 12 +- js/twister_formatpost.js | 345 +++++++++++++++------------------------ 2 files changed, 130 insertions(+), 227 deletions(-) diff --git a/js/interface_common.js b/js/interface_common.js index 1368a8e..1032e60 100644 --- a/js/interface_common.js +++ b/js/interface_common.js @@ -636,17 +636,7 @@ var postExpandFunction = function( e, postLi ) /*is there any link in the post?*/ for (var i=0; i")); } } diff --git a/js/twister_formatpost.js b/js/twister_formatpost.js index ac27e6c..45c4f65 100644 --- a/js/twister_formatpost.js +++ b/js/twister_formatpost.js @@ -52,71 +52,71 @@ function postToElem( post, kind, promoted ) { // Now create the html elements var elem = $.MAL.getPostTemplate().clone(true); - elem.removeAttr('id'); - elem.addClass(kind); - elem.attr('data-time', t); + elem.removeAttr('id') + .addClass(kind) + .attr('data-time', t) + ; - if( post["isNew"] ) + if( post['isNew'] ) elem.addClass('new'); - var postData = elem.find(".post-data"); - postData.addClass(kind); - postData.attr('data-userpost', postJson); - postData.attr('data-content_to_rt', content_to_rt); - postData.attr('data-content_to_sigrt', content_to_sigrt); - postData.attr('data-screen-name', n); - postData.attr('data-id', k); - postData.attr('data-lastk', userpost["lastk"]); - postData.attr('data-text', msg); - if( "reply" in userpost ) { - postData.attr('data-replied-to-screen-name', userpost["reply"]["n"]); - postData.attr('data-replied-to-id', userpost["reply"]["k"]); - - postData.find('.post-expand').text(polyglot.t("Show conversation")); - } else if ( "rt" in userpost && "reply" in userpost["rt"] ) { - postData.attr('data-replied-to-screen-name', userpost["rt"]["reply"]["n"]); - postData.attr('data-replied-to-id', userpost["rt"]["reply"]["k"]); - - postData.find('.post-expand').text(polyglot.t("Show conversation")); + var postData = elem.find('.post-data'); + postData.addClass(kind) + .attr('data-userpost', postJson) + .attr('data-content_to_rt', content_to_rt) + .attr('data-content_to_sigrt', content_to_sigrt) + .attr('data-screen-name', n) + .attr('data-id', k) + .attr('data-lastk', userpost["lastk"]) + .attr('data-text', msg) + ; + if( 'reply' in userpost ) { + postData.attr('data-replied-to-screen-name', userpost.reply.n) + .attr('data-replied-to-id', userpost.reply.k) + .find('.post-expand').text(polyglot.t('Show conversation')) + ; + } else if ( 'rt' in userpost && 'reply' in userpost.rt ) { + postData.attr('data-replied-to-screen-name', userpost.rt.reply.n) + .attr('data-replied-to-id', userpost.rt.reply.k) + .find('.post-expand').text(polyglot.t('Show conversation')) + ; } - var postInfoName = elem.find(".post-info-name"); - postInfoName.attr('href',$.MAL.userUrl(n)); - postInfoName.text(n); + var postInfoName = elem.find('.post-info-name'); + postInfoName.text(n).attr('href', $.MAL.userUrl(n)); getFullname( n, postInfoName ); - elem.find(".post-info-tag").text = "@" + n; - getAvatar( n, elem.find(".avatar") ); - elem.find(".post-info-time").text(timeGmtToText(t)); - elem.find(".post-info-time").attr("title",timeSincePost(t)); + //elem.find('.post-info-tag').text("@" + n); + getAvatar( n, elem.find('.avatar') ); + elem.find('.post-info-time').text(timeGmtToText(t)).attr('title', timeSincePost(t)); var mentions = []; - htmlFormatMsg( msg, elem.find(".post-text"), mentions); + elem.find('.post-text').html(htmlFormatMsg(msg, mentions)); postData.attr('data-text-mentions', mentions); - var replyTo = ""; - if( n != defaultScreenName ) - replyTo += "@" + n + " "; - for( var i = 0; i < mentions.length; i++ ) { - if( mentions[i] != n && mentions[i] != defaultScreenName ) { - replyTo += "@" + mentions[i] + " "; - } - } - if(!defaultScreenName) - { - elem.find(".post-area-new textarea").attr("placeholder", polyglot.t("You have to log in to post replies.")); + var replyTo = []; + if( n !== defaultScreenName ) + replyTo.push(['@', n, ' '].join('')); + for (var i = 0; i < mentions.length; i++) { + if (mentions[i] !== n && mentions[i] !== defaultScreenName) + replyTo.push(['@', mentions[i], ' '].join('')); } + replyTo = replyTo.join(''); + + var postTextArea = elem.find('.post-area-new textarea'); + postTextArea.attr('data-reply-to', replyTo); + if (!defaultScreenName) + postTextArea.attr('placeholder', polyglot.t('You have to log in to post replies.')); else - { - elem.find(".post-area-new textarea").attr("placeholder", polyglot.t("reply_to", { fullname: replyTo })+ "..."); - } - elem.find(".post-area-new textarea").attr("data-reply-to",replyTo); - postData.attr("data-reply-to",replyTo); + postTextArea.attr('placeholder', polyglot.t('reply_to', { fullname: replyTo })+ '...'); + + postData.attr('data-reply-to', replyTo); if( retweeted_by != undefined ) { - elem.find(".post-context").show(); - var retweetedByElem = elem.find(".post-retransmited-by"); - retweetedByElem.attr("href", $.MAL.userUrl(retweeted_by)); - retweetedByElem.text('@'+retweeted_by); + elem.find('.post-context').show(); + elem.find('.post-retransmited-by') + .attr('href', $.MAL.userUrl(retweeted_by)) + .text('@' + retweeted_by) + ; } if (typeof(promoted) !== 'undefined' && promoted) { @@ -130,8 +130,9 @@ function postToElem( post, kind, promoted ) { else var mlm = ''; - elem.append('
'+polyglot.t('This post is treated by language filter', {'treated': ''+((post['langFilter']['pass']) ? polyglot.t('passed') : polyglot.t('blocked'))+''})+'
'); - elem.append('
'+polyglot.t('Reason: this', {'this': ''+post['langFilter']['reason']+''})+mlm+'
'); + elem.append('
'+polyglot.t('This post is treated by language filter', {'treated': ''+((post['langFilter']['pass']) ? polyglot.t('passed') : polyglot.t('blocked'))+''})+'
') + .append('
'+polyglot.t('Reason: this', {'this': ''+post['langFilter']['reason']+''})+mlm+'
') + ; } else { elem.append('
'+polyglot.t('This post is treated by language filter', {'treated': ''+polyglot.t('not analyzed')+''})+'
'); } @@ -158,8 +159,7 @@ function dmDataToSnippetItem(dmData, remoteUser) { else getFullname( remoteUser, dmItem.find("a.post-info-name") ); dmItem.find(".post-text").html(escapeHtmlEntities(dmData.text)); - dmItem.find(".post-info-time").text(timeGmtToText(dmData.time)); - dmItem.find(".post-info-time").attr("title",timeSincePost(dmData.time)); + dmItem.find(".post-info-time").text(timeGmtToText(dmData.time)).attr("title",timeSincePost(dmData.time)); return dmItem; } @@ -171,183 +171,96 @@ function dmDataToConversationItem(dmData, localUser, remoteUser) { dmItem.removeAttr('id'); dmItem.addClass(classDm); getAvatar(dmData.fromMe ? localUser : remoteUser, dmItem.find(".post-photo").find("img") ); - dmItem.find(".post-info-time").text(timeGmtToText(dmData.time)); - dmItem.find(".post-info-time").attr("title",timeSincePost(dmData.time)); + dmItem.find(".post-info-time").text(timeGmtToText(dmData.time)).attr("title",timeSincePost(dmData.time)); var mentions = []; - htmlFormatMsg( dmData.text, dmItem.find(".post-text"), mentions); + dmItem.find('.post-text').html(htmlFormatMsg(dmData.text, mentions)); + return dmItem; } // convert message text to html, featuring @users and links formating. -// todo: hashtags -function htmlFormatMsg( msg, output, mentions ) { - var tmp; - var match = null; - var index; - var strUrlRegexp = "http[s]?://"; - var strEmailRegexp = "\\S+@\\S+\\.\\S+"; - var strSplitCounterR = "\\(\\d{1,2}\\/\\d{1,2}\\)$"; - var reAll = new RegExp("(?:^|[ \\n\\t.,:\\/?!])(#|@|" + strUrlRegexp + "|" + strEmailRegexp + "|" + strSplitCounterR + ")"); - var reHttp = new RegExp(strUrlRegexp); - var reEmail = new RegExp(strEmailRegexp); - var reSplitCounter = new RegExp(strSplitCounterR); - - msg = escapeHtmlEntities(msg); - - while( msg != undefined && msg.length ) { - - match = reAll.exec(msg); - if( match ) { - index = (match[0] === match[1]) ? match.index : match.index + 1; - if( match[1] == "@" ) { - output.append(_formatText(msg.substr(0, index))); - tmp = msg.substr(index+1); - var username = _extractUsername(tmp); - if( username.length ) { - if( mentions.indexOf(username) < 0 ) - mentions.push(username); - var userLinkTemplate = $("#msg-user-link-template").clone(true); - userLinkTemplate.removeAttr("id"); - userLinkTemplate.attr("href",$.MAL.userUrl(username)); - userLinkTemplate.text("@"+username); - output.append(userLinkTemplate); - msg = tmp.substr(String(username).length); - continue; - } - output.append('@'); - msg = tmp; - continue; - } - - if( reHttp.exec(match[1]) ) { - output.append(_formatText(msg.substr(0, index))); - tmp = msg.substring(index); - var space = tmp.search(/[ \n\t]/); - var url; - if( space != -1 ) url = tmp.substring(0,space); else url = tmp; - if( url.length ) { - msg = tmp.substr(String(url).length); - url = reverseHtmlEntities(url); - var extLinkTemplate = $("#external-page-link-template").clone(true); - extLinkTemplate.removeAttr("id"); - - if ($.Options.getUseProxyOpt() !== 'disable' && !$.Options.getUseProxyForImgOnlyOpt()){ - //proxy alternatives may be added to options page... - if ($.Options.getUseProxyOpt() === 'ssl-proxy-my-addr') { - extLinkTemplate.attr('href', 'https://ssl-proxy.my-addr.org/myaddrproxy.php/' + - url.substring(0, url.indexOf(':')) + - url.substr(url.indexOf('/') + 1)); - } else if ($.Options.getUseProxyOpt() ==='anonymouse') { - extLinkTemplate.attr('href', 'http://anonymouse.org/cgi-bin/anon-www.cgi/' + url); - } - } else { - extLinkTemplate.attr("href",url); - } - - extLinkTemplate.text(url); - extLinkTemplate.attr("title",url); - output.append(extLinkTemplate); - continue; - } - } +function htmlFormatMsg(msg, mentions) { + function htmlMention(str, pre) { + str = str.replace(new RegExp(['^', pre, '@'].join('')), '').toLowerCase(); + + mentions.push(str); // FIXME feel the scope + + // FIXME we're trying to not interact with DOM, coz' we want to run really fast [to hell of RegExps] + // FIXME actually we should avoid it by dropping a template idea and construct html right here + return $('#msg-user-link-template')[0].outerHTML + .replace(/\bid\s*=\s*"[^]*?"+/ig, '') // $().removeAttr('id') + //.replace(/\bhref\s*=\s*"[^]*?"+/ig, '') // $().removeAttr('href') + .replace(/]*?\bclass\s*=\s*"(?=[^"]*?\bopen-profile-modal\b))/ig, [pre, ']*?\bclass\s*=\s*"(?=[^"]*?\bopen-profile-modal\b))[^]*?>)[^]*?(<\/a>)/ig, [pre, '$1@', str, '$2'].join('')) // $().closest('a.open-profile-modal').text('@'+username) + ; + } - if( reEmail.exec(match[1]) ) { - output.append(_formatText(msg.substr(0, index))); - tmp = msg.substring(index); - var space = tmp.search(/[ \n\t]/); - var email; - if( space != -1 ) email = tmp.substring(0,space); else email = tmp; - if( email.length ) { - var extLinkTemplate = $("#external-page-link-template").clone(true); - extLinkTemplate.removeAttr("id"); - extLinkTemplate.attr("href","mailto:" + email); - extLinkTemplate.text(email); - extLinkTemplate.attr("title",email); - output.append(extLinkTemplate); - msg = tmp.substr(String(email).length); - continue; - } - } - - if( match[1] == "#" ) { - output.append(_formatText(msg.substr(0, index))); - tmp = msg.substr(index+1); - var hashtag = _extractHashtag(tmp); - if( hashtag.length ) { - var hashtag_lc=''; - for( var i = 0; i < hashtag.length; i++ ) { - var c = hashtag[i]; - hashtag_lc += (c >= 'A' && c <= 'Z') ? c.toLowerCase() : c; - } - var hashtagLinkTemplate = $("#hashtag-link-template").clone(true); - hashtagLinkTemplate.removeAttr("id"); - hashtagLinkTemplate.attr("href",$.MAL.hashtagUrl(hashtag_lc)); - hashtagLinkTemplate.text("#"+hashtag); - output.append(hashtagLinkTemplate); - msg = tmp.substr(String(hashtag).length); - continue; - } - output.append('#'); - msg = tmp; - continue; - } + function htmlHashtag(str, pre) { + str = str.replace(new RegExp(['^', pre, '#'].join('')), ''); - if (reSplitCounter.exec(match[1])) { - output.append(_formatText(msg.substr(0, index))); - tmp = msg.substring(index); - if( tmp.length ) { - var splitCounter = $(''); - splitCounter.text(tmp); - output.append(splitCounter); - msg = ""; - continue; - } - } - } + return $('#hashtag-link-template')[0].outerHTML + .replace(/\bid\s*=\s*"[^]*?"+/ig, '') // $().removeAttr('id') + //.replace(/\bhref\s*=\s*"[^]*?"+/ig, '') // $().removeAttr('href') + .replace(/]*?\bclass\s*=\s*"(?=[^"]*?\bopen-hashtag-modal\b))/ig, [']*?\bclass\s*=\s*"(?=[^"]*?\bopen-hashtag-modal\b))[^]*?>)[^]*?(<\/a>)/ig, [pre, '$1#', str, '$2'].join('')) // $().closest('a.open-profile-modal').text('#'+hashtag) + ; + } - output.append(_formatText(msg)); - msg = ""; + function htmlHttp(str) { + return $('#external-page-link-template')[0].outerHTML + .replace(/\bid\s*=\s*"[^]*?"+/ig, '') // $().removeAttr('id') + //.replace(/\bhref\s*=\s*"[^]*?"+/ig, '') // $().removeAttr('href') + .replace(/)[^]*?(<\/a>)/ig, ['$1', str, '$2'].join('')) // $().closest('a').text(url) + ; } -} -// internal function for htmlFormatMsg -function _formatText(msg) -{ - // TODO: add options for emotions and linefeeds - //msg = $.emotions(msg); - if( $.Options.getLineFeedsOpt() == "enable" ) - msg = msg.replace(/\n/g, '
'); - return msg; + function htmlEmail(str) { + return $('#external-page-link-template')[0].outerHTML + .replace(/\bid\s*=\s*"[^]*?"+/ig, '') // $().removeAttr('id') + //.replace(/\bhref\s*=\s*"[^]*?"+/ig, '') // $().removeAttr('href') + .replace(/)[^]*?(<\/a>)/ig, ['$1', str, '$2'].join('')) // $().closest('a').text(url) + ; + } + + function htmlSplitCounter(str) { + return ['', str, ''].join(''); + } + + msg = escapeHtmlEntities(msg) + .replace(/(^|\s|\w)@\S\w*/g, htmlMention) + .replace(/(^|\s|\w)#\S\w*/g, htmlHashtag) + .replace(/\bhttps?:\/\/\S+/ig, htmlHttp) + .replace(/\S+@\S+\.\S+/g, htmlEmail) + .replace(/\(\d{1,2}\/\d{1,2}\)$/, htmlSplitCounter) + ; + + return _formatText(msg); } -function _extractUsername(s) { - var username = ""; - for( var i = 0; i < s.length; i++ ) { - var c = s.charCodeAt(i); - if( (c >= 'a'.charCodeAt(0) && c <= 'z'.charCodeAt(0)) || - (c >= 'A'.charCodeAt(0) && c <= 'Z'.charCodeAt(0)) || - (c >= '0'.charCodeAt(0) && c <= '9'.charCodeAt(0)) || - c == '_'.charCodeAt(0) ) { - username += s[i]; - } else { - break; - } +function proxyURL(url) { + var proxyOpt = $.Options.getUseProxyOpt(); + if (proxyOpt !== 'disable' && !$.Options.getUseProxyForImgOnlyOpt()) { + // proxy alternatives may be added to options page + if (proxyOpt === 'ssl-proxy-my-addr') { + url = ['https://ssl-proxy.my-addr.org/myaddrproxy.php/', + url.substring(0, url.indexOf(':')), url.substr(url.indexOf('/') + 1)].join(''); + } else if (proxyOpt === 'anonymouse') + url = ['http://anonymouse.org/cgi-bin/anon-www.cgi/', url].join(''); } - return username.toLowerCase(); + + return url; } // internal function for htmlFormatMsg -function _extractHashtag(s) { - var hashtag = ""; - s = reverseHtmlEntities(s); - for( var i = 0; i < s.length; i++ ) { - if( " \n\t.,:/?!;'\"()[]{}*#".indexOf(s[i]) < 0 ) { - hashtag += s[i]; - } else { - break; - } - } - return hashtag; + // TODO: add options for emotions; msg = $.emotions(msg); + // TODO: add at least basic markdown (optional) like *text* -> bold text and _text_ -> italic text +function _formatText(msg) { + if ($.Options.getLineFeedsOpt() === 'enable') + msg = msg.replace(/\n/g, '
'); + + return msg; } function escapeHtmlEntities(str) { From c149e8bbc1f6c4a608aaf391cf92acbaf37a795c Mon Sep 17 00:00:00 2001 From: Simon Grim Date: Tue, 12 May 2015 20:38:41 +0500 Subject: [PATCH 09/12] fixes of RegExps and behaviour of htmlFormatMsg() and slightly filterLang() --- js/mobile_abstract.js | 4 +-- js/twister_formatpost.js | 55 +++++++++++++++++++++++++--------------- 2 files changed, 36 insertions(+), 23 deletions(-) diff --git a/js/mobile_abstract.js b/js/mobile_abstract.js index 2c1bcb6..bc165c1 100644 --- a/js/mobile_abstract.js +++ b/js/mobile_abstract.js @@ -506,13 +506,13 @@ function filterLang(string) { // before detection attempts we cut out any mentions and links, and replace _ with space langFilterSubj = string.replace(/@\S\w*|https?:\/\/\S*/g, '').replace(/_+/g, ' ') // cut out common frequently used words FIXME I believe there is a list of similar international stuff somewhere outside which is waiting for us, we should just find it - .replace(/\btwister|github|google|twitter\b/g, '') + .replace(/\btwister|tox|github|linux|ubuntu|debian|windows|google|twitter|facebook|microsoft|ping|pong|email|javascript\b/ig, '') // replace zero-width word boundaries, such as between letters from different alphabets [or other symbols], with spaces // FIXME not so good idea because 'Za pomocą białej listy' may turn into 'Za pomoc ą bia ł ej listy' for e.g. // FIXME but first one was recognized as 'hrv' and second as 'pol' and you know it's 'pol' actually .replace(/\b/g, ' ') // cut out some more symbols - .replace(/[#\[\]\(\)\{\}\-\+\=\^\:\;\\\/0-9]/g, '') + .replace(/[#<>\.,:;\?\!\*\[\]\(\)\{\}\-\+\=\^\\\/0-9\u201C\u201D\u2026\u2014\u4E00\u3002\uFF0C\uFF1A\uFF1F\uFF01\u3010\u3011]/g, '') // unicode escaped stuff is '“”…—一。,:?!【】' // clear unwanted spaces .replace(/\s+/g, ' ').trim(); diff --git a/js/twister_formatpost.js b/js/twister_formatpost.js index 45c4f65..c962a71 100644 --- a/js/twister_formatpost.js +++ b/js/twister_formatpost.js @@ -183,60 +183,73 @@ function htmlFormatMsg(msg, mentions) { function htmlMention(str, pre) { str = str.replace(new RegExp(['^', pre, '@'].join('')), '').toLowerCase(); - mentions.push(str); // FIXME feel the scope + mentions.push(str); // FIXME feel the pain of the scope chain // FIXME we're trying to not interact with DOM, coz' we want to run really fast [to hell of RegExps] // FIXME actually we should avoid it by dropping a template idea and construct html right here - return $('#msg-user-link-template')[0].outerHTML + html.push($('#msg-user-link-template')[0].outerHTML .replace(/\bid\s*=\s*"[^]*?"+/ig, '') // $().removeAttr('id') //.replace(/\bhref\s*=\s*"[^]*?"+/ig, '') // $().removeAttr('href') - .replace(/]*?\bclass\s*=\s*"(?=[^"]*?\bopen-profile-modal\b))/ig, [pre, '
]*?\bclass\s*=\s*"(?=[^"]*?\bopen-profile-modal\b))/ig, [']*?\bclass\s*=\s*"(?=[^"]*?\bopen-profile-modal\b))[^]*?>)[^]*?(<\/a>)/ig, [pre, '$1@', str, '$2'].join('')) // $().closest('a.open-profile-modal').text('@'+username) - ; + ); + + return ['>', html.length - 1, '<'].join(''); } function htmlHashtag(str, pre) { str = str.replace(new RegExp(['^', pre, '#'].join('')), ''); - return $('#hashtag-link-template')[0].outerHTML + html.push($('#hashtag-link-template')[0].outerHTML .replace(/\bid\s*=\s*"[^]*?"+/ig, '') // $().removeAttr('id') //.replace(/\bhref\s*=\s*"[^]*?"+/ig, '') // $().removeAttr('href') .replace(/]*?\bclass\s*=\s*"(?=[^"]*?\bopen-hashtag-modal\b))/ig, [']*?\bclass\s*=\s*"(?=[^"]*?\bopen-hashtag-modal\b))[^]*?>)[^]*?(<\/a>)/ig, [pre, '$1#', str, '$2'].join('')) // $().closest('a.open-profile-modal').text('#'+hashtag) - ; + ); + + return ['>', html.length - 1, '<'].join(''); } function htmlHttp(str) { - return $('#external-page-link-template')[0].outerHTML + html.push($('#external-page-link-template')[0].outerHTML .replace(/\bid\s*=\s*"[^]*?"+/ig, '') // $().removeAttr('id') //.replace(/\bhref\s*=\s*"[^]*?"+/ig, '') // $().removeAttr('href') .replace(/)[^]*?(<\/a>)/ig, ['$1', str, '$2'].join('')) // $().closest('a').text(url) - ; + ); + + return ['>', html.length - 1, '<'].join(''); } - function htmlEmail(str) { - return $('#external-page-link-template')[0].outerHTML + function htmlEmail(str, pre) { + str = str.replace(new RegExp(['^', pre].join('')), ''); + + html.push($('#external-page-link-template')[0].outerHTML .replace(/\bid\s*=\s*"[^]*?"+/ig, '') // $().removeAttr('id') //.replace(/\bhref\s*=\s*"[^]*?"+/ig, '') // $().removeAttr('href') .replace(/)[^]*?(<\/a>)/ig, ['$1', str, '$2'].join('')) // $().closest('a').text(url) - ; + .replace(/()[^]*?(<\/a>)/ig, [pre, '$1', str, '$2'].join('')) // $().closest('a').text(url) + ); + + return ['>', html.length - 1, '<'].join(''); } function htmlSplitCounter(str) { - return ['', str, ''].join(''); + html.push(['', str, ''].join('')); + + return ['>', html.length - 1, '<'].join(''); } - msg = escapeHtmlEntities(msg) - .replace(/(^|\s|\w)@\S\w*/g, htmlMention) - .replace(/(^|\s|\w)#\S\w*/g, htmlHashtag) - .replace(/\bhttps?:\/\/\S+/ig, htmlHttp) - .replace(/\S+@\S+\.\S+/g, htmlEmail) - .replace(/\(\d{1,2}\/\d{1,2}\)$/, htmlSplitCounter) - ; + var html = []; - return _formatText(msg); + return _formatText(escapeHtmlEntities(msg) + .replace(/(^|[^\/]\B(?!\S*:\/\/\S*@))@\w+\b/g, htmlMention) + .replace(/(^|[^<\/]\B(?!\S*:\/\/\S*#))#[^#\\\/\.,:;\?\!\*\[\]\(\)\{\}\-\+\=\^\|%'"\u201C\u201D\u2026\u2014\u4E00\u3002\uFF0C\uFF1A\uFF1F\uFF01\u3010\u3011>\s]+/g, htmlHashtag) // unicode escaped stuff is '“”…—一。,:?!【】' for our chinese friends + .replace(/\bhttps?:\/\/\S[^>\s]+/ig, htmlHttp) + .replace(/([^<\/])\b(?!\S*:\/\/\S*@)\S+@\S+\.\S[^>\s]+/g, htmlEmail) + .replace(/\(\d{1,2}\/\d{1,2}\)$/, htmlSplitCounter) + .replace(/>(\d+) Date: Wed, 13 May 2015 00:38:36 +0500 Subject: [PATCH 10/12] exluding advert msg of random guy from twisterday reminder routine, fixes of its css --- css/style.css | 8 ++++++-- js/interface_home.js | 43 +++++++++++++++++++-------------------- theme_calm/css/style.css | 8 ++++++-- theme_nin/css/style.css | 12 ++++++++--- theme_nin/sass/style.sass | 9 +++++--- 5 files changed, 48 insertions(+), 32 deletions(-) diff --git a/css/style.css b/css/style.css index 1d1c22a..825b221 100644 --- a/css/style.css +++ b/css/style.css @@ -836,7 +836,7 @@ ol.toptrends-list { .twistday-reminder h4 { margin: 1% 1% 1% 16%; - font-size: 90%; + font-size: 10px; color: rgba(0, 0, 0, 0.5); } @@ -849,6 +849,10 @@ ol.toptrends-list { padding: 5px; } +.twistday-reminder .twister-user-info { + margin: 1.2% 0 -2.8% 0; +} + .twistday-reminder .twister-user-tag, .twistday-reminder .twister-user-full { display: block; @@ -857,7 +861,7 @@ ol.toptrends-list { } .twistday-reminder .twisterday { - font-size: 80%; + font-size: 11px; margin-left: 11%; } diff --git a/js/interface_home.js b/js/interface_home.js index 291173f..84adf92 100644 --- a/js/interface_home.js +++ b/js/interface_home.js @@ -218,11 +218,12 @@ function refreshTwistdayReminder() { item.find('.twister-user-info').attr('data-screen-name', lucky); item.find('.twister-user-name').attr('href', $.MAL.userUrl(lucky)); item.find('.twister-user-tag').text('@' +lucky); + itemTwisterday = item.find('.twisterday'); + itemTwisterday.bind('click', (function(e) { replyInitPopup(e, post); }).bind(post)); if (typeof(time) !== 'undefined') - item.find('.twisterday').text(timeGmtToText(time)); + itemTwisterday.text(timeGmtToText(time)); else - item.find('.twisterday').text(timeGmtToText(post.userpost.time)); - item.find('.twisterday').bind('click', (function(e) { replyInitPopup(e, post); }).bind(post)); + itemTwisterday.text(timeGmtToText(post.userpost.time)); getAvatar(lucky, item.find('.twister-user-photo')); getFullname(lucky, item.find('.twister-user-full')); @@ -231,8 +232,7 @@ function refreshTwistdayReminder() { } } function removeLuckyFromList(list, post) { - var lucky = post.userpost.n; - list.find('[data-screen-name='+lucky+']').closest('li').remove(); + list.find('[data-screen-name='+post.userpost.n+']').closest('li').remove(); } var showUpcomingTimer = ($.Options.getTwistdayReminderShowUpcomingOpt() === 'enable') ? $.Options.getTwistdayReminderShowUpcomingTimerOpt() *3600 : 0; @@ -246,30 +246,29 @@ function refreshTwistdayReminder() { var thatSec; posts.sort(function(a,b) { - if (parseInt(a.userpost.time) > parseInt(b.userpost.time)) - return 1; - else - return -1; + return (parseInt(a.userpost.time) > parseInt(b.userpost.time)) ? 1 : -1; }); for (var i = 0; i < posts.length; i++) { - d.setTime(0); - d.setUTCSeconds(posts[i].userpost.time); - if (d.getUTCMonth() === todayMonth && d.getUTCDate() === todayDate) { - addLuckyToList(listCurrent, posts[i]); - } else if (showUpcomingTimer > 0) { - thatSec = Date.UTC(todayYear,d.getUTCMonth(),d.getUTCDate(),d.getUTCHours(),d.getUTCMinutes(),d.getUTCSeconds()) /1000; - if (thatSec > todaySec && thatSec -todaySec <= showUpcomingTimer) { - d.setTime(0); - d.setUTCSeconds(thatSec); - addLuckyToList(listUpcoming, posts[i], d.getTime() /1000); + if (followingUsers.indexOf(posts[i].userpost.n) > -1) { + d.setTime(0); + d.setUTCSeconds(posts[i].userpost.time); + if (d.getUTCMonth() === todayMonth && d.getUTCDate() === todayDate) { + addLuckyToList(listCurrent, posts[i]); + } else if (showUpcomingTimer > 0) { + thatSec = Date.UTC(todayYear,d.getUTCMonth(),d.getUTCDate(),d.getUTCHours(),d.getUTCMinutes(),d.getUTCSeconds()) /1000; + if (thatSec > todaySec && thatSec -todaySec <= showUpcomingTimer) { + d.setTime(0); + d.setUTCSeconds(thatSec); + addLuckyToList(listUpcoming, posts[i], d.getTime() /1000); + } else { + removeLuckyFromList(listCurrent, posts[i]); + removeLuckyFromList(listUpcoming, posts[i]); + } } else { removeLuckyFromList(listCurrent, posts[i]); removeLuckyFromList(listUpcoming, posts[i]); } - } else { - removeLuckyFromList(listCurrent, posts[i]); - removeLuckyFromList(listUpcoming, posts[i]); } } diff --git a/theme_calm/css/style.css b/theme_calm/css/style.css index f142274..41a3a0d 100644 --- a/theme_calm/css/style.css +++ b/theme_calm/css/style.css @@ -1019,7 +1019,7 @@ textarea.splited-post { .twistday-reminder h4 { margin: 1% 1% 1% 16%; - font-size: 90%; + font-size: 10px; color: rgba(0, 0, 0, 0.5); } @@ -1032,6 +1032,10 @@ textarea.splited-post { padding: 5px; } +.twistday-reminder .twister-user-info { + margin: 1.2% 0 -2.8% 0; +} + .twistday-reminder .twister-user-tag, .twistday-reminder .twister-user-full { display: block; @@ -1040,7 +1044,7 @@ textarea.splited-post { } .twistday-reminder .twisterday { - font-size: 80%; + font-size: 11px; margin-left: 11%; } diff --git a/theme_nin/css/style.css b/theme_nin/css/style.css index 46ddf43..bc11378 100644 --- a/theme_nin/css/style.css +++ b/theme_nin/css/style.css @@ -2538,12 +2538,13 @@ ol.toptrends-list a:hover { } .twistday-reminder h3 { + font-size: 0.98em; float: left; } .twistday-reminder h4 { margin: 1% 1% 1% 16%; - font-size: 90%; + font-size: 0.84em; color: rgba(0, 0, 0, 0.5); } @@ -2551,9 +2552,14 @@ ol.toptrends-list a:hover { text-decoration: none; } +.twistday-reminder .current .label, .twistday-reminder .upcoming .label { + margin-right: 10%; +} + .twistday-reminder .twister-user-info { - margin-top: 8px; + margin-top: 1.2%; } + .twistday-reminder .twister-user-tag, .twistday-reminder .twister-user-full { display: block; @@ -2566,7 +2572,7 @@ ol.toptrends-list a:hover { } .twistday-reminder .twisterday { - font-size: 80%; + font-size: 0.8em; margin-left: 8%; } diff --git a/theme_nin/sass/style.sass b/theme_nin/sass/style.sass index 0d8f1c1..6bceb22 100755 --- a/theme_nin/sass/style.sass +++ b/theme_nin/sass/style.sass @@ -585,15 +585,18 @@ ol.toptrends-list small display: none h3 + font-size: 0.98em float: left h4 margin: 1% 1% 1% 16% - font-size: 90% + font-size: 0.84em color: rgba(0, 0, 0, 0.5) a:hover text-decoration: none + .current .label, .upcoming .label + margin-right: 10% .twister-user-info - margin-top: 8px + margin-top: 1.2% .twister-user-tag, .twister-user-full display: block margin: 0 @@ -601,7 +604,7 @@ ol.toptrends-list img.twister-user-photo margin: 0 .twisterday - font-size: 80% + font-size: 0.8em margin-left: 8% &.hover cursor: pointer From 371fa926c918090aa3de920b3fba1a58e2ff8046 Mon Sep 17 00:00:00 2001 From: Simon Grim Date: Thu, 14 May 2015 11:34:09 +0500 Subject: [PATCH 11/12] fix of refreshTwistdayReminder() to remove peer from listUpcoming when adding to listCurrent occurs --- js/interface_home.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/js/interface_home.js b/js/interface_home.js index 84adf92..30173fd 100644 --- a/js/interface_home.js +++ b/js/interface_home.js @@ -231,8 +231,8 @@ function refreshTwistdayReminder() { list.append(item); } } - function removeLuckyFromList(list, post) { - list.find('[data-screen-name='+post.userpost.n+']').closest('li').remove(); + function removeLuckyFromList(list, lucky) { + list.find('[data-screen-name='+lucky+']').closest('li').remove(); } var showUpcomingTimer = ($.Options.getTwistdayReminderShowUpcomingOpt() === 'enable') ? $.Options.getTwistdayReminderShowUpcomingTimerOpt() *3600 : 0; @@ -255,6 +255,7 @@ function refreshTwistdayReminder() { d.setUTCSeconds(posts[i].userpost.time); if (d.getUTCMonth() === todayMonth && d.getUTCDate() === todayDate) { addLuckyToList(listCurrent, posts[i]); + removeLuckyFromList(listUpcoming, posts[i].userpost.n); } else if (showUpcomingTimer > 0) { thatSec = Date.UTC(todayYear,d.getUTCMonth(),d.getUTCDate(),d.getUTCHours(),d.getUTCMinutes(),d.getUTCSeconds()) /1000; if (thatSec > todaySec && thatSec -todaySec <= showUpcomingTimer) { @@ -262,12 +263,12 @@ function refreshTwistdayReminder() { d.setUTCSeconds(thatSec); addLuckyToList(listUpcoming, posts[i], d.getTime() /1000); } else { - removeLuckyFromList(listCurrent, posts[i]); - removeLuckyFromList(listUpcoming, posts[i]); + removeLuckyFromList(listCurrent, posts[i].userpost.n); + removeLuckyFromList(listUpcoming, posts[i].userpost.n); } } else { - removeLuckyFromList(listCurrent, posts[i]); - removeLuckyFromList(listUpcoming, posts[i]); + removeLuckyFromList(listCurrent, posts[i].userpost.n); + removeLuckyFromList(listUpcoming, posts[i].userpost.n); } } } From 2cc86a55fb9c909e35e201963c5873a61223f24c Mon Sep 17 00:00:00 2001 From: Simon Grim Date: Thu, 14 May 2015 11:41:20 +0500 Subject: [PATCH 12/12] fix of htmlFormatMsg() RegExp to allow -+= in hashtags --- js/twister_formatpost.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/twister_formatpost.js b/js/twister_formatpost.js index c962a71..36ce3d7 100644 --- a/js/twister_formatpost.js +++ b/js/twister_formatpost.js @@ -244,7 +244,7 @@ function htmlFormatMsg(msg, mentions) { return _formatText(escapeHtmlEntities(msg) .replace(/(^|[^\/]\B(?!\S*:\/\/\S*@))@\w+\b/g, htmlMention) - .replace(/(^|[^<\/]\B(?!\S*:\/\/\S*#))#[^#\\\/\.,:;\?\!\*\[\]\(\)\{\}\-\+\=\^\|%'"\u201C\u201D\u2026\u2014\u4E00\u3002\uFF0C\uFF1A\uFF1F\uFF01\u3010\u3011>\s]+/g, htmlHashtag) // unicode escaped stuff is '“”…—一。,:?!【】' for our chinese friends + .replace(/(^|[^<\/]\B(?!\S*:\/\/\S*#))#[^#\\\/\.,:;\?\!\*\[\]\(\)\{\}\^\|%'"\u201C\u201D\u2026\u2014\u4E00\u3002\uFF0C\uFF1A\uFF1F\uFF01\u3010\u3011>\s]+/g, htmlHashtag) // unicode escaped stuff is '“”…—一。,:?!【】' for our chinese friends .replace(/\bhttps?:\/\/\S[^>\s]+/ig, htmlHttp) .replace(/([^<\/])\b(?!\S*:\/\/\S*@)\S+@\S+\.\S[^>\s]+/g, htmlEmail) .replace(/\(\d{1,2}\/\d{1,2}\)$/, htmlSplitCounter)