FileInfo = init: -> return if g.VIEW not in ['index', 'thread'] or !Conf['File Info Formatting'] Post.callbacks.push name: 'File Info Formatting' cb: @node node: -> return if !@file or @isClone oldInfo = $.el 'span', {className: 'fileText-original'} $.prepend @file.link.parentNode, oldInfo $.add oldInfo, [@file.link.previousSibling, @file.link, @file.link.nextSibling] info = $.el 'span', {className: 'file-info'} FileInfo.format Conf['fileInfo'], @, info $.prepend @file.text, info format: (formatString, post, outputNode) -> output = [] formatString.replace /%(.)|[^%]+/g, (s, c) -> output.push if c of FileInfo.formatters FileInfo.formatters[c].call post else <%= html('${s}') %> '' $.extend outputNode, <%= html('@{output}') %> formatters: t: -> <%= html('${this.file.url.match(/[^\/]*$/)[0]}') %> T: -> <%= html('&{FileInfo.formatters.t.call(this)}') %> l: -> <%= html('&{FileInfo.formatters.n.call(this)}') %> L: -> <%= html('&{FileInfo.formatters.N.call(this)}') %> n: -> fullname = @file.name shortname = Build.shortFilename @file.name, @isReply if fullname is shortname <%= html('${fullname}') %> else <%= html('${shortname}${fullname}') %> N: -> <%= html('${this.file.name}') %> p: -> <%= html('?{this.file.isSpoiler}{Spoiler, }') %> s: -> <%= html('${this.file.size}') %> B: -> <%= html('${Math.round(this.file.sizeInBytes)} Bytes') %> K: -> <%= html('${Math.round(this.file.sizeInBytes/1024)} KB') %> M: -> <%= html('${Math.round(this.file.sizeInBytes/1048576*100)/100} MB') %> r: -> <%= html('${this.file.dimensions || "PDF"}') %> '%': -> <%= html('%') %>