8

In a list of questions (such as on the home page) the HTML block for each question has a containing div like:

<div class="question-summary narrow" id="question-summary-123456">

I am requesting that "open" or "closed" be added to that class to indicate whether or not the question is currently in the "closed" state (on-hold, duplicate, etc):

 <div class="question-summary narrow open" id="question-summary-123456">

or

 <div class="question-summary narrow closed" id="question-summary-123456">

This is a technical prerequisite for CSS styling closed questions differently as requested by:

Even in it were decided not to change the style of closed questions by default, there are plenty of user scripts (Greasemonkey plugins) that could use this. Currently if somebody wants to hack their browser to add this functionality like that requested above they need to write code like this:

$('.question-summary').each(function () {
    if ($(this).find('.summary h3 a').text().indexOf('[on hold]') > -1 ||
        $(this).find('.summary h3 a').text().indexOf('[closed]') > -1) {
        ...

That code relies on text on the page that could:

  • Change over time (cough "on-hold")
  • Have cases not covered (like "migrated" and "duplicate" in the above example)
  • Not work on sites in different languages
  • Be part of the actual question title ("Why was my question [on-hold]") Edit: per animuson ♦ in the comments, the system doesn't allow that exact text in question titles, this is only an issue if you are using a heuristic like "ends in ]" to get around the language or many cases issue.

After this change is implement, that code could be:

$('.question-summary.closed').each(function () {
    ...

Adding a class attribute to the question-summary for open or closed would make these experimental scripts much easier to write, easier to maintain, and more robust.

I'd like to try out many user scripts that could use this feature:

  • Hide closed questions altogether
  • Add strike-through to the "0 answers" of closed questions
  • Change the color of closed questions
  • Move the position of the [on-hold] text
  • Count the number of closed questions on a page
  • 3
    Note: cost of supporting this includes up to 50*7=350 bytes per page load, which is fairly trivial even for performance-obsessed SE. – Nathan Tuggy Jun 16 '17 at 10:28
  • Especially since each question is at least 1500 bytes. That is a 0.4% increase per question. If SE were really worried about that level of optimization, they could start with removing the 250 bytes of indentation and new line whitespace per question. – Stephen Ostermiller Jun 16 '17 at 11:16
  • 2
    I'd think adding "closed" would be enough (lack of which would imply "open", and seems most use of this would be for closed questions anyway) – Cai Jun 16 '17 at 11:42
  • Just saying, you can't use the exact text "[on hold]" or "[closed]" in a question title. The system won't allow it to be posted like that. – animuson Jun 16 '17 at 16:00
  • @animuson I just tested that and you are right. I had no idea the system was so smart. – Stephen Ostermiller Jun 16 '17 at 16:15
  • A more robust work-around for user scripts might be to compare the question title with the URL slug (both normalized to include only ASCII letters and case-folded). This should be sufficient to reliably detect whether there's a [bracketed note] appended to the title that isn't actually present in the slug. – Ilmari Karonen Jun 17 '17 at 10:53

You must log in to answer this question.

Browse other questions tagged .