bdrathburn / TeslaForumPersonalBlocklist

2 stars 1 forks source link

Feature: Add 1st Comment and Make a Comment Anchors #3

Closed Jeffrey-R closed 8 years ago

Jeffrey-R commented 8 years ago

It is useful to have a way to jump to the 1st comment and to the comment box. I have added these links to the top of my Tips & Tricks: (1st Comment | Make a Comment)

<em align="right">(<a href="#comments">1st Comment</a> | <a href="#comment-form">Make a Comment</a>)</em>

As you can see they are pretty simple anchors. We could add them to the "submitted" DIV just under the main OP title. Currently this is the only instance of that class on the page (not sure why it's not an ID).

<div class="submitted">
      <span property="dc:date dc:created" content="2014-06-02T11:07:48-07:00" datatype="xsd:dateTime" rel="sioc:has_creator">Submitted by <span class="username ">JeffreyR</span> on June 2, 2014</span>    </div>
<div class="content">...</div>
Jeffrey-R commented 8 years ago

I've added a closure function to do this to the bottom of content.js v.1.0.2. I included it at the end w/ comments so you can find it easily.

Here is the function:

(function (){
// added JeffreyR v.1.0.3
// closure function to add 1st Comment and Make a Comment links to the "Submitted by" section at the top of an OP
    var Sub_By_Div  = document.getElementsByClassName("submitted")[0];
    if(Sub_By_Div == null) { return; }

    var Start_Comments_Div  = document.getElementsByClassName("panel-pane pane-node-content")[0];
    if(Start_Comments_Div == null) { return; }
    var Target_Comments = document.createElement('a');
    Target_Comments.id  = "comments-start";
    Start_Comments_Div.appendChild(Target_Comments);

    var Comment_Anchors = document.createElement('em');
    Comment_Anchors.style.textAlign = "right";
    Comment_Anchors.innerHTML   = ' ' + '(<a href="#comments-start">1st Comment</a> | <a href="#comment-form">Make a Comment</a>)';

    Sub_By_Div.appendChild(Comment_Anchors);
})();
Jeffrey-R commented 8 years ago

There was an obvious bug in my approach. It assumed the OP had included the anchor tag that J.T. and I use. Oops! Fixed it.

bdrathburn commented 8 years ago

Looks good, planning to integrate these changes and the search changes tonight or tomorrow. Will post an update on the forum when i publish the changes.

bdrathburn commented 8 years ago

Added to v 1.0.3 and published. Thanks