Latest topics
» [HELP] About Profile Cover Code
by MaHwOs Yesterday at 18:54

» bloquer un membre
by berlingo Fri 17 Nov 2017, 18:19

» IconSkouliki Graphics
by skouliki Fri 17 Nov 2017, 03:54

» [IN PROGRESS] Can this code work on pun version
by skouliki Thu 16 Nov 2017, 03:50

» Auto-suggest @mentions as You Type
by skouliki Wed 15 Nov 2017, 14:56

» [TUTORIAL] [ALL VERSIONS] Warning before posting
by demon99 Wed 15 Nov 2017, 08:12

» About Add Reply & New Topic button (popup form)
by omarpop23 Mon 13 Nov 2017, 20:31

» Hello everyone this is Adam from France
by Adam Mon 13 Nov 2017, 13:32

» Add a login popup for the toolbar
by Ape Sun 12 Nov 2017, 18:41

» Post a message automatically when locking a topic
by ThunderTB Sun 12 Nov 2017, 13:51

» Control pannel issue
by Ange Tuteur Sun 12 Nov 2017, 09:49

» BUG... forum members birthday's
by Ape Sat 11 Nov 2017, 11:44

» Display a Preview of Groups on Hover
by ThunderTB Fri 10 Nov 2017, 21:56

» Search box only visible on hover
by Ange Tuteur Mon 06 Nov 2017, 09:57

» [GAME] Animal Game
by SLGray Sun 05 Nov 2017, 15:04

Recent Tutorials
Who is online?
In total there are 7 users online :: 0 Registered, 0 Hidden and 7 Guests :: 1 Bot

None

[ View the whole list ]


Most users ever online was 172 on Fri 19 Feb 2016, 05:17

SyncEditor

View previous topic View next topic Go down

avatar
Ace 1
Valued Member
Title :

Beta Tester
Gender : Unspecified
Age : 18
Posts : 2151
Points : 2950
Reputation : 88
Location : USA
Language : English ?
Browser : Browser : Google Chrome Forum Version : Forum Version : phpBB3
Awards :
View all awards
View user profile http://fmdesign.forumotion.com/u190

PostAce 1 on Mon 31 Oct 2016, 23:58

If you've used StackOverflow before, then you know that they have a simplified version of the SCEditor that Forumotion uses. However, their editor shows a preview of the post as the user types.

With this plugin, that feature is now available on Forumotion!

Installation


Administration Panel > Modules > HTML & Javascript > Javascript codes management > Create new javascript (make sure Javascripts are enabled on your forum)

Title: SyncEditor
Placement: In all the pages

Code:

Code:
$(function() {
    'SyncEditor Version v0.5 ©️ 2016';
    'Developed by Ace 1';
    'All rights reserved.';
 
    var lang = {
          preview: 'Preview', // ALL VERSIONS
          subject: 'Subject', // PHPBB2
          appearance: 'This is how your post will appear once submitted' // PUNBB
        },
        select_code = false,
        preview_button_on = false;
 
    if ((/\/t\d+/.test(window.location.href) || /\/(post|(post\?(f|t|p)=\d+&mode=(newtopic|reply|quote|editpost)))/.test(window.location.href)) && $.sceditor) {
 
        if ($.sceditor) {
            var preview,
 
                version = $('.bodylinewidth')[0] ? 0 : document.getElementById('wrap') ? 1 : $('div.pun')[0] ? 2 : document.getElementById('ipbwrapper') ? 3 : document.getElementById('fa_edge') ? 4 : '',
 
                simplePreview = [
                    '<table class="forumline preview" width="100%" border="0" cellspacing="1" cellpadding="4"><tbody><tr><th class="thHead" height="25">' + lang.preview + '</th></tr><tr><td class="row1"><table width="100%" border="0" cellspacing="0" cellpadding="0"><tbody><tr><td><div class="postbody"></div></td></tr></tbody></table></td></tr><tr><td class="spaceRow" height="1"></td></tr></tbody></table><br clear="all">',
                    '<div id="preview" class="post row2"><div class="h3">' + lang.preview + '</div><div class="content"></div></div>',
                    '<div class="main-head clearfix preview"><p class="h2">' + lang.preview + '</p></div><div class="main-content topic" style="text-align: left;"><div class="post"><div class="postmain" style="margin-left: 0;"><div class="posthead"><h2>' + lang.appearance + '.</h2></div><div class="postbody"><div class="post-entry"><div class="entry-content"></div></div></div></div></div></div>',
                    '<div id="preview" class="post borderwrap" style="background-color: #e4e6e9"><div class="maintitle clearfix"><h3>' + lang.preview + '</h3></div><div class="post-entry row1"></div></div>',
                    '<div id="preview" class="content-block post"><div class="title">' + lang.preview + '</div><div class="post-inner"><div class="postbody"><div class="content"></div></div></div></div>'
                ][version],
 
                createSimplePreview = function() {
                    version == 0 // PHPBB2
                        ? $('form[action="/viewforum"]').before(simplePreview)
                        : (
                          version == 1 || version == 4 // PHPBB3 && EDGE
                            ? $('#quick_reply').after(simplePreview)
                            : (
                              version == 2 // PUNBB
                                ? $('#quick_reply').append(simplePreview)
                                : (
                                  version == 3 // INVISION
                                    ? $('#qpost').after(simplePreview)
                                    : ''
                                )
                            )
                        )
                },
 
                advancedPreview = [
                    '<table class="forumline preview" width="100%" border="0" cellspacing="1" cellpadding="4"><tbody><tr><th class="thHead" height="25">' + lang.preview + '</th></tr><tr><td class="row1"><span class="postdetails"><img src="https://illiweb.com/fa/empty.gif" alt="Post" title="Post" border="0">' + lang.subject + ': <img src="https://illiweb.com/fa/empty.gif" alt="" border="0"><span style="user-select: none !important; color: transparent !important; text-shadow: none !important; background: none !important;"><3</span>' + formatDate() + '</span></td></tr><tr><td class="row1"><table width="100%" border="0" cellspacing="0" cellpadding="0"><tbody><tr><td><div class="postbody"></div></td></tr></tbody></table></td></tr><tr><td class="spaceRow" height="1"><img src="http://illiweb.com/fa/empty.gif" height="1" width="1" alt=""></td></tr></tbody></table><br clear="all">',
                    '<div id="preview" class="post row2"><div class="inner"><span class="corners-top"><span></span></span><div class="postbody"><div class="h3">' + lang.preview + '</div><div class="content"></div></div><span class="corners-bottom"><span></span></span></div></div>',
                    '<div class="main-head clearfix preview"><p class="h2">' + lang.preview + '</p></div><div class="main-content topic"><div class="post"><div class="postmain"><div class="posthead"><h2>' + lang.appearance + '.</h2></div><div class="postbody"><div class="user"><h4 class="user-ident"><span class="username">' + _userdata.username + '</span></h4></div><div class="post-entry"><div class="entry-content"></div></div></div></div></div></div>',
                    '<div id="preview" class="post borderwrap"><div class="maintitle clearfix"><h3>' + lang.preview + '</h3></div><div class="postbody"><div class="post-entry row1"></div></div></div>',
                    simplePreview + '<hr>'
                ][version],
 
                createAdvancedPreview = function() {
                    version == 0 // PHPBB2
                        ? $('form[action="/post"]').before(advancedPreview)
                        : (
                          version == 1 || version == 4 // PHPBB3 && EDGE
                            ? $('h1.page-title').after(advancedPreview)
                            : (
                              version == 2 // PUNBB
                                ? $('form.frm-form').prepend(advancedPreview)
                                : (
                                  version == 3 // INVISION
                                    ? $('ul#navstrip').after(advancedPreview)
                                    : ''
                                )
                            )
                        )
                },
 
                actualContainer = [
                    '.preview .row1 table .postbody',
                    '#preview .content',
                    /* form.frm-form */ '.preview .entry-content',
                    '#preview .post-entry',
                    '#preview .content'
                ][version],
               
                removeandreplaceCurrent = function() {
                  preview = actualContainer.split(/\s/).shift();
                  $(preview).remove();
                  createAdvancedPreview();
                 
                  if (version == 4) $(preview).next().remove();
                };
 
            if ( version == 0 && document.forms.post.subject ) {
                document.forms.post.subject.oninput = function() {
                    var v = this.value;
                    $('span.postdetails').eq(0).contents().filter(function() {return this.nodeType == 3})[0].textContent = 'Subject: ' + (v == 'undefined' ? '' : v);
                };
            }
 
            function formatDate() {
                var d = Date(),
                    y = new Date().getFullYear(),
                    m = new Date().getMinutes(),
                    s = new Date().getSeconds(),
                    n = d.indexOf(m + ':' + s),
                    realDate = d.substring(0, n + 5);
                realDate = realDate.slice(0, realDate.indexOf(y) + 4) + " - " + realDate.slice(realDate.indexOf(y) + 5);
                return realDate;
            }
         
            /\/t\d+/.test(window.location.href)
                ? createSimplePreview()
                : (
                  /\/post\?(f|t|p)=\d+&mode=(newtopic|reply|quote|editpost)/.test(window.location.href)
                      ? createAdvancedPreview()
                      : removeandreplaceCurrent()
                )
        }
 
        $('#text_editor_textarea').ready(function() {
            var instance = $('#text_editor_textarea').sceditor('instance'),
 
                sceditorContent, previewContent,
 
                convert = function() {
                    sceditorContent = instance.val();
                    previewContent = instance.fromBBCode(sceditorContent, false);
                    $(actualContainer).html(previewContent);
             
                    // Quote Parsing
                    if (version == 0) {
                        $(actualContainer)[0].innerHTML = $(actualContainer)[0].innerHTML
                          .replace(/\<blockquote\>/g, '<dl class="codebox">')
                          .replace(/\<\/blockquote\>/g, '</dl>')
                          .replace(/\<cite\>/g, '<dt><span class="genmed"><b><a href="#" rel="nofollow">')
                          .replace(/\<\/cite\>/g, '</a> wrote:</b></span></dt>');
                 
                        $('dl.codebox > dt', actualContainer).each(function() {
                            $(this).parent().contents().filter(function() {
                                return this.tagName != 'DT' && this.className != 'code'
                            }).wrapAll('<dd class="quote" />');
                        });
                 
                        $('dl.codebox', actualContainer).each(function() {
                            $(this).parent().contents().filter(function() {
                                return this.className != 'codebox'
                            }).wrapAll('<span class="postbody" />');
                        });
                    } else {
                        $('blockquote', actualContainer).wrapInner('<div />');
                        $('blockquote cite', actualContainer).wrapInner('<a href="#" rel="nofollow" />');
                        $('blockquote cite', actualContainer).append(' wrote:');
                    }
             
                    // Code Parsing
                    var codeTitle = 'Code:' + (select_code ? selection : '');
                    $('code', actualContainer).wrap('<dl class="codebox" />');
             
                    $('.codebox code', actualContainer).before('<dt>' + (version == 0 ? '<span class="genmed"><b>' + codeTitle + '</b></span>' : codeTitle) + '</dt>').wrap('<dd' + (version == 0 ? ' class="code"' : '') + ' />');
                    $('dd.code', actualContainer).wrapInner('<div class="cont_code" />');
                    if ($('div.cont_code', actualContainer)[0]) ($('div.cont_code', actualContainer)[0].firstChild).contents().unwrap('code');
             
                    // Smilies
                    var s, s2, re;
 
                    for ( s in smileys ) {
                        if ($(actualContainer).html() && $(actualContainer).html().indexOf(s) != -1) {
                            /\W/.test(s.replace(/:/g, '')) ? s2 = s.replace(/(.{1})/g, '\\$1') : s2 = s;
                            re = new RegExp(s2, 'gi');
                            $(actualContainer).html($(actualContainer).html().replace(re, '<img src="' + smileys[s] + '" />'));
                        }
                    }
 
                    // Spoiler
                    $.sceditor.plugins.bbcode.bbcode.set('spoiler', {
                        tags: {
                            'div': {
                                'class': ['spoiler']
                            }
                        },
                        format: '[spoiler]{0}[/spoiler]',
                        html: function(token, attrs, content) {
                            var a = attrs.defaultattr,
                                c = content;
                            if (a == undefined || a == '' || a == '"' || a == '\'') a = 'Spoiler';
                            if (a && (a.charAt(0) == '"' || a.charAt(0) == '\'')) a = a.replace(/("|')/, '');
 
                          c = (version == 0 ? '<dt style="cursor: pointer;">' + a + ':</dt><dd class="spoiler_closed">&nbsp;</dd><dd><div class="spoiler_content hidden">' + c + '</div></dd>' : '<dt style="cursor: pointer;">' + a + ':</dt><dd><div class="spoiler_content">' + c + '</div></dd>');
 
                            return '<dl class="codebox spoiler">' + c + '</dl>';
                        }
                    });
 
                    if ( version == 0 || version == 2 ) {
                        // Headings For PHPBB2 && PunBB
                        $.sceditor.plugins.bbcode.bbcode.set('h2', {tags: { 'h2': null }, format: '[h2]{0}[/h2]',html: '<h2 class="post-content">{0}</h2>'});
                        $.sceditor.plugins.bbcode.bbcode.set('h3', {tags: { 'h3': null }, format: '[h3]{0}[/h3]',html: '<h3 class="post-content">{0}</h3>'});
                        $.sceditor.plugins.bbcode.bbcode.set('h4', {tags: { 'h4': null }, format: '[h4]{0}[/h4]',html: '<h4 class="post-content">{0}</h4>'});
                    }
 
                    // Scroll
                    $.sceditor.plugins.bbcode.bbcode.set('scroll', {
                        tags: {
                            'marquee': null
                        },
                        format: '[scroll]{0}[/scroll]',
                        html: function(token, attrs, content) {
                            var c = content;
                            c = '<marquee>' + c + '</marquee>';
 
                            return '<span>' + c + '</span>';
                        }
                    });
 
                    // Updown
                    $.sceditor.plugins.bbcode.bbcode.set('updown', {
                        tags: {
                            'marquee': {
                                'direction': null
                            }
                        },
                        format: '[updown]{0}[/updown]',
                        html: function(token, attrs, content) {
                            var c = content;
                            c = '<marquee direction="up" scrollamount="1" style="height: 60px;">' + c + '</marquee>';
 
                            return '<span>' + c + '</span>';
                        }
                    });
                };
 
            /\/(post|(post\?(f|t|p)=\d+&mode=(newtopic|reply|quote|editpost)))/.test(window.location.href) ? convert() : '';
 
            instance.bind('focus blur keydown keyup nodechanged', function() {convert(); });
 
            $('.sceditor-button').click(function() {
                convert();
                $('.sceditor-dropdown div input.button').add('.sceditor-header-picker *').add('.sceditor-dropdown a.sceditor-fontsize-option').add('.sceditor-dropdown a.sceditor-fontsize-option > *').on('click', function() {
                    convert()
                });
                // $('.smiley-element > img').click(function() { setTimeout(convert, 100) });
            });
 
        });
     
        if (version == 4) $('head').append('<style type="text/css">#quick_reply + #preview .post-inner { margin: 0 5px; }</style>');
 
        !preview_button_on ? $(document.forms.post.preview).remove() : '';
    }
 
    /*** Progress
    var logs = {
        v0.1 : 'Developed SyncEditor',
        v0.2 : 'Implemented Smilies -- Bug fixes for phpbb2',
        v0.3 : 'Optimized for FAE -- Smilies are completely operational -- Fixed quoting problems -- Minor bug fixes for all versions',
        v0.4 : 'Language data',
        v0.5 : 'Fully optimized for FAE -- Fixed preview button bug'
    };
    ***/
});

Modification


Code:
      lang = {
          preview: 'Preview',
          subject: 'Subject',
          appearance: 'This is how your post will appear once submitted'
        },

Change the text to your language if it isn't English. The second one is for phpBB2 and the third is for punBB.

Code:
select_code = false

Change this to
Code:
true
if you have Forumotion's Select Code feature enabled on your forum.

Click here for more information on the Select Code function.

Code:
preview_button_enabled = false

Change this to
Code:
true
if you still want to have a "Preview" button on your forum.

Other Information


On some versions, you may want to add some CSS to style the look of the preview. For example, on PHPBB3, you may want to add this to the CSS Stylesheet (AP > Display > Colors > CSS):

Code:
[name="quickreply"] + .h3 + br + #quick_reply input[type="submit"] { margin-bottom: 25px; }

#quick_reply + #preview { padding: 5px 10px; border-radius: 3px; }
#quick_reply + #preview .h3 { margin: 3px 0; }
#quick_reply + #preview .content { font-size: 1.3em; padding: 1px; }

Other than that, everything else should work out finely. If you have any questions, just ask Wink

This is how it looks on PHPBB3:





Note: This is optimized to work on all versions so if there is a bug or if there is a modification you want made personally, just let me know and I'll gladly get it done.


Last edited by Ace 1 on Wed 28 Dec 2016, 04:22; edited 5 times in total
avatar
Ange Tuteur
Administrator
Title :
Coffee Addict
Gender : Male
Age : 22
Posts : 4712
Points : 9586
Reputation : 2341
Location : Macungie, PA
Language : EN10, FR5
Browser : Browser : Brave Forum Version : Forum Version : Forumactif Edge
Awards :
View all awards
View user profile https://github.com/SethClydesdale https://twitter.com/sethc1995

PostAnge Tuteur on Tue 01 Nov 2016, 11:11

I tested it on my test forum and it works nicely. Keep up the good work ! Very good
avatar
Ace 1
Valued Member
Title :

Beta Tester
Gender : Unspecified
Age : 18
Posts : 2151
Points : 2950
Reputation : 88
Location : USA
Language : English ?
Browser : Browser : Google Chrome Forum Version : Forum Version : phpBB3
Awards :
View all awards
View user profile http://fmdesign.forumotion.com/u190

PostAce 1 on Tue 01 Nov 2016, 11:52

@Ange Tuteur Emoticons?
avatar
Ange Tuteur
Administrator
Title :
Coffee Addict
Gender : Male
Age : 22
Posts : 4712
Points : 9586
Reputation : 2341
Location : Macungie, PA
Language : EN10, FR5
Browser : Browser : Brave Forum Version : Forum Version : Forumactif Edge
Awards :
View all awards
View user profile https://github.com/SethClydesdale https://twitter.com/sethc1995

PostAnge Tuteur on Tue 01 Nov 2016, 12:06

They format just like in WYSIWYG mode.. NIIIIICE ! Surprised
avatar
Ace 1
Valued Member
Title :

Beta Tester
Gender : Unspecified
Age : 18
Posts : 2151
Points : 2950
Reputation : 88
Location : USA
Language : English ?
Browser : Browser : Google Chrome Forum Version : Forum Version : phpBB3
Awards :
View all awards
View user profile http://fmdesign.forumotion.com/u190

PostAce 1 on Mon 28 Nov 2016, 10:10

Important New Updates

  • Optimized for FAE
  • Smilies are now completely operational
  • Fixed quoting and codebox problems
  • Minor bug fixes for all versions
avatar
keko_ferkeko

Title :
Medical Student
Gender : Male
Age : 25
Posts : 137
Points : 696
Reputation : 14
Location : Egypt
Language : Arabic, English, French, Latin & Chinese
Browser : Browser : Google Chrome Forum Version : Forum Version : phpBB3
Awards :
View all awards
View user profile http://nf-son.forumotion.com https://www.facebook.com/keko.ferkeko

Postkeko_ferkeko on Sun 04 Dec 2016, 08:54

One of the best I have seen in a while.
Keep it up ya handasa Very Happy

Here is the same code with translating the word "Preview" into Arabic "معاينة".
I hope you don't mind it.

Code:
$(function() {
    'SyncEditor Version v0.3 ©️ 2016';
    'Developed by Ace 1';
    'All rights reserved.';
 
    var select_code = false,
        preview_button_on = false;
 
    if ((/\/t\d+/.test(window.location.href) || /\/(post|(post\?(f|t|p)=\d+&mode=(newtopic|reply|quote|editpost)))/.test(window.location.href)) && $.sceditor) {
 
        if (!$('#preview .content').html() && $.sceditor) {
            var preview,
 
                version = $('.bodylinewidth')[0] ? 0 : document.getElementById(!$('#fa_edge') ? 'wrap' : 'wrapper') ? 1 : $('div.pun')[0] ? 2 : document.getElementById('ipbwrapper') ? 3 : '',
 
                simplePreview = [
                    '<table class="forumline preview" width="100%" border="0" cellspacing="1" cellpadding="4"><tbody><tr><th class="thHead" height="25">معاينة</th></tr><tr><td class="row1"><table width="100%" border="0" cellspacing="0" cellpadding="0"><tbody><tr><td><div class="postbody"></div></td></tr></tbody></table></td></tr><tr><td class="spaceRow" height="1"></td></tr></tbody></table><br clear="all">',
                    '<div id="preview" class="post row2"><div class="h3">معاينة</div><div class="content"></div></div>',
                    '<div class="main-head clearfix preview"><p class="h2">معاينة</p></div><div class="main-content topic" style="text-align: left;"><div class="post"><div class="postmain" style="margin-left: 0;"><div class="posthead"><h2>This is how your post will appear once submitted.</h2></div><div class="postbody"><div class="post-entry"><div class="entry-content"></div></div></div></div></div></div>',
                    '<div id="preview" class="post borderwrap" style="background-color: #e4e6e9"><div class="maintitle clearfix"><h3>معاينة</h3></div><div class="post-entry row1"></div></div>'
                ][version],
 
                createSimplePreview = function() {
                    version == 0 // PHPBB2
                        ? $('form[action="/viewforum"]').before(simplePreview)
                        : (
                          version == 1 // PHPBB3
                            ? $('#quick_reply').after(simplePreview)
                            : (
                              version == 2 // PUNBB
                                ? $('#quick_reply').append(simplePreview)
                                : (
                                    version == 3 // INVISION
                                    ? $('#qpost').after(simplePreview)
                                    : ''
                                )
                            )
                        )
                },
 
                advancedPreview = [
                    '<table class="forumline preview" width="100%" border="0" cellspacing="1" cellpadding="4"><tbody><tr><th class="thHead" height="25">معاينة</th></tr><tr><td class="row1"><span class="postdetails"><img src="https://illiweb.com/fa/empty.gif" alt="Post" title="Post" border="0">Subject: <img src="https://illiweb.com/fa/empty.gif" alt="" border="0"><span style="user-select: none !important; color: transparent !important; text-shadow: none !important; background: none !important;"><3</span>' + formatDate() + '</span></td></tr><tr><td class="row1"><table width="100%" border="0" cellspacing="0" cellpadding="0"><tbody><tr><td><div class="postbody"></div></td></tr></tbody></table></td></tr><tr><td class="spaceRow" height="1"><img src="http://illiweb.com/fa/empty.gif" height="1" width="1" alt=""></td></tr></tbody></table><br clear="all">',
                    '<div id="preview" class="post row2"><div class="inner"><span class="corners-top"><span></span></span><div class="postbody"><div class="h3">معاينة</div><div class="content"></div></div><span class="corners-bottom"><span></span></span></div></div>',
                    '<div class="main-head clearfix preview"><p class="h2">معاينة</p></div><div class="main-content topic"><div class="post"><div class="postmain"><div class="posthead"><h2>This is how your post will appear once submitted.</h2></div><div class="postbody"><div class="user"><h4 class="user-ident"><span class="username">' + _userdata.username + '</span></h4></div><div class="post-entry"><div class="entry-content"></div></div></div></div></div></div>',
                    '<div id="preview" class="post borderwrap"><div class="maintitle clearfix"><h3>معاينة</h3></div><div class="postbody"><div class="post-entry row1"></div></div></div>'
                ][version],
 
                createAdvancedPreview = function() {
                    version == 0 // PHPBB2
                        ? $('form[action="/post"]').before(advancedPreview)
                        : (
                          version == 1 // PHPBB3
                            ? $('h1.page-title').after(advancedPreview)
                            : (
                              version == 2 // PUNBB
                                ? $('form.frm-form').prepend(advancedPreview)
                                : (
                                  version == 3 // INVISION
                                    ? $('ul#navstrip').after(advancedPreview)
                                    : ''
                                )
                            )
                        )
                },
 
                actualContainer = [
                    '.preview .row1 table .postbody',
                    '#preview .content',
                    'form.frm-form .entry-content',
                    '#preview .post-entry'
                ][version];
 
            if ( version == 0 && document.forms.post.subject ) {
                document.forms.post.subject.oninput = function() {
                    var v = this.value;
                    $('span.postdetails').eq(0).contents().filter(function() {return this.nodeType == 3})[0].textContent = 'Subject: ' + (v == 'undefined' ? '' : v);
                };
            }
 
            function formatDate() {
                var d = Date(),
                    y = new Date().getFullYear(),
                    m = new Date().getMinutes(),
                    s = new Date().getSeconds(),
                    n = d.indexOf(m + ':' + s),
                    realDate = d.substring(0, n + 5);
                realDate = realDate.slice(0, realDate.indexOf(y) + 4) + " - " + realDate.slice(realDate.indexOf(y) + 5);
                return realDate;
            }
 
            /\/t\d+/.test(window.location.href)
                ? createSimplePreview()
                : /\/(post|(post\?(f|t|p)=\d+&mode=(newtopic|reply|quote|editpost)))/.test(window.location.href) ? createAdvancedPreview() : '';
        }
 
        $('#text_editor_textarea').ready(function() {
            var instance = $('#text_editor_textarea').sceditor('instance'),
 
                sceditorContent, previewContent,
 
                convert = function() {
                    sceditorContent = instance.val();
                    previewContent = instance.fromBBCode(sceditorContent, false);
                    $(actualContainer).html(previewContent);
                
                    // Quote Parsing
                    if (version == 0) {
                        $(actualContainer)[0].innerHTML = $(actualContainer)[0].innerHTML
                          .replace(/\<blockquote\>/g, '<dl class="codebox">')
                          .replace(/\<\/blockquote\>/g, '</dl>')
                          .replace(/\<cite\>/g, '<dt><span class="genmed"><b><a href="#" rel="nofollow">')
                          .replace(/\<\/cite\>/g, '</a> wrote:</b></span></dt>');
                    
                        $('dl.codebox > dt', actualContainer).each(function() {
                            $(this).parent().contents().filter(function() {
                                return this.tagName != 'DT' && this.className != 'code'
                            }).wrapAll('<dd class="quote" />');
                        });
                    
                        $('dl.codebox', actualContainer).each(function() {
                            $(this).parent().contents().filter(function() {
                                return this.className != 'codebox'
                            }).wrapAll('<span class="postbody" />');
                        });
                    } else {
                        $('blockquote', actualContainer).wrapInner('<div />');
                        $('blockquote cite', actualContainer).wrapInner('<a href="#" rel="nofollow" />');
                        $('blockquote cite', actualContainer).append(' wrote:');
                    }
                
                    // Code Parsing
                    var codeTitle = 'Code:' + (select_code ? selection : '');
                    $('code', actualContainer).wrap('<dl class="codebox" />');
                
                    $('.codebox code', actualContainer).before('<dt>' + (version == 0 ? '<span class="genmed"><b>' + codeTitle + '</b></span>' : codeTitle) + '</dt>').wrap('<dd' + (version == 0 ? ' class="code"' : '') + ' />');
                    $('dd.code', actualContainer).wrapInner('<div class="cont_code" />');
                    if ($('div.cont_code', actualContainer)[0]) ($('div.cont_code', actualContainer)[0].firstChild).contents().unwrap('code');
                
                    // Smilies
                    var s, s2, re;
 
                    for ( s in smileys ) {
                        if ($(actualContainer).html().indexOf(s) != -1) {
                            /\W/.test(s.replace(/:/g, '')) ? s2 = s.replace(/(.{1})/g, '\\$1') : s2 = s;
                            re = new RegExp(s2, 'gi');
                            $(actualContainer).html($(actualContainer).html().replace(re, '<img src="' + smileys[s] + '" />'));
                        }
                    }
 
                    // Spoiler
                    $.sceditor.plugins.bbcode.bbcode.set('spoiler', {
                        tags: {
                            'div': {
                                'class': ['spoiler']
                            }
                        },
                        format: '[spoiler]{0}[/spoiler]',
                        html: function(token, attrs, content) {
                            var a = attrs.defaultattr,
                                c = content;
                            if (a == undefined || a == '' || a == '"' || a == '\'') a = 'Spoiler';
                            if (a && (a.charAt(0) == '"' || a.charAt(0) == '\'')) a = a.replace(/("|')/, '');
 
                          c = (version == 0 ? '<dt style="cursor: pointer;">' + a + ':</dt><dd class="spoiler_closed">&nbsp;</dd><dd><div class="spoiler_content hidden">' + c + '</div></dd>' : '<dt style="cursor: pointer;">' + a + ':</dt><dd><div class="spoiler_content">' + c + '</div></dd>');
 
                            return '<dl class="codebox spoiler">' + c + '</dl>';
                        }
                    });
 
                    if ( version == 0 || version == 2 ) {
                        // Headings For PHPBB2 && PunBB
                        $.sceditor.plugins.bbcode.bbcode.set('h2', {format: '[h2]{0}[/h2]',html: '<h2 class="post-content">{0}</h2>'});
                        $.sceditor.plugins.bbcode.bbcode.set('h3', {format: '[h3]{0}[/h3]',html: '<h3 class="post-content">{0}</h3>'});
                        $.sceditor.plugins.bbcode.bbcode.set('h4', {format: '[h4]{0}[/h4]',html: '<h4 class="post-content">{0}</h4>'});
                    }
 
                    // Scroll
                    $.sceditor.plugins.bbcode.bbcode.set('scroll', {
                        tags: {
                            'div': {
                                'class': ['scroll']
                            }
                        },
                        format: '[scroll]{0}[/scroll]',
                        html: function(token, attrs, content) {
                            var c = content;
                            c = '<marquee>' + c + '</marquee>';
 
                            return '<span>' + c + '</span>';
                        }
                    });
 
                    // Updown
                    $.sceditor.plugins.bbcode.bbcode.set('updown', {
                        tags: {
                            'div': {
                                'class': ['updown']
                            }
                        },
                        format: '[updown]{0}[/updown]',
                        html: function(token, attrs, content) {
                            var c = content;
                            c = '<marquee direction="up" scrollamount="1" style="height: 60px;">' + c + '</marquee>';
 
                            return '<span>' + c + '</span>';
                        }
                    });
                };
 
            /\/(post|(post\?(f|t|p)=\d+&mode=(newtopic|reply|quote|editpost)))/.test(window.location.href) ? convert() : '';
 
            instance.bind('focus blur keydown keyup nodechanged', function() {convert(); });
 
            $('.sceditor-button').click(function() {
                convert();
                $('.sceditor-dropdown div input.button').add('.sceditor-header-picker *').add('.sceditor-dropdown a.sceditor-fontsize-option').add('.sceditor-dropdown a.sceditor-fontsize-option > *').on('click', function() {
                    convert()
                });
                // $('.smiley-element > img').click(function() { setTimeout(convert, 100) });
            });
 
        });
 
        !preview_button_on ? $(document.forms.post.preview).remove() : '';
    }
 
    /*** Progress
    var logs = {
        v0.1 : 'Developed SyncEditor',
        v0.2 : 'Implemented Smilies, Bug fixes for phpbb2',
        v0.3 : 'Optimized for FAE, Smilies are completely operational, Fixed quoting problems, Minor bug fixes for all versions'
    };
    ***/
});

--------

Hello Guest, have a Good day!
avatar
Ace 1
Valued Member
Title :

Beta Tester
Gender : Unspecified
Age : 18
Posts : 2151
Points : 2950
Reputation : 88
Location : USA
Language : English ?
Browser : Browser : Google Chrome Forum Version : Forum Version : phpBB3
Awards :
View all awards
View user profile http://fmdesign.forumotion.com/u190

PostAce 1 on Sun 04 Dec 2016, 19:16

@keko_ferkeko I've updated the code with a language variable.

Thanks for bringing this up <3
avatar
keko_ferkeko

Title :
Medical Student
Gender : Male
Age : 25
Posts : 137
Points : 696
Reputation : 14
Location : Egypt
Language : Arabic, English, French, Latin & Chinese
Browser : Browser : Google Chrome Forum Version : Forum Version : phpBB3
Awards :
View all awards
View user profile http://nf-son.forumotion.com https://www.facebook.com/keko.ferkeko

Postkeko_ferkeko on Fri 09 Dec 2016, 00:31

@Ace 1 wrote:@keko_ferkeko I've updated the code with a language variable.

Thanks for bringing this up <3

Cool.. That's how it can go international.
Would you mind if I take it to the Arabic forums?

--------

Hello Guest, have a Good day!
avatar
Ace 1
Valued Member
Title :

Beta Tester
Gender : Unspecified
Age : 18
Posts : 2151
Points : 2950
Reputation : 88
Location : USA
Language : English ?
Browser : Browser : Google Chrome Forum Version : Forum Version : phpBB3
Awards :
View all awards
View user profile http://fmdesign.forumotion.com/u190

PostAce 1 on Fri 23 Dec 2016, 02:57

Yeah that's fine. Sorry for the late reply.
avatar
Ace 1
Valued Member
Title :

Beta Tester
Gender : Unspecified
Age : 18
Posts : 2151
Points : 2950
Reputation : 88
Location : USA
Language : English ?
Browser : Browser : Google Chrome Forum Version : Forum Version : phpBB3
Awards :
View all awards
View user profile http://fmdesign.forumotion.com/u190

PostAce 1 on Wed 28 Dec 2016, 04:25

Updates

  • Fully optimized for FAE
  • Fixed preview button bug
avatar
Guest
Guest
View all awards

PostGuest on Wed 28 Dec 2016, 14:43

Works great. Thanks for that! Smile
avatar
Redline
New Member
Title :
Gender : Unspecified
Posts : 1
Points : 409
Reputation : 0
Language : English
Browser : Browser : Google Chrome Forum Version : Forum Version : punBB
Awards :
View all awards
View user profile

PostRedline on Sat 07 Jan 2017, 06:59

Thanks, but this doesnt work on PunBB
avatar
Ace 1
Valued Member
Title :

Beta Tester
Gender : Unspecified
Age : 18
Posts : 2151
Points : 2950
Reputation : 88
Location : USA
Language : English ?
Browser : Browser : Google Chrome Forum Version : Forum Version : phpBB3
Awards :
View all awards
View user profile http://fmdesign.forumotion.com/u190

PostAce 1 on Sun 29 Jan 2017, 19:39

@Redline Slide me the link to your forum.

View previous topic View next topic Back to top

Create an account or log in to leave a reply

You need to be a member in order to leave a reply.

Create an account

Join our community by creating a new account. It's easy!


Create a new account

Log in

Already have an account? No problem, log in here.


Log in

 
Permissions in this forum:
You cannot reply to topics in this forum