Browse Source

Merge pull request #255 from slr/tasty-fixes-6

couple of small fixes
master
miguelfreitas 10 years ago
parent
commit
5764e60957
  1. 8
      css/style.css
  2. 12
      js/interface_common.js
  3. 52
      js/interface_home.js
  4. 4
      js/mobile_abstract.js
  5. 7
      js/tmobile.js
  6. 28
      js/twister_actions.js
  7. 358
      js/twister_formatpost.js
  8. 88
      js/twister_timeline.js
  9. 8
      theme_calm/css/style.css
  10. 20
      theme_nin/css/style.css
  11. 17
      theme_nin/sass/style.sass

8
css/style.css

@ -836,7 +836,7 @@ ol.toptrends-list {
.twistday-reminder h4 { .twistday-reminder h4 {
margin: 1% 1% 1% 16%; margin: 1% 1% 1% 16%;
font-size: 90%; font-size: 10px;
color: rgba(0, 0, 0, 0.5); color: rgba(0, 0, 0, 0.5);
} }
@ -849,6 +849,10 @@ ol.toptrends-list {
padding: 5px; padding: 5px;
} }
.twistday-reminder .twister-user-info {
margin: 1.2% 0 -2.8% 0;
}
.twistday-reminder .twister-user-tag, .twistday-reminder .twister-user-tag,
.twistday-reminder .twister-user-full { .twistday-reminder .twister-user-full {
display: block; display: block;
@ -857,7 +861,7 @@ ol.toptrends-list {
} }
.twistday-reminder .twisterday { .twistday-reminder .twisterday {
font-size: 80%; font-size: 11px;
margin-left: 11%; margin-left: 11%;
} }

12
js/interface_common.js

@ -636,17 +636,7 @@ var postExpandFunction = function( e, postLi )
/*is there any link in the post?*/ /*is there any link in the post?*/
for (var i=0; i<link.length; i++){ for (var i=0; i<link.length; i++){
if (/((\.jpe{0,1}g)|(\.gif)|(\.png))$/i.test(link[i].href)){ if (/((\.jpe{0,1}g)|(\.gif)|(\.png))$/i.test(link[i].href)){
var url = link[i].href; var url = proxyURL(link[i].href);
if ($.Options.getUseProxyOpt() !== 'disable' && $.Options.getUseProxyForImgOnlyOpt()){
//proxy alternatives may be added to options page...
if ($.Options.getUseProxyOpt() === 'ssl-proxy-my-addr') {
url = 'https://ssl-proxy.my-addr.org/myaddrproxy.php/' +
url.substring(0, url.indexOf(':')) +
url.substr(url.indexOf('/') + 1);
} else if ($.Options.getUseProxyOpt() ==='anonymouse') {
url = 'http://anonymouse.org/cgi-bin/anon-www.cgi/' + url;
}
}
$(previewContainer).append($("<img src='" + url + "' class='image-preview' />")); $(previewContainer).append($("<img src='" + url + "' class='image-preview' />"));
} }
} }

52
js/interface_home.js

@ -218,11 +218,12 @@ function refreshTwistdayReminder() {
item.find('.twister-user-info').attr('data-screen-name', lucky); item.find('.twister-user-info').attr('data-screen-name', lucky);
item.find('.twister-user-name').attr('href', $.MAL.userUrl(lucky)); item.find('.twister-user-name').attr('href', $.MAL.userUrl(lucky));
item.find('.twister-user-tag').text('@' +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') if (typeof(time) !== 'undefined')
item.find('.twisterday').text(timeGmtToText(time)); itemTwisterday.text(timeGmtToText(time));
else else
item.find('.twisterday').text(timeGmtToText(post.userpost.time)); itemTwisterday.text(timeGmtToText(post.userpost.time));
item.find('.twisterday').bind('click', (function(e) { replyInitPopup(e, post); }).bind(post));
getAvatar(lucky, item.find('.twister-user-photo')); getAvatar(lucky, item.find('.twister-user-photo'));
getFullname(lucky, item.find('.twister-user-full')); getFullname(lucky, item.find('.twister-user-full'));
@ -230,8 +231,7 @@ function refreshTwistdayReminder() {
list.append(item); list.append(item);
} }
} }
function removeLuckyFromList(list, post) { function removeLuckyFromList(list, lucky) {
var lucky = post.userpost.n;
list.find('[data-screen-name='+lucky+']').closest('li').remove(); list.find('[data-screen-name='+lucky+']').closest('li').remove();
} }
@ -246,36 +246,36 @@ function refreshTwistdayReminder() {
var thatSec; var thatSec;
posts.sort(function(a,b) { posts.sort(function(a,b) {
if (parseInt(a.userpost.time) > parseInt(b.userpost.time)) return (parseInt(a.userpost.time) > parseInt(b.userpost.time)) ? 1 : -1;
return 1;
else
return -1;
}); });
for (var i = 0; i < posts.length; i++) { for (var i = 0; i < posts.length; i++) {
d.setTime(0); if (followingUsers.indexOf(posts[i].userpost.n) > -1) {
d.setUTCSeconds(posts[i].userpost.time); d.setTime(0);
if (d.getUTCMonth() === todayMonth && d.getUTCDate() === todayDate) { d.setUTCSeconds(posts[i].userpost.time);
addLuckyToList(listCurrent, posts[i]); if (d.getUTCMonth() === todayMonth && d.getUTCDate() === todayDate) {
} else if (showUpcomingTimer > 0) { addLuckyToList(listCurrent, posts[i]);
thatSec = Date.UTC(todayYear,d.getUTCMonth(),d.getUTCDate(),d.getUTCHours(),d.getUTCMinutes(),d.getUTCSeconds()) /1000; removeLuckyFromList(listUpcoming, posts[i].userpost.n);
if (thatSec > todaySec && thatSec -todaySec <= showUpcomingTimer) { } else if (showUpcomingTimer > 0) {
d.setTime(0); thatSec = Date.UTC(todayYear,d.getUTCMonth(),d.getUTCDate(),d.getUTCHours(),d.getUTCMinutes(),d.getUTCSeconds()) /1000;
d.setUTCSeconds(thatSec); if (thatSec > todaySec && thatSec -todaySec <= showUpcomingTimer) {
addLuckyToList(listUpcoming, posts[i], d.getTime() /1000); d.setTime(0);
d.setUTCSeconds(thatSec);
addLuckyToList(listUpcoming, posts[i], d.getTime() /1000);
} else {
removeLuckyFromList(listCurrent, posts[i].userpost.n);
removeLuckyFromList(listUpcoming, posts[i].userpost.n);
}
} else { } else {
removeLuckyFromList(listCurrent, posts[i]); removeLuckyFromList(listCurrent, posts[i].userpost.n);
removeLuckyFromList(listUpcoming, posts[i]); removeLuckyFromList(listUpcoming, posts[i].userpost.n);
} }
} else {
removeLuckyFromList(listCurrent, posts[i]);
removeLuckyFromList(listUpcoming, posts[i]);
} }
} }
if (listCurrent.children().length > 1) if (listCurrent.children().length)
listCurrent.parent().show(); listCurrent.parent().show();
if (listUpcoming.children().length > 1) if (listUpcoming.children().length)
listUpcoming.parent().show(); listUpcoming.parent().show();
$module.find('.refresh').show(); $module.find('.refresh').show();
$module.find('.loading-roller').hide(); $module.find('.loading-roller').hide();

4
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 // before detection attempts we cut out any mentions and links, and replace _ with space
langFilterSubj = string.replace(/@\S\w*|https?:\/\/\S*/g, '').replace(/_+/g, ' ') 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 // 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 // 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 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 // FIXME but first one was recognized as 'hrv' and second as 'pol' and you know it's 'pol' actually
.replace(/\b/g, ' ') .replace(/\b/g, ' ')
// cut out some more symbols // 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 // clear unwanted spaces
.replace(/\s+/g, ' ').trim(); .replace(/\s+/g, ' ').trim();

7
js/tmobile.js

@ -24,8 +24,11 @@ function initializeTwister( redirectNetwork, redirectLogin, cbFunc, cbArg ) {
$.mobile.silentScroll(0); $.mobile.silentScroll(0);
}); });
// reply text counter both newmsg and dmchat // reply text counter both newmsg and dmchat
var $replyText = $( ".post-area-new textarea" ); $('.post-area-new textarea')
$replyText.off('input keyup').on('keyup', replyTextInput, function() { replyTextUpdateRemaining(this); }); .off('input keyup')
.on('keyup', replyTextInput)
.on('keyup', function() { replyTextUpdateRemaining(this); })
;
handlersInstalled = true; handlersInstalled = true;
} }

28
js/twister_actions.js

@ -379,33 +379,7 @@ function processHashtag(postboard, hashtag, data) {
} }
function displayHashtagPending(postboard) { function displayHashtagPending(postboard) {
for( var i = 0; i < _hashtagPendingPosts.length; i++ ) { attachPostsToStream(postboard, _hashtagPendingPosts, false);
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 );
}
}
}
$.MAL.postboardLoaded(); $.MAL.postboardLoaded();
_hashtagPendingPosts = []; _hashtagPendingPosts = [];
} }

358
js/twister_formatpost.js

@ -52,71 +52,71 @@ function postToElem( post, kind, promoted ) {
// Now create the html elements // Now create the html elements
var elem = $.MAL.getPostTemplate().clone(true); var elem = $.MAL.getPostTemplate().clone(true);
elem.removeAttr('id'); elem.removeAttr('id')
elem.addClass(kind); .addClass(kind)
elem.attr('data-time', t); .attr('data-time', t)
;
if( post["isNew"] ) if( post['isNew'] )
elem.addClass('new'); elem.addClass('new');
var postData = elem.find(".post-data"); var postData = elem.find('.post-data');
postData.addClass(kind); postData.addClass(kind)
postData.attr('data-userpost', postJson); .attr('data-userpost', postJson)
postData.attr('data-content_to_rt', content_to_rt); .attr('data-content_to_rt', content_to_rt)
postData.attr('data-content_to_sigrt', content_to_sigrt); .attr('data-content_to_sigrt', content_to_sigrt)
postData.attr('data-screen-name', n); .attr('data-screen-name', n)
postData.attr('data-id', k); .attr('data-id', k)
postData.attr('data-lastk', userpost["lastk"]); .attr('data-lastk', userpost["lastk"])
postData.attr('data-text', msg); .attr('data-text', msg)
if( "reply" in userpost ) { ;
postData.attr('data-replied-to-screen-name', userpost["reply"]["n"]); if( 'reply' in userpost ) {
postData.attr('data-replied-to-id', userpost["reply"]["k"]); postData.attr('data-replied-to-screen-name', userpost.reply.n)
.attr('data-replied-to-id', userpost.reply.k)
postData.find('.post-expand').text(polyglot.t("Show conversation")); .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"]); } else if ( 'rt' in userpost && 'reply' in userpost.rt ) {
postData.attr('data-replied-to-id', userpost["rt"]["reply"]["k"]); postData.attr('data-replied-to-screen-name', userpost.rt.reply.n)
.attr('data-replied-to-id', userpost.rt.reply.k)
postData.find('.post-expand').text(polyglot.t("Show conversation")); .find('.post-expand').text(polyglot.t('Show conversation'))
;
} }
var postInfoName = elem.find(".post-info-name"); var postInfoName = elem.find('.post-info-name');
postInfoName.attr('href',$.MAL.userUrl(n)); postInfoName.text(n).attr('href', $.MAL.userUrl(n));
postInfoName.text(n);
getFullname( n, postInfoName ); getFullname( n, postInfoName );
elem.find(".post-info-tag").text = "@" + n; //elem.find('.post-info-tag').text("@" + n);
getAvatar( n, elem.find(".avatar") ); getAvatar( n, elem.find('.avatar') );
elem.find(".post-info-time").text(timeGmtToText(t)); elem.find('.post-info-time').text(timeGmtToText(t)).attr('title', timeSincePost(t));
elem.find(".post-info-time").attr("title",timeSincePost(t));
var mentions = []; var mentions = [];
htmlFormatMsg( msg, elem.find(".post-text"), mentions); elem.find('.post-text').html(htmlFormatMsg(msg, mentions));
postData.attr('data-text-mentions', mentions); postData.attr('data-text-mentions', mentions);
var replyTo = ""; var replyTo = [];
if( n != defaultScreenName ) if( n !== defaultScreenName )
replyTo += "@" + n + " "; replyTo.push(['@', n, ' '].join(''));
for( var i = 0; i < mentions.length; i++ ) { for (var i = 0; i < mentions.length; i++) {
if( mentions[i] != n && mentions[i] != defaultScreenName ) { if (mentions[i] !== n && mentions[i] !== defaultScreenName)
replyTo += "@" + mentions[i] + " "; replyTo.push(['@', mentions[i], ' '].join(''));
}
}
if(!defaultScreenName)
{
elem.find(".post-area-new textarea").attr("placeholder", polyglot.t("You have to log in to post replies."));
} }
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 else
{ postTextArea.attr('placeholder', polyglot.t('reply_to', { fullname: replyTo })+ '...');
elem.find(".post-area-new textarea").attr("placeholder", polyglot.t("reply_to", { fullname: replyTo })+ "...");
} postData.attr('data-reply-to', replyTo);
elem.find(".post-area-new textarea").attr("data-reply-to",replyTo);
postData.attr("data-reply-to",replyTo);
if( retweeted_by != undefined ) { if( retweeted_by != undefined ) {
elem.find(".post-context").show(); elem.find('.post-context').show();
var retweetedByElem = elem.find(".post-retransmited-by"); elem.find('.post-retransmited-by')
retweetedByElem.attr("href", $.MAL.userUrl(retweeted_by)); .attr('href', $.MAL.userUrl(retweeted_by))
retweetedByElem.text('@'+retweeted_by); .text('@' + retweeted_by)
;
} }
if (typeof(promoted) !== 'undefined' && promoted) { if (typeof(promoted) !== 'undefined' && promoted) {
@ -130,8 +130,9 @@ function postToElem( post, kind, promoted ) {
else else
var mlm = ''; var mlm = '';
elem.append('<div class="langFilterSimData">'+polyglot.t('This post is treated by language filter', {'treated': '<em>'+((post['langFilter']['pass']) ? polyglot.t('passed') : polyglot.t('blocked'))+'</em>'})+'</div>'); elem.append('<div class="langFilterSimData">'+polyglot.t('This post is treated by language filter', {'treated': '<em>'+((post['langFilter']['pass']) ? polyglot.t('passed') : polyglot.t('blocked'))+'</em>'})+'</div>')
elem.append('<div class="langFilterSimData">'+polyglot.t('Reason: this', {'this': '<em>'+post['langFilter']['reason']+'</em>'})+mlm+'</div>'); .append('<div class="langFilterSimData">'+polyglot.t('Reason: this', {'this': '<em>'+post['langFilter']['reason']+'</em>'})+mlm+'</div>')
;
} else { } else {
elem.append('<div class="langFilterSimData">'+polyglot.t('This post is treated by language filter', {'treated': '<em>'+polyglot.t('not analyzed')+'</em>'})+'</div>'); elem.append('<div class="langFilterSimData">'+polyglot.t('This post is treated by language filter', {'treated': '<em>'+polyglot.t('not analyzed')+'</em>'})+'</div>');
} }
@ -158,8 +159,7 @@ function dmDataToSnippetItem(dmData, remoteUser) {
else else
getFullname( remoteUser, dmItem.find("a.post-info-name") ); getFullname( remoteUser, dmItem.find("a.post-info-name") );
dmItem.find(".post-text").html(escapeHtmlEntities(dmData.text)); dmItem.find(".post-text").html(escapeHtmlEntities(dmData.text));
dmItem.find(".post-info-time").text(timeGmtToText(dmData.time)); dmItem.find(".post-info-time").text(timeGmtToText(dmData.time)).attr("title",timeSincePost(dmData.time));
dmItem.find(".post-info-time").attr("title",timeSincePost(dmData.time));
return dmItem; return dmItem;
} }
@ -171,183 +171,109 @@ function dmDataToConversationItem(dmData, localUser, remoteUser) {
dmItem.removeAttr('id'); dmItem.removeAttr('id');
dmItem.addClass(classDm); dmItem.addClass(classDm);
getAvatar(dmData.fromMe ? localUser : remoteUser, dmItem.find(".post-photo").find("img") ); 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").text(timeGmtToText(dmData.time)).attr("title",timeSincePost(dmData.time));
dmItem.find(".post-info-time").attr("title",timeSincePost(dmData.time));
var mentions = []; var mentions = [];
htmlFormatMsg( dmData.text, dmItem.find(".post-text"), mentions); dmItem.find('.post-text').html(htmlFormatMsg(dmData.text, mentions));
return dmItem; return dmItem;
} }
// convert message text to html, featuring @users and links formating. // convert message text to html, featuring @users and links formating.
// todo: hashtags function htmlFormatMsg(msg, mentions) {
function htmlFormatMsg( msg, output, mentions ) { function htmlMention(str, pre) {
var tmp; str = str.replace(new RegExp(['^', pre, '@'].join('')), '').toLowerCase();
var match = null;
var index; mentions.push(str); // FIXME feel the pain of the scope chain
var strUrlRegexp = "http[s]?://";
var strEmailRegexp = "\\S+@\\S+\\.\\S+"; // FIXME we're trying to not interact with DOM, coz' we want to run really fast [to hell of RegExps]
var strSplitCounterR = "\\(\\d{1,2}\\/\\d{1,2}\\)$"; // FIXME actually we should avoid it by dropping a template idea and construct html right here
var reAll = new RegExp("(?:^|[ \\n\\t.,:\\/?!])(#|@|" + strUrlRegexp + "|" + strEmailRegexp + "|" + strSplitCounterR + ")"); html.push($('#msg-user-link-template')[0].outerHTML
var reHttp = new RegExp(strUrlRegexp); .replace(/\bid\s*=\s*"[^]*?"+/ig, '') // $().removeAttr('id')
var reEmail = new RegExp(strEmailRegexp); //.replace(/\bhref\s*=\s*"[^]*?"+/ig, '') // $().removeAttr('href')
var reSplitCounter = new RegExp(strSplitCounterR); .replace(/<a\s+(?=[^>]*?\bclass\s*=\s*"(?=[^"]*?\bopen-profile-modal\b))/ig, ['<a href="', $.MAL.userUrl(str), '" '].join('')) // $().closest('a.open-profile-modal').attr('href', $.MAL.userUrl(username))
.replace(/(<a\s+(?=[^>]*?\bclass\s*=\s*"(?=[^"]*?\bopen-profile-modal\b))[^]*?>)[^]*?(<\/a>)/ig, [pre, '$1@', str, '$2'].join('')) // $().closest('a.open-profile-modal').text('@'+username)
msg = escapeHtmlEntities(msg); );
while( msg != undefined && msg.length ) { return ['>', html.length - 1, '<'].join('');
}
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;
}
}
if( reEmail.exec(match[1]) ) { function htmlHashtag(str, pre) {
output.append(_formatText(msg.substr(0, index))); str = str.replace(new RegExp(['^', pre, '#'].join('')), '');
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;
}
if (reSplitCounter.exec(match[1])) { html.push($('#hashtag-link-template')[0].outerHTML
output.append(_formatText(msg.substr(0, index))); .replace(/\bid\s*=\s*"[^]*?"+/ig, '') // $().removeAttr('id')
tmp = msg.substring(index); //.replace(/\bhref\s*=\s*"[^]*?"+/ig, '') // $().removeAttr('href')
if( tmp.length ) { .replace(/<a\s+(?=[^>]*?\bclass\s*=\s*"(?=[^"]*?\bopen-hashtag-modal\b))/ig, ['<a href="', $.MAL.hashtagUrl(str.toLowerCase()), '" '].join('')) // $().closest('a.open-profile-modal').attr('href', $.MAL.hashtagUrl(hashtag))
var splitCounter = $('<span class="splited-post-counter"></span>'); .replace(/(<a\s+(?=[^>]*?\bclass\s*=\s*"(?=[^"]*?\bopen-hashtag-modal\b))[^]*?>)[^]*?(<\/a>)/ig, [pre, '$1#', str, '$2'].join('')) // $().closest('a.open-profile-modal').text('#'+hashtag)
splitCounter.text(tmp); );
output.append(splitCounter);
msg = "";
continue;
}
}
}
output.append(_formatText(msg)); return ['>', html.length - 1, '<'].join('');
msg = "";
} }
}
// internal function for htmlFormatMsg function htmlHttp(str) {
function _formatText(msg) html.push($('#external-page-link-template')[0].outerHTML
{ .replace(/\bid\s*=\s*"[^]*?"+/ig, '') // $().removeAttr('id')
// TODO: add options for emotions and linefeeds //.replace(/\bhref\s*=\s*"[^]*?"+/ig, '') // $().removeAttr('href')
//msg = $.emotions(msg); .replace(/<a\s+/ig, ['<a href="', proxyURL(str), '" '].join('')) // $().closest('a').attr('href', proxyURL(url))
if( $.Options.getLineFeedsOpt() == "enable" ) .replace(/(<a\s+[^]*?>)[^]*?(<\/a>)/ig, ['$1', str, '$2'].join('')) // $().closest('a').text(url)
msg = msg.replace(/\n/g, '<br />'); );
return msg;
return ['>', html.length - 1, '<'].join('');
}
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\s+/ig, ['<a href="mailto:', str.toLowerCase(), '" '].join('')) // $().closest('a').attr('href', 'mailto:'+url)
.replace(/(<a\s+[^]*?>)[^]*?(<\/a>)/ig, [pre, '$1', str, '$2'].join('')) // $().closest('a').text(url)
);
return ['>', html.length - 1, '<'].join('');
}
function htmlSplitCounter(str) {
html.push(['<span class="splited-post-counter">', str, '</span>'].join(''));
return ['>', html.length - 1, '<'].join('');
}
var html = [];
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+)</g, function(candy, core) {return html[core]})
);
} }
function _extractUsername(s) { function proxyURL(url) {
var username = ""; var proxyOpt = $.Options.getUseProxyOpt();
for( var i = 0; i < s.length; i++ ) { if (proxyOpt !== 'disable' && !$.Options.getUseProxyForImgOnlyOpt()) {
var c = s.charCodeAt(i); // proxy alternatives may be added to options page
if( (c >= 'a'.charCodeAt(0) && c <= 'z'.charCodeAt(0)) || if (proxyOpt === 'ssl-proxy-my-addr') {
(c >= 'A'.charCodeAt(0) && c <= 'Z'.charCodeAt(0)) || url = ['https://ssl-proxy.my-addr.org/myaddrproxy.php/',
(c >= '0'.charCodeAt(0) && c <= '9'.charCodeAt(0)) || url.substring(0, url.indexOf(':')), url.substr(url.indexOf('/') + 1)].join('');
c == '_'.charCodeAt(0) ) { } else if (proxyOpt === 'anonymouse')
username += s[i]; url = ['http://anonymouse.org/cgi-bin/anon-www.cgi/', url].join('');
} else {
break;
}
} }
return username.toLowerCase();
return url;
} }
// internal function for htmlFormatMsg // internal function for htmlFormatMsg
function _extractHashtag(s) { // TODO: add options for emotions; msg = $.emotions(msg);
var hashtag = ""; // TODO: add at least basic markdown (optional) like *text* -> bold text and _text_ -> italic text
s = reverseHtmlEntities(s); function _formatText(msg) {
for( var i = 0; i < s.length; i++ ) { if ($.Options.getLineFeedsOpt() === 'enable')
if( " \n\t.,:/?!;'\"()[]{}*#".indexOf(s[i]) < 0 ) { msg = msg.replace(/\n/g, '<br />');
hashtag += s[i];
} else { return msg;
break;
}
}
return hashtag;
} }
function escapeHtmlEntities(str) { function escapeHtmlEntities(str) {

88
js/twister_timeline.js

@ -160,7 +160,7 @@ function processReceivedPosts(req, posts)
i--; i--;
} }
} }
showPosts(req, posts); updateTimeline(req, posts);
req.doneReportProcessing(posts.length); req.doneReportProcessing(posts.length);
//if the count of recieved posts less or equals to requested then... //if the count of recieved posts less or equals to requested then...
@ -182,50 +182,58 @@ function processReceivedPosts(req, posts)
} }
} }
function showPosts(req, posts) function updateTimeline(req, posts) {
{ attachPostsToStream($.MAL.getStreamPostsParent(), posts, req.getspam);
//console.log('showPosts:'); for (var i = 0; i < posts.length; i++) {
//console.log(req); req.reportProcessedPost(posts[i]['userpost']['n'], posts[i]['userpost']['k'], true);
}
}
function attachPostsToStream(stream, posts, isPromoted) {
//console.log('attachPostsToStream:');
//console.log(posts); //console.log(posts);
var streamItemsParent = $.MAL.getStreamPostsParent(); function byTimeInDescendingOrder(a, b) {
return (a.time > b.time) ? -1 : 1;
}
for( var i = 0; i < posts.length; i++ ) { var streamItems = stream.children();
var post = posts[i]; var streamPosts = [];
//console.log(post);
var streamPost = postToElem(post, "original", req.getspam); for (var i = 0; i < streamItems.length; i++) {
var timePost = post["userpost"]["time"]; var streamItem = streamItems.eq(i);
streamPost.attr("data-time",timePost); streamPosts.push({item: streamItem, time: parseInt(streamItem.attr('data-time'))});
}
// post will only be shown if appended to the stream list //streamPosts.sort(byTimeInDescendingOrder); // currently here is no reason to sort it, it should be ok
var streamPostAppended = false;
for (var i = 0; i < posts.length; i++) {
// insert the post in timeline ordered by (you guessed) time //console.log(posts[i]);
// FIXME: lame! searching everything everytime. please optimize! var isAttached = false;
var streamItems = streamItemsParent.children(); var intrantPost = {item: postToElem(posts[i], 'original', isPromoted), time: posts[i].userpost.time};
if( streamItems.length == 0) { intrantPost.item.attr('data-time', intrantPost.time);
// timeline is empty
streamItemsParent.append( streamPost ); if (streamPosts.length) {
streamPostAppended = true; // check to avoid twist duplication and insert the post in timeline ordered by (you guessed) time
} else { for (var j = 0; j < streamPosts.length; j++) {
var j = 0; if (intrantPost.time === streamPosts[j].time &&
for( j = 0; j < streamItems.length; j++) { intrantPost.item[0].innerHTML === streamPosts[j].item[0].innerHTML) {
var streamItem = streamItems.eq(j); isAttached = true;
var timeItem = streamItem.attr("data-time"); console.log('appending of duplicate twist prevented');
if( timeItem == undefined || break;
timePost > parseInt(timeItem) ) { } else if (intrantPost.time > streamPosts[j].time) {
// this post in stream is older, so post must be inserted above // this post in stream is older, so post must be inserted above
streamItem.before(streamPost); intrantPost.item.insertBefore(streamPosts[j].item).show();
streamPostAppended = true; streamPosts.push(intrantPost);
streamPosts.sort(byTimeInDescendingOrder);
isAttached = true;
break; break;
} }
} }
} }
if (!streamPostAppended) if (!isAttached) {
streamItemsParent.append( streamPost ); intrantPost.item.appendTo(stream).show();
streamPosts.push(intrantPost);
streamPostAppended = true; streamPosts.sort(byTimeInDescendingOrder);
streamPost.show(); }
req.reportProcessedPost(post["userpost"]["n"],post["userpost"]["k"], streamPostAppended);
} }
} }
@ -241,7 +249,7 @@ function requestTimelineUpdate(mode, count, timelineUsers, getspam)
var req = new requestObj(timelineUsers, mode, count, getspam); var req = new requestObj(timelineUsers, mode, count, getspam);
if (mode === 'pending') { if (mode === 'pending') {
req.mode = 'latest'; req.mode = 'latest';
showPosts(req, _newPostsPending); updateTimeline(req, _newPostsPending);
_newPostsPending = []; _newPostsPending = [];
$.MAL.reportNewPosts(_newPostsPending.length); $.MAL.reportNewPosts(_newPostsPending.length);
$.MAL.postboardLoaded(); $.MAL.postboardLoaded();
@ -323,7 +331,7 @@ function processNewPostsConfirmation(expected, posts)
} }
if ( sendedPostsPending.length > 0 ) { if ( sendedPostsPending.length > 0 ) {
var req = new requestObj([defaultScreenName],'latest',sendedPostsPending.length,promotedPostsOnly); var req = new requestObj([defaultScreenName],'latest',sendedPostsPending.length,promotedPostsOnly);
showPosts(req, sendedPostsPending); updateTimeline(req, sendedPostsPending);
} }
if( posts.length < expected ) { if( posts.length < expected ) {

8
theme_calm/css/style.css

@ -1019,7 +1019,7 @@ textarea.splited-post {
.twistday-reminder h4 { .twistday-reminder h4 {
margin: 1% 1% 1% 16%; margin: 1% 1% 1% 16%;
font-size: 90%; font-size: 10px;
color: rgba(0, 0, 0, 0.5); color: rgba(0, 0, 0, 0.5);
} }
@ -1032,6 +1032,10 @@ textarea.splited-post {
padding: 5px; padding: 5px;
} }
.twistday-reminder .twister-user-info {
margin: 1.2% 0 -2.8% 0;
}
.twistday-reminder .twister-user-tag, .twistday-reminder .twister-user-tag,
.twistday-reminder .twister-user-full { .twistday-reminder .twister-user-full {
display: block; display: block;
@ -1040,7 +1044,7 @@ textarea.splited-post {
} }
.twistday-reminder .twisterday { .twistday-reminder .twisterday {
font-size: 80%; font-size: 11px;
margin-left: 11%; margin-left: 11%;
} }

20
theme_nin/css/style.css

@ -2538,12 +2538,13 @@ ol.toptrends-list a:hover {
} }
.twistday-reminder h3 { .twistday-reminder h3 {
font-size: 0.98em;
float: left; float: left;
} }
.twistday-reminder h4 { .twistday-reminder h4 {
margin: 1% 1% 1% 16%; margin: 1% 1% 1% 16%;
font-size: 90%; font-size: 0.84em;
color: rgba(0, 0, 0, 0.5); color: rgba(0, 0, 0, 0.5);
} }
@ -2551,9 +2552,14 @@ ol.toptrends-list a:hover {
text-decoration: none; text-decoration: none;
} }
.twistday-reminder .current .label, .twistday-reminder .upcoming .label {
margin-right: 10%;
}
.twistday-reminder .twister-user-info { .twistday-reminder .twister-user-info {
margin-top: 8px; margin-top: 1.2%;
} }
.twistday-reminder .twister-user-tag, .twistday-reminder .twister-user-tag,
.twistday-reminder .twister-user-full { .twistday-reminder .twister-user-full {
display: block; display: block;
@ -2566,7 +2572,7 @@ ol.toptrends-list a:hover {
} }
.twistday-reminder .twisterday { .twistday-reminder .twisterday {
font-size: 80%; font-size: 0.8em;
margin-left: 8%; margin-left: 8%;
} }
@ -2966,10 +2972,10 @@ ol.toptrends-list a:hover {
/********* NEW USER MODAL************* */ /********* NEW USER MODAL************* */
/* line 861, ../sass/style.sass */ /* line 861, ../sass/style.sass */
.new-user .modal-wrapper { .new-user .modal-wrapper {
width: 520px; width: 640px;
height: 600px; height: 600px;
top: 10%; top: 10%;
margin: 0 0 0 -260px; margin: 0 0 0 -320px;
overflow-x: hidden; overflow-x: hidden;
overflow-y: hidden; overflow-y: hidden;
} }
@ -2987,13 +2993,15 @@ ol.toptrends-list a:hover {
} }
/* line 874, ../sass/style.sass */ /* line 874, ../sass/style.sass */
.new-user .emphasis { .new-user .emphasis {
font-size: 18px;
text-align: center; text-align: center;
} }
/* line 877, ../sass/style.sass */ /* line 877, ../sass/style.sass */
.new-user .secret-key { .new-user .secret-key {
display: block;
margin-top: 8px;
color: black; color: black;
font-weight: bold; font-weight: bold;
font-size: 110%;
} }
/******** HASHTAG MODAL********** */ /******** HASHTAG MODAL********** */

17
theme_nin/sass/style.sass

@ -585,15 +585,18 @@ ol.toptrends-list
small small
display: none display: none
h3 h3
font-size: 0.98em
float: left float: left
h4 h4
margin: 1% 1% 1% 16% margin: 1% 1% 1% 16%
font-size: 90% font-size: 0.84em
color: rgba(0, 0, 0, 0.5) color: rgba(0, 0, 0, 0.5)
a:hover a:hover
text-decoration: none text-decoration: none
.current .label, .upcoming .label
margin-right: 10%
.twister-user-info .twister-user-info
margin-top: 8px margin-top: 1.2%
.twister-user-tag, .twister-user-full .twister-user-tag, .twister-user-full
display: block display: block
margin: 0 margin: 0
@ -601,7 +604,7 @@ ol.toptrends-list
img.twister-user-photo img.twister-user-photo
margin: 0 margin: 0
.twisterday .twisterday
font-size: 80% font-size: 0.8em
margin-left: 8% margin-left: 8%
&.hover &.hover
cursor: pointer cursor: pointer
@ -914,10 +917,10 @@ ol.toptrends-list
.new-user .new-user
.modal-wrapper .modal-wrapper
width: $postboard-modal-width width: 640px
height: 600px height: 600px
top: 10% top: 10%
margin: 0 0 0 0-($postboard-modal-width/2) margin: 0 0 0 -320px
overflow-x: hidden overflow-x: hidden
overflow-y: hidden overflow-y: hidden
.modal-content .modal-content
@ -927,11 +930,13 @@ ol.toptrends-list
.text .text
margin: 0 0 15px 0 margin: 0 0 15px 0
.emphasis .emphasis
font-size: 18px
text-align: center text-align: center
.secret-key .secret-key
display: block
margin-top: 8px
color: rgba(0.5, 0, 0, 1) color: rgba(0.5, 0, 0, 1)
font-weight: bold font-weight: bold
font-size: 110%
/******** HASHTAG MODAL***********/ /******** HASHTAG MODAL***********/

Loading…
Cancel
Save