MyBB Community Forums

Full Version: [1.8] AutoSave Draft
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3 4
Ps. Not work with quick reply (only will work with quick reply if you use sceditor in quick reply http://community.mybb.com/thread-158367.html or http://community.mybb.com/thread-160306.html)

1 - In codebuttons template

1.1 - Find:

</script>

1.2 - Add above:

function qae_as() {
    if (MyBBEditor) {
        sc_asd = JSON.parse(localStorage.getItem('sc_as'));
        link_can = location.href;
        if (!sc_asd) {
            sc_asd = {};
        }
        if (MyBBEditor.val() != sc_asd[link_can]) {
            if ($.trim(MyBBEditor.val())) {
                if(!$('#autosave').length) {
                    $('<div/>', { id: 'autosave', class: 'bottom-right' }).appendTo('body');
                }
                setTimeout(function() {
                    $('#autosave').jGrowl('Auto Save: Message Saved.', { life: 500 });
                },200);
                sc_asd[link_can] = MyBBEditor.val();
                localStorage.setItem('sc_as', JSON.stringify(sc_asd));
            }
            else {
                if (sc_asd[link_can]) {
                    delete sc_asd[link_can];
                    localStorage.setItem('sc_as', JSON.stringify(sc_asd));
                }
            }
        }
    }
}

function qae_ac() {
    sc_asd = JSON.parse(localStorage.getItem('sc_as'));
    link_can = location.href;
    if (!sc_asd) {
        sc_asd = {};
    }    
    if (sc_asd[link_can]) {
        delete sc_asd[link_can];
        localStorage.setItem('sc_as', JSON.stringify(sc_asd));
    }
}

function qae_ar() {
    sc_asd = JSON.parse(localStorage.getItem('sc_as'));
    if (!sc_asd) {
        sc_asd = {};
    }
    if(Object.keys(sc_asd).length > 20) {
        delete sc_asd[Object.keys(sc_asd)[0]];
        localStorage.setItem('sc_as', JSON.stringify(sc_asd));
    }
}

($.fn.on || $.fn.live).call($(document), 'click', 'input[name*="submit"]', function () {
    qae_ac();
});

$(document).ready(function(){
    setInterval(function() {
        qae_as();
        qae_ar();      
    },15000);

    setTimeout(function() {
        sc_asd = JSON.parse(localStorage.getItem('sc_as'));
        link_can = location.href;
        restitem = "";
        if (sc_asd) {
            restitem = sc_asd[link_can];
        }
        if (restitem) {
            var restorebut = [
                '<a class="sceditor-button" title="Restore" onclick="MyBBEditor.insert(restitem);">',
                    '<div style="background-image: url(images/rest.png); opacity: 1; cursor: pointer;">Restore</div>',
                '</a>'
            ];
            $(restorebut.join('')).appendTo('.sceditor-group:last');    
        }
    },600);
    MyBBEditor.blur(function(e) {
        if ($.trim(MyBBEditor.val())) {
            qae_as();
        }
        else {
            qae_ac();
        }
    });
});


2 - Put this image [attachment=32702] (rest.png) in root/images folder
Works really well. If you close your tab on accident or something during thread creation then your post will still be there the next time you click "Post Thread" in that specific forum.

The codebuttons template is in Default Templates > Ungrouped Templates btw.
(2014-07-25, 09:26 PM)fxzt Wrote: [ -> ]Works really well. If you close your tab on accident or something during thread creation then your post will still be there the next time you click "Post Thread" in that specific forum.

The codebuttons template is in Default Templates > Ungrouped Templates btw.

thanks for the feedback
I noticed that if you highlight backwards it will glitch.
(2014-07-26, 09:05 AM)fxzt Wrote: [ -> ]I noticed that if you highlight backwards it will glitch.

my english is very bad...
you could explain better for me about highlight backwards ?
That works fine for newreply with your plugin quickadveditor-3.3.2 but not with the quickreply. Any chance for an update?

It's really usefull for me, as I have to use the alt-num key combination and if my numlock is off when doing alt-148 the editor will close. I always forget to check that, so it's a real mind saver.
is compatible with sceditor plugin + mybb1.6?
(2014-08-26, 04:27 PM)TBO29 Wrote: [ -> ]That works fine for newreply with your plugin quickadveditor-3.3.2 but not with the quickreply. Any chance for an update?

It's really usefull for me, as I have to use the alt-num key combination and if my numlock is off when doing alt-148 the editor will close. I always forget to check that, so it's a real mind saver.

i updated initial post with support v. 3.3.2 plugin...

(2014-08-26, 05:02 PM)irestorer Wrote: [ -> ]is compatible with sceditor plugin + mybb1.6?

unfortunately this tutorial does not support mybb 1.6.
Maybe I've problems with my sights, but I can't find the template "codebutquick". I can see it in your plugin, but it's not even in the Database. Where could be the problem? 

Sorry solved: uninstalled and re-installed, now it's there. Fantastic. Thanks. The only difference is that it ends with

};
</script> and not with

}};
</script>
@martec  Is "onRelase: function() {" correct or should it be "onRelease: function() {" ?
Pages: 1 2 3 4