Fixed bug #173. Multi-select and multi-deselect no longer have
authorArt Cancro <ajc@citadel.org>
Fri, 1 Sep 2006 19:18:22 +0000 (19:18 +0000)
committerArt Cancro <ajc@citadel.org>
Fri, 1 Sep 2006 19:18:22 +0000 (19:18 +0000)
a problem where the internally selected list contains messages
that are not highlighted.

webcit/static/wclib.js

index 5a536b39661151a6aa51f72636d67281e31102f7..f328bdf81076cf4a88c22c23afe4492558afb62e 100644 (file)
@@ -146,20 +146,31 @@ function CtdlSingleClickMsg(evt, msgnum) {
                for (i=0; i<CtdlNumMsgsSelected; ++i) {
                        if (CtdlMsgsSelected[i] == msgnum) {
                                already_selected = 1;
+                               already_selected_pos = i;
                        }
                }
        }
 
        // Now select (or de-select) the message
        if ( (evt.ctrlKey) && (already_selected == 1) ) {
+
+               // Deselect: first un-highlight it...
                $('m'+msgnum).style.backgroundColor = '#fff';
                $('m'+msgnum).style.color = '#000';
-               // FIXME pull the message out of the selected list here, stupid.
-               // this will fix Bugzilla #173
+
+               // Then remove it from the selected messages list.
+               for (i=already_selected_pos; i<(CtdlNumMsgsSelected-1); ++i) {
+                       CtdlMsgsSelected[i] = CtdlMsgsSelected[i+1];
+               }
+               CtdlNumMsgsSelected = CtdlNumMsgsSelected - 1;
+               
        }
        else {
+               // Select: first highlight it...
                $('m'+msgnum).style.backgroundColor='#69aaff';
                $('m'+msgnum).style.color='#fff';
+
+               // Then add it to the selected messages list.
                CtdlNumMsgsSelected = CtdlNumMsgsSelected + 1;
                CtdlMsgsSelected[CtdlNumMsgsSelected-1] = msgnum;
        }