/
populateform.min.js
1 lines (1 loc) · 1.14 KB
/
populateform.min.js
1
!function(e,t){"undefined"!=typeof module?module.exports=t():"function"==typeof define&&"object"==typeof define.amd?define(t):this[e]=t()}("populateform",function(){function e(){var e;return Event?e=new Event("change",{bubbles:!0,cancelable:!0}):document.createEvent?(e=document.createEvent("HTMLEvents"),e.initEvent("change",!0,!0)):document.createEventObject&&(e=document.createEventObject(),e.eventType="change"),e}function t(e,t){e.dispatchEvent?e.dispatchEvent(t):document.createEventObject&&element.fireEvent("on"+t.eventType,t)}function n(e){if("string"==typeof e)return c(e);if("object"==typeof e)return e;throw"wrong format"}function c(e){"use strict";var t,n={},c=/[?&]?([^=]+)=([^&]*)/g;for(e=e.split("+").join(" ");t=c.exec(e);)n[decodeURIComponent(t[1])]=decodeURIComponent(t[2]);return n}function o(n,c,o){var r=n.querySelectorAll("[name="+c+"]");if(!(r.length<0)){var i=r[0],u=i.getAttribute("type");"radio"===u?(i=Array.prototype.filter.call(r,function(e){return e.value==o}).shift(),i.checked=!0):"checkbox"===u?i.checked=!!o:i.value=o,t(i,e())}}return function(e,t){try{t=n(t);for(var c in t)t.hasOwnProperty(c)&&o(e,c,t[c])}catch(e){}return e}});