|
|
@ -10,9 +10,10 @@ var _followsPerPage = 200; |
|
|
|
var _maxFollowingPages = 50; |
|
|
|
var _maxFollowingPages = 50; |
|
|
|
var _followingSeqNum = 0; |
|
|
|
var _followingSeqNum = 0; |
|
|
|
var _followSuggestions = []; |
|
|
|
var _followSuggestions = []; |
|
|
|
var _searchingPartialUsers = ""; |
|
|
|
var _searchingPartialName = ''; |
|
|
|
var _searchKeypressTimer = undefined; |
|
|
|
var _searchKeypressTimer = undefined; |
|
|
|
var _lastSearchUsersResults = []; |
|
|
|
var _lastSearchUsersResults = []; |
|
|
|
|
|
|
|
var _lastSearchUsersResultsRemovedFromDHTgetQueue = true; |
|
|
|
var _lastLoadFromDhtTime = 0; |
|
|
|
var _lastLoadFromDhtTime = 0; |
|
|
|
|
|
|
|
|
|
|
|
var twisterFollowingO = undefined; |
|
|
|
var twisterFollowingO = undefined; |
|
|
@ -578,101 +579,96 @@ function processWhoToFollowSuggestion(suggestion, followedBy) { |
|
|
|
console.warn('nothing to proceed: no twisters to follow was suggested'); |
|
|
|
console.warn('nothing to proceed: no twisters to follow was suggested'); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function closeSearchDialog() |
|
|
|
function closeSearchDialog(event) { |
|
|
|
{ |
|
|
|
var elemEvent = event ? $(event.target) : this; |
|
|
|
$(".userMenu-search-field").siblings().slideUp( "fast" ); |
|
|
|
elemEvent.siblings('.search-results').slideUp('fast'); |
|
|
|
|
|
|
|
if (!_lastSearchUsersResultsRemovedFromDHTgetQueue) { |
|
|
|
removeUsersFromDhtgetQueue(_lastSearchUsersResults); |
|
|
|
removeUsersFromDhtgetQueue(_lastSearchUsersResults); |
|
|
|
_lastSearchUsersResults = []; |
|
|
|
_lastSearchUsersResultsRemovedFromDHTgetQueue = true; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function userSearchKeypress(event) { |
|
|
|
function userSearchKeypress(event) { |
|
|
|
var partialName = $(".userMenu-search-field").val().toLowerCase(); |
|
|
|
var elemEvent = $(event.target); |
|
|
|
var searchResults = $(".search-results"); |
|
|
|
var partialName = elemEvent.val().toLowerCase(); |
|
|
|
|
|
|
|
|
|
|
|
if ( partialName.substr( 0, 1 ) == '#' ) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(searchResults.is(":visible")) |
|
|
|
|
|
|
|
searchResults.slideUp( "fast" ); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ( event.which == 13 ) |
|
|
|
if (event.data.hashtags && partialName[0] === '#') { |
|
|
|
window.location.hash = '#hashtag?hashtag=' + encodeURIComponent(partialName.substr(1)); |
|
|
|
var searchResults = elemEvent.siblings('.search-results'); |
|
|
|
|
|
|
|
if (searchResults.is(':visible')) |
|
|
|
|
|
|
|
searchResults.slideUp('fast'); |
|
|
|
|
|
|
|
|
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if ( partialName.substr( 0, 1 ) == '@' ) { |
|
|
|
var words = partialName.match(/\b\w+/g); |
|
|
|
partialName = partialName.substr( 1 ); |
|
|
|
if (words && words.length) { |
|
|
|
} |
|
|
|
partialName = words.pop(); |
|
|
|
|
|
|
|
|
|
|
|
//var partialName = item.val();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if( !partialName.length ) { |
|
|
|
if (typeof _searchKeypressTimer !== 'undefined') |
|
|
|
closeSearchDialog(); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
if( _searchKeypressTimer !== undefined ) |
|
|
|
|
|
|
|
clearTimeout(_searchKeypressTimer); |
|
|
|
clearTimeout(_searchKeypressTimer); |
|
|
|
|
|
|
|
|
|
|
|
if( _searchingPartialUsers.length ) { |
|
|
|
if (_searchingPartialName.length) { |
|
|
|
_searchingPartialUsers = partialName; |
|
|
|
_searchingPartialName = partialName; |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
_searchKeypressTimer = setTimeout(function () { |
|
|
|
_searchKeypressTimer = setTimeout(function () { |
|
|
|
_searchKeypressTimer = undefined; |
|
|
|
_searchKeypressTimer = undefined; |
|
|
|
searchPartialUsername(partialName); |
|
|
|
event.data.partialName = partialName; |
|
|
|
|
|
|
|
searchPartialUsername(event); |
|
|
|
}, 600); |
|
|
|
}, 600); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} else |
|
|
|
} |
|
|
|
closeSearchDialog(event); |
|
|
|
|
|
|
|
|
|
|
|
function searchPartialUsername(partialName) { |
|
|
|
|
|
|
|
_searchingPartialUsers = partialName; |
|
|
|
|
|
|
|
twisterRpc("listusernamespartial", [partialName,10], |
|
|
|
|
|
|
|
function(partialName, ret) { |
|
|
|
|
|
|
|
processDropdownUserResults(partialName, ret) |
|
|
|
|
|
|
|
}, partialName, |
|
|
|
|
|
|
|
function(cbArg, ret) { |
|
|
|
|
|
|
|
console.log("ajax error:" + ret); |
|
|
|
|
|
|
|
}, {}); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function processDropdownUserResults(partialName, results){ |
|
|
|
function searchPartialUsername(event) { |
|
|
|
|
|
|
|
_searchingPartialName = event.data.partialName; |
|
|
|
|
|
|
|
twisterRpc('listusernamespartial', [event.data.partialName, 10], |
|
|
|
|
|
|
|
function(event, ret) { |
|
|
|
|
|
|
|
if (event.data.partialName !== _searchingPartialName) |
|
|
|
|
|
|
|
setTimeout(searchPartialUsername, 100, event); |
|
|
|
|
|
|
|
else { |
|
|
|
|
|
|
|
if (!_lastSearchUsersResultsRemovedFromDHTgetQueue) |
|
|
|
|
|
|
|
removeUsersFromDhtgetQueue(_lastSearchUsersResults); |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
_lastSearchUsersResultsRemovedFromDHTgetQueue = false; |
|
|
|
|
|
|
|
_lastSearchUsersResults = ret; |
|
|
|
|
|
|
|
|
|
|
|
if( partialName != _searchingPartialUsers ) { |
|
|
|
if (ret && ret.length) { |
|
|
|
searchPartialUsername( _searchingPartialUsers ); |
|
|
|
if (event.data.handleRet) |
|
|
|
return; |
|
|
|
event.data.handleRet(event, ret); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
if (event.data.handleRetZero) |
|
|
|
|
|
|
|
event.data.handleRetZero(event); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
removeUsersFromDhtgetQueue( _lastSearchUsersResults ); |
|
|
|
_searchingPartialName = ''; |
|
|
|
_lastSearchUsersResults = results; |
|
|
|
} |
|
|
|
|
|
|
|
}, event, |
|
|
|
var typeaheadAccounts = $(".userMenu-search-profiles"); |
|
|
|
function(req, ret) {console.warn('ajax error:' + ret.message);}, null |
|
|
|
var template = $("#search-profile-template").detach(); |
|
|
|
); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
typeaheadAccounts.empty(); |
|
|
|
function processDropdownUserResults(event, results) { |
|
|
|
typeaheadAccounts.append(template); |
|
|
|
var container = $('.userMenu-search-profiles').empty(); |
|
|
|
|
|
|
|
var template = $('#search-profile-template').children(); |
|
|
|
|
|
|
|
|
|
|
|
if( results.length ) { |
|
|
|
|
|
|
|
for (var i = 0; i < results.length; i++) { |
|
|
|
for (var i = 0; i < results.length; i++) { |
|
|
|
if( results[i] == defaultScreenName ) |
|
|
|
if (results[i] === defaultScreenName) |
|
|
|
continue; |
|
|
|
continue; |
|
|
|
|
|
|
|
|
|
|
|
var resItem = template.clone(true); |
|
|
|
var item = template.clone(true); |
|
|
|
resItem.removeAttr('id'); |
|
|
|
item.find('.mini-profile-info').attr('data-screen-name', results[i]); |
|
|
|
resItem.show(); |
|
|
|
item.find('.mini-screen-name b').text(results[i]); |
|
|
|
resItem.find(".mini-profile-info").attr("data-screen-name", results[i]); |
|
|
|
item.find('a.open-profile-modal').attr('href', $.MAL.userUrl(results[i])); |
|
|
|
resItem.find(".mini-screen-name b").text(results[i]); |
|
|
|
getAvatar(results[i], item.find('.mini-profile-photo')); |
|
|
|
resItem.find("a.open-profile-modal").attr("href",$.MAL.userUrl(results[i])); |
|
|
|
getFullname(results[i], item.find('.mini-profile-name')); |
|
|
|
getAvatar(results[i],resItem.find(".mini-profile-photo")); |
|
|
|
item.appendTo(container); |
|
|
|
getFullname(results[i],resItem.find(".mini-profile-name")); |
|
|
|
|
|
|
|
resItem.appendTo(typeaheadAccounts); |
|
|
|
if (followingUsers.indexOf(results[i]) !== -1) |
|
|
|
if (followingUsers.indexOf(results[i]) >= 0) |
|
|
|
|
|
|
|
toggleFollowButton(results[i], true); |
|
|
|
toggleFollowButton(results[i], true); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$.MAL.searchUserListLoaded(); |
|
|
|
$.MAL.searchUserListLoaded(); |
|
|
|
} else { |
|
|
|
|
|
|
|
closeSearchDialog(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
_searchingPartialUsers = ""; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function userClickFollow(e) { |
|
|
|
function userClickFollow(e) { |
|
|
@ -700,10 +696,13 @@ function userClickFollow(e) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function initUserSearch() { |
|
|
|
function initUserSearch() { |
|
|
|
var $userSearchField = $( ".userMenu-search-field" ); |
|
|
|
var elem = $('.userMenu-search-field') |
|
|
|
$userSearchField.keyup( userSearchKeypress ); |
|
|
|
.on('click input', |
|
|
|
$userSearchField.bind( "click", userSearchKeypress ); |
|
|
|
{hashtags: true, handleRet: processDropdownUserResults, |
|
|
|
$(".userMenu-search").clickoutside( closeSearchDialog ); |
|
|
|
handleRetZero: closeSearchDialog}, userSearchKeypress) |
|
|
|
|
|
|
|
.on('keyup', userSearchEnter) |
|
|
|
|
|
|
|
; |
|
|
|
|
|
|
|
$('.userMenu-search').clickoutside(closeSearchDialog.bind(elem)); |
|
|
|
|
|
|
|
|
|
|
|
// following stuff should be moved to special function
|
|
|
|
// following stuff should be moved to special function
|
|
|
|
$('button.follow').on('click', userClickFollow); |
|
|
|
$('button.follow').on('click', userClickFollow); |
|
|
@ -716,6 +715,14 @@ function initUserSearch() { |
|
|
|
; |
|
|
|
; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function userSearchEnter(event) { |
|
|
|
|
|
|
|
if (event.which === 13) { |
|
|
|
|
|
|
|
var str = $(event.target).val().toLowerCase().trim(); |
|
|
|
|
|
|
|
if (str[0] === '#') |
|
|
|
|
|
|
|
window.location.hash = '#hashtag?hashtag=' + encodeURIComponent(str.slice(1)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function followingListPublicCheckbox(e) { |
|
|
|
function followingListPublicCheckbox(e) { |
|
|
|
e.stopPropagation(); |
|
|
|
e.stopPropagation(); |
|
|
|
|
|
|
|
|
|
|
|