Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
  #1  
Old 06-29-2009, 08:28 AM
Saurdo Saurdo is offline
 
Join Date: Nov 2005
Location: Eureka, California
Posts: 3
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Trying to put a link in window.open window that puts text in post textarea-half works

On my forum I have replaced the attachment window popup with a window.open link to a page of my own. I want this page to operate in a manner similar to the smilies page. In that, when you click on a link, it puts text in the textarea for your post.

I wanted to use the exact method the smilies page used but the code has been compressed and is too hard to read. Instead, I tried to simulate that page from what I could decipher.

In the post area I modified the existing attachment javascript to be this:
HTML Code:
document.write('<input type="button" id="manage_attachments_button" class="button" tabindex="1" style="font-weight:normal" value="$vbphrase[manage_attachments]" title="$vbphrase[add_edit_files_attached]" onclick="window.open(\'http://www.reefsome.com/gallery/v/ludnix\',\'\',\'width=1024,height=768\');" />');
I removed the usual method just to make sure it wasn't messing things up. (it didn't work with the usual function either)

In the page that opens I put this javascript:
HTML Code:
function addToPost(text){
	posttext = window.opener.document.getElementById('vB_Editor_001_textarea');
	posttext.value += text;
}
if(window.opener != null){
	document.write('<br /><a onclick="addToPost(\'\\nadded some content\');" style="cursor: pointer;">test</a>');
}
What the code does is detect if the page was opened by a window.open function and then writes a link that calls the "addToPost" function when clicked. The add to post function simply gets the text from the textarea and then adds to the textareas value.

This code works - but not for everyone.

It seems as though, on some systems, it doesn't write to the text area. However, when tested, it does write to another textarea on the same page. When I added another textarea to the post page and modified the javascript to add to that textarea it successfully added the message to that textarea.

You can test if for yourself by going to www.reefsome.com/forums/ and using this login:
Code:
username: test
password: brokenjs
Simply click the attachment button, and then in the window that opens click the "test" link. It should add some text to your textarea.

I have absolutely no idea what could be causing this. The smilies page works on the same systems and as far as I could tell (and it was kind of hard to tell) the smilies page works in a manner similar to this.

--------------- Added [DATE]1246328205[/DATE] at [TIME]1246328205[/TIME] ---------------

I retrieved the generated HTML source code from one of the systems that this code wasn't working on. I then compared that source with the html source of my own and found that this line did not match:

HTML Code:
<input type="hidden" name="wysiwyg" id="vB_Editor_001_mode" value="1" />

<script type="text/javascript">
<!--
vB_Editor['vB_Editor_001'] = new vB_Text_Editor('vB_Editor_001', 1, '14', '1', undefined, '');
//-->
</script>
The difference between my code and the others is that the second value in the vb_text_editor class was 0 instead of 1.

After figuring out that these lines were the difference between the "enhanced" editor and the "standard" editor I ended up disabling use of the enhanced editor.

This is sort of the easy way out but I really don't feel as though the use of the enhanced editor is worth the time it would take to learn vbulletin's method and adapt it.

However, if anyone could offer insight on an easy way to get around this then I'm all for it.
Reply With Quote
Reply

Thread Tools
Display Modes

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 07:18 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.04863 seconds
  • Memory Usage 2,160KB
  • Queries Executed 11 (?)
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)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)bbcode_code
  • (3)bbcode_html
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)post_thanks_box
  • (1)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit_info
  • (1)postbit
  • (1)postbit_onlinestatus
  • (1)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