From 80916da9d109cfb6109f00e502f307e78eda6f3f Mon Sep 17 00:00:00 2001 From: WubTheCaptain Date: Sat, 19 Sep 2015 10:51:34 +0000 Subject: Change JS indentation from tabs to two spaces Airbnb, Google, npm, Node.js and Idiomatic style guides suggest to use two spaces for indentation. It seems to be the widely agreed consensus. --- js/pomf.js | 292 ++++++++++++++++++++++++++++++------------------------------- 1 file changed, 146 insertions(+), 146 deletions(-) (limited to 'js/pomf.js') diff --git a/js/pomf.js b/js/pomf.js index c066b7f..aa7d64d 100644 --- a/js/pomf.js +++ b/js/pomf.js @@ -1,148 +1,148 @@ $(function () { - var uploadInput = $('#upload-input') - , uploadBtn = $('#upload-btn') - , uploadFiles = $('#upload-filelist') - - var btnContent = "" - - if (!$.hasFileAPI()) { - $('#no-file-api').show() - uploadBtn.hide() - } - - uploadBtn.cabinet(uploadInput) - - uploadBtn.on('dragenter', function (e) { - if (this === e.target) { - $(this).addClass('drop') - btnContent = $(this).html() - $(this).html('Drop it here~') - } - }) - - uploadBtn.on('drop', function (e) { - $(this).trigger('dragleave') - }) - - uploadBtn.on('dragleave', function (e) { - node = e.target - do { - if (node === this) { - $(this).removeClass('drop') - $(this).html(btnContent) - break - } - } while (node = node.parentNode) - }) - - var MAX_SIZE = (function (node) { - var max = node.attr('data-max-size') || '120MiB' - var num = parseInt(/([0-9,]+).*/.exec(max)[1].replace(',', '')) - var unit = /(?:([KMGTPEZY])(i)?B|([BKMGTPEZY]))/.exec(max) || ["B","",""] - - var oneUnit = Math.pow( - (unit[2] === "i" ? 1024 : 1000), - 'BKMGTPEZY'.indexOf(unit[1]) - ) - - return num * oneUnit - })(uploadInput) - - var createRow = function (filename, size, extra) { - var rowItem = $('
  • ') - , rowName = $('') - , rowProg = $('
    ') - , rowSize = $('') - , rowUrl = $('') - - rowItem.addClass(extra || '') - - $('
    ').appendTo(rowProg) - - rowItem.attr('data-filename', escape(filename)) - rowName.text(filename) - rowSize.text(size) - - rowItem.append(rowName, rowProg, rowSize, rowUrl) - - return rowItem - } - - uploadBtn.on('change', function (e) { - uploadFiles.empty().removeClass('error completed') - - var files = uploadInput[0].filelist; - - files.forEach(function (file) { - createRow(file.name, file.humanSize).appendTo(uploadFiles) - }) - - var totalRow = createRow('', files.humanSize, 'total') - totalRow.appendTo(uploadFiles) - - if (files.size > MAX_SIZE) { - uploadFiles.addClass('error') - - $('.file-name', totalRow).html('onii-chan y-your upload is t-too big…'); - return - } - - var up = files.upload("upload.php") - - var eachRow = function (files, fn) { - var hits = {} - files.forEach(function (file) { - ++hits[file.name] || (hits[file.name] = 0) - var row = $($('li[data-filename="' + escape(file.name) + '"]')[hits[file.name] || 0]) - fn.call(row, row, file, files) - }) - } - - var totalName = $('.file-name', totalRow) - - up.on('uploadprogress', function (e, files) { - eachRow(files, function (row, file, files) { - $('.progress-inner', row).width((file.percentUploaded * 100) + '%') - }) - $('.progress-inner', totalRow).width((files.percentUploaded * 100) + '%') - }) - - up.on('uploadcomplete', function (e) { - $('.progress-inner').width('100%') - totalName.text('Grabbing URLs...') - }) - - up.on('load', function (e, res) { - switch (e.target.status) { - case 200: - var res = JSON.parse(res) - if (!res.success) { - uploadFiles.addClass('error') - $('.file-name', totalRow).text('Something went wrong; try again later.') - break - } - eachRow(res.files, function (row, file, files) { - var link = $('') - - link.attr('href', file.url) - .attr('target', '_BLANK') - .text(file.url.replace("http://","").replace("https://","")) - - $('.file-url', row).append(link) - }) - uploadFiles.addClass('completed') - totalName.text('Done!') - break - case 413: - uploadFiles.addClass('error completed') - // Terrible work-around, but necessary since otherwise the '…' entity is left decoded - totalName.html($('
    ').html('onii-chan, y-your upload is t-too big…').text()); - break - default: - uploadFiles.addClass('error completed') - totalName.text('Something went wrong; try again later.') - } - }) - up.upload() - }) + var uploadInput = $('#upload-input') + , uploadBtn = $('#upload-btn') + , uploadFiles = $('#upload-filelist') + + var btnContent = "" + + if (!$.hasFileAPI()) { + $('#no-file-api').show() + uploadBtn.hide() + } + + uploadBtn.cabinet(uploadInput) + + uploadBtn.on('dragenter', function (e) { + if (this === e.target) { + $(this).addClass('drop') + btnContent = $(this).html() + $(this).html('Drop it here~') + } + }) + + uploadBtn.on('drop', function (e) { + $(this).trigger('dragleave') + }) + + uploadBtn.on('dragleave', function (e) { + node = e.target + do { + if (node === this) { + $(this).removeClass('drop') + $(this).html(btnContent) + break + } + } while (node = node.parentNode) + }) + + var MAX_SIZE = (function (node) { + var max = node.attr('data-max-size') || '120MiB' + var num = parseInt(/([0-9,]+).*/.exec(max)[1].replace(',', '')) + var unit = /(?:([KMGTPEZY])(i)?B|([BKMGTPEZY]))/.exec(max) || ["B","",""] + + var oneUnit = Math.pow( + (unit[2] === "i" ? 1024 : 1000), + 'BKMGTPEZY'.indexOf(unit[1]) + ) + + return num * oneUnit + })(uploadInput) + + var createRow = function (filename, size, extra) { + var rowItem = $('
  • ') + , rowName = $('') + , rowProg = $('
    ') + , rowSize = $('') + , rowUrl = $('') + + rowItem.addClass(extra || '') + + $('
    ').appendTo(rowProg) + + rowItem.attr('data-filename', escape(filename)) + rowName.text(filename) + rowSize.text(size) + + rowItem.append(rowName, rowProg, rowSize, rowUrl) + + return rowItem + } + + uploadBtn.on('change', function (e) { + uploadFiles.empty().removeClass('error completed') + + var files = uploadInput[0].filelist; + + files.forEach(function (file) { + createRow(file.name, file.humanSize).appendTo(uploadFiles) + }) + + var totalRow = createRow('', files.humanSize, 'total') + totalRow.appendTo(uploadFiles) + + if (files.size > MAX_SIZE) { + uploadFiles.addClass('error') + + $('.file-name', totalRow).html('onii-chan y-your upload is t-too big…'); + return + } + + var up = files.upload("upload.php") + + var eachRow = function (files, fn) { + var hits = {} + files.forEach(function (file) { + ++hits[file.name] || (hits[file.name] = 0) + var row = $($('li[data-filename="' + escape(file.name) + '"]')[hits[file.name] || 0]) + fn.call(row, row, file, files) + }) + } + + var totalName = $('.file-name', totalRow) + + up.on('uploadprogress', function (e, files) { + eachRow(files, function (row, file, files) { + $('.progress-inner', row).width((file.percentUploaded * 100) + '%') + }) + $('.progress-inner', totalRow).width((files.percentUploaded * 100) + '%') + }) + + up.on('uploadcomplete', function (e) { + $('.progress-inner').width('100%') + totalName.text('Grabbing URLs...') + }) + + up.on('load', function (e, res) { + switch (e.target.status) { + case 200: + var res = JSON.parse(res) + if (!res.success) { + uploadFiles.addClass('error') + $('.file-name', totalRow).text('Something went wrong; try again later.') + break + } + eachRow(res.files, function (row, file, files) { + var link = $('') + + link.attr('href', file.url) + .attr('target', '_BLANK') + .text(file.url.replace("http://","").replace("https://","")) + + $('.file-url', row).append(link) + }) + uploadFiles.addClass('completed') + totalName.text('Done!') + break + case 413: + uploadFiles.addClass('error completed') + // Terrible work-around, but necessary since otherwise the '…' entity is left decoded + totalName.html($('
    ').html('onii-chan, y-your upload is t-too big…').text()); + break + default: + uploadFiles.addClass('error completed') + totalName.text('Something went wrong; try again later.') + } + }) + up.upload() + }) }) -- cgit v1.2.3 From 00de9a775b2bdcb5d3285b2048261612b64c6f27 Mon Sep 17 00:00:00 2001 From: WubTheCaptain Date: Sat, 19 Sep 2015 11:16:44 +0000 Subject: Add JSHint header --- js/pomf.js | 1 + 1 file changed, 1 insertion(+) (limited to 'js/pomf.js') diff --git a/js/pomf.js b/js/pomf.js index aa7d64d..81c7ac8 100644 --- a/js/pomf.js +++ b/js/pomf.js @@ -1,3 +1,4 @@ +/* jshint browser:true, jquery:true */ $(function () { var uploadInput = $('#upload-input') , uploadBtn = $('#upload-btn') -- cgit v1.2.3 From f93e6e1eec495bbf6af43754355c5f7ba1bdf47e Mon Sep 17 00:00:00 2001 From: WubTheCaptain Date: Sat, 19 Sep 2015 14:35:40 +0000 Subject: JSBeautify with few hand adjustments This fixes another npm style guide idiom, which is "comma first". --- js/pomf.js | 52 ++++++++++++++++++++++++++-------------------------- 1 file changed, 26 insertions(+), 26 deletions(-) (limited to 'js/pomf.js') diff --git a/js/pomf.js b/js/pomf.js index 81c7ac8..34fed72 100644 --- a/js/pomf.js +++ b/js/pomf.js @@ -1,8 +1,8 @@ /* jshint browser:true, jquery:true */ -$(function () { - var uploadInput = $('#upload-input') - , uploadBtn = $('#upload-btn') - , uploadFiles = $('#upload-filelist') +$(function() { + var uploadInput = $('#upload-input'), + uploadBtn = $('#upload-btn'), + uploadFiles = $('#upload-filelist') var btnContent = "" @@ -13,7 +13,7 @@ $(function () { uploadBtn.cabinet(uploadInput) - uploadBtn.on('dragenter', function (e) { + uploadBtn.on('dragenter', function(e) { if (this === e.target) { $(this).addClass('drop') btnContent = $(this).html() @@ -21,11 +21,11 @@ $(function () { } }) - uploadBtn.on('drop', function (e) { + uploadBtn.on('drop', function(e) { $(this).trigger('dragleave') }) - uploadBtn.on('dragleave', function (e) { + uploadBtn.on('dragleave', function(e) { node = e.target do { if (node === this) { @@ -36,10 +36,10 @@ $(function () { } while (node = node.parentNode) }) - var MAX_SIZE = (function (node) { + var MAX_SIZE = (function(node) { var max = node.attr('data-max-size') || '120MiB' var num = parseInt(/([0-9,]+).*/.exec(max)[1].replace(',', '')) - var unit = /(?:([KMGTPEZY])(i)?B|([BKMGTPEZY]))/.exec(max) || ["B","",""] + var unit = /(?:([KMGTPEZY])(i)?B|([BKMGTPEZY]))/.exec(max) || ["B", "", ""] var oneUnit = Math.pow( (unit[2] === "i" ? 1024 : 1000), @@ -49,12 +49,12 @@ $(function () { return num * oneUnit })(uploadInput) - var createRow = function (filename, size, extra) { - var rowItem = $('
  • ') - , rowName = $('') - , rowProg = $('
    ') - , rowSize = $('') - , rowUrl = $('') + var createRow = function(filename, size, extra) { + var rowItem = $('
  • '), + rowName = $(''), + rowProg = $('
    '), + rowSize = $(''), + rowUrl = $('') rowItem.addClass(extra || '') @@ -69,12 +69,12 @@ $(function () { return rowItem } - uploadBtn.on('change', function (e) { + uploadBtn.on('change', function(e) { uploadFiles.empty().removeClass('error completed') var files = uploadInput[0].filelist; - files.forEach(function (file) { + files.forEach(function(file) { createRow(file.name, file.humanSize).appendTo(uploadFiles) }) @@ -90,9 +90,9 @@ $(function () { var up = files.upload("upload.php") - var eachRow = function (files, fn) { + var eachRow = function(files, fn) { var hits = {} - files.forEach(function (file) { + files.forEach(function(file) { ++hits[file.name] || (hits[file.name] = 0) var row = $($('li[data-filename="' + escape(file.name) + '"]')[hits[file.name] || 0]) fn.call(row, row, file, files) @@ -101,19 +101,19 @@ $(function () { var totalName = $('.file-name', totalRow) - up.on('uploadprogress', function (e, files) { - eachRow(files, function (row, file, files) { + up.on('uploadprogress', function(e, files) { + eachRow(files, function(row, file, files) { $('.progress-inner', row).width((file.percentUploaded * 100) + '%') }) $('.progress-inner', totalRow).width((files.percentUploaded * 100) + '%') }) - up.on('uploadcomplete', function (e) { + up.on('uploadcomplete', function(e) { $('.progress-inner').width('100%') totalName.text('Grabbing URLs...') }) - up.on('load', function (e, res) { + up.on('load', function(e, res) { switch (e.target.status) { case 200: var res = JSON.parse(res) @@ -122,12 +122,12 @@ $(function () { $('.file-name', totalRow).text('Something went wrong; try again later.') break } - eachRow(res.files, function (row, file, files) { + eachRow(res.files, function(row, file, files) { var link = $('') - link.attr('href', file.url) + link.attr('href', file.url) .attr('target', '_BLANK') - .text(file.url.replace("http://","").replace("https://","")) + .text(file.url.replace("http://", "").replace("https://", "")) $('.file-url', row).append(link) }) -- cgit v1.2.3 From 40de8d58015700a04ccd376f3a8324422f6c9132 Mon Sep 17 00:00:00 2001 From: WubTheCaptain Date: Sat, 19 Sep 2015 14:38:15 +0000 Subject: Hand align variables to same indentation --- js/pomf.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'js/pomf.js') diff --git a/js/pomf.js b/js/pomf.js index 34fed72..c5474fb 100644 --- a/js/pomf.js +++ b/js/pomf.js @@ -51,10 +51,10 @@ $(function() { var createRow = function(filename, size, extra) { var rowItem = $('
  • '), - rowName = $(''), - rowProg = $('
    '), - rowSize = $(''), - rowUrl = $('') + rowName = $(''), + rowProg = $('
    '), + rowSize = $(''), + rowUrl = $('') rowItem.addClass(extra || '') -- cgit v1.2.3 From 109e8c3b85bbea468607b92c3e09650093a2a7e4 Mon Sep 17 00:00:00 2001 From: WubTheCaptain Date: Sat, 19 Sep 2015 14:46:39 +0000 Subject: Add semicolons to JavaScript source The npm style guide is bad. Don't use it! The lack of semicolons can create very subtle bugs that are hard to debug. This commit fixes about a hundred JSHint warnings. --- js/pomf.js | 146 ++++++++++++++++++++++++++++++------------------------------- 1 file changed, 73 insertions(+), 73 deletions(-) (limited to 'js/pomf.js') diff --git a/js/pomf.js b/js/pomf.js index c5474fb..ec69360 100644 --- a/js/pomf.js +++ b/js/pomf.js @@ -2,148 +2,148 @@ $(function() { var uploadInput = $('#upload-input'), uploadBtn = $('#upload-btn'), - uploadFiles = $('#upload-filelist') + uploadFiles = $('#upload-filelist'); - var btnContent = "" + var btnContent = ""; if (!$.hasFileAPI()) { - $('#no-file-api').show() - uploadBtn.hide() + $('#no-file-api').show(); + uploadBtn.hide(); } - uploadBtn.cabinet(uploadInput) + uploadBtn.cabinet(uploadInput); uploadBtn.on('dragenter', function(e) { if (this === e.target) { - $(this).addClass('drop') - btnContent = $(this).html() - $(this).html('Drop it here~') + $(this).addClass('drop'); + btnContent = $(this).html(); + $(this).html('Drop it here~'); } - }) + }); uploadBtn.on('drop', function(e) { - $(this).trigger('dragleave') - }) + $(this).trigger('dragleave'); + }); uploadBtn.on('dragleave', function(e) { - node = e.target + node = e.target; do { if (node === this) { - $(this).removeClass('drop') - $(this).html(btnContent) - break + $(this).removeClass('drop'); + $(this).html(btnContent); + break; } - } while (node = node.parentNode) - }) + } while (node = node.parentNode); + }); var MAX_SIZE = (function(node) { - var max = node.attr('data-max-size') || '120MiB' - var num = parseInt(/([0-9,]+).*/.exec(max)[1].replace(',', '')) - var unit = /(?:([KMGTPEZY])(i)?B|([BKMGTPEZY]))/.exec(max) || ["B", "", ""] + var max = node.attr('data-max-size') || '120MiB'; + var num = parseInt(/([0-9,]+).*/.exec(max)[1].replace(',', '')); + var unit = /(?:([KMGTPEZY])(i)?B|([BKMGTPEZY]))/.exec(max) || ["B", "", ""]; var oneUnit = Math.pow( (unit[2] === "i" ? 1024 : 1000), 'BKMGTPEZY'.indexOf(unit[1]) - ) + ); - return num * oneUnit - })(uploadInput) + return num * oneUnit; + })(uploadInput); var createRow = function(filename, size, extra) { var rowItem = $('
  • '), rowName = $(''), rowProg = $('
    '), rowSize = $(''), - rowUrl = $('') + rowUrl = $(''); - rowItem.addClass(extra || '') + rowItem.addClass(extra || ''); - $('
    ').appendTo(rowProg) + $('
    ').appendTo(rowProg); - rowItem.attr('data-filename', escape(filename)) - rowName.text(filename) - rowSize.text(size) + rowItem.attr('data-filename', escape(filename)); + rowName.text(filename); + rowSize.text(size); - rowItem.append(rowName, rowProg, rowSize, rowUrl) + rowItem.append(rowName, rowProg, rowSize, rowUrl); - return rowItem - } + return rowItem; + }; uploadBtn.on('change', function(e) { - uploadFiles.empty().removeClass('error completed') + uploadFiles.empty().removeClass('error completed'); var files = uploadInput[0].filelist; files.forEach(function(file) { - createRow(file.name, file.humanSize).appendTo(uploadFiles) - }) + createRow(file.name, file.humanSize).appendTo(uploadFiles); + }); - var totalRow = createRow('', files.humanSize, 'total') - totalRow.appendTo(uploadFiles) + var totalRow = createRow('', files.humanSize, 'total'); + totalRow.appendTo(uploadFiles); if (files.size > MAX_SIZE) { - uploadFiles.addClass('error') + uploadFiles.addClass('error'); $('.file-name', totalRow).html('onii-chan y-your upload is t-too big…'); - return + return; } - var up = files.upload("upload.php") + var up = files.upload("upload.php"); var eachRow = function(files, fn) { - var hits = {} + var hits = {}; files.forEach(function(file) { - ++hits[file.name] || (hits[file.name] = 0) - var row = $($('li[data-filename="' + escape(file.name) + '"]')[hits[file.name] || 0]) - fn.call(row, row, file, files) - }) - } + ++hits[file.name] || (hits[file.name] = 0); + var row = $($('li[data-filename="' + escape(file.name) + '"]')[hits[file.name] || 0]); + fn.call(row, row, file, files); + }); + }; - var totalName = $('.file-name', totalRow) + var totalName = $('.file-name', totalRow); up.on('uploadprogress', function(e, files) { eachRow(files, function(row, file, files) { - $('.progress-inner', row).width((file.percentUploaded * 100) + '%') - }) - $('.progress-inner', totalRow).width((files.percentUploaded * 100) + '%') - }) + $('.progress-inner', row).width((file.percentUploaded * 100) + '%'); + }); + $('.progress-inner', totalRow).width((files.percentUploaded * 100) + '%'); + }); up.on('uploadcomplete', function(e) { - $('.progress-inner').width('100%') - totalName.text('Grabbing URLs...') - }) + $('.progress-inner').width('100%'); + totalName.text('Grabbing URLs...'); + }); up.on('load', function(e, res) { switch (e.target.status) { case 200: - var res = JSON.parse(res) + var res = JSON.parse(res); if (!res.success) { - uploadFiles.addClass('error') - $('.file-name', totalRow).text('Something went wrong; try again later.') - break + uploadFiles.addClass('error'); + $('.file-name', totalRow).text('Something went wrong; try again later.'); + break; } eachRow(res.files, function(row, file, files) { - var link = $('') + var link = $(''); link.attr('href', file.url) .attr('target', '_BLANK') - .text(file.url.replace("http://", "").replace("https://", "")) + .text(file.url.replace("http://", "").replace("https://", "")); - $('.file-url', row).append(link) - }) - uploadFiles.addClass('completed') - totalName.text('Done!') - break + $('.file-url', row).append(link); + }); + uploadFiles.addClass('completed'); + totalName.text('Done!'); + break; case 413: - uploadFiles.addClass('error completed') + uploadFiles.addClass('error completed'); // Terrible work-around, but necessary since otherwise the '…' entity is left decoded totalName.html($('
    ').html('onii-chan, y-your upload is t-too big…').text()); - break + break; default: - uploadFiles.addClass('error completed') - totalName.text('Something went wrong; try again later.') + uploadFiles.addClass('error completed'); + totalName.text('Something went wrong; try again later.'); } - }) - up.upload() - }) -}) + }); + up.upload(); + }); +}); -- cgit v1.2.3 From bc9ddfdf951cd03d3d00af10a082284c6c3ccb8f Mon Sep 17 00:00:00 2001 From: WubTheCaptain Date: Sat, 19 Sep 2015 14:47:33 +0000 Subject: Align link attr indentation --- js/pomf.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'js/pomf.js') diff --git a/js/pomf.js b/js/pomf.js index ec69360..389b590 100644 --- a/js/pomf.js +++ b/js/pomf.js @@ -126,8 +126,8 @@ $(function() { var link = $(''); link.attr('href', file.url) - .attr('target', '_BLANK') - .text(file.url.replace("http://", "").replace("https://", "")); + .attr('target', '_BLANK') + .text(file.url.replace("http://", "").replace("https://", "")); $('.file-url', row).append(link); }); -- cgit v1.2.3 From 556c60d9027d6da1dc373d50adede97ade86d61f Mon Sep 17 00:00:00 2001 From: WubTheCaptain Date: Sat, 19 Sep 2015 15:40:40 +0000 Subject: Use singlequotes Both Google and Node.js style guides prefer the use of ' over ". Much of the rest of this code also uses singlequotes, so this brings the rest of it to same level of consistency. --- js/pomf.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'js/pomf.js') diff --git a/js/pomf.js b/js/pomf.js index 389b590..c1d89de 100644 --- a/js/pomf.js +++ b/js/pomf.js @@ -4,7 +4,7 @@ $(function() { uploadBtn = $('#upload-btn'), uploadFiles = $('#upload-filelist'); - var btnContent = ""; + var btnContent = ''; if (!$.hasFileAPI()) { $('#no-file-api').show(); @@ -39,10 +39,10 @@ $(function() { var MAX_SIZE = (function(node) { var max = node.attr('data-max-size') || '120MiB'; var num = parseInt(/([0-9,]+).*/.exec(max)[1].replace(',', '')); - var unit = /(?:([KMGTPEZY])(i)?B|([BKMGTPEZY]))/.exec(max) || ["B", "", ""]; + var unit = /(?:([KMGTPEZY])(i)?B|([BKMGTPEZY]))/.exec(max) || ['B', '', '']; var oneUnit = Math.pow( - (unit[2] === "i" ? 1024 : 1000), + (unit[2] === 'i' ? 1024 : 1000), 'BKMGTPEZY'.indexOf(unit[1]) ); @@ -88,7 +88,7 @@ $(function() { return; } - var up = files.upload("upload.php"); + var up = files.upload('upload.php'); var eachRow = function(files, fn) { var hits = {}; @@ -127,7 +127,7 @@ $(function() { link.attr('href', file.url) .attr('target', '_BLANK') - .text(file.url.replace("http://", "").replace("https://", "")); + .text(file.url.replace('http://', '').replace('https://', '')); $('.file-url', row).append(link); }); -- cgit v1.2.3 From 287d0536213783c778a69fc9a28ba8b819384156 Mon Sep 17 00:00:00 2001 From: WubTheCaptain Date: Sat, 19 Sep 2015 16:40:48 +0000 Subject: Wrap long lines to 80 characters in length String concatenation is used because line terminating characters are not allowed in the ECMAScript spec. Certain style guides such as Airbnb also endorse using string concatenation. --- js/pomf.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'js/pomf.js') diff --git a/js/pomf.js b/js/pomf.js index c1d89de..7375797 100644 --- a/js/pomf.js +++ b/js/pomf.js @@ -84,7 +84,8 @@ $(function() { if (files.size > MAX_SIZE) { uploadFiles.addClass('error'); - $('.file-name', totalRow).html('onii-chan y-your upload is t-too big…'); + $('.file-name', totalRow).html('onii-chan y-your upload is t-too ' + + 'big…'); return; } @@ -94,7 +95,8 @@ $(function() { var hits = {}; files.forEach(function(file) { ++hits[file.name] || (hits[file.name] = 0); - var row = $($('li[data-filename="' + escape(file.name) + '"]')[hits[file.name] || 0]); + var row = $($('li[data-filename="' + escape(file.name) + '"]') + + [hits[file.name] || 0]); fn.call(row, row, file, files); }); }; @@ -119,7 +121,8 @@ $(function() { var res = JSON.parse(res); if (!res.success) { uploadFiles.addClass('error'); - $('.file-name', totalRow).text('Something went wrong; try again later.'); + $('.file-name', totalRow).text('Something went wrong; try again ' + + 'later.'); break; } eachRow(res.files, function(row, file, files) { @@ -136,8 +139,10 @@ $(function() { break; case 413: uploadFiles.addClass('error completed'); - // Terrible work-around, but necessary since otherwise the '…' entity is left decoded - totalName.html($('
    ').html('onii-chan, y-your upload is t-too big…').text()); + // Terrible work-around, but necessary since otherwise the '…' + // entity is left decoded. + totalName.html($('
    ').html('onii-chan, y-your upload is t-too ' + + 'big…').text()); break; default: uploadFiles.addClass('error completed'); -- cgit v1.2.3