vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 3.0 Full Releases (https://vborg.vbsupport.ru/forumdisplay.php?f=33)
-   -   Existing Topics Check (https://vborg.vbsupport.ru/showthread.php?t=59940)

Velocd 01-08-2004 10:00 PM

Existing Topics Check
 
http://www.animesystem.com/temp/etc1-0.jpg

This hack will allow you and your members to check for existing topics, or similar ones, of the thread you plan to create when at newthread.php.

This should help to prevent double topics that often appear from newbish members who neglect to use the search feature.

It uses the exact functions as the "similar threads" feature, therefore has the same accuracy.

Tested to work on:
  • vBulletin 3 RC2
  • Internet Explorer 6 (with Javascript enabled)
  • Mozilla Firebird 0.7 / Mozilla 1.5 (with Javascript enabled)

------------------------------------------------

Tweak #1

If you would like the find icon to show upon typing in the input box, and then disappear if the input box is empty upon change, please do the following:


In the template newthread, find:
Code:

function showFind(object)
{
  if(object.value != '')
  {
    document.findicon.src = "$stylevar[imgdir_button]/findicon_on.gif";
    document.findicon.style.cursor = "pointer";
  }
  else
  {
    document.findicon.src = "$stylevar[imgdir_button]/findicon_off.gif";
    document.findicon.style.cursor = "default";
  }
}

Replace it with:
Code:

function showFind()
{
    document.findicon.src = "$stylevar[imgdir_button]/findicon_on.gif";
    document.findicon.style.cursor = "pointer";
}

function hideFind(object)
{
  if(object.value == '')
  {
    document.findicon.src = "$stylevar[imgdir_button]/findicon_off.gif";
    document.findicon.style.cursor = "default";
  }
}

In the same template, find:
Code:

<td><input type="text" class="bginput" name="subject" onChange="showFind(this)" value="$subject" size="40" maxlength="85" tabindex="1" /></td>
Replace it with:
Code:

<td><input type="text" class="bginput" name="subject" onchange="hideFind(object)" onkeypress="showFind()" value="$subject" size="40" maxlength="85" tabindex="1" /></td>
------------------------------------------------

Attached is a screenshot.

Inside the zip are English, German, and French installation instructions. Please be aware I used a software translator for the German and French docs.

Enjoy. ;)

MrNase 01-09-2004 10:26 AM

Hey very cool :)

albibak 01-09-2004 12:56 PM

Thx Velocd for this hack.
I do the translation in french for vbulletin-fr.com and I join it on this post, because I see that you put in the zip file a speed translation by a software translator ;)

FleaBag 01-09-2004 02:10 PM

Excellent idea and wonderfully executed. I think my users will appreciate this as much as I shall.

sabret00the 01-09-2004 04:19 PM

great hack :)

NuclioN 01-09-2004 04:44 PM

--edit-- forgot a template :) Works fine

Koutaru 01-09-2004 07:13 PM

Thanks Velocd! :D

[high]* Koutaru installs[/high]

Boofo 01-10-2004 10:52 AM

I ran into a small problem with this. I have a thread titled:

Nesting conditional statements in templates

It did not find it when I tested for the exact same phrase or conditional statements, either one. And that thread was in the same forum.

Also, the button is off before you click it the first time. Shouldn't it be on so you know it is available to click (or am I missing something here)? ;)

Velocd 01-10-2004 06:12 PM

Quote:

It did not find it when I tested for the exact same phrase or conditional statements, either one. And that thread was in the same forum.
It uses the same functions as the smiilar threads feature, so if it's not finding it I'm not sure what to say.

Create two threads called "Nesting conditional statements in templates", go into one of them, and scroll to the bottom and see if the other thread shows up in the "similar threads" feature.

Quote:

Also, the button is off before you click it the first time. Shouldn't it be on so you know it is available to click (or am I missing something here)?
There is an onchange Javascript behavior on the subject field, and when the subject field changes that icon becomes active. Otherwise, you don't want somebody clicking the button when the subject field is empty (although it would just give a Javascript alert box).

Boofo 01-10-2004 06:33 PM

Shouldn't the icon become active when you type soemthing in there? It only becomes active here after I click it.

And yes the title shows up in the similar threads when there are 2 of them.

I never changed any of the default settings for the similar threads in the Admin CP. Do those need to be changed, too?

Dean C 01-10-2004 06:57 PM

What a great idea! I'd love to see this installed here. :)

PranK 01-11-2004 06:37 AM

nice work mate! Thanks.

/me clicks install

Christian

Velocd 01-11-2004 04:14 PM

Quote:

Originally Posted by Boofo
Shouldn't the icon become active when you type soemthing in there? It only becomes active here after I click it.

Ah ha!

Good point. I'll tweak it a bit, since that does seem more suitable.

Quote:

And yes the title shows up in the similar threads when there are 2 of them.
Are both topics exactly (case-sensitive) the same? Maybe there is a case-sensitive problem in the hack.

I'll look into the code to see what could be causing the conflict of it not showing another of the same topic.

Edit:

Check out the attachment Boofo, I tested the topic on my localhost and it seems to work.

Boofo 01-11-2004 04:20 PM

Thank you, sir. Let me know when you have something and I will be glad to test it out for you. I'm really looking forward to this hack. ;)

Yes, they are exactly the same in case-sensitivity. But it wouldn't even find a part of the title either (i.e. conditional statements). ;)

Boofo 01-11-2004 04:22 PM

Quote:

Originally Posted by Velocd
Ah ha!

Good point. I'll tweak it a bit, since that does seem more suitable.



Are both topics exactly (case-sensitive) the same? Maybe there is a case-sensitive problem in the hack.

I'll look into the code to see what could be causing the conflict of it not showing another of the same topic.

Edit:

Check out the attachment Boofo, I tested the topic on my localhost and it seems to work.

Could it be because they are in a private forum and passworded as to why it won't work here??

Velocd 01-11-2004 04:40 PM

Yes, if you don't have permission to view the forum those threads are in, they wont show. Although I'm guessing you do have permission since you're the administrator.

For those wanting the suggestion made by Boofo, I've added the instructions to the tweak in the first post. ;)

Boofo 01-11-2004 04:42 PM

I don't have a lot of threads since I am starting from scratch so maybe it has to do with that then. I don't know. ;)

Boofo 01-11-2004 04:47 PM

Have the instructions been updated to include this?

Velocd 01-11-2004 04:50 PM

Quote:

Originally Posted by Boofo
Have the instructions been updated to include this?

If you're referring to the tweak, no.

The tweak instructions are in the first post. ;)

buro9 01-14-2004 07:56 PM

Quote:

Originally Posted by Velocd
If you're referring to the tweak, no.

The tweak instructions are in the first post. ;)

I had a very similar thing running on my old VB2 forums, I have now installed this hack on my VB3 test site... and it's nice :) Very nice.

I have made a few adjustments though:

I've used document.getElementById() rather than use IE based document.all access. This will ensure compatibility with standards compliant browsers. You need to add id="" to the relevant pieces of HTML, subject and findicon I think are the only two.

I already added an onKeyUp alongside the onChange on the subject input box. This runs it everytime a key is lifted... though I left the onChange in there as it makes no difference and ensures that more limited browsers will still support it.

Aside from that... lovely hack :)

NTLDR 01-14-2004 08:41 PM

Quote:

Originally Posted by buro9
I've used document.getElementById() rather than use IE based document.all access.

You should use fetch_object() (a vB JS function) this will give the best compatibility will all thr browsers vB supports properly.

Boofo 01-14-2004 09:45 PM

The fix in the first post works great if you type it in, but if you paste something in the thread title, it doesn't turn on the button. Any fix for this? ;)

Boofo 02-16-2004 01:28 AM

I'm getting a 406 error (object undefined) with this now after making the changes to the code in the first post. Any fix for this?

gmarik 02-22-2004 07:04 AM

nice working ...

Boofo 02-22-2004 03:54 PM

Quote:

Originally Posted by buro9
I had a very similar thing running on my old VB2 forums, I have now installed this hack on my VB3 test site... and it's nice :) Very nice.

I have made a few adjustments though:

I've used document.getElementById() rather than use IE based document.all access. This will ensure compatibility with standards compliant browsers. You need to add id="" to the relevant pieces of HTML, subject and findicon I think are the only two.

I already added an onKeyUp alongside the onChange on the subject input box. This runs it everytime a key is lifted... though I left the onChange in there as it makes no difference and ensures that more limited browsers will still support it.

Aside from that... lovely hack :)

Can you share the changes you made? ;)

buro9 02-22-2004 06:55 PM

Quote:

Originally Posted by Boofo
Can you share the changes you made? ;)

Yes, I hope this won't offend the hack creator... but here are snippets of my newthread template:

Code:

function showFind(element) {
  if(element.value != '') {
    document.getElementById('findicon').src = "$stylevar[imgdir_button]/findicon_on.gif";
    document.getElementById('findicon').style.cursor = "pointer";
  } else {
    document.getElementById('findicon').src = "$stylevar[imgdir_button]/findicon_off.gif";
    document.getElementById('findicon').style.cursor = "default";
  }
}

Code:

                <!-- subject field -->
                <table cellpadding="0" cellspacing="0" border="0" class="fieldset">
                <tr>
                        <td class="smallfont" colspan="3">$vbphrase[title]:</td>
                </tr>
                <tr>
                        <td><input type="text" class="bginput" name="subject" id="subject" onChange="showFind(this);" onKeyUp="showFind(this);" value="$subject" size="40" maxlength="85" tabindex="1" /></td>
<td>&nbsp;&nbsp;</td>
<td><img id="findicon" name="findicon" src="$stylevar[imgdir_button]/findicon_off.gif" alt="Search for existing topics" onclick="openWindow()" /></td>
                        <td>&nbsp;&nbsp;</td>
                        <td><img id="display_posticon" src="$selectedicon[src]" alt="$selectedicon[alt]" /></td>                </tr>
                </table>
                <!-- / subject field -->

Obviously I'm trusting that you can take the applicable small bits and merge them as appropriate into whatever you have.

Boofo 02-23-2004 03:01 AM

How can you get this to show the button on when you start typing in the subject filed Box (like from tthe first post)?

buro9 02-23-2004 04:26 AM

Quote:

Originally Posted by Boofo
How can you get this to show the button on when you start typing in the subject filed Box (like from tthe first post)?

Code:

onKeyUp="showFind(this);"
From the first key it is activated.

Though a trim() function should be added to prevent it being activated on pressing of the space bar.

Boofo 02-23-2004 05:19 AM

Quote:

Originally Posted by buro9
Code:

onKeyUp="showFind(this);"
From the first key it is activated.

Though a trim() function should be added to prevent it being activated on pressing of the space bar.

How do we add the trim code to this? ;)

Boofo 02-23-2004 10:01 AM

Found a bug with this hack. If you have quotes in a thread title, you will get a javascript error when you click the button to check the topic and also the window will have the table in it without any topics. The title I used was:

"Killing all my chickens"

Any fix for this?

buro9 02-23-2004 01:32 PM

Quote:

Originally Posted by Boofo
How do we add the trim code to this? ;)

To add trim you'd do something like this:

Code:

function trim(str) {return str.replace(/^\s+/,'').replace(/\s+$/,'');}

function showFind(element) {
  if(trim(element.value) != '') {

And then carry on as before.

As regards your quotes bug, it isn't apparent on my site using Firefox and IE6 to test with.

Boofo 02-23-2004 01:41 PM

I get a line 7 expected ')' error when I use the quotes in a thread title. Isn't there a way to trim any code like that in the trim statement so it only looks for words? ;) I use IE 6, by the way. ;)

buro9 02-23-2004 02:04 PM

Quote:

Originally Posted by Boofo
I get a line 7 expected ')' error when I use the quotes in a thread title. Isn't there a way to trim any code like that in the trim statement so it only looks for words? ;) I use IE 6, by the way. ;)

I have just registered on your site and tested this, and I cannot generate an error.

I believe that the problem lies elsewhere... try CTRL+F5 to refreh your IE cache in case it has old files... and then look at any changes you've made to other JavaScript on the page (such as any hacks you've put into the vb supplied javascript).

I tested with "'` and all worked fine.

Line 7 also suggests something much higher in the file... maybe in one of the included files?

Cheers

David K

Boofo 02-23-2004 02:21 PM

It only seems to happen when you use the quotes with a topic that doesn't exist. It the topic exists (like "testing") then I don't get the error. If I use "killing my chickens", I get the error. Does this make any sense?

buro9 02-23-2004 05:42 PM

Quote:

Originally Posted by Boofo
It only seems to happen when you use the quotes with a topic that doesn't exist. It the topic exists (like "testing") then I don't get the error. If I use "killing my chickens", I get the error. Does this make any sense?

Got it... it's here:

Code:

<script language="javascript">
  window.alert("No matches found for:\n\""killing all chickens"\"");
  window.close();
</script>

The double quotes aren't escaped in the javascript error message.

Boofo 02-23-2004 05:46 PM

How do we fix that? ;)

buro9 02-23-2004 05:47 PM

Quote:

Originally Posted by buro9
Got it... it's here:

Code:

<script language="javascript">
  window.alert("No matches found for:\n\""killing all chickens"\"");
  window.close();
</script>

The double quotes aren't escaped in the javascript error message.

Simple solution... in findtopic.php at the bottom, find:

Code:

eval('print_output("' . fetch_template('newthread_find') . '");');
Above it add:
Code:

if (empty($threads)) {
  $subject = str_replace('"','\"',$subject);
}


Boofo 02-23-2004 05:52 PM

You are a saint! Thank you, sir. That worked great! ;)

I'm glad it wasn't my imagination. ;)

Zilvia 03-25-2004 06:50 PM

Does this work with the final release of vB 3.0.0?

Velocd 03-29-2004 09:57 PM

Yes.


All times are GMT. The time now is 10:10 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.02048 seconds
  • Memory Usage 1,837KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (13)bbcode_code_printable
  • (16)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (40)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete