all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Philip Kaludercic <philipk@posteo.net>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: 69132@debbugs.gnu.org
Subject: bug#69132: [ELPA] Remove jQuery from elpa.gnu.org
Date: Thu, 15 Feb 2024 08:12:56 +0000	[thread overview]
Message-ID: <87h6iap2lz.fsf@posteo.net> (raw)
In-Reply-To: <jwvttma64df.fsf-monnier+emacs@gnu.org> (Stefan Monnier's message of "Wed, 14 Feb 2024 18:05:47 -0500")

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?

>
>         Stefan





  reply	other threads:[~2024-02-15  8:12 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-14 19:41 bug#69132: [ELPA] Remove jQuery from elpa.gnu.org Philip Kaludercic
2024-02-14 23:05 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-02-15  8:12   ` Philip Kaludercic [this message]
2024-02-15 11:07     ` Philip Kaludercic
2024-02-15 15:37     ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-02-17 18:25       ` Stefan Kangas
2024-02-17 20:57       ` Dmitry Gutov
2024-02-17 21:04         ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-02-17 22:26           ` Dmitry Gutov
2024-02-17 22:44             ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-02-17 22:49               ` Dmitry Gutov
2024-02-18  4:05                 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-02-18 12:14                   ` Dmitry Gutov
2024-02-18 14:13                     ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-02-18 14:24                       ` Dmitry Gutov
2024-02-18 14:37                         ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-02-18 14:38                           ` Dmitry Gutov
2024-02-18  3:28       ` Richard Stallman
2024-02-18  4:07         ` Corwin Brust
2024-02-18  4:20           ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-02-21  2:56           ` Richard Stallman
2024-02-22 12:00             ` Philip Kaludercic
2024-02-25  3:13               ` Richard Stallman
2024-02-25 10:55                 ` Philip Kaludercic
2024-02-25 15:18                 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-02-18 15:07         ` Philip Kaludercic
2024-02-18 18:19           ` Corwin Brust
2024-02-24 10:03 ` Philip Kaludercic
2024-02-25 10:06   ` Daniel Mendler via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-02-25 10:44     ` Philip Kaludercic

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87h6iap2lz.fsf@posteo.net \
    --to=philipk@posteo.net \
    --cc=69132@debbugs.gnu.org \
    --cc=monnier@iro.umontreal.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.