Thread Rating:
  • 2 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[For 1.8] [1.8] AutoSave Draft
#1
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     (rest.png) in root/images folder
Reply
#2
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.
Reply
#3
(07-25-2014, 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
Reply
#4
I noticed that if you highlight backwards it will glitch.
Reply
#5
(07-26-2014, 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 ?
Reply
#6
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.
Reply
#7
is compatible with sceditor plugin + mybb1.6?
Reply
#8
(08-26-2014, 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...

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

unfortunately this tutorial does not support mybb 1.6.
Reply
#9
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>
Reply
#10
@martec  Is "onRelase: function() {" correct or should it be "onRelease: function() {" ?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)