vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   Member Archives (https://vborg.vbsupport.ru/forumdisplay.php?f=202)
-   -   [RELEASE] Find word in thread (https://vborg.vbsupport.ru/showthread.php?t=12045)

TAW 03-22-2001 01:46 PM

Yes...... its another javascript template hack!!!

This one is VERY useful in my opinion and I think will be very popular

It places a search box on the thread page, that can search through all the words on the page and show them one by one

First decide where you want to place it and in which template

Once done, place this code into the relevant position where you want it.

I suggest under the "Recieve updates from this thread" part

Then you are done!

Code:

<script language="JavaScript">

var NS4 = (document.layers);   
var IE4 = (document.all);

var win = window;   
var n  = 0;

function findInPage(str) {

  var txt, i, found;

  if (str == "")
    return false;

 

  if (NS4) {

    if (!win.find(str))
      while(win.find(str, false, true))
        n++;
    else
      n++;

   

    if (n == 0)
      alert("Not found.");
  }

  if (IE4) {
    txt = win.document.body.createTextRange();


    for (i = 0; i <= n && (found = txt.findText(str)) != false; i++) {
      txt.moveStart("character", 1);
      txt.moveEnd("textedit");
    }

   

    if (found) {
      txt.moveStart("character", -1);
      txt.findText(str);
      txt.select();
      txt.scrollIntoView();
      n++;
    }

   

    else {
      if (n > 0) {
        n = 0;
        findInPage(str);
      }

     

      else
        alert("Not found on this page");
    }
  }

  return false;
}

</script>

<form name="search" onSubmit="return findInPage(this.string.value);">
<font size=3><input name="string" type="text" size=15 onChange="n = 0;"></font>
<input type="submit" value="Find in this thread">
</form>

Enjoy!

And give me feedback on my javascript hacks!

Note - this only search the page that you are reading and not all the thread if it is more than one page

Also, this could be a nice keyword finder in a forum, because it doesn't involve going to another page.

03-22-2001 09:05 PM

No to diss your hack or anything man, I really think you did a great job and all, but wouldn't is just be easier to click CTRL+F on Internet Explorer?


All times are GMT. The time now is 05:59 AM.

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.00986 seconds
  • Memory Usage 1,715KB
  • 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
  • (1)bbcode_code_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (2)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
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete