2014-07-18, 03:27 PM
(This post was last modified: 2014-12-24, 08:42 PM by martec.
Edit Reason: rewrite totally
)
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:
1.2 - Add above:
2 - Put this image (rest.png) in root/images folder
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