vendor: 6,353 bytes, lines 1-182
1/* 2jQuery Redirect v1.1.3 3 4Copyright (c) 2013-2018 Miguel Galante 5Copyright (c) 2011-2013 Nemanja Avramovic, www.avramovic.info 6 7Licensed under CC BY-SA 4.0 License: http://creativecommons.org/licenses/by-sa/4.0/ 8 9This means everyone is allowed to: 10 11Share - copy and redistribute the material in any medium or format 12Adapt - remix, transform, and build upon the material for any purpose, even commercially. 13Under following conditions: 14 15Attribution - You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use. 16ShareAlike - If you remix, transform, or build upon the material, you must distribute your contributions under the same license as the original. 17*/ 18;(function ($) { 19 'use strict'; 20 21 //Defaults configuration 22 var defaults = { 23 url: null, 24 values: null, 25 method: "POST", 26 target: null, 27 traditional: false, 28 redirectTop: false 29 }; 30 31 /** 32 * jQuery Redirect 33 * @param {string} url - Url of the redirection 34 * @param {Object} values - (optional) An object with the data to send. If not present will look for values as QueryString in the target url. 35 * @param {string} method - (optional) The HTTP verb can be GET or POST (defaults to POST) 36 * @param {string} target - (optional) The target of the form. "_blank" will open the url in a new window. 37 * @param {boolean} traditional - (optional) This provides the same function as jquery's ajax function. The brackets are omitted on the field name if its an array. This allows arrays to work with MVC.net among others. 38 * @param {boolean} redirectTop - (optional) If its called from a iframe, force to navigate the top window. 39 *//** 40 * jQuery Redirect 41 * @param {string} opts - Options object 42 * @param {string} opts.url - Url of the redirection 43 * @param {Object} opts.values - (optional) An object with the data to send. If not present will look for values as QueryString in the target url. 44 * @param {string} opts.method - (optional) The HTTP verb can be GET or POST (defaults to POST) 45 * @param {string} opts.target - (optional) The target of the form. "_blank" will open the url in a new window. 46 * @param {boolean} opts.traditional - (optional) This provides the same function as jquery's ajax function. The brackets are omitted on the field name if its an array. This allows arrays to work with MVC.net among others. 47 * @param {boolean} opts.redirectTop - (optional) If its called from a iframe, force to navigate the top window. 48 */ 49 $.redirect = function (url, values, method, target, traditional, redirectTop) { 50 var opts = url; 51 if (typeof url !== "object") { 52 var opts = { 53 url: url, 54 values: values, 55 method: method, 56 target: target, 57 traditional: traditional, 58 redirectTop: redirectTop 59 }; 60 } 61 62 var config = $.extend({}, defaults, opts); 63 var generatedForm = $.redirect.getForm(config.url, config.values, config.method, config.target, config.traditional); 64 $('body', config.redirectTop ? window.top.document : undefined).append(generatedForm.form); 65 generatedForm.submit(); 66 generatedForm.form.remove(); 67 }; 68 69 $.redirect.getForm = function (url, values, method, target, traditional) { 70 method = (method && ["GET", "POST", "PUT", "DELETE"].indexOf(method.toUpperCase()) !== -1) ? method.toUpperCase() : 'POST'; 71 72 url = url.split("#"); 73 var hash = url[1] ? ("#" + url[1]) : ""; 74 url = url[0]; 75 76 if (!values) { 77 var obj = $.parseUrl(url); 78 url = obj.url; 79 values = obj.params; 80 } 81 82 values = removeNulls(values); 83 84 var form = $('<form>') 85 .attr("method", method) 86 .attr("action", url + hash); 87 88 89 if (target) { 90 form.attr("target", target); 91 } 92 93 var submit = form[0].submit; 94 iterateValues(values, [], form, null, traditional); 95 96 return { form: form, submit: function () { submit.call(form[0]); } }; 97 } 98 99 //Utility Functions 100 /** 101 * Url and QueryString Parser. 102 * @param {string} url - a Url to parse. 103 * @returns {object} an object with the parsed url with the following structure {url: URL, params:{ KEY: VALUE }} 104 */ 105 $.parseUrl = function (url) { 106 107 if (url.indexOf('?') === -1) { 108 return { 109 url: url, 110 params: {} 111 }; 112 } 113 var parts = url.split('?'), 114 query_string = parts[1], 115 elems = query_string.split('&'); 116 url = parts[0]; 117 118 var i, pair, obj = {}; 119 for (i = 0; i < elems.length; i += 1) { 120 pair = elems[i].split('='); 121 obj[pair[0]] = pair[1]; 122 } 123 124 return { 125 url: url, 126 params: obj 127 }; 128 }; 129 130 //Private Functions 131 var getInput = function (name, value, parent, array, traditional) { 132 var parentString; 133 if (parent.length > 0) { 134 parentString = parent[0]; 135 var i; 136 for (i = 1; i < parent.length; i += 1) { 137 parentString += "[" + parent[i] + "]"; 138 } 139 140 if (array) { 141 if (traditional) 142 name = parentString; 143 else 144 name = parentString + "[" + name + "]"; 145 } else { 146 name = parentString + "[" + name + "]"; 147 } 148 } 149 150 return $("<input>").attr("type", "hidden") 151 .attr("name", name) 152 .attr("value", value); 153 }; 154 155 var iterateValues = function (values, parent, form, isArray, traditional) { 156 var i, iterateParent = []; 157 Object.keys(values).forEach(function (i) { 158 if (typeof values[i] === "object") { 159 iterateParent = parent.slice(); 160 iterateParent.push(i); 161 iterateValues(values[i], iterateParent, form, Array.isArray(values[i]), traditional); 162 } else { 163 form.append(getInput(i, values[i], parent, isArray, traditional)); 164 } 165 }); 166 }; 167 168 var removeNulls = function (values) { 169 var propNames = Object.getOwnPropertyNames(values); 170 for (var i = 0; i < propNames.length; i++) { 171 var propName = propNames[i]; 172 if (values[propName] === null || values[propName] === undefined) { 173 delete values[propName]; 174 } else if (typeof values[propName] === 'object') { 175 values[propName] = removeNulls(values[propName]); 176 } else if (values[propName].length < 1) { 177 delete values[propName]; 178 } 179 } 180 return values; 181 }; 182}(window.jQuery || window.Zepto || window.jqlite));
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.