|
|
|
@ -77,7 +77,7 @@ var InterfaceFunctions = function() {
@@ -77,7 +77,7 @@ var InterfaceFunctions = function() {
|
|
|
|
|
loadFollowing( function(args) { |
|
|
|
|
$(".mini-profile .following-count").text(followingUsers.length-1); |
|
|
|
|
requestLastHave(); |
|
|
|
|
setInterval("requestLastHave()", 1000); |
|
|
|
|
setInterval(requestLastHave, 1000); |
|
|
|
|
initMentionsCount(); |
|
|
|
|
initDMsCount(); |
|
|
|
|
requestTimelineUpdate("latestFirstTime",postsPerRefresh,followingUsers,promotedPostsOnly); |
|
|
|
@ -227,92 +227,94 @@ function initTwistdayReminder() {
@@ -227,92 +227,94 @@ function initTwistdayReminder() {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function refreshTwistdayReminder() { |
|
|
|
|
var $module = $('.module.twistday-reminder'); |
|
|
|
|
var $list = $module.find('.list'); |
|
|
|
|
var module = $('.module.twistday-reminder'); |
|
|
|
|
var list = module.find('.list'); |
|
|
|
|
|
|
|
|
|
if ($list.length) { |
|
|
|
|
$module.find('.refresh').hide(); |
|
|
|
|
$module.find('.loading-roller').show(); |
|
|
|
|
if (defaultScreenName && typeof(followingUsers) !== 'undefined') { |
|
|
|
|
var suggests = followingUsers.slice(); |
|
|
|
|
if (suggests.length > 0) { |
|
|
|
|
for (var i = 0; i < suggests.length; i++) { |
|
|
|
|
suggests[i] = {'username': suggests[i], 'max_id': 0}; |
|
|
|
|
} |
|
|
|
|
twisterRpc('getposts', [suggests.length + 1,suggests], |
|
|
|
|
function(arg, posts) { |
|
|
|
|
function addLuckyToList(list, post, time) { |
|
|
|
|
var lucky = post.userpost.n; |
|
|
|
|
if (list.find('[data-screen-name='+lucky+']').length < 1) { |
|
|
|
|
var item = $('#twistday-reminder-suggestion-template').clone(true); |
|
|
|
|
item.removeAttr('id'); |
|
|
|
|
item.find('.twister-user-info').attr('data-screen-name', lucky); |
|
|
|
|
item.find('.twister-user-name').attr('href', $.MAL.userUrl(lucky)); |
|
|
|
|
item.find('.twister-user-tag').text('@' +lucky); |
|
|
|
|
itemTwisterday = item.find('.twisterday'); |
|
|
|
|
itemTwisterday.bind('click', (function(e) { replyInitPopup(e, post); }).bind(post)); |
|
|
|
|
if (typeof(time) !== 'undefined') |
|
|
|
|
itemTwisterday.text(timeGmtToText(time)); |
|
|
|
|
else |
|
|
|
|
itemTwisterday.text(timeGmtToText(post.userpost.time)); |
|
|
|
|
|
|
|
|
|
getAvatar(lucky, item.find('.twister-user-photo')); |
|
|
|
|
getFullname(lucky, item.find('.twister-user-full')); |
|
|
|
|
|
|
|
|
|
list.append(item); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
function removeLuckyFromList(list, lucky) { |
|
|
|
|
list.find('[data-screen-name='+lucky+']').closest('li').remove(); |
|
|
|
|
if (list.length) { |
|
|
|
|
module.find('.refresh').hide(); |
|
|
|
|
module.find('.loading-roller').show(); |
|
|
|
|
if (defaultScreenName && typeof followingUsers !== 'undefined' && followingUsers.length) { |
|
|
|
|
var suggests = []; |
|
|
|
|
for (var i = 0; i < followingUsers.length; i++) { |
|
|
|
|
suggests[i] = {username: followingUsers[i], max_id: 0}; |
|
|
|
|
} |
|
|
|
|
twisterRpc('getposts', [suggests.length + 1, suggests], |
|
|
|
|
function(arg, posts) { |
|
|
|
|
function addLuckyToList(list, post, time) { |
|
|
|
|
var lucky = post.userpost.n; |
|
|
|
|
if (!list.find('[data-screen-name=' + lucky + ']').length) { |
|
|
|
|
var item = $('#twistday-reminder-suggestion-template').clone(true) |
|
|
|
|
.removeAttr('id'); |
|
|
|
|
item.find('.twister-user-info').attr('data-screen-name', lucky); |
|
|
|
|
item.find('.twister-user-name').attr('href', $.MAL.userUrl(lucky)); |
|
|
|
|
item.find('.twister-user-tag').text('@' + lucky); |
|
|
|
|
itemTwisterday = item.find('.twisterday'); |
|
|
|
|
itemTwisterday.on('click', (function(e) {replyInitPopup(e, post);}).bind(post)); |
|
|
|
|
if (typeof time !== 'undefined') |
|
|
|
|
itemTwisterday.text(timeGmtToText(time)); |
|
|
|
|
else |
|
|
|
|
itemTwisterday.text(timeGmtToText(post.userpost.time)); |
|
|
|
|
|
|
|
|
|
getAvatar(lucky, item.find('.twister-user-photo')); |
|
|
|
|
getFullname(lucky, item.find('.twister-user-full')); |
|
|
|
|
|
|
|
|
|
list.append(item); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
function removeLuckyFromList(list, lucky) { |
|
|
|
|
list.find('[data-screen-name=' + lucky + ']').closest('li').remove(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
var showUpcomingTimer = ($.Options.TwistdayReminderShowUpcoming.val === 'enable') ? $.Options.TwistdayReminderShowUpcomingTimer.val * 3600 : 0; |
|
|
|
|
var listCurrent = $module.find('.current .list'); |
|
|
|
|
var listUpcoming = $module.find('.upcoming .list'); |
|
|
|
|
var d = new Date(); |
|
|
|
|
var todayYear = d.getUTCFullYear(); |
|
|
|
|
var todayMonth = d.getUTCMonth(); |
|
|
|
|
var todayDate = d.getUTCDate(); |
|
|
|
|
var todaySec = Date.UTC(todayYear,todayMonth,todayDate,d.getUTCHours(),d.getUTCMinutes(),d.getUTCSeconds()) /1000; |
|
|
|
|
var thatSec; |
|
|
|
|
|
|
|
|
|
posts.sort(function(a,b) { |
|
|
|
|
return (parseInt(a.userpost.time) > parseInt(b.userpost.time)) ? 1 : -1; |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
for (var i = 0; i < posts.length; i++) { |
|
|
|
|
if (followingUsers.indexOf(posts[i].userpost.n) > -1) { |
|
|
|
|
d.setTime(0); |
|
|
|
|
d.setUTCSeconds(posts[i].userpost.time); |
|
|
|
|
if (d.getUTCMonth() === todayMonth && d.getUTCDate() === todayDate) { |
|
|
|
|
addLuckyToList(listCurrent, posts[i]); |
|
|
|
|
removeLuckyFromList(listUpcoming, posts[i].userpost.n); |
|
|
|
|
} else if (showUpcomingTimer > 0) { |
|
|
|
|
thatSec = Date.UTC(todayYear,d.getUTCMonth(),d.getUTCDate(),d.getUTCHours(),d.getUTCMinutes(),d.getUTCSeconds()) /1000; |
|
|
|
|
if (thatSec > todaySec && thatSec -todaySec <= showUpcomingTimer) { |
|
|
|
|
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); |
|
|
|
|
} |
|
|
|
|
var showUpcomingTimer = ($.Options.TwistdayReminderShowUpcoming.val === 'enable') ? |
|
|
|
|
$.Options.TwistdayReminderShowUpcomingTimer.val * 3600 : 0; |
|
|
|
|
var listCurrent = module.find('.current .list'); |
|
|
|
|
var listUpcoming = module.find('.upcoming .list'); |
|
|
|
|
var d = new Date(); |
|
|
|
|
var todayYear = d.getUTCFullYear(); |
|
|
|
|
var todayMonth = d.getUTCMonth(); |
|
|
|
|
var todayDate = d.getUTCDate(); |
|
|
|
|
var todaySec = Date.UTC(todayYear, todayMonth, todayDate, |
|
|
|
|
d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds()) /1000; |
|
|
|
|
var thatSec; |
|
|
|
|
|
|
|
|
|
posts.sort(function(a, b) { |
|
|
|
|
return (parseInt(a.userpost.time) > parseInt(b.userpost.time)) ? 1 : -1; |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
for (var i = 0; i < posts.length; i++) { |
|
|
|
|
if (followingUsers.indexOf(posts[i].userpost.n) > -1) { |
|
|
|
|
d.setTime(0); |
|
|
|
|
d.setUTCSeconds(posts[i].userpost.time); |
|
|
|
|
if (d.getUTCMonth() === todayMonth && d.getUTCDate() === todayDate) { |
|
|
|
|
addLuckyToList(listCurrent, posts[i]); |
|
|
|
|
removeLuckyFromList(listUpcoming, posts[i].userpost.n); |
|
|
|
|
} else if (showUpcomingTimer > 0) { |
|
|
|
|
thatSec = Date.UTC(todayYear, d.getUTCMonth(), d.getUTCDate(), |
|
|
|
|
d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds()) /1000; |
|
|
|
|
if (thatSec > todaySec && thatSec -todaySec <= showUpcomingTimer) { |
|
|
|
|
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 { |
|
|
|
|
removeLuckyFromList(listCurrent, posts[i].userpost.n); |
|
|
|
|
removeLuckyFromList(listUpcoming, posts[i].userpost.n); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (listCurrent.children().length) |
|
|
|
|
listCurrent.parent().show(); |
|
|
|
|
if (listUpcoming.children().length) |
|
|
|
|
listUpcoming.parent().show(); |
|
|
|
|
$module.find('.refresh').show(); |
|
|
|
|
$module.find('.loading-roller').hide(); |
|
|
|
|
}, null, |
|
|
|
|
function(arg, ret) { console.log('ajax error:' + ret); }, null); |
|
|
|
|
} |
|
|
|
|
if (listCurrent.children().length) |
|
|
|
|
listCurrent.parent().show(); |
|
|
|
|
if (listUpcoming.children().length) |
|
|
|
|
listUpcoming.parent().show(); |
|
|
|
|
module.find('.refresh').show(); |
|
|
|
|
module.find('.loading-roller').hide(); |
|
|
|
|
}, null, |
|
|
|
|
function(arg, ret) {console.log('ajax error:' + ret);}, null |
|
|
|
|
); |
|
|
|
|
} |
|
|
|
|
if ($.Options.TwistdayReminderAutoUpdate.val === 'enable' && $.Options.TwistdayReminderAutoUpdateTimer.val > 0) |
|
|
|
|
setTimeout(refreshTwistdayReminder, $.Options.TwistdayReminderAutoUpdateTimer.val * 1000); |
|
|
|
|