-
Notifications
You must be signed in to change notification settings - Fork 9
/
RForm2Json.min.js
1 lines (1 loc) · 2.84 KB
/
RForm2Json.min.js
1
"use strict";function _objectSpread(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{},n=Object.keys(r);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(r).filter(function(e){return Object.getOwnPropertyDescriptor(r,e).enumerable}))),n.forEach(function(t){_defineProperty(e,t,r[t])})}return e}function _defineProperty(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function _instanceof(e,t){return null!=t&&"undefined"!=typeof Symbol&&t[Symbol.hasInstance]?t[Symbol.hasInstance](e):e instanceof t}!function(e,t){var r=[],n=[];function l(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;if(null!=e){this.selector=e;var l={keySelectorType:"attribute",keySelector:"name",valueSelectorType:"value",valueSelector:"value",keys:[],exclude:[]},o=function(){try{var l=t.querySelector(e);return!!l&&(r.push(e),n.push(l),n[n.length-1])}catch(e){console.error(e)}},u=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(null!=e)switch(t.keySelectorType){case"name":return e.getAttribute("name");case"attribute":return e.getAttribute(t.keySelector);default:return!1}},c=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(null!=e)switch(t.valueSelectorType){case"value":return"checkbox"==e.type||"radio"==e.type?e.checked?e.value:"":"select-multiple"===e.type?function(e){for(var t,r=[],n=e&&e.options,l=0,o=n.length;l<o;l++)(t=n[l]).selected&&r.push(t.value||t.text);return r}(e):e.value;case"attribute":return e.getAttribute(t.valueSelector);default:return!1}},i=this.selectedElemRef=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";try{if(null!=e){if(r.length>0){var l=r.indexOf(e);if(l>=0)return n[l];var u=t.querySelector(e);return(l=n.findIndex(function(e){return e===u}))>=0?n[l]:o()}return o()}return!1}catch(e){console.error(e)}}(e);this.getJSON=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{var t=function(e,t){(t||""==t)&&(!r.hasOwnProperty(e)||r.hasOwnProperty(e)&&""===r[e]&&""!==t)&&(r[e]=t)};e=_objectSpread({},l,e);var r={};if(i){for(var n=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;try{var t=[];return null!==e&&_instanceof(e,HTMLElement)&&(t=e.querySelectorAll("input,select,textarea")),t}catch(e){console.error(e)}}(i),o=0;o<n.length;o++){var a=n[o],f=u(a,e);if(f){var s=c(a,e);e.keys.length>0?e.keys.indexOf(f)>=0&&(e.exclude.length>0?e.exclude.indexOf(f)<0&&t(f,s):t(f,s)):e.exclude.length>0?e.exclude.indexOf(f)<0&&t(f,s):t(f,s)}}return r}}catch(e){console.error(e)}}}}window.RForm2Json=window.F2J=function(e){try{return new l(e)}catch(e){console.error(e)}}}(window,document);