Code Lab
Would you like to react to this message? Create an account in a few clicks or log in to continue.
Search
Display results as :
Advanced Search
Latest topics
dasaasfagaegadfgsgsgs gssfgsfSat Sep 01, 2018 2:56 pmBetaTester
dasaasfagaegadfgsgsgs gssfgsfTue Mar 27, 2018 5:35 amBetaTester
dasaasfagaegadfgsgsgs gssfgsfTue Mar 27, 2018 5:35 amBetaTester
dasdadadad adssadadad asdsadadadadTue Mar 27, 2018 5:29 amBetaTester
dasdadadad adssadadad asdsadadadadTue Feb 27, 2018 1:33 pmAdmin
pruebassssssssTue Feb 27, 2018 9:42 amAdmin
probando probandoSun Feb 11, 2018 4:13 amBetaTester
[test] test ok ok ok ok Sat Dec 23, 2017 7:14 pmBetaTester
Probando :)Sat Mar 04, 2017 7:09 amBetaTester

Go down
Admin
Admin
Admin
Mensajes : 616
Puntos : 849
Reputación : 170
Fecha de inscripción : 2016-05-15
https://codelab.forumotion.com

ok test test Empty ok test test

Sat Oct 29, 2016 2:07 pm
Code:
console.log('//-----Written by Chalo ------- Open Source 2014-2016 -----//');
console.log('//------------ http://www.opensourcephpbb3.com ------------//');
console.log('//--------------------- Version: 1.3 ----------------------//');
console.log('//Reply, preview, quote, delete and more, without reload   //');
var os = {
    lang: {
        success_reply: 'Your message has been entered successfully', // <--- change this text exactly like is display in your language board
        flood: 'Flood control is active on this forum, please wait 10 second(s) before replying or posting',
        newpost: 'A new message has been posted',
        error_reply: 'Try again',
        words_reply: 'You need 5 letters at least',
        button_send_reply: 'Send data...',
        notice_original: 'No predefined text',
        no_message: 'There is nothing written in the editor',
        no_subject: 'You must specify a subject for your message.',
        pm_error_a: 'You must specify a username to whom to send this message.',
        pm_error_b: 'This or these user(s) do not exist',
        pm_error_c: 'You cannot make another post so soon after your last',
        pm_success: 'Your message has been sent',
        placeholder: 'write something here...',
        main_delete: 'Do you want delete the post #',
        delete_yes: 'Delete',
        delete_cancel: 'Cancel',
        edit_mode: 'Editing post #',
        quote_mode: 'Quoting post #',
        loading: 'Loading...',
        save: 'Save',
        wait_notice: 'Please be patient, sending data to the server',
        color_a: 'linear-gradient(to bottom, #febbbb 0%,#fe9090 45%,#ff5c5c 100%)',
        color_b: 'linear-gradient(to bottom, #ffaf4b 0%,#ff920a 100%)',
        color_c: 'linear-gradient(to bottom, #87e0fd 0%,#53cbf1 40%,#05abe0 100%)',
        color_d: 'linear-gradient(to bottom, #ff3019 0%,#cf0404 100%)',
        color_e: 'linear-gradient(to bottom, #d2ff52 0%,#91e842 100%)'
    },
    length_reply: 5, //min letters in the textarea before reply
    time: 3000,
    previewHTML: '<div id="preview_content"><a id="close" style="float:right;cursor:pointer;" onclick="os.close(\'preview\')"><img src="http://2img.net/i/fa/prosilver/icon_post_delete.gif"></a></div>',
    delete_style: '#confirm_content { color: #fff; margin-bottom: 7px; padding-bottom: 5px; font-size: 30px}#confirm >a { display: inline-block; padding: 4px 12px; margin-bottom: 0; font-size: 12px; line-height: 20px; color: #333; text-align: center; text-shadow: 0 1px 1px rgba(255, 255, 255, 0.75); vertical-align: middle; cursor: pointer; text-decoration: none!important;}#yes { color: #fff!important; text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25); background-color: #5bb75b; background-image: linear-gradient(to bottom, #62c462, #51a351)!important; background-repeat: repeat-x; border-color: #51a351 #51a351 #387038; border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25); text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25)!important;}#cancel { margin-left: 5px; color: #fff!important; background: linear-gradient(to bottom, #db5530 5%, #db1f1f 100%)!important; background-color: #db5530; text-shadow: 0 1px 0 #854629;}',
    init: function () {
        os.isTheme = /\/t\d+/g.test(window.location.pathname);
        os.isPost = /\/post\?f=(\d+)&mode=(newtopic)/.test(window.location.href);
        os.isEditPost = /\/post\?p=(\d+)&mode=(editpost)/.test(window.location.href);
        os.isMP = /\/privmsg\?mode=(post|reply|edit)/.test(window.location.href);
        os.phpbb2 = document.getElementsByClassName('bodylinewidth').length;
        os.phpbb3 = document.getElementById('phpbb');
        os.invision = document.getElementById('ipbwrapper');
        os.punbb = document.getElementById('pun-intro');
        os.subject = os.isTheme && document.getElementsByTagName('h1')[0].textContent;
        os.form = document.forms.post;
        os.b_r = os.form.post;
        os.b_r_v = os.form.post.value;
        os.textarea = os.form.message;
        os.action = os.form.action;
        os.group = document.getElementsByClassName('sceditor-group')[0];
        os.b_p = os.form.preview;
        os.b_p_v = os.b_p.value;
        os.url = os.isTheme ? '/post?t=' + os.form.t.value + '&mode=reply' : os.isPost && document.location.href;
        os.sceditor = $(os.textarea).sceditor('instance');
        os.content = os.punbb ? 'entry-content' : os.phpbb3 ? 'content' : os.invision ? 'post-entry' : os.phpbb2 && 'postbody';
        os.b_p.setAttribute('onclick', 'os.post(this, \'preview\');return false');
        os.b_r.setAttribute('onclick', (os.isMP ? 'os.post(this, \'mp\');return false' : 'os.post(this, \'reply\');return false'));
        os.a = document.getElementsByTagName('a');
        os.form.getElementsByTagName('textarea')[1].placeholder = os.lang.placeholder;
        os.buttons(os.a);
        os.beforeunload();
    },
    buttons: function (a) {
        for (var i = 0; i < a.length; i++) {
            /(?!\&(mode)\=)(quote)/.test(a[i].href) && a[i].setAttribute('onclick', 'os.get(this, \'quote\');return false');
            /(?!\&(mode)\=)(delete)/.test(a[i].href) && a[i].setAttribute('onclick', 'os.set_delete(this);return false');
            /(?!\&(mode)\=)(edit)/.test(a[i].href) && a[i].setAttribute('onclick', 'os.get(this,\'edit\');return false');
        }
    },
    notice: function (c, f, h) {
        var a, b, d, e, g;
        g = document.getElementsByClassName('notice_reply');
        b = os.group;
        d = b.parentNode;
        a = !g.length ? document.createElement('DIV') : g[0];
        e = 'height:20px;line-height: 1.5;border-radius: 3px; text-shadow: 0 1px rgba(255, 255, 255, 0.46);text-align:center';
        !g.length && (a.classList.add('notice_reply'), a.setAttribute('style', e), d.insertBefore(a, b));
        a.style.display = 'block';
        a.innerHTML = 'undefined' == typeof c ? os.lang.notice_original : c;
        a.style.background = ('undefined' == typeof f || f == '') ? os.lang.color_a : f;
        'false' != h && setTimeout(function () {
            'block' == a.style.display && (a.style.display = 'none')
        }, os.time);
    },
    get: function (c, d) {
        os.url_universal = "undefined" != typeof c.href ? c.href : c;
        var a = os.url_universal.match(/(?!\/post\?p=(\w+)\&mode=)(editpost|quote)|viewtopic/)[0],
            b = os.post_number(os.url_universal),
            f, g, h, j, k, l, m, n, t, u, x;
        os.XML('', os.url_universal, function (e) {
            x = e.responseXML;
            switch (a) {
            case 'editpost':
                os.sceditor.updateOriginal();
                os.scroll(10, os.form);
                f = x.forms.post.message.value;
                m = document.getElementsByClassName('post--' + b);
                g = document.createElement('input');
                g.className = 'inputbox medium edit_subject';
                g.name = 'subject';
                g.style = 'display:table;margin:0 auto;width: 99%;margin-bottom: 5px';
                g.value = x.forms.post.subject.value;
                os.group.parentNode.insertBefore(g, os.group);
                os.edit_subject = document.getElementsByClassName('edit_subject')[0];
                m.length && (m[0].style.border = '1px solid orange');
                os.sceditor.val(f);
                os.b_r.setAttribute('onclick', 'os.post(this, \'edit\');return false');
                os.encode_edit = os.serialize(x.forms.post);
                os.url_edit = c.href, os.edit_number = b;
                os.b_r.value = os.lang.save;
                os.notice(os.lang.edit_mode + b, os.lang.color_b, 'false');
                break;
            case 'quote':
                os.sceditor.updateOriginal();
                os.scroll(10, os.form);
                f = x.forms.post.message.value;
                h = os.sceditor.val();
                os.sceditor.val(h + f);
                os.notice(os.lang.quote_mode + b, os.lang.color_b, 'false');
                break;
            case 'viewtopic':
                k = x.getElementsByClassName('post--' + b)[0];
                k.style.display = 'none';
                k.className += ' new_ajax_post';
                j = document.getElementsByClassName('post--' + b)[0];
                'reply' == d && (os.buttons(k.getElementsByTagName('a')), os.set_post(k));
                'edit' == d && (t = k.getElementsByClassName(os.content), u = t[0].innerHTML, j.getElementsByClassName(os.content)[0].innerHTML = u, os.b_r.setAttribute('onclick', 'os.post(this, \'reply\');return false'), os.fadeIn(j, 500), os.scroll(15, j));
                os.sceditor.val('');
                os.notice(os.lang.success_reply, os.lang.color_e, 'true');
                break;
            }
        })
    },
    post: function (f, m) {
        var a, b, c, g, h, i, j, k, l, n, o, p, d, q, r, s, u, v, w, x;
        console.log(m);
        os.sceditor.updateOriginal();
        clearInterval(a);
        n = 'edit' == m && encodeURIComponent(os.sceditor.val());
        x = 'edit' == m && encodeURIComponent(os.edit_subject.value);
        os.url_post = m == 'delete' ? f.href : os.form.action;
        os.uritexto = 'reply' == m || 'mp' == m ? os.serialize(os.form) + '&post=1&prevent_post=1' : "preview" == m ? os.serialize(os.form) + '&preview=Preview' : 'delete' == m ? '&confirm=1' : '&subject=' + x + '&message=' + n + '&mode=editpost&p=' + os.edit_number + '&notify=on&&post=1&prevent_post=1';
        k = document.getElementsByClassName('new_ajax_post');
        k.length && k[0].classList.remove('new_ajax_post');
        if (os.sceditor.val().length > os.length_reply || 'delete' == m) {
            if ((os.isPost || os.isMP) && (os.form.subject && os.form.subject.value.length >= 10) || m == 'preview' || os.isEditPost || os.isTheme) {
                'delete' != m && (f.value = 'preview' == m ? os.lang.loading : os.lang.button_send_reply, 'preview' == m ? os.b_p.style = 'color:#fff;background:' + os.lang.color_d : os.b_r.style = 'color:#fff;background:' + os.lang.color_d);
                os.XML(os.uritexto, os.url_post, function (e) {
                    h = e.responseXML;
                    j = h.getElementById(os.phpbb2 ? 'page-body' : 'main');
                    o = h.getElementsByClassName('postbody')[0];
                    a = j.innerHTML.indexOf(os.lang.success_reply);
                    b = j.innerHTML.indexOf(os.lang.flood);
                    l = j.innerHTML.indexOf(os.lang.newpost);
                    s = j.innerHTML.indexOf(os.lang.pm_error_b);
                    u = j.innerHTML.indexOf(os.lang.pm_error_c);
                    v = j.innerHTML.indexOf(os.lang.pm_success);
                    w = j.innerHTML.indexOf(os.lang.pm_error_a);
                    if (/mp/.test(m)) {
                        if (w > 0) {
                            os.notice(os.lang.pm_error_a, os.lang.color_c, 'true');
                            os.refresh(os.b_r, os.b_r_v);
                        } else if (s > 0) {
                            os.notice(os.lang.pm_error_b, os.lang.color_c, 'true');
                            os.refresh(os.b_r, os.b_r_v);
                        } else if (u > 0) {
                            os.notice(os.lang.pm_error_c, os.lang.color_a, 'true');
                            os.refresh(os.b_r, os.b_r_v);
                        } else if (v > 0) {
                            os.sceditor.val('');
                            os.refresh(os.b_r, os.b_r_v);
                            setTimeout(function () {
                                document.location.href = '/privmsg?folder=inbox'
                            }, 2e3)
                        }
                    } else if (/(reply|edit)/.test(m)) {
                        os.viewtopic(h);
                        c = os.view_url;
                        os.b_r.style = 'color:#fff;background:' + os.lang.color_d;
                        if (b > 0) {
                            os.notice(os.lang.flood, os.lang.color_b, 'true');
                            os.refresh(os.b_r, os.b_r_v);
                        } else if (l > 0) {
                            os.notice(os.lang.newpost, os.lang.color_b, 'true');
                            os.refresh(os.b_r, os.b_r_v);
                        } else if (0 > a) {
                            os.notice(os.lang.error_reply, '', 'true');
                            os.refresh(os.b_r, os.b_r_v);
                        } else {
                            if (os.isTheme) {
                                'undefined' != typeof c && os.get(c, m);
                                m == 'edit' && os.edit_subject.remove();
                                os.notice(os.lang.wait_notice, os.lang.color_c, 'true');
                                os.refresh(os.b_r, os.b_r_v);
                            } else {
                                os.sceditor.val('');
                                setTimeout(function () {
                                    document.location.href = c
                                }, 2e3);
                                os.refresh(os.b_r, os.b_r_v);
                            }
                        };
                    } else if (/preview/.test(m)) {
                        os.create_preview();
                        p = document.getElementById('preview_content');
                        p.appendChild(o);
                        os.fadeIn(o, 500);
                        os.b_p.value = os.b_p_v;
                        os.b_p.style = ''
                    } else if (/delete/.test(m)) {
                        d = document.getElementsByClassName('post--' + os.post_number(os.url_post));
                        r = document.getElementById('confirm_wrap');
                        q = document.getElementById('overlay');
                        d.length && (os.phpbb2 ? (d[0].nextElementSibling.remove(), d[0].remove()) : d[0].remove());
                        r && r.remove();
                        q && q.remove(); //componer para phpbb2
                    }
                })
            } else {
                os.notice(os.lang.no_subject, os.lang.color_d, 'true');
                os.refresh(os.b_r, os.b_r_v);
                os.b_r.style = '';
            }
        } else {
            os.notice(os.lang.words_reply, os.lang.color_d, 'true');
            m == 'reply' ? os.refresh(os.b_r, os.b_r_v) : os.refresh(os.b_p, os.b_p_v);
        }
    },
    refresh: function (c, d) {
        c.value = d;
        c.style = '';
    },
    overlay: function () {
        var a = document.createElement('div');
        a.style = 'display:block;position:fixed;top:0;left:0;min-height:101%;width:100%;background-color:rgba(0, 0, 0, .4);z-index:999;color:#fff;';
        a.id = 'overlay';
        document.body.appendChild(a);
    },
    create_preview: function () {
        var m = document.createElement('div');
        m.style = 'background:#fff;left:15%;position:fixed;top:10%;width:70%;height:65%;overflow:auto;z-index:999;box-shadow:10px 10px 40px black;border-radius:3px;font-size:1.2em;padding:10px;font-family:Arial;text-shadow:0 1px 1px white;color:#666;';
        m.id = 'preview_content';
        m.innerHTML = os.previewHTML;
        os.overlay();
        document.body.appendChild(m);
    },
    set_delete: function (f) {
        var d, b, c;
        b = document.createElement('div');
        c = document.createElement('style');
        b.innerHTML = '<div id="confirm_content">' + os.lang.main_delete + os.post_number(f.href) + '?' + '</div><div id="confirm"><a id="yes" class="yes" href="' + f.href + '" onclick="os.post(this,\'delete\');return false">' + os.lang.delete_yes + '</a><a id="cancel" onclick="os.close(\'delete\')">' + os.lang.delete_cancel + '</a></div>';
        b.id = 'confirm_wrap';
        b.style = 'display: inline-block; vertical-align: top; width: auto; text-align: center; z-index: 9999; padding: 7px 13px; position: fixed; top: 35%; left: 30%';
        os.overlay();
        document.body.appendChild(b);
        c.innerHTML = os.delete_style;
        c.type = 'text/css';
        c.id = 'd_style';
        !document.getElementById('d_style') && document.head.appendChild(c);
        d = document.getElementById('yes');
    },
    set_post: function (h) {
        var e = os.punbb ? document.getElementsByClassName('topic')[0] : os.phpbb2 ? document.getElementsByClassName('catBottom')[0].parentNode.previousElementSibling : os.phpbb3 ? document.getElementsByName('bottomtitle')[0].previousElementSibling : os.invision && document.getElementsByClassName('topic-footer')[0].previousElementSibling;
        os.punbb ? e.appendChild(h) : e.parentNode.insertBefore(h, e.nextSibling);
        os.fadeIn(h, 500);
        os.scroll(15, h)
    },
    XML: function (a, b, f) {
        var c;
        c = window.XMLHttpRequest ? new XMLHttpRequest : window.ActiveXObject && (new ActiveXObject('Microsoft.XMLHTTP'));
        'undefined' != typeof a ? c.open('POST', b) : c.open('GET', b, true);
        c.responseType = 'document';
        c.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
        'undefined' != typeof a ? c.send(a) : c.send();
        c.onreadystatechange = function () {
            this.readyState == 4 && this.status == 200 && (f(this));
        };
    },
    serialize: function (b) {
        var a, i, j, l, s = [];
        if ('object' == typeof b && 'FORM' == b.nodeName) {
            l = b.elements.length;
            for (i = 0; l > i; i++)
                if (a = b.elements[i], a.name && !a.disabled && 'file' != a.type && 'reset' != a.type && 'submit' != a.type && 'button' != a.type)
                    if ('select-multiple' == a.type)
                        for (j = b.elements[i].options.length - 1; j >= 0; j--) a.options[j].selected && (s[s.length] = encodeURIComponent(a.name) + '=' + encodeURIComponent(a.options[j].value));
                    else('checkbox' != a.type && 'radio' != a.type || a.checked) && (s[s.length] = encodeURIComponent(a.name) + '=' + encodeURIComponent(a.value))
        }
        return s.join('&').replace(/%20/g, '+');
    },
    fadeIn: function (a, b) {
        var e, d;
        if (!a) return;
        a.style.opacity = 0, a.style.filter = 'alpha(opacity=0)', a.style.display = '', a.style.visibility = 'visible',
            b ? (e = 0, d = setInterval(function () {
                e += 50 / b, e >= 1 && (clearInterval(d), e = 1), a.style.opacity = e, a.style.filter = 'alpha(opacity=' + e * 100 + ')'
            }, 50)) : (a.style.opacity = 1, a.style.filter = 'alpha(opacity=1)')
    },
    close: function (c) {
        var a = document.getElementById(c == 'delete' ? 'confirm_wrap' : 'preview_content'),
            b = document.getElementById('overlay');
        a.remove();
        b.remove();
    },
    offset: function (a) {
        if (!a) a = this;
        var x = a.offsetLeft,
            y = a.offsetTop;
        while (a = a.offsetParent) {
            x += a.offsetLeft;
            y += a.offsetTop;
        }
        return {
            left: x,
            top: y
        };
    },
    beforeunload: function () {
        var a = os.sceditor;
        a && (window.onbeforeunload = function () {
            if (a.val().length) {
                return 'ok'
            }
        });
    },
    scroll: function (c, d) {
        var a, b, e = 0 == d.offsetTop ? os.offset(d).top - 300 : d.offsetTop - 300,
            f = 0 == document.body.scrollTop ? document.documentElement : document.body;
        f.scrollTop < e && (a = setInterval(function () {
            f.scrollTop < e ? f.scrollTop += 50 : clearInterval(a)
        }, c)), f.scrollTop > e && (b = setInterval(function () {
            f.scrollTop > e ? f.scrollTop += -50 : clearInterval(b)
        }, c));
    },
    viewtopic: function (h) {
        var i, g = h.getElementsByTagName('a');
        for (i = 0; i < g.length; i++) {
            /\/viewtopic/g.test(g[i].href) && (os.view_url = g[i].href)
        }
    },
    post_number: function (c) {
        return c.match(/viewtopic/) ? c.match(/(\w+)$/g)[0] : c.match(/[\p\=](\w+)(?=\&)/)[1]
    },
};
$(function () {
    $(function () {
        (document.getElementById('logout') && /\/t\d+/g.test(window.location.pathname) || /\/post/.test(window.location.pathname) || /\/privmsg\?mode=(post|reply|edit)/.test(window.location.href)) && os.init()
    });
});
Back to top
Permissions in this forum:
You cannot reply to topics in this forum