Build = h_staticPath: '//s.4cdn.org/image/' h_gifIcon: if window.devicePixelRatio >= 2 then '@2x.gif' else '.gif' spoilerRange: {} h_escape: (text) -> (text+'').replace /[&"'<>]/g, (c) -> {'&': '&', "'": ''', '"': '"', '<': '<', '>': '>'}[c] unescape: (text) -> return text unless text? text.replace /&(amp|#039|quot|lt|gt);/g, (c) -> {'&': '&', ''': "'", '"': '"', '<': '<', '>': '>'}[c] shortFilename: (filename, isReply) -> # FILENAME SHORTENING SCIENCE: # OPs have a +10 characters threshold. # The file extension is not taken into account. threshold = if isReply then 30 else 40 ext = filename.match(/\.?[^\.]*$/)[0] if filename.length - ext.length > threshold "#{filename[...threshold - 5]}(...)#{ext}" else filename thumbRotate: do -> n = 0 -> n = (n + 1) % 3 postFromObject: (data, boardID) -> o = # id postID: data.no threadID: data.resto or data.no boardID: boardID # info name: Build.unescape data.name capcode: data.capcode tripcode: data.trip uniqueID: data.id email: Build.unescape data.email subject: Build.unescape data.sub flagCode: data.country flagName: Build.unescape data.country_name date: data.now dateUTC: data.time h_comment: data.com or '' # thread status isSticky: !!data.sticky isClosed: !!data.closed # file if data.filedeleted o.file = isDeleted: true else if data.ext o.file = name: (Build.unescape data.filename) + data.ext timestamp: "#{data.tim}#{data.ext}" url: if boardID is 'f' "//i.4cdn.org/#{boardID}/#{encodeURIComponent data.filename}#{data.ext}" else "//i.4cdn.org/#{boardID}/#{data.tim}#{data.ext}" height: data.h width: data.w MD5: data.md5 size: data.fsize turl: "//#{Build.thumbRotate()}.t.4cdn.org/#{boardID}/#{data.tim}s.jpg" theight: data.tn_h twidth: data.tn_w isSpoiler: !!data.spoiler isDeleted: false Build.post o post: (o, isArchived) -> ### This function contains code from 4chan-JS (https://github.com/4chan/4chan-JS). @license: https://github.com/4chan/4chan-JS/blob/master/LICENSE ### E = Build.h_escape { postID, threadID, boardID name, capcode, tripcode, uniqueID, email, subject, flagCode, flagName, date, dateUTC isSticky, isClosed h_comment file } = o name or= '' subject or= '' isOP = postID is threadID {h_staticPath, h_gifIcon} = Build if isOP h_sideArrows = '' else h_sideArrows = "
"
else
h_flag = " "
if file?.isDeleted
if isOP
h_file = "