-
Notifications
You must be signed in to change notification settings - Fork 3
/
inputStore.jquery.min.js
1 lines (1 loc) · 1005 Bytes
/
inputStore.jquery.min.js
1
!function(e){function n(e,n,t){var o=new Date;o.setTime(o.getTime()+24*t*60*60*1e3);var i=o.toUTCString();document.cookie=e+"="+n+"; expires="+i+"; path=/"}function t(t,o,i){"checkbox"===o?(n(t.name,e(i).prop("checked"),t.expire),t.debug&&console.log("Previous Input for ["+t.name+"] = ["+e(i).prop("checked")+"]")):(n(t.name,i.value,t.expire),t.debug&&console.log("Previous Input for ["+t.name+"] = ["+i.value+"]"))}e.fn.inputStore=function(n){var o=e.extend({name:this.attr("name"),expire:365,debug:!1},n),i=function(e){for(var n=e+"=",t=decodeURIComponent(document.cookie).split(";"),o=0;o<t.length;o++){for(var i=t[o];" "==i.charAt(0);)i=i.substring(1);if(0==i.indexOf(n))return i.substring(n.length,i.length)}return""}(o.name),r=this.attr("type")||this[0].nodeName;return r&&"checkbox"==r&&"true"==i?this.prop("checked",i):this.val(i),o.debug&&console.log("Previous Input for ["+o.name+"] = ["+i+"]"),this.on("keyup",function(){t(o,r,this)}),this.on("change",function(){t(o,r,this)}),this}}(jQuery);