Browse Source

Merge pull request #366 from erqan/newusers

newcomers' exploration module
readme-update
Сёма Мрачный 8 years ago committed by GitHub
parent
commit
f385ed289d
  1. 29
      css/style.css
  2. 19
      home.html
  3. 54
      js/interface_common.js
  4. 31
      js/interface_home.js
  5. 52
      js/interface_localization.js
  6. 11
      js/options.js
  7. 153
      js/twister_following.js
  8. 38
      js/twister_network.js
  9. 20
      options.html
  10. 29
      theme_calm/css/style.css
  11. 41
      theme_nin/css/style.css

29
css/style.css

@ -843,13 +843,13 @@ textarea.splited-post {
/*********************************** /***********************************
********************* WHO TO FOLLOW ********************* WHO TO FOLLOW
***********************************/ ***********************************/
.who-to-follow .who-to-follow,
{ .new-users {
padding: 10px; padding: 10px;
margin-bottom: 10px; margin-bottom: 10px;
} }
.who-to-follow h3 .who-to-follow h3,
{ .new-users h3 {
display: inline; display: inline;
} }
.twister-user .twister-user
@ -1943,32 +1943,39 @@ ol.toptrends-list {
********* WHO TO FOLLOW MODAL ******** ********* WHO TO FOLLOW MODAL ********
**************************************/ **************************************/
.who-to-follow-modal ol { .who-to-follow-modal ol,
.new-users-modal ol {
margin: 5px; margin: 5px;
} }
.who-to-follow-modal .open-profile-modal:hover { .who-to-follow-modal .open-profile-modal:hover,
.new-users-modal .open-profile-modal:hover {
text-decoration: none; text-decoration: none;
} }
.who-to-follow-modal .open-profile-modal span { .who-to-follow-modal .open-profile-modal span,
.new-users-modal .open-profile-modal span {
vertical-align: middle; vertical-align: middle;
} }
.who-to-follow-modal .open-profile-modal span:hover { .who-to-follow-modal .open-profile-modal span:hover,
.new-users-modal .open-profile-modal span:hover {
text-decoration: underline; text-decoration: underline;
} }
.who-to-follow-modal .follow { .who-to-follow-modal .follow,
.new-users-modal .follow {
float: right; float: right;
margin: -30px 10px 0 10px; margin: -30px 10px 0 10px;
} }
.who-to-follow-modal .twister-user-info span { .who-to-follow-modal .twister-user-info span,
.new-users-modal .twister-user-info span {
vertical-align: bottom; vertical-align: bottom;
} }
.who-to-follow-modal .bio { .who-to-follow-modal .bio,
.new-users-modal .bio {
font-size: 12px; font-size: 12px;
color: rgba( 0, 0, 0, .6 ); color: rgba( 0, 0, 0, .6 );
} }

19
home.html

@ -146,6 +146,8 @@
<!-- TWISTDAY REMINDER MODULE --> <!-- TWISTDAY REMINDER MODULE -->
<div class="module twistday-reminder" style="display: none;"></div> <div class="module twistday-reminder" style="display: none;"></div>
<div class="module new-users" style="display: none;"></div>
</div> </div>
<!-- LADO ESQUERDO DE MÓDULOS END --> <!-- LADO ESQUERDO DE MÓDULOS END -->
@ -227,6 +229,23 @@
</div> </div>
</div> </div>
<!-- TEMPLATE OF NEW-USERS MODULE -->
<div id="new-users-template">
<div>
<h3 class="label">New Users</h3>
<small>.</small>
<a class="refresh-users">Refresh</a>
<small>.</small>
<a class="view-all-users" href="#newusers">View All</a>
<ol class="follow-suggestions">
<!-- use "follow-suggestion-template" here -->
</ol>
</div>
<div class="loading-roller">
<div></div>
</div>
</div>
<!-- TEMPLATE DE TOP TRENDS MODULE --> <!-- TEMPLATE DE TOP TRENDS MODULE -->
<div id="toptrends-template"> <div id="toptrends-template">
<div> <div>

54
js/interface_common.js

@ -119,6 +119,9 @@ function closeModal(req, switchMode) {
else else
this.remove(); // if it's minimized it will be removed with twister.modal[i].drapper this.remove(); // if it's minimized it will be removed with twister.modal[i].drapper
if (typeof twister.modal[i].onClose === 'function')
twister.modal[i].onClose(twister.modal[i].closeArg);
twister.modal[i].drapper.remove(); twister.modal[i].drapper.remove();
twister.modal[i] = undefined; twister.modal[i] = undefined;
} }
@ -731,9 +734,6 @@ function addPeerToFollowingList(list, peerAlias) {
} }
function fillWhoToFollowModal(list, hlist, start) { function fillWhoToFollowModal(list, hlist, start) {
var itemTmp = $('#follow-suggestion-template').clone(true)
.removeAttr('id');
for (var i = 0; i < followingUsers.length && list.length < start + 20; i++) { for (var i = 0; i < followingUsers.length && list.length < start + 20; i++) {
if (typeof twisterFollowingO.followingsFollowings[followingUsers[i]] !== 'undefined') { if (typeof twisterFollowingO.followingsFollowings[followingUsers[i]] !== 'undefined') {
for (var j = 0; j < twisterFollowingO.followingsFollowings[followingUsers[i]].following.length && list.length < start + 25; j++) { for (var j = 0; j < twisterFollowingO.followingsFollowings[followingUsers[i]].following.length && list.length < start + 25; j++) {
@ -741,27 +741,11 @@ function fillWhoToFollowModal(list, hlist, start) {
if (followingUsers.indexOf(utf) < 0 && list.indexOf(utf) < 0) { if (followingUsers.indexOf(utf) < 0 && list.indexOf(utf) < 0) {
list.push(utf); list.push(utf);
var item = itemTmp.clone(true); processWhoToFollowSuggestion(hlist, utf, followingUsers[i]);
item.find('.twister-user-info').attr('data-screen-name', utf);
item.find('.twister-user-name').attr('href', $.MAL.userUrl(utf));
item.find('.twister-by-user-name').attr('href', $.MAL.userUrl(followingUsers[i]));
item.find('.twister-user-tag').text('@' + utf);
getAvatar(utf, item.find('.twister-user-photo'));
getFullname(utf, item.find('.twister-user-full'));
getBioToElem(utf, item.find('.bio'));
getFullname(followingUsers[i], item.find('.followed-by').text(followingUsers[i]));
getStatusTime(utf, item.find('.latest-activity .time'));
item.find('.twister-user-remove').remove();
hlist.append(item);
} }
} }
} }
} }
itemTmp.remove();
if (i >= followingUsers.length - 1) if (i >= followingUsers.length - 1)
return false; return false;
@ -782,12 +766,36 @@ function openWhoToFollowModal() {
modal.content.on('scroll', function() { modal.content.on('scroll', function() {
if (modal.content.scrollTop() >= hlist.height() - modal.content.height() - 20) { if (modal.content.scrollTop() >= hlist.height() - modal.content.height() - 20) {
if (!fillWhoToFollowModal(tmplist, hlist, tmplist.length)) if (!fillWhoToFollowModal(tmplist, modal.self, tmplist.length))
modal.content.off('scroll'); modal.content.off('scroll');
} }
}); });
fillWhoToFollowModal(tmplist, hlist, 0); fillWhoToFollowModal(tmplist, modal.self, 0);
}
function openNewUsersModal() {
var modal = openModal({
classAdd: 'new-users-modal',
title: polyglot.t('New Users'),
onClose: function() {
NewUserSearch.isNewUserModalOpen = false;
}
});
var hlist = $('<ol class="follow-suggestions"></ol>')
.appendTo(modal.content);
var count = 15;
modal.content.on('scroll', function() {
if (modal.content.scrollTop() >= hlist.height() - modal.content.height() - 20) {
if (newUsers.getLastNUsers(5, count, modal.self))
count += 5;
}
});
NewUserSearch.isNewUserModalOpen = true;
newUsers.getLastNUsers(15, 0, modal.self);
} }
function openModalUriShortener() function openModalUriShortener()
@ -1237,6 +1245,8 @@ function loadModalFromHash() {
openWhoToFollowModal(); openWhoToFollowModal();
else if (hashstring === '#/uri-shortener') else if (hashstring === '#/uri-shortener')
openModalUriShortener(); openModalUriShortener();
else if (hashstring === '#newusers')
openNewUsersModal();
} }
function initHashWatching() { function initHashWatching() {

31
js/interface_home.js

@ -100,6 +100,11 @@ var InterfaceFunctions = function() {
else else
killInterfaceModule('who-to-follow'); killInterfaceModule('who-to-follow');
if ($.Options.NewUsers.val === 'enable')
initNewUsers();
else
killInterfaceModule('new-users');
if ($.Options.TwistdayReminder.val === 'enable') if ($.Options.TwistdayReminder.val === 'enable')
initTwistdayReminder(); initTwistdayReminder();
else else
@ -113,7 +118,7 @@ var InterfaceFunctions = function() {
if ($.Options.WebTorrent.val === 'enable') if ($.Options.WebTorrent.val === 'enable')
initWebTorrent(); initWebTorrent();
} }
} };
function initTopTrends() { function initTopTrends() {
var $tt = initInterfaceModule('toptrends'); var $tt = initInterfaceModule('toptrends');
@ -200,6 +205,30 @@ function refreshWhoToFollow() {
} }
} }
function initNewUsers() {
var nus = initInterfaceModule('new-users');
newUsers = NewUserSearch();
if (nus.length) {
var nusRefresh = nus.find('.refresh-users');
nusRefresh.on('click', refreshNewUsers);
setTimeout(function() {nusRefresh.click();}, 100);
}
}
function refreshNewUsers() {
var module = $('.module.new-users');
var list = module.find('.follow-suggestions');
if (list.length) {
list.empty().hide();
module.find('.refresh-users').hide();
module.find('.loading-roller').show();
newUsers.getLastNUsers(3, 0, module, true);
}
}
function initTwistdayReminder() { function initTwistdayReminder() {
var $module = initInterfaceModule('twistday-reminder'); var $module = initInterfaceModule('twistday-reminder');

52
js/interface_localization.js

@ -372,7 +372,9 @@ if(preferredLanguage == "en"){
"Favorites": "Favorites", "Favorites": "Favorites",
"You have to log in to favorite messages.": "You have to log in to favorite messages.", "You have to log in to favorite messages.": "You have to log in to favorite messages.",
"fav_this": "Is it for you only?", "fav_this": "Is it for you only?",
"Last activity": "Last activity" "Last activity": "Last activity",
"New Users": "New Users",
"Live tracking" : "Live tracking"
}; };
} }
if(preferredLanguage == "es"){ if(preferredLanguage == "es"){
@ -717,7 +719,9 @@ if(preferredLanguage == "es"){
"Favorites": "Favorites", "Favorites": "Favorites",
"You have to log in to favorite messages.": "You have to log in to favorite messages.", "You have to log in to favorite messages.": "You have to log in to favorite messages.",
"fav_this": "Is it for you only?", "fav_this": "Is it for you only?",
"Last activity": "Last activity" "Last activity": "Last activity",
"New Users": "New Users",
"Live tracking" : "Live tracking"
}; };
} }
@ -1061,7 +1065,9 @@ if(preferredLanguage == "uk"){
"Favorites": "Favorites", "Favorites": "Favorites",
"You have to log in to favorite messages.": "You have to log in to favorite messages.", "You have to log in to favorite messages.": "You have to log in to favorite messages.",
"fav_this": "Is it for you only?", "fav_this": "Is it for you only?",
"Last activity": "Last activity" "Last activity": "Last activity",
"New Users": "New Users",
"Live tracking" : "Live tracking"
}; };
} }
@ -1410,7 +1416,9 @@ if(preferredLanguage == "zh-CN"){
"Favorites": "Favorites", "Favorites": "Favorites",
"You have to log in to favorite messages.": "You have to log in to favorite messages.", "You have to log in to favorite messages.": "You have to log in to favorite messages.",
"fav_this": "Is it for you only?", "fav_this": "Is it for you only?",
"Last activity": "Last activity" "Last activity": "Last activity",
"New Users": "New Users",
"Live tracking" : "Live tracking"
}; };
} }
@ -1756,7 +1764,9 @@ if(preferredLanguage == "nl"){
"Favorites": "Favorites", "Favorites": "Favorites",
"You have to log in to favorite messages.": "You have to log in to favorite messages.", "You have to log in to favorite messages.": "You have to log in to favorite messages.",
"fav_this": "Is it for you only?", "fav_this": "Is it for you only?",
"Last activity": "Last activity" "Last activity": "Last activity",
"New Users": "New Users",
"Live tracking" : "Live tracking"
}; };
} }
@ -2100,7 +2110,9 @@ if(preferredLanguage == "it"){
"Favorites": "Favorites", "Favorites": "Favorites",
"You have to log in to favorite messages.": "You have to log in to favorite messages.", "You have to log in to favorite messages.": "You have to log in to favorite messages.",
"fav_this": "Is it for you only?", "fav_this": "Is it for you only?",
"Last activity": "Last activity" "Last activity": "Last activity",
"New Users": "New Users",
"Live tracking" : "Live tracking"
}; };
} }
@ -2445,7 +2457,9 @@ if(preferredLanguage == "fr"){
"users_favs": "Favorites of @%{username}", "users_favs": "Favorites of @%{username}",
"Favorites": "Favorites", "Favorites": "Favorites",
"You have to log in to favorite messages.": "You have to log in to favorite messages.", "You have to log in to favorite messages.": "You have to log in to favorite messages.",
"Last activity": "Last activity" "Last activity": "Last activity",
"New Users": "New Users",
"Live tracking" : "Live tracking"
}; };
} }
@ -2797,7 +2811,9 @@ if(preferredLanguage == "ru"){
"Favorites": "Favorites", "Favorites": "Favorites",
"You have to log in to favorite messages.": "You have to log in to favorite messages.", "You have to log in to favorite messages.": "You have to log in to favorite messages.",
"fav_this": "Is it for you only?", "fav_this": "Is it for you only?",
"Last activity": "Last activity" "Last activity": "Last activity",
"New Users": "New Users",
"Live tracking" : "Live tracking"
}; };
} }
@ -3145,7 +3161,9 @@ if(preferredLanguage == "de"){
"Favorites": "Favorites", "Favorites": "Favorites",
"You have to log in to favorite messages.": "You have to log in to favorite messages.", "You have to log in to favorite messages.": "You have to log in to favorite messages.",
"fav_this": "Is it for you only?", "fav_this": "Is it for you only?",
"Last activity": "Last activity" "Last activity": "Last activity",
"New Users": "New Users",
"Live tracking" : "Live tracking"
}; };
} }
@ -3488,7 +3506,9 @@ if(preferredLanguage == "ja"){
"Favorites": "Favorites", "Favorites": "Favorites",
"You have to log in to favorite messages.": "You have to log in to favorite messages.", "You have to log in to favorite messages.": "You have to log in to favorite messages.",
"fav_this": "Is it for you only?", "fav_this": "Is it for you only?",
"Last activity": "Last activity" "Last activity": "Last activity",
"New Users": "New Users",
"Live tracking" : "Live tracking"
}; };
} }
@ -3837,7 +3857,9 @@ if(preferredLanguage == "pt-BR"){
"Favorites": "Favorites", "Favorites": "Favorites",
"You have to log in to favorite messages.": "You have to log in to favorite messages.", "You have to log in to favorite messages.": "You have to log in to favorite messages.",
"fav_this": "Is it for you only?", "fav_this": "Is it for you only?",
"Last activity": "Last activity" "Last activity": "Last activity",
"New Users": "New Users",
"Live tracking" : "Live tracking"
}; };
} }
@ -4182,7 +4204,9 @@ if(preferredLanguage == "tr"){
"Favorites": "Favoriler", "Favorites": "Favoriler",
"You have to log in to favorite messages.": "İletileri favorine eklemek için giriş yapmalısın.", "You have to log in to favorite messages.": "İletileri favorine eklemek için giriş yapmalısın.",
"fav_this": "Sana özel mi?", "fav_this": "Sana özel mi?",
"Last activity": "Son etkinlik" "Last activity": "Son etkinlik",
"New Users": "Yeni Kullanıcılar",
"Live tracking" : "Canlı takip"
}; };
} }
@ -4530,7 +4554,9 @@ if(preferredLanguage == "cs"){
"Favorites": "Favorites", "Favorites": "Favorites",
"You have to log in to favorite messages.": "You have to log in to favorite messages.", "You have to log in to favorite messages.": "You have to log in to favorite messages.",
"fav_this": "Is it for you only?", "fav_this": "Is it for you only?",
"Last activity": "Last activity" "Last activity": "Last activity",
"New Users": "New Users",
"Live tracking" : "Live tracking"
}; };
} }

11
js/options.js

@ -41,6 +41,17 @@ function twisterOptions() {
name: 'WhoToFollow', name: 'WhoToFollow',
valDefault: 'enable' valDefault: 'enable'
}); });
this.add({
name: 'NewUsers',
valDefault: 'enable',
tickMethod: function (elem) {
$('#NewUsersCont').css('display', (elem.value === 'enable') ? 'block' : 'none');
}
});
this.add({
name: 'NewUsersLiveTracking',
valDefault: 'enable'
});
this.add({ this.add({
name: 'TwistdayReminder', name: 'TwistdayReminder',
valDefault: 'enable', valDefault: 'enable',

153
js/twister_following.js

@ -17,6 +17,7 @@ var _lastSearchUsersResultsRemovedFromDHTgetQueue = true;
var _lastLoadFromDhtTime = 0; var _lastLoadFromDhtTime = 0;
var twisterFollowingO = undefined; var twisterFollowingO = undefined;
var newUsers = undefined;
var TwisterFollowing = function (user) { var TwisterFollowing = function (user) {
if (!(this instanceof TwisterFollowing)) if (!(this instanceof TwisterFollowing))
@ -427,6 +428,127 @@ function followingEmptyOrMyself() {
return (!followingUsers.length || (followingUsers.length === 1 && followingUsers[0] === defaultScreenName)) return (!followingUsers.length || (followingUsers.length === 1 && followingUsers[0] === defaultScreenName))
} }
/* NEW USER SEARCH */
var NewUserSearch = function(){
if (!(this instanceof NewUserSearch))
return new NewUserSearch();
this.init();
};
NewUserSearch.knownNewUsers = [];
NewUserSearch.isNewUserThRunning = false;
NewUserSearch.isNewUserModalOpen = false;
NewUserSearch.startProcessedBlock = -1;
NewUserSearch.lastProcessedBlock = -1;
NewUserSearch.processBlockUsersProxy = function(block, args){
if (args.obj instanceof NewUserSearch)
args.obj.processBlockUsers(block, args);
};
NewUserSearch.live = function(module) {
newUsers.getNewUsers(module);
};
NewUserSearch.processBestBlockUsersProxy = function(block, args){
if (block.height > NewUserSearch.startProcessedBlock) {
if (args.obj instanceof NewUserSearch)
args.obj.processBlockUsers(block, {obj: args.obj, args: {n: 0, offset: 0, module: args.args.module, prepend: true, live: true}});
}
};
NewUserSearch.prototype = {
storage: undefined,
isForced: false,
init: function() {
this.storage = $.initNamespaceStorage(defaultScreenName).sessionStorage;
if (this.storage.isSet("knownNewUsers"))
NewUserSearch.knownNewUsers = this.storage.get("knownNewUsers");
if (this.storage.isSet("lastProcessedBlock"))
NewUserSearch.lastProcessedBlock = this.storage.get("lastProcessedBlock");
if (this.storage.isSet("startProcessedBlock"))
NewUserSearch.startProcessedBlock = this.storage.get("startProcessedBlock");
if ($.Options.NewUsersLiveTracking.val === 'enable')
setInterval(function(){NewUserSearch.live($('.module.new-users'));}, 10000);
},
save: function(){
this.storage.set("knownNewUsers", NewUserSearch.knownNewUsers);
this.storage.set("lastProcessedBlock", NewUserSearch.lastProcessedBlock);
this.storage.set("startProcessedBlock", NewUserSearch.startProcessedBlock);
},
getNewUsers: function(module) {
requestBestBlock(NewUserSearch.processBestBlockUsersProxy, {obj: this, args: {module: module}});
},
getLastNUsers: function (n, offset, module, forced) {
for (var i = offset; i < NewUserSearch.knownNewUsers.length && i < offset + n; i++)
processWhoToFollowSuggestion(module, NewUserSearch.knownNewUsers[i]);
if (NewUserSearch.knownNewUsers.length >= n + offset) {
NewUserSearch.isNewUserThRunning = false;
return true;
}
if (NewUserSearch.isNewUserThRunning)
return false;
NewUserSearch.isNewUserThRunning = true;
this.isForced = forced;
if (NewUserSearch.lastProcessedBlock == -1)
requestBestBlock(NewUserSearch.processBlockUsersProxy, {obj: this, args: {n: n, offset: offset, module: module}});
else
requestNthBlock(NewUserSearch.lastProcessedBlock - 1, NewUserSearch.processBlockUsersProxy, {obj: this, args: {n: n, offset: offset, module: module}});
return true;
},
processBlockUsers: function (block, args) {
if (NewUserSearch.startProcessedBlock === -1)
NewUserSearch.startProcessedBlock = block.height;
if (NewUserSearch.lastProcessedBlock === -1 || block.height < NewUserSearch.lastProcessedBlock)
NewUserSearch.lastProcessedBlock = block.height;
if ((this.isForced || NewUserSearch.isNewUserModalOpen) &&
NewUserSearch.knownNewUsers.length + block.usernames.length < args.args.n + args.args.offset &&
typeof block.previousblockhash !== 'undefined') {
setTimeout(function () {
requestBlock(block.previousblockhash, NewUserSearch.processBlockUsersProxy, {obj: args.obj, args: args.args});
}, 10);
} else {
NewUserSearch.isNewUserThRunning = false;
this.isForced = false;
}
var i = 0;
for (; i < block.usernames.length; i++) {
if (NewUserSearch.knownNewUsers.indexOf(block.usernames[i]) == -1) {
processWhoToFollowSuggestion(args.args.module, block.usernames[i], undefined, args.args.prepend);
if (args.args.prepend)
NewUserSearch.knownNewUsers.unshift(block.usernames[i]);
else
NewUserSearch.knownNewUsers.push(block.usernames[i]);
if (!args.args.live && NewUserSearch.knownNewUsers.length >= args.args.n + args.args.offset)
break;
}
}
for (; i < block.usernames.length; i++) {
if (NewUserSearch.knownNewUsers.indexOf(block.usernames[i]) == -1) {
if (args.args.prepend)
NewUserSearch.knownNewUsers.unshift(block.usernames[i]);
else
NewUserSearch.knownNewUsers.push(block.usernames[i]);
}
}
this.save();
}
};
// randomly choose a user we follow, get "following1" from him and them // randomly choose a user we follow, get "following1" from him and them
// choose a suggestion from their list. this function could be way better, but // choose a suggestion from their list. this function could be way better, but
// that's about the simplest we may get to start with. // that's about the simplest we may get to start with.
@ -446,10 +568,11 @@ function getRandomFollowSuggestion() {
var suggested = false; var suggested = false;
var j = Math.floor(Math.random() * twisterFollowingO.followingsFollowings[followingUsers[i]].following.length); var j = Math.floor(Math.random() * twisterFollowingO.followingsFollowings[followingUsers[i]].following.length);
var module = $('.module.who-to-follow');
for( ; j < twisterFollowingO.followingsFollowings[followingUsers[i]].following.length; j++ ) { for( ; j < twisterFollowingO.followingsFollowings[followingUsers[i]].following.length; j++ ) {
if( followingUsers.indexOf(twisterFollowingO.followingsFollowings[followingUsers[i]].following[j]) < 0 && if( followingUsers.indexOf(twisterFollowingO.followingsFollowings[followingUsers[i]].following[j]) < 0 &&
_followSuggestions.indexOf(twisterFollowingO.followingsFollowings[followingUsers[i]].following[j]) < 0) { _followSuggestions.indexOf(twisterFollowingO.followingsFollowings[followingUsers[i]].following[j]) < 0) {
processWhoToFollowSuggestion(twisterFollowingO.followingsFollowings[followingUsers[i]].following[j], followingUsers[i]); processWhoToFollowSuggestion(module, twisterFollowingO.followingsFollowings[followingUsers[i]].following[j], followingUsers[i]);
_followSuggestions.push(twisterFollowingO.followingsFollowings[followingUsers[i]].following[j]); _followSuggestions.push(twisterFollowingO.followingsFollowings[followingUsers[i]].following[j]);
suggested = true; suggested = true;
break; break;
@ -501,28 +624,46 @@ function getWhoFollows(peerAlias, elem) {
; ;
} }
function processWhoToFollowSuggestion(suggestion, followedBy) { function processWhoToFollowSuggestion(module, suggestion, followedBy, prepend) {
if (suggestion) { if (suggestion) {
var module = $('.module.who-to-follow');
var list = module.find('.follow-suggestions'); var list = module.find('.follow-suggestions');
var item = $('#follow-suggestion-template').clone(true) var item = $('#follow-suggestion-template').clone(true)
.removeAttr('id'); .removeAttr('id');
item.find('.twister-user-info').attr('data-screen-name', suggestion); item.find('.twister-user-info').attr('data-screen-name', suggestion);
item.find('.twister-user-name').attr('href', $.MAL.userUrl(suggestion)); item.find('.twister-user-name').attr('href', $.MAL.userUrl(suggestion));
item.find('.twister-by-user-name').attr('href', $.MAL.userUrl(followedBy));
item.find('.twister-user-tag').text('@' + suggestion); item.find('.twister-user-tag').text('@' + suggestion);
getAvatar(suggestion, item.find('.twister-user-photo')); getAvatar(suggestion, item.find('.twister-user-photo'));
getFullname(followedBy, item.find('.followed-by').text(followedBy));
getStatusTime(suggestion, item.find('.latest-activity .time')); getStatusTime(suggestion, item.find('.latest-activity .time'));
item.find('.twister-user-remove').on('click', function() { if (module.hasClass('who-to-follow') || module.hasClass('who-to-follow-modal')) {
item.find('.twister-by-user-name').attr('href', $.MAL.userUrl(followedBy));
getFullname(followedBy, item.find('.followed-by').text(followedBy));
item.find('.twister-user-remove').on('click', function () {
item.remove(); item.remove();
getRandomFollowSuggestion(); getRandomFollowSuggestion();
}); });
}
else if (module.hasClass('new-users') || module.hasClass('new-users-modal')){
item.find('.followers').remove();
item.find('.twister-user-remove').remove();
}
if (module.hasClass('modal-wrapper')) {
getFullname(suggestion, item.find('.twister-user-full'));
getBioToElem(suggestion, item.find('.bio'));
item.find('.twister-user-remove').remove();
}
if (prepend)
list.prepend(item).show();
else
list.append(item).show(); list.append(item).show();
while (module.hasClass('new-users') && list.children().length > 3)
list.children().last().remove();
module.find('.refresh-users').show(); module.find('.refresh-users').show();
module.find('.loading-roller').hide(); module.find('.loading-roller').hide();
} else } else

38
js/twister_network.js

@ -146,31 +146,41 @@ function requestBestBlock(cbFunc, cbArg) {
}, {}); }, {});
} }
function requestNthBlock(n, cbFunc, cbArg) {
twisterRpc("getblockhash", [n],
function(args, hash) {
requestBlock(hash, args.cbFunc, args.cbArg);
}, {cbFunc:cbFunc, cbArg:cbArg},
function(args, ret) {
console.log("getblockhash error");
}, {});
}
function requestBlock(hash, cbFunc, cbArg) { function requestBlock(hash, cbFunc, cbArg) {
twisterRpc("getblock", [hash], twisterRpc("getblock", [hash],
function(args, block) { function(args, block) {
twisterdLastBlockTime = block.time;
$(".last-block-time").text( timeGmtToText(twisterdLastBlockTime) );
if( args.cbFunc ) if( args.cbFunc )
args.cbFunc(args.cbArg); args.cbFunc(block, args.cbArg);
}, {cbFunc:cbFunc, cbArg:cbArg}, }, {cbFunc:cbFunc, cbArg:cbArg},
function(args, ret) { function(args, ret) {
console.log("requestBlock error"); console.log("requestBlock error");
}, {}); }, {});
} }
function networkUpdate(cbFunc, cbArg) { function networkUpdate(cbFunc, cbArg) {
requestNetInfo(function () { requestNetInfo(function () {
requestBestBlock(function(args) { requestBestBlock(function(block, args) {
twisterdLastBlockTime = block.time;
$(".last-block-time").text(timeGmtToText(twisterdLastBlockTime));
var curTime = new Date().getTime() / 1000; var curTime = new Date().getTime() / 1000;
if( twisterdConnections ) { if (twisterdConnections) {
if( twisterdLastBlockTime > curTime + 3600 ) { if (twisterdLastBlockTime > curTime + 3600) {
$.MAL.setNetworkStatusMsg(polyglot.t("Last block is ahead of your computer time, check your clock."), false); $.MAL.setNetworkStatusMsg(polyglot.t("Last block is ahead of your computer time, check your clock."), false);
twisterdConnectedAndUptodate = false; twisterdConnectedAndUptodate = false;
} else if( twisterdLastBlockTime > curTime - (2 * 3600) ) { } else if (twisterdLastBlockTime > curTime - (2 * 3600)) {
if( twisterDhtNodes ) { if (twisterDhtNodes) {
$.MAL.setNetworkStatusMsg(polyglot.t("Block chain is up-to-date, twister is ready to use!"), true); $.MAL.setNetworkStatusMsg(polyglot.t("Block chain is up-to-date, twister is ready to use!"), true);
twisterdConnectedAndUptodate = true; twisterdConnectedAndUptodate = true;
} else { } else {
@ -178,14 +188,14 @@ function networkUpdate(cbFunc, cbArg) {
twisterdConnectedAndUptodate = true; twisterdConnectedAndUptodate = true;
} }
} else { } else {
var daysOld = (curTime - twisterdLastBlockTime) / (3600*24); var daysOld = (curTime - twisterdLastBlockTime) / (3600 * 24);
$.MAL.setNetworkStatusMsg(polyglot.t("downloading_block_chain", { days: daysOld.toFixed(2) }), false); $.MAL.setNetworkStatusMsg(polyglot.t("downloading_block_chain", {days: daysOld.toFixed(2)}), false);
// don't alarm user if blockchain is just a little bit behind // don't alarm user if blockchain is just a little bit behind
twisterdConnectedAndUptodate = (daysOld < 2); twisterdConnectedAndUptodate = (daysOld < 2);
} }
} }
if( args.cbFunc ) if (args.cbFunc)
args.cbFunc(args.cbArg) args.cbFunc(args.cbArg);
}, {cbFunc:cbFunc, cbArg:cbArg} ); }, {cbFunc:cbFunc, cbArg:cbArg} );
}); });
} }

20
options.html

@ -353,6 +353,26 @@
</form> </form>
</div> </div>
</div> </div>
<div class="module">
<p class="label label-h"> New Users </p>
<div class="container">
<form>
<p>
<select id="NewUsers">
<option value="enable">Enable</option>
<option value="disable">Disable</option>
</select>
</p>
<div id="NewUsersCont" class="container">
<p class="label">Live tracking</p>
<select id="NewUsersLiveTracking" class="container">
<option value="enable">Enable</option>
<option value="disable">Disable</option>
</select>
</div>
</form>
</div>
</div>
<div class="module"> <div class="module">
<p class="label label-h"> Twistday Reminder </p> <p class="label label-h"> Twistday Reminder </p>
<div class="container"> <div class="container">

29
theme_calm/css/style.css

@ -1024,12 +1024,12 @@ textarea.splited-post {
/*********************************** /***********************************
********************* WHO TO FOLLOW ********************* WHO TO FOLLOW
***********************************/ ***********************************/
.who-to-follow .who-to-follow,
{ .new-users {
padding: 10px; padding: 10px;
} }
.who-to-follow h3 .who-to-follow h3,
{ .new-users h3 {
display: inline; display: inline;
} }
.twister-user .twister-user
@ -2345,19 +2345,23 @@ textarea.splited-post {
********* WHO TO FOLLOW MODAL ******** ********* WHO TO FOLLOW MODAL ********
**************************************/ **************************************/
.who-to-follow-modal .modal-content { .who-to-follow-modal .modal-content,
.new-users-modal .modal-content {
padding: 15px; padding: 15px;
} }
.who-to-follow-modal ol { .who-to-follow-modal ol,
.new-users-modal ol {
margin: 5px; margin: 5px;
} }
.who-to-follow-modal .open-profile-modal:hover { .who-to-follow-modal .open-profile-modal:hover,
.new-users-modal .open-profile-modal span:hover {
text-decoration: none; text-decoration: none;
} }
.who-to-follow-modal .open-profile-modal span { .who-to-follow-modal .open-profile-modal span,
.new-users-modal .open-profile-modal span {
vertical-align: middle; vertical-align: middle;
} }
@ -2365,16 +2369,19 @@ textarea.splited-post {
text-decoration: underline; text-decoration: underline;
} }
.who-to-follow-modal .follow { .who-to-follow-modal .follow,
.new-users-modal .follow {
float: right; float: right;
margin: -30px 10px 0 10px; margin: -30px 10px 0 10px;
} }
.who-to-follow-modal .twister-user-info span { .who-to-follow-modal .twister-user-info span,
.new-users-modal .twister-user-info span {
vertical-align: bottom; vertical-align: bottom;
} }
.who-to-follow-modal .bio { .who-to-follow-modal .bio,
.new-users-modal .bio {
font-size: 12px; font-size: 12px;
color: rgba( 0, 0, 0, .6 ); color: rgba( 0, 0, 0, .6 );
} }

41
theme_nin/css/style.css

@ -2159,27 +2159,32 @@ textarea.splited-post {
/******** WHO TO FOLLOW ********/ /******** WHO TO FOLLOW ********/
/* line 411, ../sass/style.sass */ /* line 411, ../sass/style.sass */
.who-to-follow.module { .who-to-follow.module,
.new-users.module {
width: inherit; width: inherit;
margin-bottom: 20px; margin-bottom: 20px;
} }
/* line 414, ../sass/style.sass */ /* line 414, ../sass/style.sass */
.who-to-follow small { .who-to-follow small,
.new-users small {
display: none; display: none;
} }
/* line 416, ../sass/style.sass */ /* line 416, ../sass/style.sass */
.who-to-follow h3 { .who-to-follow h3,
.new-users h3 {
float: left; float: left;
} }
/* line 418, ../sass/style.sass */ /* line 418, ../sass/style.sass */
.who-to-follow ol { .who-to-follow ol,
.new-users ol {
clear: both; clear: both;
} }
.who-to-follow .twister-user-info { .who-to-follow .twister-user-info,
.new-users .twister-user-info {
margin-top: 8px; margin-top: 8px;
} }
@ -3130,45 +3135,53 @@ ol.toptrends-list a:hover {
/******* WHO TO FOLLOW MODAL****** */ /******* WHO TO FOLLOW MODAL****** */
/* line 943, ../sass/style.sass */ /* line 943, ../sass/style.sass */
.modal-wrapper.who-to-follow-modal { .modal-wrapper.who-to-follow-modal,
.modal-wrapper.new-users-modal {
width: 520px; width: 520px;
height: 580px; height: 580px;
margin: -290px 0 0 -260px; margin: -290px 0 0 -260px;
} }
/* line 949, ../sass/style.sass */ /* line 949, ../sass/style.sass */
.who-to-follow-modal .modal-content { .who-to-follow-modal .modal-content,
.new-users-modal .modal-content {
padding: 15px; padding: 15px;
} }
/* line 955, ../sass/style.sass */ /* line 955, ../sass/style.sass */
.who-to-follow-modal ol { .who-to-follow-modal ol,
.new-users-modal ol {
margin: 5px; margin: 5px;
} }
/* line 958, ../sass/style.sass */ /* line 958, ../sass/style.sass */
.who-to-follow-modal .open-profile-modal:hover { .who-to-follow-modal .open-profile-modal:hover,
.new-users-modal .open-profile-modal:hover {
text-decoration: none; text-decoration: none;
} }
/* line 960, ../sass/style.sass */ /* line 960, ../sass/style.sass */
.who-to-follow-modal .twister-user { .who-to-follow-modal .twister-user,
position: relative; .new-users-modal .twister-user {
position: relative;
padding: 5px; padding: 5px;
} }
/* line 963, ../sass/style.sass */ /* line 963, ../sass/style.sass */
.who-to-follow-modal .twister-user-photo { .who-to-follow-modal .twister-user-photo,
.new-users-modal .twister-user-photo {
position: relative; position: relative;
left: 0; left: 0;
float: left; float: left;
display: block; display: block;
} }
/* line 968, ../sass/style.sass */ /* line 968, ../sass/style.sass */
.who-to-follow-modal .twister-user-info { .who-to-follow-modal .twister-user-info,
.new-users-modal .twister-user-info {
position: relative; position: relative;
margin-top: 4px; margin-top: 4px;
padding-left: 70px; padding-left: 70px;
width: auto; width: auto;
} }
/* line 972, ../sass/style.sass */ /* line 972, ../sass/style.sass */
.who-to-follow-modal .bio { .who-to-follow-modal .bio,
.new-users-modal .bio {
color: rgba(0, 0, 0, 0.6); color: rgba(0, 0, 0, 0.6);
font-style: italic; font-style: italic;
} }

Loading…
Cancel
Save