Fossil

Diff
Login

Diff

Differences From Artifact [44bd53b6bd]:

To Artifact [4b01166c9c]:


1

2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18




























19
(function(){

  function absoluteY(obj){
    var top = 0;
    if( obj.offsetParent ){
      do{
        top += obj.offsetTop;
      }while( obj = obj.offsetParent );
    }
    return top;
  }
  var x = document.getElementsByClassName('forumSel');
  if(x[0]){
    var w = window.innerHeight;
    var h = x[0].scrollHeight;
    var y = absoluteY(x[0]);
    if( w>h ) y = y + (h-w)/2;
    if( y>0 ) window.scrollTo(0, y);
  }




























})()

>

















>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
(function(){
  "use strict";
  function absoluteY(obj){
    var top = 0;
    if( obj.offsetParent ){
      do{
        top += obj.offsetTop;
      }while( obj = obj.offsetParent );
    }
    return top;
  }
  var x = document.getElementsByClassName('forumSel');
  if(x[0]){
    var w = window.innerHeight;
    var h = x[0].scrollHeight;
    var y = absoluteY(x[0]);
    if( w>h ) y = y + (h-w)/2;
    if( y>0 ) window.scrollTo(0, y);
  }

  // Set up click handlers for "in reply to" links...
  var respondeeSelectClass = 'forumSelReplyTo'
  /* CSS class to apply to selected "in reply to" post. */;
  var responseLinkClick = function(){
    /** This <A> tag has an href in the form /something#post-{UID},
        and post-{UID} is the ID of a forum post DIV on this
        page. Here we fish that ID out of this anchor,
        unmark any currently-selected DIV, and mark this anchor's
        corresponding DIV.
    */
    var m = /#post-\w+/.exec(this.href);
    if(!m || !m.length) return /*unexpected*/;
    // Remove respondeeSelectClass from all entries...
    document.querySelectorAll('.forumPost.'+respondeeSelectClass)
      .forEach(function(e){
        e.classList.remove(respondeeSelectClass);
      });
    // Add respondeeSelectClass to the matching entry...
    document.querySelectorAll(m[0])
      .forEach(function(e){
        e.classList.add(respondeeSelectClass);
      });
  };
  document.querySelectorAll('a[href*="#post-"]')
    .forEach(function(e){
      e.addEventListener( "click", responseLinkClick, false );
    });
})();