| @@ 3911-4024 (lines=114) @@ | ||
| 3908 | ||
| 3909 | } |
|
| 3910 | })(this); |
|
| 3911 | },{}],11:[function(require,module,exports){ |
|
| 3912 | (function (global){ |
|
| 3913 | // Best place to find information on XHR features is: |
|
| 3914 | // https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest |
|
| 3915 | ||
| 3916 | var reqfields = [ |
|
| 3917 | 'responseType', 'withCredentials', 'timeout', 'onprogress' |
|
| 3918 | ] |
|
| 3919 | ||
| 3920 | // Simple and small ajax function |
|
| 3921 | // Takes a parameters object and a callback function |
|
| 3922 | // Parameters: |
|
| 3923 | // - url: string, required |
|
| 3924 | // - headers: object of `{header_name: header_value, ...}` |
|
| 3925 | // - body: |
|
| 3926 | // + string (sets content type to 'application/x-www-form-urlencoded' if not set in headers) |
|
| 3927 | // + FormData (doesn't set content type so that browser will set as appropriate) |
|
| 3928 | // - method: 'GET', 'POST', etc. Defaults to 'GET' or 'POST' based on body |
|
| 3929 | // - cors: If your using cross-origin, you will need this true for IE8-9 |
|
| 3930 | // |
|
| 3931 | // The following parameters are passed onto the xhr object. |
|
| 3932 | // IMPORTANT NOTE: The caller is responsible for compatibility checking. |
|
| 3933 | // - responseType: string, various compatability, see xhr docs for enum options |
|
| 3934 | // - withCredentials: boolean, IE10+, CORS only |
|
| 3935 | // - timeout: long, ms timeout, IE8+ |
|
| 3936 | // - onprogress: callback, IE10+ |
|
| 3937 | // |
|
| 3938 | // Callback function prototype: |
|
| 3939 | // - statusCode from request |
|
| 3940 | // - response |
|
| 3941 | // + if responseType set and supported by browser, this is an object of some type (see docs) |
|
| 3942 | // + otherwise if request completed, this is the string text of the response |
|
| 3943 | // + if request is aborted, this is "Abort" |
|
| 3944 | // + if request times out, this is "Timeout" |
|
| 3945 | // + if request errors before completing (probably a CORS issue), this is "Error" |
|
| 3946 | // - request object |
|
| 3947 | // |
|
| 3948 | // Returns the request object. So you can call .abort() or other methods |
|
| 3949 | // |
|
| 3950 | // DEPRECATIONS: |
|
| 3951 | // - Passing a string instead of the params object has been removed! |
|
| 3952 | // |
|
| 3953 | exports.ajax = function (params, callback) { |
|
| 3954 | // Any variable used more than once is var'd here because |
|
| 3955 | // minification will munge the variables whereas it can't munge |
|
| 3956 | // the object access. |
|
| 3957 | var headers = params.headers || {} |
|
| 3958 | , body = params.body |
|
| 3959 | , method = params.method || (body ? 'POST' : 'GET') |
|
| 3960 | , called = false |
|
| 3961 | ||
| 3962 | var req = getRequest(params.cors) |
|
| 3963 | ||
| 3964 | function cb(statusCode, responseText) { |
|
| 3965 | return function () { |
|
| 3966 | if (!called) { |
|
| 3967 | callback(req.status === undefined ? statusCode : req.status, |
|
| 3968 | req.status === 0 ? "Error" : (req.response || req.responseText || responseText), |
|
| 3969 | req) |
|
| 3970 | called = true |
|
| 3971 | } |
|
| 3972 | } |
|
| 3973 | } |
|
| 3974 | ||
| 3975 | req.open(method, params.url, true) |
|
| 3976 | ||
| 3977 | var success = req.onload = cb(200) |
|
| 3978 | req.onreadystatechange = function () { |
|
| 3979 | if (req.readyState === 4) success() |
|
| 3980 | } |
|
| 3981 | req.onerror = cb(null, 'Error') |
|
| 3982 | req.ontimeout = cb(null, 'Timeout') |
|
| 3983 | req.onabort = cb(null, 'Abort') |
|
| 3984 | ||
| 3985 | if (body) { |
|
| 3986 | setDefault(headers, 'X-Requested-With', 'XMLHttpRequest') |
|
| 3987 | ||
| 3988 | if (!global.FormData || !(body instanceof global.FormData)) { |
|
| 3989 | setDefault(headers, 'Content-Type', 'application/x-www-form-urlencoded') |
|
| 3990 | } |
|
| 3991 | } |
|
| 3992 | ||
| 3993 | for (var i = 0, len = reqfields.length, field; i < len; i++) { |
|
| 3994 | field = reqfields[i] |
|
| 3995 | if (params[field] !== undefined) |
|
| 3996 | req[field] = params[field] |
|
| 3997 | } |
|
| 3998 | ||
| 3999 | for (var field in headers) |
|
| 4000 | req.setRequestHeader(field, headers[field]) |
|
| 4001 | ||
| 4002 | req.send(body) |
|
| 4003 | ||
| 4004 | return req |
|
| 4005 | } |
|
| 4006 | ||
| 4007 | function getRequest(cors) { |
|
| 4008 | // XDomainRequest is only way to do CORS in IE 8 and 9 |
|
| 4009 | // But XDomainRequest isn't standards-compatible |
|
| 4010 | // Notably, it doesn't allow cookies to be sent or set by servers |
|
| 4011 | // IE 10+ is standards-compatible in its XMLHttpRequest |
|
| 4012 | // but IE 10 can still have an XDomainRequest object, so we don't want to use it |
|
| 4013 | if (cors && global.XDomainRequest && !/MSIE 1/.test(navigator.userAgent)) |
|
| 4014 | return new XDomainRequest |
|
| 4015 | if (global.XMLHttpRequest) |
|
| 4016 | return new XMLHttpRequest |
|
| 4017 | } |
|
| 4018 | ||
| 4019 | function setDefault(obj, key, value) { |
|
| 4020 | obj[key] = obj[key] || value |
|
| 4021 | } |
|
| 4022 | ||
| 4023 | }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) |
|
| 4024 | },{}],12:[function(require,module,exports){ |
|
| 4025 | 'use strict'; |
|
| 4026 | ||
| 4027 | var replace = String.prototype.replace; |
|
| @@ 1-114 (lines=114) @@ | ||
| 1 | (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){ |
|
| 2 | (function (global){ |
|
| 3 | // Best place to find information on XHR features is: |
|
| 4 | // https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest |
|
| 5 | ||
| 6 | var reqfields = [ |
|
| 7 | 'responseType', 'withCredentials', 'timeout', 'onprogress' |
|
| 8 | ] |
|
| 9 | ||
| 10 | // Simple and small ajax function |
|
| 11 | // Takes a parameters object and a callback function |
|
| 12 | // Parameters: |
|
| 13 | // - url: string, required |
|
| 14 | // - headers: object of `{header_name: header_value, ...}` |
|
| 15 | // - body: |
|
| 16 | // + string (sets content type to 'application/x-www-form-urlencoded' if not set in headers) |
|
| 17 | // + FormData (doesn't set content type so that browser will set as appropriate) |
|
| 18 | // - method: 'GET', 'POST', etc. Defaults to 'GET' or 'POST' based on body |
|
| 19 | // - cors: If your using cross-origin, you will need this true for IE8-9 |
|
| 20 | // |
|
| 21 | // The following parameters are passed onto the xhr object. |
|
| 22 | // IMPORTANT NOTE: The caller is responsible for compatibility checking. |
|
| 23 | // - responseType: string, various compatability, see xhr docs for enum options |
|
| 24 | // - withCredentials: boolean, IE10+, CORS only |
|
| 25 | // - timeout: long, ms timeout, IE8+ |
|
| 26 | // - onprogress: callback, IE10+ |
|
| 27 | // |
|
| 28 | // Callback function prototype: |
|
| 29 | // - statusCode from request |
|
| 30 | // - response |
|
| 31 | // + if responseType set and supported by browser, this is an object of some type (see docs) |
|
| 32 | // + otherwise if request completed, this is the string text of the response |
|
| 33 | // + if request is aborted, this is "Abort" |
|
| 34 | // + if request times out, this is "Timeout" |
|
| 35 | // + if request errors before completing (probably a CORS issue), this is "Error" |
|
| 36 | // - request object |
|
| 37 | // |
|
| 38 | // Returns the request object. So you can call .abort() or other methods |
|
| 39 | // |
|
| 40 | // DEPRECATIONS: |
|
| 41 | // - Passing a string instead of the params object has been removed! |
|
| 42 | // |
|
| 43 | exports.ajax = function (params, callback) { |
|
| 44 | // Any variable used more than once is var'd here because |
|
| 45 | // minification will munge the variables whereas it can't munge |
|
| 46 | // the object access. |
|
| 47 | var headers = params.headers || {} |
|
| 48 | , body = params.body |
|
| 49 | , method = params.method || (body ? 'POST' : 'GET') |
|
| 50 | , called = false |
|
| 51 | ||
| 52 | var req = getRequest(params.cors) |
|
| 53 | ||
| 54 | function cb(statusCode, responseText) { |
|
| 55 | return function () { |
|
| 56 | if (!called) { |
|
| 57 | callback(req.status === undefined ? statusCode : req.status, |
|
| 58 | req.status === 0 ? "Error" : (req.response || req.responseText || responseText), |
|
| 59 | req) |
|
| 60 | called = true |
|
| 61 | } |
|
| 62 | } |
|
| 63 | } |
|
| 64 | ||
| 65 | req.open(method, params.url, true) |
|
| 66 | ||
| 67 | var success = req.onload = cb(200) |
|
| 68 | req.onreadystatechange = function () { |
|
| 69 | if (req.readyState === 4) success() |
|
| 70 | } |
|
| 71 | req.onerror = cb(null, 'Error') |
|
| 72 | req.ontimeout = cb(null, 'Timeout') |
|
| 73 | req.onabort = cb(null, 'Abort') |
|
| 74 | ||
| 75 | if (body) { |
|
| 76 | setDefault(headers, 'X-Requested-With', 'XMLHttpRequest') |
|
| 77 | ||
| 78 | if (!global.FormData || !(body instanceof global.FormData)) { |
|
| 79 | setDefault(headers, 'Content-Type', 'application/x-www-form-urlencoded') |
|
| 80 | } |
|
| 81 | } |
|
| 82 | ||
| 83 | for (var i = 0, len = reqfields.length, field; i < len; i++) { |
|
| 84 | field = reqfields[i] |
|
| 85 | if (params[field] !== undefined) |
|
| 86 | req[field] = params[field] |
|
| 87 | } |
|
| 88 | ||
| 89 | for (var field in headers) |
|
| 90 | req.setRequestHeader(field, headers[field]) |
|
| 91 | ||
| 92 | req.send(body) |
|
| 93 | ||
| 94 | return req |
|
| 95 | } |
|
| 96 | ||
| 97 | function getRequest(cors) { |
|
| 98 | // XDomainRequest is only way to do CORS in IE 8 and 9 |
|
| 99 | // But XDomainRequest isn't standards-compatible |
|
| 100 | // Notably, it doesn't allow cookies to be sent or set by servers |
|
| 101 | // IE 10+ is standards-compatible in its XMLHttpRequest |
|
| 102 | // but IE 10 can still have an XDomainRequest object, so we don't want to use it |
|
| 103 | if (cors && global.XDomainRequest && !/MSIE 1/.test(navigator.userAgent)) |
|
| 104 | return new XDomainRequest |
|
| 105 | if (global.XMLHttpRequest) |
|
| 106 | return new XMLHttpRequest |
|
| 107 | } |
|
| 108 | ||
| 109 | function setDefault(obj, key, value) { |
|
| 110 | obj[key] = obj[key] || value |
|
| 111 | } |
|
| 112 | ||
| 113 | }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) |
|
| 114 | },{}],2:[function(require,module,exports){ |
|
| 115 | 'use strict'; |
|
| 116 | ||
| 117 | var replace = String.prototype.replace; |
|