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