inherit
Peabrained Codebreaker
107114
0
Mar 11, 2020 7:47:27 GMT -8
Boy_Wonder
6,249
July 2007
natzy24
|
Post by Boy_Wonder on Feb 19, 2011 23:25:30 GMT -8
the last person to have posted on the thread? I'm trying to work out how to hide a delete button without it being the last post on the thread. I have been planning part two of a request through that if I can work this part out I might be able to answer, though this is primarily for my own personal use. If anyone wants to see my planning and the notes I've been making www.scribd.com/doc/49168779/Planning < the link's there
|
|
#00AF33
14306
0
1
Sept 8, 2023 8:54:17 GMT -8
Jordan
What is truth?
11,838
October 2003
jab2
|
Post by Jordan on Feb 20, 2011 9:23:17 GMT -8
You'll need to first check to see if the text "Page x of y » Jump to page" exists, and if it does, you won't want to delete the last delete button if x == y. If it doesn't exist, then you know you are on the first and last page of the thread, so you simply don't delete the last delete button.
|
|
inherit
Peabrained Codebreaker
107114
0
Mar 11, 2020 7:47:27 GMT -8
Boy_Wonder
6,249
July 2007
natzy24
|
Post by Boy_Wonder on Feb 20, 2011 9:27:15 GMT -8
Okay - so I'll need to be working out how to search and check for that text first - what about if this doesn't exist? If its only a one page thread?
Also is this what I'm looking for - pageSpan to check if it exists before looking for the users info from the mini profile?
|
|
#00AF33
14306
0
1
Sept 8, 2023 8:54:17 GMT -8
Jordan
What is truth?
11,838
October 2003
jab2
|
Post by Jordan on Feb 20, 2011 9:56:44 GMT -8
Try this. Basically, if the text doesn't exist, then you are on the last page so the last post on that page is the last post in the entire thread. If the text does exist, then you may not be on the last page so we need to check first.
<script type="text/javascript"> <!--
(function() {
// If we are viewing a thread if(pb_action == "display") {
// True if we are on the last page var lastPage = false;
// Get reference to the input element next to the text var inputElement = document.getElementById("pageNo1");
// If the input text box exists, then the text exists as well if(inputElement) {
// Get a reference to the span that contains the text var span = inputElement.parentNode.getElementsByTagName("span")[0];
// Now we need to extract the two numbers from this markup: // Page x of <a href="/index.cgi?board=pbgt&action=display&thread=380662&page=y">y</a> var x = parseInt(span.firstChild.data.split(" ")[1]); var y = parseInt(span.getElementsByTagName("a")[0].firstChild.data);
// If we are on the last page of the thread if(x == y) { lastPage = true; } } else { lastPage = true; }
// You can loop through the posts here and delete the "Delete" buttons // You'll want to check to see if you are on the last page so you don't delete the last button
// If we are on the last page if(lastPage) { // do what you need to do here } } })();
//--> </script>
|
|
inherit
Peabrained Codebreaker
107114
0
Mar 11, 2020 7:47:27 GMT -8
Boy_Wonder
6,249
July 2007
natzy24
|
Post by Boy_Wonder on Feb 20, 2011 10:02:43 GMT -8
Thanks ^_^ I'll have a play around that
|
|
#00AF33
14306
0
1
Sept 8, 2023 8:54:17 GMT -8
Jordan
What is truth?
11,838
October 2003
jab2
|
Post by Jordan on Feb 20, 2011 10:07:06 GMT -8
Let me know if you need any help.
I re-worded my previous posts since I slightly read your question wrong. The code above will still work since it lets you know if you are on the last page or not so you can then know whether to remove the last delete button or not.
|
|
inherit
Peabrained Codebreaker
107114
0
Mar 11, 2020 7:47:27 GMT -8
Boy_Wonder
6,249
July 2007
natzy24
|
Post by Boy_Wonder on Feb 20, 2011 10:23:06 GMT -8
I will do ^_^ thanks for your help.
|
|
inherit
Peabrained Codebreaker
107114
0
Mar 11, 2020 7:47:27 GMT -8
Boy_Wonder
6,249
July 2007
natzy24
|
Post by Boy_Wonder on Feb 20, 2011 10:37:00 GMT -8
just clarifying here - the easiest way to 'hide' the delete button is going to be replacing delete.png with a transparent 1px png unless its the very last post yes? which means on the page I need to find delete.png first? -wanting to make sure before I really start playing around-
I also need to set it so it only replaces the delete button with the transparent image up to the last post yes?
|
|
#00AF33
14306
0
1
Sept 8, 2023 8:54:17 GMT -8
Jordan
What is truth?
11,838
October 2003
jab2
|
Post by Jordan on Feb 20, 2011 11:27:26 GMT -8
If you want to remove the delete button on the entire forum, including for yourself, then yes, replacing it with a transparent 1x1 image is the best thing to do. However, if you are going to hide it with Javascript in a specific thread then all you need to do is: anchorTagOfDeleteImage.style.display = "none"; to each delete image's anchor tag (the link that contains the image). Changing the URL would be slower.
So basically you need to loop through the page anchors or images on the page, check to see if they are a delete button, and then make sure that the current button is not part of the last post and hide it.
Edit: It may be faster to loop through each post by looping through the <tr> elements on the page. Each table row element that contains a post has an ID (tr_postID#) and a className (tr_post). If the table row's nextSibling does not have a className of "tr_post", then you know that the current table row contains the last post on the page, and so if the lastPage boolean is also true, then you know that table row contains the last post of the entire thread.
Here's the basic idea, but this is not tested.
var tr = document.getElementsByTagName("tr");
for(var x = 0; x < tr.length; x++) {
// If the current table row contains a post, and we are not on the // last page OR we are on the last page but this is not the last post if(tr[x].className == "tr_post" && (!lastPage || (lastPage && tr[x+1].className == "tr_post"))) { // Delete the button from the post } }
|
|
inherit
Peabrained Codebreaker
107114
0
Mar 11, 2020 7:47:27 GMT -8
Boy_Wonder
6,249
July 2007
natzy24
|
Post by Boy_Wonder on Feb 20, 2011 12:14:40 GMT -8
Okay I'll give it a play
|
|
#00AF33
14306
0
1
Sept 8, 2023 8:54:17 GMT -8
Jordan
What is truth?
11,838
October 2003
jab2
|
Post by Jordan on Feb 20, 2011 18:31:24 GMT -8
Let me know if something doesn't make sense. You basically just need to stick the code in my previous post into the code that I posted earlier, and then add the code that finds and removes the delete button.
|
|
inherit
Peabrained Codebreaker
107114
0
Mar 11, 2020 7:47:27 GMT -8
Boy_Wonder
6,249
July 2007
natzy24
|
Post by Boy_Wonder on Feb 20, 2011 21:48:57 GMT -8
I gathered that much ^_^ and it all makes perfect sense thank you ^_^
|
|