A possible code to enable WYSIWYG mode for certain forums? Hitskin_logo Hitskin.com

This is a Hitskin.com skin preview
Install the skinReturn to the skin page

The forum of the forums
Would you like to react to this message? Create an account in a few clicks or log in to continue.
3 posters

    A possible code to enable WYSIWYG mode for certain forums?

    Ramdaman
    Ramdaman
    Active Poster


    Male Posts : 1590
    Reputation : 99
    Language : English, Albanian, Macedonian, Russian | HTML, CSS
    Location : New York City

    Solved A possible code to enable WYSIWYG mode for certain forums?

    Post by Ramdaman September 2nd 2014, 2:07 am

    Hi everyone,

    I was wondering if it was possible to only enable WYSIWYG mode for a certain forum or certain forums, but not the whole thing. Thanks in advance Smile


    Last edited by Ramdaman on September 2nd 2014, 11:33 pm; edited 1 time in total
    Row
    Row
    New Member


    Male Posts : 24
    Reputation : 1
    Language : English and French
    Location : France

    Solved Re: A possible code to enable WYSIWYG mode for certain forums?

    Post by Row September 2nd 2014, 8:27 am

    Hi, it is impossible for the moment on Forumotion, see the suggestions of the members on the forum. Nice day.
    Ange Tuteur
    Ange Tuteur
    Forumaster


    Male Posts : 13207
    Reputation : 3000
    Language : English & 日本語
    Location : Pennsylvania

    Solved Re: A possible code to enable WYSIWYG mode for certain forums?

    Post by Ange Tuteur September 2nd 2014, 12:31 pm

    Hello Ramdaman,

    This is absolutely possible with a bit of JavaScript. Wink

    Go to Administration Panel > Modules > JavaScript codes management > create a new script

    Title : Your choice
    Placement : In the topics
    Paste the code below :
    Code:
    $(function(){$(function(){
      var editor = $('#text_editor_textarea').sceditor('instance');
      if ( forum(1) || forum(2) || forum(3) ) {
        if (editor.inSourceMode()) {
          editor.sourceMode(false);
          $('.sceditor-button-source').removeClass('hover');
          $.cookie('WYSIWYG_STATE', '1', { expires: 365 });
        }
      }
      else {
        editor.sourceMode(true);
        $('.sceditor-button-source').addClass('hover');
        $.cookie('WYSIWYG_STATE', '0', { expires: 365 });
      }
      function forum(n) {return RegExp('\/f'+n+'-').test($('.topic-actions .pathname-box p a.nav:last').attr('href'))}
    })});

    In the script is a condition :
    Code:
    if ( forum(1) || forum(2) || forum(3) )

    These are the forums whose topics you'll enabled WYSIWYG mode for. Simply write : forum(n) with n being a number value, that is the forum ID. You must separate multiple forums by ||.

    So for example, if you wanted to enable WYSIWYG mode in announcement, you would write :
    Code:
    if ( forum(6) )

    You can see the forum ID from the address bar while viewing the forum. e.g. http://www.agg-community.com/f6-announcements = f6 - f = 6

    Note :
    * The forums which don't allow WYSIWYG mode by default will start in source mode
    * The mode can still be switched if the source button is visible
    Ramdaman
    Ramdaman
    Active Poster


    Male Posts : 1590
    Reputation : 99
    Language : English, Albanian, Macedonian, Russian | HTML, CSS
    Location : New York City

    Solved Re: A possible code to enable WYSIWYG mode for certain forums?

    Post by Ramdaman September 2nd 2014, 1:46 pm

    I have made a form as shown in the Tips and Tricks, and I wanted to have it like forumotion has it for the graphic requests. Since forumotion has enabled WYSIWYG mode in the admin panel, I was wondering if this WYSIWYG script would work with the form script. Because it currently does not show.

    Code for the form JS
    Code:
    $(function() {
        if (location.pathname == '/post' && location.search == '?f=17&mode=newtopic') {
           $('#text_editor_textarea').val('[FONT=ARIAL BLACK][B][COLOR=#3399ff]Time:[/B][COLOR=#3399ff][/COLOR][/FONT] Answer Here\n
    [FONT=ARIAL BLACK][B][COLOR=#669900]In\-Game name of the player:[/B][COLOR=#669900][/COLOR][/FONT] Answer Here \n
    [FONT=ARIAL BLACK][B][COLOR=#3399ff]What happened:[/B][COLOR=#3399ff][/COLOR][/FONT] Answer Here \n
    [FONT=ARIAL BLACK][B][COLOR=#669900]Proof -Pictures or video-:[/B][COLOR=#669900][/COLOR][/FONT]  Answer Here');
        }
    });

    Code I inserted for certain forums containing WYSIWYG
    Code:
    $(function(){$(function(){
      var editor = $('#text_editor_textarea').sceditor('instance');
      if ( forum(17) ) {
        if (editor.inSourceMode()) {
          editor.sourceMode(false);
          $('.sceditor-button-source').removeClass('hover');
          $.cookie('WYSIWYG_STATE', '1', { expires: 365 });
        }
      }
      else {
        editor.sourceMode(true);
        $('.sceditor-button-source').addClass('hover');
        $.cookie('WYSIWYG_STATE', '0', { expires: 365 });
      }
      function forum(n) {return RegExp('\/f'+n+'-').test($('.topic-actions .pathname-box p a.nav:last').attr('href'))}
    })});


    I basically want the form to not be displayed with the BBBcodes in brackets but I want the BBCodes showing the design.
    Ange Tuteur
    Ange Tuteur
    Forumaster


    Male Posts : 13207
    Reputation : 3000
    Language : English & 日本語
    Location : Pennsylvania

    Solved Re: A possible code to enable WYSIWYG mode for certain forums?

    Post by Ange Tuteur September 2nd 2014, 9:15 pm

    If that's the case, remove the last script and replace your form script by :
    Code:
    $$(function(){
      if (location.pathname == '/post' && location.search == '?f=17&mode=newtopic') {
        $('#text_editor_textarea').val('[FONT=ARIAL BLACK][B][COLOR=#3399ff]Time:[/B][COLOR=#3399ff][/COLOR][/FONT] Answer Here\n[FONT=ARIAL BLACK][B][COLOR=#669900]In\-Game name of the player:[/B][COLOR=#669900][/COLOR][/FONT] Answer Here \n[FONT=ARIAL BLACK][B][COLOR=#3399ff]What happened:[/B][COLOR=#3399ff][/COLOR][/FONT] Answer Here \n[FONT=ARIAL BLACK][B][COLOR=#669900]Proof -Pictures or video-:[/B][COLOR=#669900][/COLOR][/FONT]  Answer Here');
       
        $(function(){
          var editor = $('#text_editor_textarea').sceditor('instance');
          if (editor.inSourceMode()) {
            editor.sourceMode(false);
            $('.sceditor-button-source').removeClass('hover');
            $.cookie('WYSIWYG_STATE', '1', { expires: 365 });
          }
        });
      }
    });
    Ramdaman
    Ramdaman
    Active Poster


    Male Posts : 1590
    Reputation : 99
    Language : English, Albanian, Macedonian, Russian | HTML, CSS
    Location : New York City

    Solved Re: A possible code to enable WYSIWYG mode for certain forums?

    Post by Ramdaman September 2nd 2014, 9:29 pm

    Still shows the bbcodes
    Ange Tuteur
    Ange Tuteur
    Forumaster


    Male Posts : 13207
    Reputation : 3000
    Language : English & 日本語
    Location : Pennsylvania

    Solved Re: A possible code to enable WYSIWYG mode for certain forums?

    Post by Ange Tuteur September 2nd 2014, 9:39 pm

    Oops, I made a typo ^^' replace your script by :
    Code:
    $(function(){
      if (location.pathname == '/post' && location.search == '?f=17&mode=newtopic') {
        $('#text_editor_textarea').val('[FONT=ARIAL BLACK][B][COLOR=#3399ff]Time:[/B][COLOR=#3399ff][/COLOR][/FONT] Answer Here\n[FONT=ARIAL BLACK][B][COLOR=#669900]In\-Game name of the player:[/B][COLOR=#669900][/COLOR][/FONT] Answer Here \n[FONT=ARIAL BLACK][B][COLOR=#3399ff]What happened:[/B][COLOR=#3399ff][/COLOR][/FONT] Answer Here \n[FONT=ARIAL BLACK][B][COLOR=#669900]Proof -Pictures or video-:[/B][COLOR=#669900][/COLOR][/FONT]  Answer Here');
     
        $(function(){
          var editor = $('#text_editor_textarea').sceditor('instance');
          if (editor.inSourceMode()) {
            editor.sourceMode(false);
            $('.sceditor-button-source').removeClass('hover');
            $.cookie('WYSIWYG_STATE', '1', { expires: 365 });
          }
        });
      }
    });
    Ramdaman
    Ramdaman
    Active Poster


    Male Posts : 1590
    Reputation : 99
    Language : English, Albanian, Macedonian, Russian | HTML, CSS
    Location : New York City

    Solved Re: A possible code to enable WYSIWYG mode for certain forums?

    Post by Ramdaman September 2nd 2014, 11:32 pm

    That fixes it. Thank you Smile
    Ange Tuteur
    Ange Tuteur
    Forumaster


    Male Posts : 13207
    Reputation : 3000
    Language : English & 日本語
    Location : Pennsylvania

    Solved Re: A possible code to enable WYSIWYG mode for certain forums?

    Post by Ange Tuteur September 3rd 2014, 12:20 am

    You're welcome.

    Topic archived

    Have a nice day. Smile