[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


Messages In This Thread
[1.8] AutoSave Draft - by martec - 2014-07-18, 03:27 PM
RE: [1.8] AutoSave Draft (sisyphus) - by fxzt - 2014-07-25, 09:26 PM
RE: [1.8] AutoSave Draft (sisyphus) - by martec - 2014-07-26, 05:59 AM
RE: [1.8] AutoSave Draft (sisyphus) - by fxzt - 2014-07-26, 09:05 AM
RE: [1.8] AutoSave Draft (sisyphus) - by martec - 2014-07-26, 12:52 PM
RE: [1.8] AutoSave Draft (sisyphus) - by TBO29 - 2014-08-26, 04:27 PM
RE: [1.8] AutoSave Draft (sisyphus) - by martec - 2014-08-27, 02:10 PM
RE: [1.8] AutoSave Draft (sisyphus) - by TBO29 - 2014-08-27, 06:09 PM
RE: [1.8] AutoSave Draft (sisyphus) - by doylecc - 2014-08-27, 06:50 PM
RE: [1.8] AutoSave Draft (sisyphus) - by TBO29 - 2014-08-27, 07:42 PM
RE: [1.8] AutoSave Draft (sisyphus) - by martec - 2014-08-27, 10:10 PM
RE: [1.8] AutoSave Draft (sisyphus) - by TBO29 - 2014-08-28, 07:48 PM
RE: [1.8] AutoSave Draft (sisyphus) - by martec - 2014-08-30, 01:35 PM
RE: [1.8] AutoSave Draft (sisyphus) - by TBO29 - 2014-08-31, 07:13 PM
RE: [1.8] AutoSave Draft (sisyphus) - by martec - 2014-08-31, 11:47 PM
RE: [1.8] AutoSave Draft (sisyphus) - by TBO29 - 2014-09-01, 09:34 PM
RE: [1.8] AutoSave Draft - by martec - 2014-09-28, 04:40 AM
RE: [1.8] AutoSave Draft - by martec - 2014-10-05, 11:05 PM
RE: [1.8] AutoSave Draft - by garra8 - 2014-10-14, 02:16 PM
RE: [1.8] AutoSave Draft - by TBO29 - 2014-10-14, 08:48 PM
RE: [1.8] AutoSave Draft - by martec - 2014-10-15, 01:50 AM
RE: [1.8] AutoSave Draft - by TBO29 - 2014-10-17, 12:47 AM
RE: [1.8] AutoSave Draft - by martec - 2014-10-19, 06:02 PM
RE: [1.8] AutoSave Draft - by Eldenroot - 2014-12-24, 08:14 PM
RE: [1.8] AutoSave Draft - by martec - 2014-12-24, 08:45 PM
RE: [1.8] AutoSave Draft - by expat - 2015-02-22, 02:45 AM
RE: [1.8] AutoSave Draft - by expat - 2015-02-23, 03:27 PM
RE: [1.8] AutoSave Draft - by AndyAndreiH - 2015-03-04, 09:44 AM
RE: [1.8] AutoSave Draft - by Azik - 2015-03-15, 01:18 PM
RE: [1.8] AutoSave Draft - by Sgt Cheesepuffs - 2015-03-21, 02:11 AM
RE: [1.8] AutoSave Draft - by Parsian™ - 2015-08-27, 05:50 PM
RE: [1.8] AutoSave Draft - by IdolwSzutrab7 - 2015-09-20, 01:29 PM
RE: [1.8] AutoSave Draft - by Ronshaan - 2016-08-31, 08:09 PM
RE: [1.8] AutoSave Draft - by Arasnia - 2021-10-13, 08:18 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)