mirror of
https://github.com/twisterarmy/twister-html.git
synced 2025-02-04 19:14:14 +00:00
fixing & developing
This commit is contained in:
parent
99f8940d38
commit
16da1c8e31
@ -119,6 +119,9 @@ function closeModal(req, switchMode) {
|
||||
else
|
||||
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] = undefined;
|
||||
}
|
||||
@ -731,9 +734,6 @@ function addPeerToFollowingList(list, peerAlias) {
|
||||
}
|
||||
|
||||
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++) {
|
||||
if (typeof twisterFollowingO.followingsFollowings[followingUsers[i]] !== 'undefined') {
|
||||
for (var j = 0; j < twisterFollowingO.followingsFollowings[followingUsers[i]].following.length && list.length < start + 25; j++) {
|
||||
@ -746,7 +746,6 @@ function fillWhoToFollowModal(list, hlist, start) {
|
||||
}
|
||||
}
|
||||
}
|
||||
itemTmp.remove();
|
||||
|
||||
if (i >= followingUsers.length - 1)
|
||||
return false;
|
||||
@ -778,7 +777,10 @@ function openWhoToFollowModal() {
|
||||
function openNewUsersModal() {
|
||||
var modal = openModal({
|
||||
classAdd: 'new-users-modal',
|
||||
title: polyglot.t('New Users')
|
||||
title: polyglot.t('New Users'),
|
||||
onClose: function() {
|
||||
NewUserSearch.isNewUserModalOpen = false;
|
||||
}
|
||||
});
|
||||
|
||||
var hlist = $('<ol class="follow-suggestions"></ol>')
|
||||
@ -787,12 +789,13 @@ function openNewUsersModal() {
|
||||
|
||||
modal.content.on('scroll', function() {
|
||||
if (modal.content.scrollTop() >= hlist.height() - modal.content.height() - 20) {
|
||||
if (getLastNUsers(5, count, modal.self))
|
||||
if (newUsers.getLastNUsers(5, count, modal.self))
|
||||
count += 5;
|
||||
}
|
||||
});
|
||||
|
||||
getLastNUsers(15, 0, modal.self);
|
||||
NewUserSearch.isNewUserModalOpen = true;
|
||||
newUsers.getLastNUsers(15, 0, modal.self);
|
||||
}
|
||||
|
||||
function openModalUriShortener()
|
||||
|
@ -118,7 +118,7 @@ var InterfaceFunctions = function() {
|
||||
if ($.Options.WebTorrent.val === 'enable')
|
||||
initWebTorrent();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
function initTopTrends() {
|
||||
var $tt = initInterfaceModule('toptrends');
|
||||
@ -208,6 +208,7 @@ function refreshWhoToFollow() {
|
||||
function initNewUsers() {
|
||||
var nus = initInterfaceModule('new-users');
|
||||
|
||||
newUsers = NewUserSearch();
|
||||
if (nus.length) {
|
||||
var nusRefresh = nus.find('.refresh-users');
|
||||
nusRefresh.on('click', refreshNewUsers);
|
||||
@ -224,7 +225,7 @@ function refreshNewUsers() {
|
||||
module.find('.refresh-users').hide();
|
||||
module.find('.loading-roller').show();
|
||||
|
||||
getLastNUsers(3, 0, module);
|
||||
newUsers.getLastNUsers(3, 0, module, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -373,7 +373,8 @@ if(preferredLanguage == "en"){
|
||||
"You have to log in to favorite messages.": "You have to log in to favorite messages.",
|
||||
"fav_this": "Is it for you only?",
|
||||
"Last activity": "Last activity",
|
||||
"New Users": "New Users"
|
||||
"New Users": "New Users",
|
||||
"Live tracking" : "Live tracking"
|
||||
};
|
||||
}
|
||||
if(preferredLanguage == "es"){
|
||||
@ -719,7 +720,8 @@ if(preferredLanguage == "es"){
|
||||
"You have to log in to favorite messages.": "You have to log in to favorite messages.",
|
||||
"fav_this": "Is it for you only?",
|
||||
"Last activity": "Last activity",
|
||||
"New Users": "New Users"
|
||||
"New Users": "New Users",
|
||||
"Live tracking" : "Live tracking"
|
||||
};
|
||||
}
|
||||
|
||||
@ -1064,7 +1066,8 @@ if(preferredLanguage == "uk"){
|
||||
"You have to log in to favorite messages.": "You have to log in to favorite messages.",
|
||||
"fav_this": "Is it for you only?",
|
||||
"Last activity": "Last activity",
|
||||
"New Users": "New Users"
|
||||
"New Users": "New Users",
|
||||
"Live tracking" : "Live tracking"
|
||||
};
|
||||
}
|
||||
|
||||
@ -1414,7 +1417,8 @@ if(preferredLanguage == "zh-CN"){
|
||||
"You have to log in to favorite messages.": "You have to log in to favorite messages.",
|
||||
"fav_this": "Is it for you only?",
|
||||
"Last activity": "Last activity",
|
||||
"New Users": "New Users"
|
||||
"New Users": "New Users",
|
||||
"Live tracking" : "Live tracking"
|
||||
};
|
||||
}
|
||||
|
||||
@ -1761,7 +1765,8 @@ if(preferredLanguage == "nl"){
|
||||
"You have to log in to favorite messages.": "You have to log in to favorite messages.",
|
||||
"fav_this": "Is it for you only?",
|
||||
"Last activity": "Last activity",
|
||||
"New Users": "New Users"
|
||||
"New Users": "New Users",
|
||||
"Live tracking" : "Live tracking"
|
||||
};
|
||||
}
|
||||
|
||||
@ -2106,7 +2111,8 @@ if(preferredLanguage == "it"){
|
||||
"You have to log in to favorite messages.": "You have to log in to favorite messages.",
|
||||
"fav_this": "Is it for you only?",
|
||||
"Last activity": "Last activity",
|
||||
"New Users": "New Users"
|
||||
"New Users": "New Users",
|
||||
"Live tracking" : "Live tracking"
|
||||
};
|
||||
}
|
||||
|
||||
@ -2452,7 +2458,8 @@ if(preferredLanguage == "fr"){
|
||||
"Favorites": "Favorites",
|
||||
"You have to log in to favorite messages.": "You have to log in to favorite messages.",
|
||||
"Last activity": "Last activity",
|
||||
"New Users": "New Users"
|
||||
"New Users": "New Users",
|
||||
"Live tracking" : "Live tracking"
|
||||
};
|
||||
}
|
||||
|
||||
@ -2805,7 +2812,8 @@ if(preferredLanguage == "ru"){
|
||||
"You have to log in to favorite messages.": "You have to log in to favorite messages.",
|
||||
"fav_this": "Is it for you only?",
|
||||
"Last activity": "Last activity",
|
||||
"New Users": "New Users"
|
||||
"New Users": "New Users",
|
||||
"Live tracking" : "Live tracking"
|
||||
};
|
||||
}
|
||||
|
||||
@ -3154,7 +3162,8 @@ if(preferredLanguage == "de"){
|
||||
"You have to log in to favorite messages.": "You have to log in to favorite messages.",
|
||||
"fav_this": "Is it for you only?",
|
||||
"Last activity": "Last activity",
|
||||
"New Users": "New Users"
|
||||
"New Users": "New Users",
|
||||
"Live tracking" : "Live tracking"
|
||||
};
|
||||
}
|
||||
|
||||
@ -3498,7 +3507,8 @@ if(preferredLanguage == "ja"){
|
||||
"You have to log in to favorite messages.": "You have to log in to favorite messages.",
|
||||
"fav_this": "Is it for you only?",
|
||||
"Last activity": "Last activity",
|
||||
"New Users": "New Users"
|
||||
"New Users": "New Users",
|
||||
"Live tracking" : "Live tracking"
|
||||
};
|
||||
}
|
||||
|
||||
@ -3848,7 +3858,8 @@ if(preferredLanguage == "pt-BR"){
|
||||
"You have to log in to favorite messages.": "You have to log in to favorite messages.",
|
||||
"fav_this": "Is it for you only?",
|
||||
"Last activity": "Last activity",
|
||||
"New Users": "New Users"
|
||||
"New Users": "New Users",
|
||||
"Live tracking" : "Live tracking"
|
||||
};
|
||||
}
|
||||
|
||||
@ -4194,7 +4205,8 @@ if(preferredLanguage == "tr"){
|
||||
"You have to log in to favorite messages.": "İletileri favorine eklemek için giriş yapmalısın.",
|
||||
"fav_this": "Sana özel mi?",
|
||||
"Last activity": "Son etkinlik",
|
||||
"New Users": "Yeni Kullanıcılar"
|
||||
"New Users": "Yeni Kullanıcılar",
|
||||
"Live tracking" : "Canlı takip"
|
||||
};
|
||||
}
|
||||
|
||||
@ -4543,7 +4555,8 @@ if(preferredLanguage == "cs"){
|
||||
"You have to log in to favorite messages.": "You have to log in to favorite messages.",
|
||||
"fav_this": "Is it for you only?",
|
||||
"Last activity": "Last activity",
|
||||
"New Users": "New Users"
|
||||
"New Users": "New Users",
|
||||
"Live tracking" : "Live tracking"
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -43,6 +43,13 @@ function twisterOptions() {
|
||||
});
|
||||
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({
|
||||
|
@ -15,11 +15,9 @@ var _searchKeypressTimer = undefined;
|
||||
var _lastSearchUsersResults = [];
|
||||
var _lastSearchUsersResultsRemovedFromDHTgetQueue = true;
|
||||
var _lastLoadFromDhtTime = 0;
|
||||
var _lastProcessedBlock = -1;
|
||||
var knownNewUsers = [];
|
||||
var isNewUserThRunning = false;
|
||||
|
||||
var twisterFollowingO = undefined;
|
||||
var newUsers = undefined;
|
||||
|
||||
var TwisterFollowing = function (user) {
|
||||
if (!(this instanceof TwisterFollowing))
|
||||
@ -430,46 +428,116 @@ function followingEmptyOrMyself() {
|
||||
return (!followingUsers.length || (followingUsers.length === 1 && followingUsers[0] === defaultScreenName))
|
||||
}
|
||||
|
||||
function getLastNUsers(n,offset,module) {
|
||||
/* NEW USER SEARCH */
|
||||
var NewUserSearch = function(){
|
||||
if (!(this instanceof NewUserSearch))
|
||||
return new NewUserSearch();
|
||||
|
||||
if (isNewUserThRunning)
|
||||
return false;
|
||||
this.init();
|
||||
};
|
||||
|
||||
isNewUserThRunning = true;
|
||||
for (var i = offset; i < knownNewUsers.length && i < offset + n; i++)
|
||||
processWhoToFollowSuggestion(module, knownNewUsers[i]);
|
||||
|
||||
if (knownNewUsers.length >= n + offset)
|
||||
{
|
||||
isNewUserThRunning = false;
|
||||
return true;
|
||||
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}});
|
||||
}
|
||||
};
|
||||
|
||||
if (_lastProcessedBlock == -1)
|
||||
requestBestBlock(processBlockUsers, {n: n, offset: offset, module: module});
|
||||
else
|
||||
requestNthBlock(_lastProcessedBlock - 1, processBlockUsers, {n: n, offset: offset, module: module});
|
||||
NewUserSearch.prototype = {
|
||||
storage: undefined,
|
||||
isForced: false,
|
||||
|
||||
return true;
|
||||
}
|
||||
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");
|
||||
|
||||
function processBlockUsers(block, users){
|
||||
_lastProcessedBlock = block.height;
|
||||
if ($.Options.NewUsersLiveTracking.val === 'enable')
|
||||
setInterval(function(){NewUserSearch.live($('.module.new-users'));}, 10000);
|
||||
},
|
||||
|
||||
if (knownNewUsers.length + block.usernames.length < users.n + users.offset && typeof block.previousblockhash !== 'undefined')
|
||||
setTimeout(function(){requestBlock(block.previousblockhash, processBlockUsers, users);}, 100);
|
||||
else
|
||||
isNewUserThRunning = false;
|
||||
save: function(){
|
||||
this.storage.set("knownNewUsers", NewUserSearch.knownNewUsers);
|
||||
this.storage.set("lastProcessedBlock", NewUserSearch.lastProcessedBlock);
|
||||
this.storage.set("startProcessedBlock", NewUserSearch.startProcessedBlock);
|
||||
},
|
||||
|
||||
for (var i = 0; i < block.usernames.length; i++) {
|
||||
if (knownNewUsers.indexOf(block.usernames[i]) == -1) {
|
||||
processWhoToFollowSuggestion(users.module, block.usernames[i]);
|
||||
knownNewUsers.push(block.usernames[i]);
|
||||
if (knownNewUsers.length >= users.n + users.offset)
|
||||
break;
|
||||
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});
|
||||
}, 100);
|
||||
|
||||
} else {
|
||||
NewUserSearch.isNewUserThRunning = false;
|
||||
this.isForced = false;
|
||||
}
|
||||
|
||||
for (var i = 0; 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;
|
||||
}
|
||||
}
|
||||
this.save();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// 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
|
||||
@ -546,7 +614,7 @@ function getWhoFollows(peerAlias, elem) {
|
||||
;
|
||||
}
|
||||
|
||||
function processWhoToFollowSuggestion(module, suggestion, followedBy) {
|
||||
function processWhoToFollowSuggestion(module, suggestion, followedBy, prepend) {
|
||||
if (suggestion) {
|
||||
var list = module.find('.follow-suggestions');
|
||||
var item = $('#follow-suggestion-template').clone(true)
|
||||
@ -578,7 +646,14 @@ function processWhoToFollowSuggestion(module, suggestion, followedBy) {
|
||||
item.find('.twister-user-remove').remove();
|
||||
}
|
||||
|
||||
list.append(item).show();
|
||||
if (prepend)
|
||||
list.prepend(item).show();
|
||||
else
|
||||
list.append(item).show();
|
||||
|
||||
while (module.hasClass('new-users') && list.children().length > 3)
|
||||
list.children().last().remove();
|
||||
|
||||
module.find('.refresh-users').show();
|
||||
module.find('.loading-roller').hide();
|
||||
} else
|
||||
|
17
options.html
17
options.html
@ -357,10 +357,19 @@
|
||||
<p class="label label-h"> New Users </p>
|
||||
<div class="container">
|
||||
<form>
|
||||
<select id="NewUsers">
|
||||
<option value="enable">Enable</option>
|
||||
<option value="disable">Disable</option>
|
||||
</select>
|
||||
<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>
|
||||
|
Loading…
x
Reference in New Issue
Block a user