diff --git a/_scripts/app.js b/_scripts/app.js index e2bc3b6..d6562c3 100644 --- a/_scripts/app.js +++ b/_scripts/app.js @@ -15,7 +15,6 @@ function runApp () { var fs = require('fs-extra'); var path = require('path'); - var stat = require('folder-stat'); var base64Img = require('base64-img'); var appData = nw.App.dataPath; var temp = path.join(appData, 'temp'); @@ -427,60 +426,61 @@ function runApp () { $('#imageAltsModal .modal-footer .btn').click(function () { if (!$(this).hasClass('disabled')) { - $('#imageAltsModal').slideUp('slow'); - - var allData = JSON.parse($('#imagealts').val()); - var imagesWithDescriptiveAltText = 0; + var altTagsUnder100Characters = 0; + var totalImages = window.imgAltsParsed.length; + var imagesUnder100KB = 0; + var totalFileSizeInBytes = 0; + var imagesLoaded = 0; + window.confirmedImages.forEach(function (img) { if (img) { imagesWithDescriptiveAltText = imagesWithDescriptiveAltText + 1; } }); - var altTagsUnder100Characters = 0; - allData.forEach(function (img) { - if (img.alt.length <= 100) { - altTagsUnder100Characters = altTagsUnder100Characters + 1; + for (var i = 0, len = window.imgAltsParsed.length; i < len; i++) { + window.imgAltsParsed[i].size = 0; + var imgPath = window.imgAltsParsed[i].path; + var imgAlt = window.imgAltsParsed[i].alt; + + if (imgPath && imgPath.length > 1) { + window.imgAltsParsed[i].size = fs.statSync(imgPath).size; } - }); - var imagesUnder100KB = 0; - var totalFileSizeInBytes = 0; - var imagesLoaded = 0; + var size = window.imgAltsParsed[i].size; - stat(path.join(nw.App.dataPath, 'temp'), function (err, stats, files) { - if (err) { - // eslint-disable-next-line no-console - console.log(err); + if (size <= (100 * 1024)) { + imagesUnder100KB = imagesUnder100KB + 1; } - if (stats) { - stats.forEach(function (file) { - if (file.size <= (100 * 1024)) { - imagesUnder100KB = imagesUnder100KB + 1; - } - totalFileSizeInBytes = totalFileSizeInBytes + file.size; - }); - imagesLoaded = files.length; + totalFileSizeInBytes = totalFileSizeInBytes + size; + + if (size > 0) { + imagesLoaded = imagesLoaded + 1; } - window.imageStats = { - 'totalImages': allData.length, - 'descriptive': imagesWithDescriptiveAltText, - 'nondescriptive': allData.length - imagesWithDescriptiveAltText, - 'under100Char': altTagsUnder100Characters, - 'under100KB': imagesUnder100KB, - 'imagesLoaded': imagesLoaded, - 'totalFileSizeInBytes': totalFileSizeInBytes, - 'totalFileSizeInKB': Math.round((totalFileSizeInBytes / 1024) * 10) / 10, - 'descriptivePercent': Math.round((imagesWithDescriptiveAltText / allData.length) * 100), - 'under100CharPercent': Math.round((altTagsUnder100Characters / allData.length) * 100), - 'under100KBPercent': Math.round((imagesUnder100KB / allData.length) * 100), - 'imagesLoadedPercent': Math.round((imagesLoaded / allData.length) * 100) - }; + if (imgAlt.length <= 100) { + altTagsUnder100Characters = altTagsUnder100Characters + 1; + } + } - runPa11y(); - }); + window.imageStats = { + 'totalImages': totalImages, + 'descriptive': imagesWithDescriptiveAltText, + 'nondescriptive': totalImages - imagesWithDescriptiveAltText, + 'under100Char': altTagsUnder100Characters, + 'under100KB': imagesUnder100KB, + 'imagesLoaded': imagesLoaded, + 'totalFileSizeInBytes': totalFileSizeInBytes, + 'totalFileSizeInKB': Math.round((totalFileSizeInBytes / 1024) * 10) / 10, + 'descriptivePercent': Math.round((imagesWithDescriptiveAltText / totalImages) * 100), + 'under100CharPercent': Math.round((altTagsUnder100Characters / totalImages) * 100), + 'under100KBPercent': Math.round((imagesUnder100KB / totalImages) * 100), + 'imagesLoadedPercent': Math.round((imagesLoaded / totalImages) * 100) + }; + + $('#imageAltsModal').slideUp('slow'); + runPa11y(); } }); diff --git a/index.htm b/index.htm index 84f4a5c..466c845 100644 --- a/index.htm +++ b/index.htm @@ -309,10 +309,12 @@

About Koa11y

This program will load an invisible (headless) browser and go to the URL you've supplied to test the page for accessibility issues. Then it outputs any issues to a file.

- Koa11y created by The Jared Wilcurt
- Visit the Koa11y website.
- For more information visit: Pa11y.org.
- Koala Logo designed by Charlotte Schmidt. + Koa11y was created by The Jared Wilcurt.
+ Koa11y uses Pa11y under the hood to automate checking your page for issues. For more information visit: Pa11y.org.
+ Koala Logo designed by Charlotte Schmidt.

+

+ Visit the Koa11y website. +

diff --git a/package.json b/package.json index 641d000..709c169 100644 --- a/package.json +++ b/package.json @@ -47,7 +47,6 @@ "pa11y": "4.1.1", "phantomjs-prebuilt": "^2.1.14", "json2csv": "3.7.3", - "folder-stat": "^1.0.1", "base64-img": "^1.0.3", "fs-extra": "^0.30.x", "semver": "^5.3.x"