Complete mobile post info for archive fetched posts. Use fourchan_date.
This commit is contained in:
parent
c3995a173b
commit
4e49c1f8b3
@ -479,42 +479,6 @@
|
||||
}
|
||||
size = unit > 1 ? Math.round(size * 100) / 100 : Math.round(size);
|
||||
return "" + size + " " + ['B', 'KB', 'MB', 'GB'][unit];
|
||||
},
|
||||
isDST: function(d) {
|
||||
var date, day, hours, month, sunday;
|
||||
date = d.getUTCDate();
|
||||
day = d.getUTCDay();
|
||||
hours = d.getUTCHours();
|
||||
month = d.getUTCMonth();
|
||||
if (2 > month || month > 10) {
|
||||
return false;
|
||||
}
|
||||
if ((2 < month && month < 10)) {
|
||||
return true;
|
||||
}
|
||||
sunday = date - day;
|
||||
if (month === 2) {
|
||||
if (sunday < 8) {
|
||||
return false;
|
||||
}
|
||||
if (sunday < 15 && day === 0) {
|
||||
if (hours < 7) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (sunday < 1) {
|
||||
return true;
|
||||
}
|
||||
if (sunday < 8 && day === 0) {
|
||||
if (hours < 6) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
@ -3109,7 +3073,7 @@
|
||||
}
|
||||
},
|
||||
parseArchivedPost: function(req, board, postID, root, cb) {
|
||||
var bq, capcode, data, date, email, file, filesize, isOP, nameBlock, p, pc, pi, piM, span, time;
|
||||
var bq, br, capcode, data, email, file, filesize, isOP, nameBlock, p, pc, pi, piM, span;
|
||||
data = JSON.parse(req.response);
|
||||
if (data.error) {
|
||||
root.textContent = data.error;
|
||||
@ -3128,18 +3092,39 @@
|
||||
piM = $.el('div', {
|
||||
id: "pim" + postID,
|
||||
className: 'postInfoM mobile',
|
||||
innerHTML: ''
|
||||
innerHTML: "<span class=nameBlock><span class=name></span><br><span class=subject></span></span><span class='dateTime postNum' data-utc=" + timestamp + ">" + data.fourchan_date + "<br><em></em><a href='/" + board + "/res/" + data.thread_num + "#p" + postID + "' title='Highlight this post'>No.</a><a href='/" + board + "/res/" + data.thread_num + "#q" + postID + "' title='Quote this post'>" + postID + "</a></span>"
|
||||
});
|
||||
$('.name', piM).textContent = data.name;
|
||||
$('.subject', piM).textContent = data.title;
|
||||
br = $('br', piM);
|
||||
if (data.trip) {
|
||||
$.before(br, [
|
||||
$.tn(' '), $.el('span', {
|
||||
className: 'postertrip',
|
||||
textContent: data.trip
|
||||
})
|
||||
]);
|
||||
}
|
||||
capcode = data.capcode;
|
||||
if (capcode !== 'N') {
|
||||
$.addClass(br.parentNode, capcode === 'A' ? 'capcodeAdmin' : 'capcodeMod');
|
||||
$.before(br, [
|
||||
$.tn(' '), $.el('strong', {
|
||||
className: 'capcode',
|
||||
textContent: capcode === 'A' ? '## Admin' : '## Mod'
|
||||
}), $.tn(' '), $.el('img', {
|
||||
src: capcode === 'A' ? '//static.4chan.org/image/adminicon.gif' : '//static.4chan.org/image/modicon.gif',
|
||||
alt: capcode === 'A' ? 'This user is the 4chan Administrator.' : 'This user is a 4chan Moderator.',
|
||||
title: capcode === 'A' ? 'This user is the 4chan Administrator.' : 'This user is a 4chan Moderator.',
|
||||
className: 'identityIcon'
|
||||
})
|
||||
]);
|
||||
}
|
||||
pi = $.el('div', {
|
||||
id: "pi" + postID,
|
||||
className: 'postInfo desktop',
|
||||
innerHTML: "<input type=checkbox name=" + postID + " value=delete> <span class=userInfo><span class=subject></span> <span class=nameBlock></span></span> <span class=dateTime data-utc=" + data.timestamp + "></span> <span class='postNum desktop'><a href='/" + board + "/res/" + data.thread_num + "#p" + postID + "' title='Highlight this post'>No.</a><a href='/" + board + "/res/" + data.thread_num + "#q" + postID + "' title='Quote this post'>" + postID + "</a>" + (isOP ? ' ' : '') + "</span> "
|
||||
innerHTML: "<input type=checkbox name=" + postID + " value=delete> <span class=userInfo><span class=subject></span> <span class=nameBlock></span></span> <span class=dateTime data-utc=" + data.timestamp + ">data.fourchan_date</span> <span class='postNum desktop'><a href='/" + board + "/res/" + data.thread_num + "#p" + postID + "' title='Highlight this post'>No.</a><a href='/" + board + "/res/" + data.thread_num + "#q" + postID + "' title='Quote this post'>" + postID + "</a>" + (isOP ? ' ' : '') + "</span> "
|
||||
});
|
||||
time = $('.dateTime', pi);
|
||||
date = new Date(data.timestamp * 1000);
|
||||
date.setHours(date.getHours() + date.getTimezoneOffset() / 60 - 5 + 1 * $.isDST(date));
|
||||
Time.date = date;
|
||||
time.textContent = "" + (Time.formatters.m()) + "/" + (Time.formatters.d()) + "/" + (Time.formatters.y()) + "(" + (Time.formatters.a()) + ")" + (Time.formatters.H()) + ":" + (Time.formatters.M());
|
||||
$('.subject', pi).textContent = data.title;
|
||||
nameBlock = $('.nameBlock', pi);
|
||||
if (data.email) {
|
||||
@ -3162,7 +3147,6 @@
|
||||
})
|
||||
]);
|
||||
}
|
||||
capcode = data.capcode;
|
||||
if (capcode !== 'N') {
|
||||
$.add(nameBlock, [
|
||||
$.tn(' '), $.el('strong', {
|
||||
|
||||
@ -370,60 +370,6 @@ $.extend $,
|
||||
# Round to an integer otherwise.
|
||||
Math.round size
|
||||
"#{size} #{['B', 'KB', 'MB', 'GB'][unit]}"
|
||||
isDST: (d) ->
|
||||
# http://en.wikipedia.org/wiki/Eastern_Time_Zone
|
||||
# Its UTC time offset is −5 hrs (UTC−05) during standard time and −4
|
||||
# hrs (UTC−04) during daylight saving time.
|
||||
|
||||
# Since 2007, the local time changes at 02:00 EST to 03:00 EDT on the second
|
||||
# Sunday in March and returns at 02:00 EDT to 01:00 EST on the first Sunday
|
||||
# in November, in the U.S. as well as in Canada.
|
||||
|
||||
# 0200 EST (UTC-05) = 0700 UTC
|
||||
# 0200 EDT (UTC-04) = 0600 UTC
|
||||
|
||||
date = d.getUTCDate()
|
||||
day = d.getUTCDay()
|
||||
hours = d.getUTCHours()
|
||||
month = d.getUTCMonth()
|
||||
|
||||
# This is the easy part.
|
||||
if 2 > month or month > 10
|
||||
return false
|
||||
if 2 < month < 10
|
||||
return true
|
||||
|
||||
# (sunday's date) = (today's date) - (number of days past sunday)
|
||||
# date is not zero-indexed
|
||||
sunday = date - day
|
||||
|
||||
if month is 2
|
||||
# before second sunday
|
||||
if sunday < 8
|
||||
return false
|
||||
|
||||
# during second sunday
|
||||
if sunday < 15 and day is 0
|
||||
if hours < 7
|
||||
return false
|
||||
return true
|
||||
|
||||
# after second sunday
|
||||
return true
|
||||
|
||||
# month is 10
|
||||
# before first sunday
|
||||
if sunday < 1
|
||||
return true
|
||||
|
||||
# during first sunday
|
||||
if sunday < 8 and day is 0
|
||||
if hours < 6
|
||||
return true
|
||||
return false
|
||||
|
||||
# after first sunday
|
||||
return false
|
||||
|
||||
$.cache.requests = {}
|
||||
|
||||
@ -2436,22 +2382,40 @@ Get =
|
||||
piM = $.el 'div',
|
||||
id: "pim#{postID}"
|
||||
className: 'postInfoM mobile'
|
||||
innerHTML: '' # XXX
|
||||
innerHTML: "<span class=nameBlock><span class=name></span><br><span class=subject></span></span><span class='dateTime postNum' data-utc=#{timestamp}>#{data.fourchan_date}<br><em></em><a href='/#{board}/res/#{data.thread_num}#p#{postID}' title='Highlight this post'>No.</a><a href='/#{board}/res/#{data.thread_num}#q#{postID}' title='Quote this post'>#{postID}</a></span>"
|
||||
$('.name', piM).textContent = data.name
|
||||
$('.subject', piM).textContent = data.title
|
||||
br = $ 'br', piM
|
||||
if data.trip
|
||||
$.before br, [$.tn(' '), $.el 'span',
|
||||
className: 'postertrip'
|
||||
textContent: data.trip
|
||||
]
|
||||
{capcode} = data
|
||||
if capcode isnt 'N' # 'A'dmin or 'M'od
|
||||
# XXX not sure if this is correct for mods
|
||||
$.addClass br.parentNode, if capcode is 'A' then 'capcodeAdmin' else 'capcodeMod'
|
||||
$.before br, [
|
||||
$.tn(' '),
|
||||
$.el('strong',
|
||||
className: 'capcode',
|
||||
textContent: if capcode is 'A' then '## Admin' else '## Mod'
|
||||
),
|
||||
$.tn(' '),
|
||||
$.el('img',
|
||||
src: if capcode is 'A' then '//static.4chan.org/image/adminicon.gif' else '//static.4chan.org/image/modicon.gif',
|
||||
alt: if capcode is 'A' then 'This user is the 4chan Administrator.' else 'This user is a 4chan Moderator.',
|
||||
title: if capcode is 'A' then 'This user is the 4chan Administrator.' else 'This user is a 4chan Moderator.',
|
||||
className: 'identityIcon'
|
||||
)
|
||||
]
|
||||
|
||||
|
||||
# post info
|
||||
pi = $.el 'div',
|
||||
id: "pi#{postID}"
|
||||
className: 'postInfo desktop'
|
||||
innerHTML: "<input type=checkbox name=#{postID} value=delete> <span class=userInfo><span class=subject></span> <span class=nameBlock></span></span> <span class=dateTime data-utc=#{data.timestamp}></span> <span class='postNum desktop'><a href='/#{board}/res/#{data.thread_num}#p#{postID}' title='Highlight this post'>No.</a><a href='/#{board}/res/#{data.thread_num}#q#{postID}' title='Quote this post'>#{postID}</a>#{if isOP then ' ' else ''}</span> "
|
||||
# time
|
||||
time = $ '.dateTime', pi
|
||||
# UTC -> Local time
|
||||
date = new Date data.timestamp * 1000
|
||||
# Local time -> UTC -> EST/EDT (UTC-5/UTC-4)
|
||||
date.setHours date.getHours() + date.getTimezoneOffset() / 60 - 5 + 1 * $.isDST date
|
||||
Time.date = date
|
||||
time.textContent = "#{Time.formatters.m()}/#{Time.formatters.d()}/#{Time.formatters.y()}(#{Time.formatters.a()})#{Time.formatters.H()}:#{Time.formatters.M()}"
|
||||
innerHTML: "<input type=checkbox name=#{postID} value=delete> <span class=userInfo><span class=subject></span> <span class=nameBlock></span></span> <span class=dateTime data-utc=#{data.timestamp}>data.fourchan_date</span> <span class='postNum desktop'><a href='/#{board}/res/#{data.thread_num}#p#{postID}' title='Highlight this post'>No.</a><a href='/#{board}/res/#{data.thread_num}#q#{postID}' title='Quote this post'>#{postID}</a>#{if isOP then ' ' else ''}</span> "
|
||||
# subject
|
||||
$('.subject', pi).textContent = data.title
|
||||
|
||||
@ -2467,7 +2431,6 @@ Get =
|
||||
textContent: data.name
|
||||
if data.trip
|
||||
$.add nameBlock, [$.tn(' '), $.el('span', className: 'postertrip', textContent: data.trip)]
|
||||
{capcode} = data
|
||||
if capcode isnt 'N' # 'A'dmin or 'M'od
|
||||
$.add nameBlock, [
|
||||
$.tn(' '),
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user