Go Back   vb.org Archive > vBulletin Modifications > Archive > vB.org Archives > General > Member Archives
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools
Quick-Qoute hack (need help with javascript).. Details »»
Quick-Qoute hack (need help with javascript)..
Version: , by EvilLS1 EvilLS1 is offline
Developer Last Online: May 2021 Show Printable Version Email this Page

Version: Unknown Rating:
Released: 06-25-2003 Last Update: Never Installs: 0
 
No support by the author.

Hi,
Last night I started working on what I believe will be a very useful hack. It will allow you to directly reply (with a quote) to any post in a thread without having to load the newreply page..

In each post will be a small "QuickQoute" button.. When you click it a reply box will instantly drop down below that post.

I've put together an html example to show you exactly what I'm talking about.

Note: View this with Internet Explorer (6.0)... I haven't got around to making it work with other browsers but that won't be a problem.

Click here to see how QuickQoute works. (Click the QuickQuote button).

Anyway, what I will do is add some code to functions.php to check permissions, and then if everything is all good a variable will call the "QuickQoute" template which contains the reply form.. This variable will be placed in the postbit template.

Adding the PHP code isn't a problem.. I already know how to do that.

This is the problem:
Each form must have a unique ID or it will not work.. So I need to place some kind of variable that will display a unique value inside the javascript function.

Making it work in an HTML page is easy because you can define each form id yourself.. But making it work in the postbit is a bit more of a challenge because each postbit is generated dynamically (the same form will show up in each post).

Originally I planned to use the postid since it would be unique for every post, but I soon realized that php variables will not work in javascript functions.

Here's an example to show you what I need:

Example:
-----------------------------------------------

<script language="javascript">
function showDiv(objDiv)
{
Obj=eval((navigator.appName=="Netscape")?"document .layers['"+objDiv+"']":"document.all['"+objDiv+"'].style");
Obj.visibility="visible";
}
function hideDiv(objDiv)
{
Obj=eval((navigator.appName=="Netscape")?"document .layers['"+objDiv+"']":"document.all['"+objDiv+"'].style");
Obj.visibility="hidden";
}
</script>

<form enctype="multipart/form-data" action="newreply.php" name="vbform" method="post" onSubmit="return validate(this)">

<INPUT type="button" size="1" value="QuickQuote" name=button1 onClick="javascript:showDiv('formIDvariable ')">

<INPUT type="button" value="Hide" name=button2 onClick="javascript:hideDiv('formIDvariable ')">

<div id="formIDvariable " style="visibility:hidden;position:absolute">

~~~~~Reply Form goes here~~~~~

</div>

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

Basically what I need is some way to change the form ID variable (highlighted in orange) to something unique for each post. The $post[postid] would be perfect if it were possible to make a php variable work with a javascript function, but that won't work. So I'm wondering if there's any way to do this with javascript?

I hope I've explained this clearly, but if you have no idea what the heck I'm talking about just let me know and I'll try again.

Any help would be appreciated.

Show Your Support

  • This modification may not be copied, reproduced or published elsewhere without author's permission.

Comments
  #2  
Old 06-25-2003, 05:39 AM
SmEdD's Avatar
SmEdD SmEdD is offline
 
Join Date: Mar 2003
Location: Ontario, Canada
Posts: 381
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

PHP Code:
<script language="javascript">
function showDiv(objDiv) 

     Obj=eval((navigator.appName=="Netscape")?"document.layers['"+objDiv+"']":"document.all['"+objDiv+"'].style"); 
     Obj.visibility="visible"; 

function hideDiv(objDiv) 

     Obj=eval((navigator.appName=="Netscape")?"document.layers['"+objDiv+"']":"document.all['"+objDiv+"'].style"); 
     Obj.visibility="hidden"; 
}
</script>

<form enctype="multipart/form-data" action="newreply.php" name="vbform" method="post" onSubmit="return validate(this)">

<INPUT type="button" size="1" value="QuickQuote"  name=button1 onClick="javascript:showDiv('<?php echo $post[postid]; ?>')">

<INPUT type="button" value="Hide"  name=button2 onClick="javascript:hideDiv('<?php echo $post[postid]; ?>')">

    <div id="<?php echo $post[postid]; ?>" style="visibility:hidden;position:absolute">
And if that works can you please add me to the credits in the install.txt or what ever, thanks.
Reply With Quote
  #3  
Old 06-25-2003, 06:12 AM
EvilLS1's Avatar
EvilLS1 EvilLS1 is offline
 
Join Date: Apr 2002
Location: Georgia, USA
Posts: 987
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks for the reply SmEdD, but that won't work either (remember, this will be placed in the postbit template).

And yes, if anyone can help me solve this problem I will gladly put their name in the hack credits.
Reply With Quote
  #4  
Old 06-26-2003, 12:35 AM
EvilLS1's Avatar
EvilLS1 EvilLS1 is offline
 
Join Date: Apr 2002
Location: Georgia, USA
Posts: 987
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Problem solved! After doing some reading on javascript I found out that javascript variables cannot start with a number (like the postid).. So I fixed it by adding a prefix to the variable like so:

onClick="java script:showDiv('pf$post[postid] ')"

Now its working. For those who are interrested, the hack has been released here:
https://vborg.vbsupport.ru/showthrea...threadid=54759
Reply With Quote
  #5  
Old 06-26-2003, 10:12 AM
Dean C's Avatar
Dean C Dean C is offline
 
Join Date: Jan 2002
Location: England
Posts: 9,071
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Sounds like a really nice hack

- miSt
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 05:28 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.08028 seconds
  • Memory Usage 2,244KB
  • Queries Executed 18 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)modsystem_post
  • (1)navbar
  • (6)navbar_link
  • (120)option
  • (5)post_thanks_box
  • (5)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (5)post_thanks_postbit_info
  • (4)postbit
  • (5)postbit_onlinestatus
  • (5)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.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
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete