vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Custom CTRL codes in edit-/reply box (https://vborg.vbsupport.ru/showthread.php?t=175115)

Antyrael 04-04-2008 09:41 AM

Custom CTRL codes in edit-/reply box
 
Hello, I was wondering if anyone could help me with adding my own custom CTRL-X key press while editing or (quick) replying.

For example, when I'm typing a message, hitting CTRL-B will put [b][ /b] around the cursor, or around the selected text.

I'm using a hack that shows tooltip links for World of Warcraft items, and this requires people to put the item names between [item][ /item] tags.

What I want to do, is add a keypress, similar to CTRL-B, that instantly prints [item][ /item] on the cursor or around the selected text.

I would really appreciate it, because I also hope it will give me a little better understanding of how this works.
I have been digging through some files, but unfortunately I'm not that familiar with Javascripting so I'm stuck real fast...

Antyrael 04-22-2008 08:23 PM

No one has any idea? that's too bad :(

Opserty 04-23-2008 10:57 AM

Have you tried the vbulletin_textedit.js file? There is a function or whatever they call it in javascript: [minicode]vB_Text_Editor_Events.prototype.editdoc_onkeypress = function(e)[/minicode] (Search for that).

You might be able to mess around with that and follow it through. How to edit it exactly I don't know.

P.S. Don't forget the Ctrl+X combination is used for "Cutting" so you should use another key instead of X.

Antyrael 04-23-2008 11:37 AM

Thanks for pointing me in the right direction, I figured it out! :)

For those who are interested, here's what I did:

In vbulletin_textedit.js

- Added the line
Code:

case 'q': cmd = 'itemlink'; break;
Right after this:
Code:

case 'b': cmd = 'bold'; break;
case 'i': cmd = 'italic'; break;
case 'u': cmd = 'underline'; break;

- Added the following code
Code:

case 'itemlink':
{
  this.wrap_tags('item', false);
  return;
}

Right after this:
Code:

case 'bold':
case 'italic':
case 'underline':
{
  this.wrap_tags(cmd.substr(0, 1), false);
  return;
}

That's all there is to it, when I press CTRL-q it works as intended, pretty simple after all ;)
Only had to find a non-functioning CTRL- key combination, as most are shortcuts for the browser.

Opserty 04-23-2008 12:01 PM

I was suspecting it would be something simple like that ;)

Glad you got it working. :)

Antyrael 05-13-2008 03:46 PM

Well, with vBulletin 3.7 this solution is no longer viable.

The file vbulletin_textedit.js is just one big line of text and it appears they changed the scripting as well.
I'm going to try to fix it anyway, if anyone's interested I'll post my solution here (if I find it!).

Edit: I was able to fix it, quite easily actually, it's just a b*tch to document because there are no line numbers to go by ...

Opserty 05-13-2008 04:50 PM

You should be able to download a zip file containing the uncompressed Javascript files, edit this script and upload it to your server instead of the compressed one.


All times are GMT. The time now is 03:33 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.00963 seconds
  • Memory Usage 1,722KB
  • 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
  • (4)bbcode_code_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (7)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