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:
- Should the questions put on hold be marked on questions list with a color?
- Different font color for question status => closed <=
- Proposal to make
duplicate
,closed
andmigrated
in the title more obvious in question lists
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
[bracketed note]
appended to the title that isn't actually present in the slug.