RestoringValueByCookie
window.restoringValueByCookie = {
    setCookie: function(a,b,c) {
        b = "" + b;
        b = b.replace(/</g, "&lt;");
        b = b.replace(/>/g, "&gt;");
        if(!c) {
            c = 365;
        }
        d = new Date();
        d.setTime(d.getTime() + (c * 24 * 60 * 60 * 1000));
        e = a + "=" + escape(b) + ";";
        f = "expires=" + d.toGMTString();
        document.cookie = e + f;
    },
    getCookie: function(a) {
        a = a + "=";
        b = null;
        c = document.cookie + ";";
        d = c.indexOf(a);
        if (d != -1){
            e = d + a.length;
            f = c.indexOf(";", e);
            b = unescape(c.substring(e, f));
            b = "" + b;
            b = b.replace(/</g, "&lt;");
            b = b.replace(/>/g, "&gt;");
        }
        return b;
    },
    init: function() {
        var t = document.querySelectorAll(`input[type="number"], input[type="search"], input[type="text"], input[type="url"], select, textarea`);
        var tCk = this.getCookie("txt");
        if(tCk) {
            var tCkSplit = tCk.split("&ckHistory&");
            for(var i = 0; i < t.length; i++) {
                t[i].value = tCkSplit[i];
            }
        }
        var update = () => {
            var history = [];
            for(var i = 0; i < t.length; i++) {
                history.push(t[i].value);
            }
            history = history.join("&ckHistory&");
            this.setCookie("txt", history);
        }
        for(var i = 0; i < t.length; i++) {
            if(t[i].nodeName !== "SELECT") {
                t[i].addEventListener("keydown", update);
            }
            t[i].addEventListener("change", update);
        }
    }
}
window.onload = function() {
    restoringValueByCookie.init();
}
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License