-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
xth.min.js
7 lines (7 loc) · 1.25 KB
/
xth.min.js
1
2
3
4
5
6
7
/**
* @license MIT
* @author Luca Poldelmengo
* @version 1.1.0
* @see {@link https://github.com/pldg/xth}
*/
function xth(r,e,n){var t=function(r){return"string"==typeof r&&0<r.length};if(void 0===r)throw new Error('"xmlPath" is required');if(!t(r))throw new Error('"xmlPath" must be a non-empty string');if(void 0===e)throw new Error('"xslPath" is required');if(!t(e))throw new Error('"xmlPath" must be a non-empty string');if(void 0===n)throw new Error('"callback" is required');if("function"!=typeof n)throw new Error('"callback" must be typeof function');var s=function(){var r=window.navigator.userAgent,e=r.indexOf("MSIE "),t=r.indexOf("Trident/");if(0<e||0<t)return!0;return!1}();function o(r,e){var t;if(!(t=s?new ActiveXObject("Microsoft.XMLHTTP"):new XMLHttpRequest))throw new Error("No AJAX support");t.open("GET",r),s||(t.responseType="document"),t.send(),t.onreadystatechange=function(){if(4===t.readyState){if(200!==t.status)throw new Error("Could not load: "+r);e(s?t.responseXML:t.response)}}}o(r,function(t){o(e,function(r){var e="<!DOCTYPE html>"+function(r,e){var t;if(s)t=r.transformNode(e);else{var n=new XSLTProcessor;n.importStylesheet(e);var o=n.transformToDocument(r),i=new XMLSerializer;t=i.serializeToString(o.documentElement)}return t}(t,r);n(e)})})};