'Saving work in progress' javascript causing posting problems

Go down

'Saving work in progress' javascript causing posting problems

Post by jkh on January 9th 2018, 9:50 pm

Hello

I hope I'm posting this in the correct place.

I recently added a 'saving work in progress' javascript to my forum, but it seemed to be creating posting problems for some of my members. As soon as I deactivated it their posting problems disappeared.

This is the code and I wonder if it might be outdated and, if so, whether anyone has got a more recent version or a solution?

I found this javascript very useful so would be grateful for a solution. Many thanks, and Happy New Year to everyone!

Code:
window.localStorage&&$(function(){
        $(function(){
        if($("#text_editor_textarea").length&&typeof $.sceditor!="undefined"){
        var a=$(document.post.mode).val(),
        d=$("#text_editor_textarea").sceditor("instance"),
        e,f,g=function(){
        localStorage.setItem(a,d.val());
        f=0},
        b=JSON.parse(localStorage.getItem("br-data"))||[],c;
        switch(a){
        case"editpost":return;
        case"reply":a+=$(document.post.t).val();
        break;
        case"newtopic":a+=$(document.post.f).val()
        }
        a=parseInt((my_getcookie("fa_"+location.hostname.replace(/\./g,"_")+"_data")||"0").replace(/.*s:6:"userid";(i:([0-9]+)|s:[0-9]+:"([0-9]+)");.*/,"$2$3"))+a;
        -1!=(c=$.inArray(a,b))&&b.splice(c,1);
        if(20<b.length){
        for(c=b.length-1;0<=c;c--)/^\s*$/.test(localStorage.getItem(b[c])||"")&&(localStorage.removeItem(b[c]),
        b.splice(c,1));
        20<b.length&&(localStorage.removeItem(b[0]),
        b.splice(0,1))}b.push(a);
        localStorage.setItem("br-data",JSON.stringify(b));
        $(document.post).submit(function(){
        localStorage.setItem("br-target",a)
        });
        !d.val()&&((e=localStorage.getItem(a))&&d.val(e));
        d.keyUp(function(){
        f||(f=setTimeout(g,3E3))
        })}})});
        window.localStorage&&(localStorage.getItem("br-target")&&function(){
        $("meta[http-equiv='refresh'][content]:first").length&&function(){
        var a=JSON.parse(localStorage.getItem("br-data")),
        b=localStorage.getItem("br-target"),c;
        if(-1!=(c=$.inArray(b,a)))a.splice(c,1),
        localStorage.setItem("br-data",JSON.stringify(a));
        localStorage.removeItem(b)}();
        localStorage.removeItem("br-target")}());
avatar
jkh
Forumember

Posts : 385
Reputation : 13
Language : english

http://jillhavern.forumotion.net/

Back to top Go down

Re: 'Saving work in progress' javascript causing posting problems

Post by skouliki on January 10th 2018, 8:48 am

avatar
skouliki
Graphic Designer
Graphic Designer

Female Posts : 4124
Reputation : 675
Language : English,Greek
Location : Greece

http://iconskouliki.forumgreek.com

Back to top Go down

Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum