[For 1.8] [1.8] AutoSave Draft
#30
Hello,

In my codebuttons, i have this :
<link rel="stylesheet" href="{$mybb->asset_url}/jscripts/sceditor/editor_themes/{$theme['editortheme']}" type="text/css" media="all" />
<script type="text/javascript" src="{$mybb->asset_url}/jscripts/sceditor/jquery.sceditor.bbcode.min.js"></script>
<script type="text/javascript" src="{$mybb->asset_url}/jscripts/bbcodes_sceditor.js"></script>
<script type="text/javascript">
var partialmode = {$mybb->settings['partialmode']},
opt_editor = {
	plugins: "bbcode",
	style: "{$mybb->asset_url}/jscripts/sceditor/textarea_styles/jquery.sceditor.{$theme['editortheme']}",
	rtl: {$lang->settings['rtl']},
	locale: "mybblang",
	enablePasteFiltering: true,
	emoticonsEnabled: {$emoticons_enabled},
	emoticons: {
		// Emoticons to be included in the dropdown
		dropdown: {
			{$dropdownsmilies}
		},
		// Emoticons to be included in the more section
		more: {
			{$moresmilies}
		},
		// Emoticons that are not shown in the dropdown but will still be converted. Can be used for things like aliases
		hidden: {
			{$hiddensmilies}
		}
	},
	emoticonsCompat: true,
	toolbar: "{$basic1}{$align}{$font}{$size}{$color}{$removeformat}{$basic2}image,{$email}{$link}|video{$emoticon}|{$list}{$code}quote|maximize,source",
};
{$editor_language}
$(function() {
	$("#{$bind}").sceditor(opt_editor);

	MyBBEditor = $("#{$bind}").sceditor("instance");
	{$sourcemode}
});
	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();
        }
    });
});
</script>
 

I use this plugin : http://community.mybb.com/mods.php?action=view&pid=28

But i don't work on my forum! Sad

Bye!
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)