1$.fn.serializeData = 2 function () { 3 4 var formData = new FormData(); 5 var $inputs = $(this).find("input[name], textarea[name], select[name]"); 6 $inputs.each(function (index) { 7 if ($inputs[index].getAttribute("type") == "file") { 8 9 len = $inputs[index].files.length; 10 for (var i = 0; i < len; i++) { 11 var value = $inputs[index].files[i]; 12 formData.append($inputs[index].getAttribute("name"), value); 13 } 14 15 } else if ($inputs[index].getAttribute("type") == "checkbox") { 16 if ($inputs[index].checked) { 17 formData.append($inputs[index].getAttribute("name"), $inputs[index].value); 18 } 19 } else if ($inputs[index].getAttribute("type") == "radio") { 20 if ($inputs[index].checked) { 21 formData.append($inputs[index].getAttribute("name"), $inputs[index].value); 22 } 23 } else if ($inputs[index].type == "select-multiple" || $inputs[index].type == "select-one") { 24 opt = ""; 25 for (var i = 0, len = $inputs[index].options.length; i < len; i++) { 26 opt = $inputs[index].options[i]; 27 if (opt.selected) { 28 formData.append($inputs[index].getAttribute("name"), opt.value); 29 } 30 } 31 } else { 32 formData.append($inputs[index].getAttribute("name"), $input
32s[index].value); 33 } 34 }); 35 36 var $contentEditableItems = $(this).find('[contenteditable=true]'); 37 $contentEditableItems.each(function (index) { 38 formData.append($contentEditableItems[index].getAttribute("name"), $contentEditableItems[index].innerHTML); 39 }); 40 41 return formData; 42 }; 43 44 45var isFormSubmit = false; 46$.fn.request = 47 function (params, callback, caller) { 48 var defaultParams = 49 { 50 'method': "POST", 51 'url': false, 52 'element': "form", 53 'validator': true, 54 'returnAlert': true, 55 'loadingAnimate': false 56 } 57 58 if (isFormSubmit != false) { 59 return false; 60 } 61 62 /* fonksiyondan gelen verileri parametrelete aktarıyoruz */ 63 if (params) { 64 /* string olarak geliyorsa url geliyordur */ 65 if (typeof params == "string") { 66 defaultParams['url'] = params; 67 params = ""; 68 } 69 70 for (var index in params) { 71 if (typeof params[index] != "undefined") defaultParams[index] = params[index]; 72 } 73 } 74 75 76 77 /* POST methodu haricindekilerde validataion kullanılmaz */ 78 if (defaultParams['method'] == "GET") { 79 defaultParams['validator'] = false; 80 } 81 82 /* form valide iÅlemi yaptırıyoruz */ 83 if (defaultParams['validator'] == true) { 84 isValidate = validate(defaultParams['element']); 85 if (isValidate == false) { 86 return false; 87 } 88 } 89 90 /* Yükleme barını aktif ediyoruz */ 91 if (defaultParams['loadingAnimate'] == true) { 92 $('.progress').css({width: 2 + '%'}); 93 } 94 95 if (typeof defaultParams['url'] == "undefined" || typeof defaultParams['url'] == "false" || defaultParams['url'] == false) { 96 var link = window.location.href; 97 } else { 98 var link = defaultParams['url']; 99 } 100 101 link = link.replace("#",""); 102 103 if (link.indexOf("?") != "-1") { 104 link = link + '&format=json'; 105 } else { 106 link = link + '?format=json'; 107 } 108 109 110 if (caller) { 111 caller(defaultParams, callback, caller); 112 } 113 114 isFormSubmit = true; 115 116 /* Transient network blip (no HTTP response reached / timeout) â retry ONCE before 117 surfacing failure to the caller, so a single blip self-heals silently. Genuine 118 server responses (including HTTP error statuses that actually reached the server) 119 are not retried here; only {'result':'error'} is ever handed to callbacks, same as 120 before, on final failure. */ 121 function doAjaxRequest(isRetry) { 122 $.ajax({ 123 xhr: function () { 124 125 var xhr = new window.XMLHttpRequest(); 126 127 xhr.upload.addEventListener("progress", function (evt) { 128 if (evt.lengthComputable) { 129 130 var newWidth = Math.floor(evt.loaded / evt.total * 100); 131 132 if (isNaN(newWidth)) { 133 newWidth = 1; 134 } 135 if (newWidth > 100) { 136 newWidth = 100; 137 } 138 139 $(".progress").attr('bar', newWidth); 140 $(".progress").css({ 141 width: newWidth + '%' 142 }); 143 144 } 145 }, false); 146 147 xhr.addEventListener("progress", function (evt) { 148 if (evt.lengthComputable) { 149 var newWidth = Math.floor(evt.loaded / evt.total * 100); 150 151 if (isNaN(newWidth)) { 152 newWidth = 1; 153 } 154 if (newWidth > 100) { 155 newWidth = 100; 156 } 157 158 $(".progress").attr('bar', newWidth); 159 $(".progress").css({ 160 width: newWidth + '%' 161 }); 162 163 } 164 }, false); 165 return xhr; 166 }, 167 type: defaultParams['method'], 168 method: defaultParams['method'], 169 url: link, 170 enctype: 'multipart/form-data', 171 processData: false, 172 contentType: false, 173 data: $(defaultParams['element']).serializeData(), 174 dataType: "json", 175 cache: false, 176 success: function (response) { 177 178 isFormSubmit = false;
179 var text = ""; 180 181 if (isset(response.description) != false) { 182 text = response.description; 183 } 184 if (isset(response.error) != false) { 185 text = response.error; 186 } 187 if (response.result == "ok") { 188 addinotalClass = "success"; 189 text = response.title + '<div class="mt10"></div><p>' + text + '</p>'; 190 } else { 191 addinotalClass = "unsuccess"; 192 text = response.title + '<div class="mt10"></div><p>' + text + '</p>'; 193 } 194 /* DELIVERABLE_MAIL_v1 â sunucu "bu hesabın maili eSIM teslimine uygun 195 deÄil" dediÄinde (Payment::deliverableMailBlock â mail_required=1) 196 düz bir hata kutusu göstermek çıkmaz sokak olurdu: kullanıcı ne 197 yapacaÄını bilemez. Onun yerine e-posta girme kutusu açılır ve mail 198 kaydedilince AYNI istek aynı verilerle tekrarlanır â kullanıcı 199 sepetini/adımını kaybetmez. Burada, merkezde durduÄu için her ödeme 200 yüzeyi (ödeme sayfası, quick-buy modal, ileride eklenecek yöntemler) 201 ek kod olmadan kapsanır. */ 202 if (response.mail_required == "1" && typeof esimRequireMail === "function") { 203 $(".progress").attr('bar', "0").css({width: 0 + '%'}); 204 $("#boxUpModal").remove().hide(0); 205 esimRequireMail(function () { 206 isFormSubmit = true; 207 doAjaxRequest(false); 208 }); 209 return true; 210 } 211 212 if (defaultParams['returnAlert'] == true || response.result == "fail") { 213 boxup(text); 214 $("#boxUpModal").remove().hide(0); 215 } 216 217 $(".progress").attr('bar', "0"); 218 $(".progress").animate({ 219 width: 0 + '%', 220 duration: 2000 221 }, 0); 222 223 if (callback) { 224 callback(response, defaultParams); 225 } 226 227 return true; 228 229 }, error: function (r, t) { 230 /* Pure network failure (status 0 -> request never reached the server, e.g. 231 offline/DNS/CORS) or a timeout -> retry ONCE before giving up. Any other 232 error (a real HTTP status from the server) is surfaced immediately. */ 233 var isTransient = (!r || r.status === 0 || t === 'timeout'); 234 if (isTransient && !isRetry) { 235 doAjaxRequest(true); 236 return; 237 } 238 callback({'result':'error'}, defaultParams); 239 isFormSubmit = false; 240 } 241 }); 242 } 243 244 doAjaxRequest(false); 245 };
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.