bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#69132: [ELPA] Remove jQuery from elpa.gnu.org


From: Philip Kaludercic
Subject: bug#69132: [ELPA] Remove jQuery from elpa.gnu.org
Date: Thu, 15 Feb 2024 11:07:59 +0000

Philip Kaludercic <philipk@posteo.net> writes:

> Stefan Monnier <monnier@iro.umontreal.ca> writes:
>
>>> I was recently surprised to see that elpa.gnu.org uses a jQuery library,
>>> where it really isn't necessary.  Re-implementing the same functionality
>>> can be done in a few more lines of plain Javascript, without the need
>>> for any minified code.  Tested with relatively recent versions of
>>> Firefox and Chromium, so perhaps it would be nice if someone with an
>>> older browser could check if I didn't make any bold assumptions. 
>>
>> Works for me, but I'm not using an "older browser" 🙁
>
> I have a few older machines that I could try it out on.
>
>>> diff --git a/html/javascript/package-search.js 
>>> b/html/javascript/package-search.js
>>> index 47134045eb..92f29703a3 100644
>>> --- a/html/javascript/package-search.js
>>> +++ b/html/javascript/package-search.js
>>> @@ -1,6 +1,35 @@
>>> -$(document).ready(function() {
>>> -   $('table').filterTable({
>>> -           label: '',
>>> -           placeholder: 'Search packages...'
>>> -   });
>>> +window.addEventListener("load", function (event) {
>>> +   const table = document.getElementById("packages");
>>> +
>>> +   const search = document.createElement("input");
>>> +   search.setAttribute("placeholder", "Search packages...");
>>> +   search.setAttribute("type", "search");
>> [...]
>>
>> I know very little about Javascript, but I'm curious: can't we add the
>> `input` element directly in the HTML file, and skip those first 4 lines or 
>> so?
>
> Of course, I just replicated what the jquery plugin did.  I suppose the
> idea was to not have a broken search field labelled "Search
> packages...", if there is no Javascript to make it work in the first
> place.
>
>>> diff --git a/html/layout.css b/html/layout.css
>>> index 4f5c50d393..434220f8c1 100644
>>> --- a/html/layout.css
>>> +++ b/html/layout.css
>>
>> A rationale/description of this part of the change would be welcome.
>>
>>> From 73a9335634f54b71e9723047f327cf782cfb7244 Mon Sep 17 00:00:00 2001
>>> From: Philip Kaludercic <philipk@posteo.net>
>>> Date: Wed, 14 Feb 2024 20:37:37 +0100
>>> Subject: [PATCH] Update HTML generation for new filter implementation
>>>
>>> ---
>>>  elpa-admin.el | 27 +++++++++++----------------
>>>  1 file changed, 11 insertions(+), 16 deletions(-)
>>
>> Same here.
>
> The idea is just to not use CSS classes to pinpoint specific Elements in
> the DOM.  That is what IDs are for (ideally the "ID -> elements" map
> should be injective).  I needed that to use document.getElementById in
> the new script.
>
> Should I update the commit messages to explain the change?

I have updated patches with a few more cases that I had initially
forgotten and split the one for the main branch into two:



Attachment: 0001-Generate-HTML5-tags-instead-of-div-s-with-custom-cla.patch
Description: Text Data

Attachment: 0001-Use-more-HTML5-tags-instead-of-custom-CSS-classes.patch
Description: Text Data

Attachment: 0002-Replace-jQuery-filtertable-script-with-plain-Javascr.patch
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]