vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   Problems with Javascript for Editor (https://vborg.vbsupport.ru/showthread.php?t=279553)

sz1 03-05-2012 07:28 AM

Problems with Javascript for Editor
 
1 Attachment(s)
Hi,

I have installed the latex editor for my forum, so that mathematical expressions within [TEX] BBCodes can be converted automatically to a respectable image. For the integration into vB, I used the addon vLatex, which is actually only compatible till vB 4.0.4. The corresponding developer does not seem to be active anymore. I run my forum with version 4.1.10 - nonetheless, the addon works except for one small thing.

When writing a post, there is a small but very handy Quick Menu.
https://vborg.vbsupport.ru/attachmen...1&d=1330935700

It should speed up and simplify the use of latex. By clicking on an icon, the appropriate BBCode should then be inserted in the editor. That just does?nt happen. If you click on an icon, simply nothing happens. As I understand it, this menu is controlled via a JavaScript, which is presented as follows. I only know that the editor has changed since 4.0.4 vB very much. I hope someone can help me there because my Java knowledge is very limited or not available.

Code:

window.status = 'actualizado';

vB_Text_Editor.prototype.pod_vlatex_insertcommand = function (code)
{
  if (this.wysiwyg_mode)
  {
    while (code.indexOf('{br}') != -1) code = code.replace('{br}', '<br />');
  }
  else
  {
    while (code.indexOf('{br}') != -1) code = code.replace('{br}', "\n");
  }

  var anchorpos = code.indexOf('#');
 
  if (anchorpos == -1)
  {
    this.insert_text(code+' ', code.length+1);
  }
  else
  {   
    var seltext = this.get_selection();

    if ((seltext === false) || (seltext.length == 0))
    {
      seltext = "";
    }
    else
    {
      seltext = new String(seltext);
    }

    var precode = code.substring(0, anchorpos);
    var poscode = code.substring(anchorpos+1);
    this.insert_text(precode + seltext + poscode+' ', precode.length, poscode.length+1);
  }
}

vB_Text_Editor.prototype.pod_vlatex_init = function()
{
  this.vlatex_commandmenu = document.getElementById('vlatex_commandmenu');
 
  if (is_ie)
    { var buttonTagName = 'img'; }
  else
    { var buttonTagName = 'li'; }
 
  var buttons = this.vlatex_commandmenu.getElementsByTagName(buttonTagName);
   
  for (var i=0; i < buttons.length; i++)
  {
    buttons[i].editorid = this.editorid;
   
    buttons[i].onclick      = function () { vB_Editor[this.editorid].check_focus(); };
    buttons[i].onmousedown  = function () {
                                            if (is_ie)
                                              { vB_Editor[this.editorid].pod_vlatex_insertcommand(this.alt); }
                                            else
                                              { vB_Editor[this.editorid].pod_vlatex_insertcommand(this.title); }
                                          };
  }
}

Regards
Koch (Germany)


All times are GMT. The time now is 11:20 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.01021 seconds
  • Memory Usage 1,720KB
  • 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
  • (1)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