diff --git a/.eslintrc b/.eslintrc index fb9e312..1f7106f 100644 --- a/.eslintrc +++ b/.eslintrc @@ -19,6 +19,7 @@ globals: it: false jsc: false jsdom: true + kjua: true # http://eslint.org/docs/rules/ rules: diff --git a/.jshintrc b/.jshintrc index 2eb6bce..fabd7e6 100644 --- a/.jshintrc +++ b/.jshintrc @@ -16,26 +16,31 @@ "nonew": true, "quotmark": "single", "singleGroups": true, - "strict": "global", + "strict": true, "undef": true, "unused": true, "jquery": true, + "browser": true, "predef": { - "after": true, - "before": true, - "cleanup": true, - "console": true, - "describe": false, - "document": true, - "fs": false, - "global": true, - "exports": true, - "it": false, - "jsc": false, - "jsdom": true, - "require": false, - "setTimeout": false, - "window": true + "after": true, + "before": true, + "cleanup": true, + "console": true, + "describe": false, + "document": true, + "fs": false, + "global": true, + "exports": true, + "it": false, + "jsc": false, + "jsdom": true, + "require": false, + "setTimeout": false, + "window": true + }, + "globals": { + "sjcl": true, + "DOMPurify": true, + "kjua": true } } - diff --git a/js/privatebin.js b/js/privatebin.js index 197ec58..a39c38a 100644 --- a/js/privatebin.js +++ b/js/privatebin.js @@ -28,6 +28,7 @@ sjcl.random.startCollectors(); // main application start, called when DOM is fully loaded jQuery(document).ready(function() { + 'use strict'; // run main controller $.PrivateBin.Controller.init(); }); @@ -331,7 +332,7 @@ jQuery.PrivateBin = (function($, sjcl, Base64, RawDeflate) { var usesPlurals = $.isArray(args[0]); if (usesPlurals) { // use the first plural form as messageId, otherwise the singular - messageId = (args[0].length > 1 ? args[0][1] : args[0][0]); + messageId = args[0].length > 1 ? args[0][1] : args[0][0]; } else { messageId = args[0]; } @@ -415,16 +416,16 @@ jQuery.PrivateBin = (function($, sjcl, Base64, RawDeflate) { case 'fr': case 'oc': case 'zh': - return (n > 1 ? 1 : 0); + return n > 1 ? 1 : 0; case 'pl': - return (n === 1 ? 0 : (n % 10 >= 2 && n %10 <=4 && (n % 100 < 10 || n % 100 >= 20) ? 1 : 2)); + return n === 1 ? 0 : (n % 10 >= 2 && n %10 <=4 && (n % 100 < 10 || n % 100 >= 20) ? 1 : 2); case 'ru': - return (n % 10 === 1 && n % 100 !== 11 ? 0 : (n % 10 >= 2 && n % 10 <= 4 && (n % 100 < 10 || n % 100 >= 20) ? 1 : 2)); + return n % 10 === 1 && n % 100 !== 11 ? 0 : (n % 10 >= 2 && n % 10 <= 4 && (n % 100 < 10 || n % 100 >= 20) ? 1 : 2); case 'sl': - return (n % 100 === 1 ? 1 : (n % 100 === 2 ? 2 : (n % 100 === 3 || n % 100 === 4 ? 3 : 0))); + return n % 100 === 1 ? 1 : (n % 100 === 2 ? 2 : (n % 100 === 3 || n % 100 === 4 ? 3 : 0)); // de, en, es, it, no, pt default: - return (n !== 1 ? 1 : 0); + return n !== 1 ? 1 : 0; } }; @@ -660,7 +661,7 @@ jQuery.PrivateBin = (function($, sjcl, Base64, RawDeflate) { */ me.hasCipherData = function() { - return (me.getCipherData().length > 0); + return me.getCipherData().length > 0; }; /** @@ -831,7 +832,7 @@ jQuery.PrivateBin = (function($, sjcl, Base64, RawDeflate) { var viewportTop = $(window).scrollTop(); var viewportBottom = viewportTop + $(window).height(); - return (elementTop > viewportTop && elementTop < viewportBottom); + return elementTop > viewportTop && elementTop < viewportBottom; }; /** @@ -1194,8 +1195,8 @@ jQuery.PrivateBin = (function($, sjcl, Base64, RawDeflate) { */ function sendToShortener() { - window.location.href = $shortenButton.data('shortener') - + encodeURIComponent($pasteUrl.attr('href')); + window.location.href = $shortenButton.data('shortener') + + encodeURIComponent($pasteUrl.attr('href')); } /** @@ -2008,7 +2009,7 @@ jQuery.PrivateBin = (function($, sjcl, Base64, RawDeflate) { me.hasAttachment = function() { var link = $attachmentLink.prop('href'); - return (typeof link !== 'undefined' && link !== ''); + return typeof link !== 'undefined' && link !== ''; }; /** diff --git a/tpl/bootstrap.php b/tpl/bootstrap.php index c1e3a6e..f97437b 100644 --- a/tpl/bootstrap.php +++ b/tpl/bootstrap.php @@ -75,7 +75,7 @@ if ($MARKDOWN): - + diff --git a/tpl/page.php b/tpl/page.php index 5992336..370f5f9 100644 --- a/tpl/page.php +++ b/tpl/page.php @@ -54,7 +54,7 @@ if ($QRCODE): - +