Skip to content

Commit b33cf16

Browse files
committed
Gadgets/Stdrev: Replace uses of mark identifiers with visibility map
1 parent 30a34a7 commit b33cf16

File tree

1 file changed

+6
-80
lines changed

1 file changed

+6
-80
lines changed

gadgets/standard_revisions.js

Lines changed: 6 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -122,74 +122,6 @@ $(function() {
122122
rev_css_classes = rev_css_classes_c;
123123
}
124124

125-
/** A 'mark identifier' is an object that specifies a half-open range of
126-
standards. It contains the following fields:
127-
'since' - a bool value identifying which half of the range is open.
128-
'rev' - the revision of the standard. Rev.DIFF is not an accepted
129-
value.
130-
*/
131-
132-
/* Given a mark identifier and a revision, returns true if the range
133-
specified by the mark identifier includes the revision in question
134-
*/
135-
function should_be_shown(rev, mark) {
136-
if (rev === Rev.DIFF) {
137-
return true;
138-
}
139-
if (mark.since) {
140-
return (rev >= mark.rev);
141-
} else {
142-
return (rev < mark.rev);
143-
}
144-
}
145-
146-
/* Returns a mark identifier for a jQuery object. This function only
147-
supports elements that may contain at most one mark css tag.
148-
*/
149-
function get_mark_cxx(el) {
150-
if (el.hasClass('t-since-cxx11')) {
151-
return { since: true, rev: Rev.CXX11 };
152-
}
153-
if (el.hasClass('t-since-cxx14')) {
154-
return { since: true, rev: Rev.CXX14 };
155-
}
156-
if (el.hasClass('t-since-cxx17')) {
157-
return { since: true, rev: Rev.CXX17 };
158-
}
159-
if (el.hasClass('t-since-cxx20')) {
160-
return { since: true, rev: Rev.CXX20 };
161-
}
162-
if (el.hasClass('t-until-cxx11')) {
163-
return { since: false, rev: Rev.CXX11 };
164-
}
165-
if (el.hasClass('t-until-cxx14')) {
166-
return { since: false, rev: Rev.CXX14 };
167-
}
168-
if (el.hasClass('t-until-cxx17')) {
169-
return { since: false, rev: Rev.CXX17 };
170-
}
171-
if (el.hasClass('t-until-cxx20')) {
172-
return { since: false, rev: Rev.CXX20 };
173-
}
174-
return { since: true, rev: Rev.CXX98 };
175-
}
176-
177-
function get_mark_c(el) {
178-
if (el.hasClass('t-since-c99')) {
179-
return { since: true, rev: Rev.C99 };
180-
}
181-
if (el.hasClass('t-since-c11')) {
182-
return { since: true, rev: Rev.C11 };
183-
}
184-
if (el.hasClass('t-until-c99')) {
185-
return { since: false, rev: Rev.C99 };
186-
}
187-
if (el.hasClass('t-until-c11')) {
188-
return { since: false, rev: Rev.C11 };
189-
}
190-
return { since: true, rev: Rev.C89 };
191-
}
192-
193125
/* This class stores information about what revisions a certain object
194126
should be shown on. A number of convenience functions are provided.
195127
*/
@@ -329,14 +261,6 @@ $(function() {
329261
return map;
330262
}
331263

332-
var get_mark;
333-
334-
if (is_cxx) { // select either C or C++ version
335-
get_mark = get_mark_cxx;
336-
} else {
337-
get_mark = get_mark_c;
338-
}
339-
340264
/** This class keeps track of objects that need to be shown or hidden for
341265
specific standard revision.
342266
*/
@@ -776,8 +700,9 @@ $(function() {
776700
// template by chance
777701
marks = $(this).find('.t-mark-rev');
778702
if (marks.length > 0) {
779-
var mark = get_mark(marks.first());
780-
if (!should_be_shown(rev, mark)) {
703+
var visible = get_visibility_map(marks.first());
704+
visible.add(Rev.DIFF);
705+
if (!visible.is_visible_on(rev)) {
781706
$(this).remove();
782707
} else {
783708
marks.remove(); // do not show marks in any case
@@ -1661,8 +1586,9 @@ $(function() {
16611586
marks.each(function(index) {
16621587
var mark_span = $(this).children('.t-mark-rev');
16631588
if (mark_span.length > 0) {
1664-
var mark = get_mark(mark_span.first());
1665-
if (!should_be_shown(rev, mark)) {
1589+
var visible = get_visibility_map(mark_span.first());
1590+
visible.add(Rev.DIFF);
1591+
if (!visible.is_visible_on(rev)) {
16661592
titles.eq(index).remove();
16671593
$(this).remove();
16681594
num_deleted++;

0 commit comments

Comments
 (0)