/* * decaffeinate suggestions: * DS102: Remove unnecessary code created because of implicit returns * Full docs: https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md */ var FileInfo = { init() { if (!['index', 'thread', 'archive'].includes(g.VIEW) || !Conf['File Info Formatting']) { return; } return Callbacks.Post.push({ name: 'File Info Formatting', cb: this.node }); }, node() { if (!this.file) { return; } if (this.isClone) { let a; for (a of $$('.file-info .download-button', this.file.text)) { $.on(a, 'click', ImageCommon.download); } for (a of $$('.file-info .quick-filter-md5', this.file.text)) { $.on(a, 'click', Filter.quickFilterMD5); } return; } const oldInfo = $.el('span', {className: 'fileText-original'}); $.prepend(this.file.link.parentNode, oldInfo); $.add(oldInfo, [this.file.link.previousSibling, this.file.link, this.file.link.nextSibling]); const info = $.el('span', {className: 'file-info'}); FileInfo.format(Conf['fileInfo'], this, info); return $.prepend(this.file.text, info); }, format(formatString, post, outputNode) { let a; const output = []; formatString.replace(/%(.)|[^%]+/g, function(s, c) { output.push($.hasOwn(FileInfo.formatters, c) ? FileInfo.formatters[c].call(post) : {innerHTML: E(s)} ); return ''; }); $.extend(outputNode, {innerHTML: E.cat(output)}); for (a of $$('.download-button', outputNode)) { $.on(a, 'click', ImageCommon.download); } for (a of $$('.quick-filter-md5', outputNode)) { $.on(a, 'click', Filter.quickFilterMD5); } }, formatters: { t() { return {innerHTML: E(this.file.url.match(/[^/]*$/)[0])}; }, T() { return {innerHTML: "" + (FileInfo.formatters.t.call(this)).innerHTML + ""}; }, l() { return {innerHTML: "" + (FileInfo.formatters.n.call(this)).innerHTML + ""}; }, L() { return {innerHTML: "" + (FileInfo.formatters.N.call(this)).innerHTML + ""}; }, n() { const fullname = this.file.name; const shortname = SW.yotsuba.Build.shortFilename(this.file.name, this.isReply); if (fullname === shortname) { return {innerHTML: E(fullname)}; } else { return {innerHTML: "" + E(shortname) + "" + E(fullname) + ""}; } }, N() { return {innerHTML: E(this.file.name)}; }, d() { return {innerHTML: ""}; }, f() { return {innerHTML: ""}; }, p() { return {innerHTML: ((this.file.isSpoiler) ? "Spoiler, " : "")}; }, s() { return {innerHTML: E(this.file.size)}; }, B() { return {innerHTML: E(Math.round(this.file.sizeInBytes)) + " Bytes"}; }, K() { return {innerHTML: E(Math.round(this.file.sizeInBytes/1024)) + " KB"}; }, M() { return {innerHTML: E(Math.round(this.file.sizeInBytes/1048576*100)/100) + " MB"}; }, r() { return {innerHTML: E(this.file.dimensions || "PDF")}; }, g() { return {innerHTML: ((this.file.tag) ? ", " + E(this.file.tag) : "")}; }, '%'() { return {innerHTML: "%"}; } } };