소스 검색

chore: remove jQuery library

rugk 1 개월 전
부모
커밋
df04d3692e
8개의 변경된 파일27개의 추가작업 그리고 35개의 파일을 삭제
  1. 1 1
      .github/copilot-instructions.md
  2. 1 1
      .jshintrc
  3. 0 2
      js/.istanbul.yml
  4. 0 1
      js/common.js
  5. 0 1
      js/jquery-3.7.1.js
  6. 8 9
      js/legacy.js
  7. 15 17
      js/privatebin.js
  8. 2 3
      lib/Configuration.php

+ 1 - 1
.github/copilot-instructions.md

@@ -38,7 +38,7 @@
 
 - **No explicit build step** for PHP. The web app is served directly from source.
   - This means **composer directory** need to be comitted (_except_ of big optional dependences like Google Cloud like GCS support or similar!)
-- **For JavaScript:** There is no webpack/bundler step for release; browser JS is written in compatible ES6+ syntax, except in `legacy.js` (which must be designed to run cleanly even on ancient IE4 or Netscape to display the error message that a browser upgrade is necessary). We are trying to avoid jQuery in any new code and would like to eventually drop use of jQuery. We are considering modularizing the JS logic, but need to ensure to do so in a way that will work both in the browser as well as for node JS driven unit tests.
+- **For JavaScript:** There is no webpack/bundler step for release; browser JS is written in compatible ES6+ syntax, except in `legacy.js` (which must be designed to run cleanly even on ancient IE4 or Netscape to display the error message that a browser upgrade is necessary). We dropped use of jQuery. We are considering modularizing the JS logic, but need to ensure to do so in a way that will work both in the browser as well as for node JS driven unit tests.
 
 ### Run
 

+ 1 - 1
.jshintrc

@@ -19,7 +19,7 @@
     "strict": true,
     "undef": true,
     "unused": true,
-    "jquery": true,
+    "jquery": false,
     "browser": true,
     "predef": {
       "after": true,

+ 0 - 2
js/.istanbul.yml

@@ -1,7 +1,5 @@
 ---
 instrumentation:
-  excludes:
-    - jquery-3.7.1.js
   baseline-file: ../tst/log/js-coverage-baseline.json
 reporting:
   dir: ../tst/log/js-coverage-report

+ 0 - 1
js/common.js

@@ -26,7 +26,6 @@ global.fs = require('fs');
 global.WebCrypto = require('@peculiar/webcrypto').Crypto;
 
 // application libraries to test
-global.$ = global.jQuery = require('./jquery-3.7.1');
 global.zlib = require('./zlib').zlib;
 require('./prettify');
 global.prettyPrint = window.PR ? window.PR.prettyPrint : function() {};

파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 0 - 1
js/jquery-3.7.1.js


+ 8 - 9
js/legacy.js

@@ -13,7 +13,6 @@
 /**
  * IMPORTANT NOTICE FOR DEVELOPERS:
  * The logic in this file is intended to run in legacy browsers. Avoid any use of:
- * - jQuery (doesn't work in older browsers)
  * - ES5 or newer in general
  * - const/let, use the traditional var declarations instead
  * - async/await or Promises, use traditional callbacks
@@ -68,26 +67,26 @@
             'Spider',
             'scraper',
             'Scraper',
-            
+
             // Search Engines
             'Mediapartners-Google',
             'BingPreview',
             'Yahoo! Slurp',
-            
+
             // SEO & Analytics
             'Screaming Frog',
-            
+
             // Social Media
             'facebookexternalhit',
-            
+
             // AI & LLM
             'ChatGPT-User',
             'anthropic-ai',
-            
+
             // Security Scanners
             'CensysInspect',
             'Shodan',
-            
+
             // Other Common Crawlers
             '80legs',
             'ia_archiver',
@@ -171,7 +170,7 @@
          * @private
          * @name   Check.isBadBot
          * @function
-         * @return {bool}
+         * @return {Boolean}
          */
         function isBadBot() {
             // check whether a bot user agent part can be found in the current
@@ -262,7 +261,7 @@
          *
          * @name   Check.getStatus
          * @function
-         * @return {bool}
+         * @return {Boolean}
          */
         me.getStatus = function()
         {

+ 15 - 17
js/privatebin.js

@@ -397,7 +397,6 @@ window.PrivateBin = (function () {
         /**
          * text range selection
          *
-         * @see    {@link https://stackoverflow.com/questions/985272/jquery-selecting-text-in-an-element-akin-to-highlighting-with-your-mouse}
          * @name   Helper.selectText
          * @function
          * @param  {HTMLElement} element
@@ -405,13 +404,12 @@ window.PrivateBin = (function () {
         me.selectText = function (element) {
             let range, selection;
 
-            // MS
-            if (document.body.createTextRange) {
-                range = document.body.createTextRange();
-                range.moveToElementText(element);
-                range.select();
-            } else if (window.getSelection) {
+            if (window.getSelection) {
                 selection = window.getSelection();
+                if (!selection) {
+                    console.warn('window.getSelection() returned null, could not get any select text');
+                    return;
+                }
                 range = document.createRange();
                 range.selectNodeContents(element);
                 selection.removeAllRanges();
@@ -1875,7 +1873,7 @@ window.PrivateBin = (function () {
          * alertType (see array), $element, args, icon
          * If it returns true, the own processing will be stopped so the message
          * will not be displayed. Otherwise it will continue.
-         * As an aditional feature it can return q jQuery element, which will
+         * As an aditional feature it can return a HTMLElement, which will
          * then be used to add the message there. Icons are not supported in
          * that case and will be ignored.
          * Pass 'null' to reset/delete the custom handler.
@@ -1893,7 +1891,7 @@ window.PrivateBin = (function () {
         /**
          * init status manager
          *
-         * preloads jQuery elements
+         * preloads HTMLElements
          *
          * @name   Alert.init
          * @function
@@ -2141,7 +2139,7 @@ window.PrivateBin = (function () {
         /**
          * init status manager
          *
-         * preloads jQuery elements
+         * preloads HTMLElements
          *
          * @name   PasteStatus.init
          * @function
@@ -2280,7 +2278,7 @@ window.PrivateBin = (function () {
         /**
          * init status manager
          *
-         * preloads jQuery elements
+         * preloads HTMLElements
          *
          * @name   Prompt.init
          * @function
@@ -2345,8 +2343,8 @@ window.PrivateBin = (function () {
          *
          * @name   Editor.supportTabs
          * @function
-         * @param  {Event} event
-         * @this $message (but not used, so it is jQuery-free, possibly faster)
+         * @param  {KeyboardEvent} event
+         * @this message
          */
         function supportTabs(event) {
             // support disabling tab support using [Esc] and [Ctrl]+[m]
@@ -2547,7 +2545,7 @@ window.PrivateBin = (function () {
         /**
          * init editor
          *
-         * preloads jQuery elements
+         * preloads HTMLElements and binds events
          *
          * @name   Editor.init
          * @function
@@ -3372,7 +3370,7 @@ window.PrivateBin = (function () {
         /**
          * initiate
          *
-         * preloads jQuery elements
+         * preloads HTMLElements
          *
          * @name   AttachmentViewer.init
          * @function
@@ -3484,7 +3482,7 @@ window.PrivateBin = (function () {
          * @name   DiscussionViewer.handleNotification
          * @function
          * @param  {string} alertType
-         * @return {bool|jQuery}
+         * @return {Boolean|HTMLElement}
          */
         me.handleNotification = function (alertType) {
             // ignore loading messages
@@ -3712,7 +3710,7 @@ window.PrivateBin = (function () {
         /**
          * initiate
          *
-         * preloads jQuery elements
+         * preloads HTML elements
          *
          * @name   DiscussionViewer.init
          * @function

+ 2 - 3
lib/Configuration.php

@@ -118,11 +118,10 @@ class Configuration
             'js/bootstrap-3.4.1.js'  => 'sha512-oBTprMeNEKCnqfuqKd6sbvFzmFQtlXS3e0C/RGFV0hD6QzhHV+ODfaQbAlmY6/q0ubbwlAM/nCJjkrgA3waLzg==',
             'js/bootstrap-5.3.8.js'  => 'sha512-BkZvJ5rZ3zbDCod5seWHpRGg+PRd6ZgE8Nua/OMtcxqm8Wtg0PqwhUUXK5bqvl3oclMt5O+3zjRVX0L+L2j7fA==',
             'js/dark-mode-switch.js' => 'sha512-BhY7dNU14aDN5L+muoUmA66x0CkYUWkQT0nxhKBLP/o2d7jE025+dvWJa4OiYffBGEFgmhrD/Sp+QMkxGMTz2g==',
-            'js/jquery-3.7.1.js'     => 'sha512-v2CJ7UaYy4JwqLDIrZUI/4hqeoQieOmAZNXBeQyjo21dadnwR+8ZaIJVT8EE2iyI61OV8e6M8PP2/4hpQINQ/g==',
             'js/kjua-0.10.0.js'      => 'sha512-BYj4xggowR7QD150VLSTRlzH62YPfhpIM+b/1EUEr7RQpdWAGKulxWnOvjFx1FUlba4m6ihpNYuQab51H6XlYg==',
-            'js/legacy.js'           => 'sha512-RQEo1hxpNc37i+jz/D9/JiAZhG8GFx3+SNxjYnI7jUgirDIqrCSj6QPAAZeaidditcWzsJ3jxfEj5lVm7ZwTRQ==',
+            'js/legacy.js'           => 'sha512-pRofxsrf5UItjiP22Dcjh3FAcBjF/n7h8U9/W5xqJk17U0N2U1oajhXypq/omo9jhwS1iVGOhWrRepoPeFns+w==',
             'js/prettify.js'         => 'sha512-puO0Ogy++IoA2Pb9IjSxV1n4+kQkKXYAEUtVzfZpQepyDPyXk8hokiYDS7ybMogYlyyEIwMLpZqVhCkARQWLMg==',
-            'js/privatebin.js'       => 'sha512-6PFjuvKnCOL4WSvbMyTdXlxGqnX9uaeG9aLktkvvrTmtwAn3eOvASE4DkJbQHe12gyrjy1okRwuIgjXRavxkqA==',
+            'js/privatebin.js'       => 'sha512-t6/mD1j71AXFsvNABUyVrYDKWhBoyaBTZqcnwMEgSQ+qqpbbqYjqsklgPhUbsXBTEjdYsIBAG2asiIPpQ94F0A==',
             'js/purify-3.4.1.js'     => 'sha512-280a/Vb6fVFsYaeRrkuDp4EDmdYlt2XS+dlDEO/U9qljPrAraA2bIzHTNmP+9dpwPDDwTML+RS+h5iaagPwTzA==',
             'js/showdown-2.1.0.js'   => 'sha512-WYXZgkTR0u/Y9SVIA4nTTOih0kXMEd8RRV6MLFdL6YU8ymhR528NLlYQt1nlJQbYz4EW+ZsS0fx1awhiQJme1Q==',
             'js/zlib-1.3.2.js'       => 'sha512-RAhJgxg9siMIA8ky4c10Rc2zUgnK80olHB8Tt1IOYWY4Eh1WmrviQkDn+sgBlb38ZHq3tzufGC41kP360gmosQ==',

이 변경점에서 너무 많은 파일들이 변경되어 몇몇 파일들은 표시되지 않았습니다.