1/* 2 3Cross-Browser XMLHttpRequest v1.2 4================================= 5 6Emulate Gecko 'XMLHttpRequest()' functionality in IE and Opera. Opera requires 7the Sun Java Runtime Environment <http://www.java.com/>. 8 9by Andrew Gregory 10http://www.scss.com.au/family/andrew/webdesign/xmlhttprequest/ 11 12This work is licensed under the Creative Commons Attribution License. To view a 13copy of this license, visit http://creativecommons.org/licenses/by-sa/2.5/ or 14send a letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California 1594305, USA. 16 17Attribution: Leave my name and web address in this script intact. 18 19Not Supported in Opera 20---------------------- 21* user/password authentication 22* responseXML data member 23 24Not Fully Supported in Opera 25---------------------------- 26* async requests 27* abort() 28* getAllResponseHeaders(), getAllResponseHeader(header) 29 30*/ 31// IE support 32if (window.ActiveXObject && !window.XMLHttpRequest) { 33 window.XMLHttpRequest = function() { 34 var msxmls = new Array( 35 'Msxml2.XMLHTTP.5.0', 36 'Msxml2.XMLHTTP.4.0', 37 'Msxml2.XMLHTTP.3.0', 38 'Msxml2.XMLHTTP', 39 'Microsoft.XMLHTTP'); 40 for (var i = 0; i < msxmls.length; i++) { 41 try { 42 return new ActiveXObject(msxmls[i]); 43 } catch (e) { 44 } 45 } 46 return null; 47 }; 48} 49// Gecko support 50/* ;-) */
51// Opera support 52if (window.opera && !window.XMLHttpRequest) { 53 window.XMLHttpRequest = function() { 54 this.readyState = 0; // 0=uninitialized,1=loading,2=loaded,3=interactive,4=complete 55 this.status = 0; // HTTP status codes 56 this.statusText = ''; 57 this._headers = []; 58 this._aborted = false; 59 this._async = true; 60 this._defaultCharset = 'ISO-8859-9'; 61 this._getCharset = function() { 62 var charset = _defaultCharset; 63 var contentType = this.getResponseHeader('Content-type').toUpperCase(); 64 val = contentType.indexOf('CHARSET='); 65 if (val != -1) { 66 charset = contentType.substring(val); 67 } 68 val = charset.indexOf(';'); 69 if (val != -1) { 70 charset = charset.substring(0, val); 71 } 72 val = charset.indexOf(','); 73 if (val != -1) { 74 charset = charset.substring(0, val); 75 } 76 return charset; 77 }; 78 this.abort = function() { 79 this._aborted = true; 80 }; 81 this.getAllResponseHeaders = function() { 82 return this.getAllResponseHeader('*'); 83 }; 84 this.getAllResponseHeader = function(header) { 85 var ret = ''; 86 for (var i = 0; i < this._headers.length; i++) { 87 if (header == '*' || this._headers[i].h == header) { 88 ret += this._headers[i].h + ': ' + this._headers[i].v + '\n'; 89 } 90 } 91 return ret; 92 }; 93 this.getResponseHeader = function(header) { 94 var ret = getAllResponseHeader(header); 95 var i = ret.indexOf('\n'); 96 if (i != -1) { 97 ret = ret.substring(0, i); 98 } 99 return ret; 100 }; 101 this.setRequestHeader = function(header, value) { 102 this._headers[this._headers.length] = {h:header, v:value}; 103 }; 104 this.open = function(method, url, async, user, password) { 105 this.method = method; 106 this.url = url; 107 this._async = true; 108 this._aborted = false; 109 this._headers = []; 110 if (arguments.length >= 3) { 111 this._async = async; 112 } 113 if (arguments.length > 3) { 114 opera.postError('XMLHttpRequest.open() - user/password not supported'); 115 } 116 this.readyState = 1; 117 if (this.onreadystatechange) { 118 this.onreadystatechange(); 119 } 120 }; 121 this.send = function(data) { 122 if (!navigator.javaEnabled()) { 123 alert("XMLHttpRequest.send() - Java must be installed and enabled."); 124 return; 125 } 126 if (this._async) { 127 setTimeout(this._sendasync, 0, this, data); 128 // this is not really asynchronous and won't execute until the current 129 // execution context ends 130 } else { 131 this._sendsync(data); 132 } 133 } 134 this._sendasync = function(req, data) { 135 if (!req._aborted) { 136 req._sendsync(data); 137 } 138 }; 139 this._sendsync = function(data) { 140 this.readyState = 2; 141 if (this.onreadystatechange) { 142 this.onreadystatechange(); 143 } 144 // open connection 145 var url = new java.net.URL(new java.net.URL(window.location.href), this.url); 146 var conn = url.openConnection(); 147 for (var i = 0; i < this._headers.length; i++) { 148 conn.setRequestProperty(this._headers[i].h, this._headers[i].v); 149 } 150 this._headers = []; 151 if (this.method == 'POST') { 152 // POST data 153 conn.setDoOutput(true); 154 var wr = new java.io.OutputStreamWriter(conn.getOutputStream(), this._getCharset()); 155 wr.write(data); 156 wr.flush(); 157 wr.close(); 158 } 159 // read response headers 160 // NOTE: the getHeaderField() methods always return nulls for me :( 161 var gotContentEncoding = false; 162 var gotContentLength = false; 163 var gotContentType = false; 164 var gotDate = false; 165 var gotExpiration = false; 166 var gotLastModified = false; 167 for (var i = 0; ; i++) { 168 var hdrName = conn.getHeaderFieldKey(i); 169 var hdrValue = conn.getHeaderField(i); 170 if (hdrName == null && hdrValue == null) { 171 break; 172 } 173 if (hdrName != null) { 174 this._headers[this._headers.length] = {h:hdrName, v:hdrValue}; 175 switch (hdrName.toLowerCase()) { 176 case 'content-encoding': gotContentEncoding = true; break; 177 case 'content-length' : gotContentLength = true; break; 178 case 'content-type' : gotContentType = true; break; 179 case 'date' : gotDate = true; break; 180 case 'expires' : gotExpiration = true; break; 181 case 'last-modified' : gotLastModified = true; break; 182 } 183 } 184 } 185 // try to fill in any missing header information 186 var val; 187 val = conn.getContentEncoding(); 188 if (val != null && !gotContentEncoding) this._headers[this._headers.length] = {h:'
188Content-encoding', v:val}; 189 val = conn.getContentLength(); 190 if (val != -1 && !gotContentLength) this._headers[this._headers.length] = {h:'Content-length', v:val}; 191 val = conn.getContentType(); 192 if (val != null && !gotContentType) this._headers[this._headers.length] = {h:'Content-type', v:val}; 193 val = conn.getDate(); 194 if (val != 0 && !gotDate) this._headers[this._headers.length] = {h:'Date', v:(new Date(val)).toUTCString()}; 195 val = conn.getExpiration(); 196 if (val != 0 && !gotExpiration) this._headers[this._headers.length] = {h:'Expires', v:(new Date(val)).toUTCString()}; 197 val = conn.getLastModified(); 198 if (val != 0 && !gotLastModified) this._headers[this._headers.length] = {h:'Last-modified', v:(new Date(val)).toUTCString()}; 199 // read response data 200 var reqdata = ''; 201 var stream = conn.getInputStream(); 202 if (stream) { 203 var reader = new java.io.BufferedReader(new java.io.InputStreamReader(stream, this._getCharset())); 204 var line; 205 while ((line = reader.readLine()) != null) { 206 if (this.readyState == 2) { 207 this.readyState = 3; 208 if (this.onreadystatechange) { 209 this.onreadystatechange(); 210 } 211 } 212 reqdata += line + '\n'; 213 } 214 reader.close(); 215 this.status = 200; 216 this.statusText = 'OK'; 217 this.responseText = reqdata; 218 this.readyState = 4; 219 if (this.onreadystatechange) { 220 this.onreadystatechange(); 221 } 222 if (this.onload) { 223 this.onload(); 224 } 225 } else { 226 // error 227 this.status = 404; 228 this.statusText = 'Not Found'; 229 this.responseText = ''; 230 this.readyState = 4; 231 if (this.onreadystatechange) { 232 this.onreadystatechange(); 233 } 234 if (this.onerror) { 235 this.onerror(); 236 } 237 } 238 }; 239 }; 240} 241// ActiveXObject emulation 242if (!window.ActiveXObject && window.XMLHttpRequest) { 243 window.ActiveXObject = function(type) { 244 switch (type.toLowerCase()) { 245 case 'microsoft.xmlhttp': 246 case 'msxml2.xmlhttp': 247 case 'msxml2.xmlhttp.3.0': 248 case 'msxml2.xmlhttp.4.0': 249 case 'msxml2.xmlhttp.5.0': 250 return new XMLHttpRequest(); 251 } 252 return null; 253 }; 254} 255 256function writit(text,id) { 257 if (document.getElementById) { 258 x = document.getElementById(id); 259 x.innerHTML = ''; 260 x.innerHTML = text; 261 x.style.visibility = "visible"; 262 263 } else if (document.all) { 264 x = document.all[id]; 265 x.innerHTML = text; 266 x.style.visibility = "visible"; 267 } else if (document.layers) { 268 x = document.layers[id]; 269 text2 = '<p class="testclass">' + text + '</p>'; 270 x.document.open(); 271 x.document.write(text2); 272 x.document.close(); 273 x.style.visibility = "visible"; 274 } 275} 276/*diger sayfa fonksiyonlari*/ 277function haberdarEt(param,div1,div2) { 278 279 var req; 280 try 281 { 282 // Firefox, Opera 8.0+, Safari 283 req=new XMLHttpRequest(); 284 } 285 catch (e) 286 { 287 // Internet Explorer 288 try 289 { 290 req=new ActiveXObject("Msxml2.XMLHTTP"); 291 } 292 catch (e) 293 { 294 try 295 { 296 req=new ActiveXObject("Microsoft.XMLHTTP"); 297 } 298 catch (e) 299 { 300 alert("Tarayýcýnýz AJAX desteklememektedir!"); 301 return false; 302 } 303 } 304 } 305 306 if (req) { 307 req.onreadystatechange = function() { 308 document.getElementById(div2).disabled = true; 309 writit('E-Posta kaydediliyor...',div1); 310 if (req.readyState == 4) { 311 writit(req.responseText,div1); 312 } 313 }; 314 req.open('POST', '/haberdar_et.asp'); 315 req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8'); 316 //alert(post_text); 317 req.send(param); 318 } 319 return false; 320} 321 322function puanVer() { 323 var req = new XMLHttpRequest(); 324 if (req) { 325 req.onreadystatechange = function() { 326 document.getElementById('puan_submit').disabled = true; 327 writit('Puan kaydediliyor...','puan-sonuc'); 328 if (req.readyState == 4) { 329 writit(req.responseText,'puan-sonuc'); 330 } 331 }; 332 req.open('POST', '/puan_ver.asp'); 333 req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8'); 334 var post_text = 'puan='+document.getElementById('puan').value+'&haber='+document.getElementById('haber').value+''; 335 //alert(post_text); 336 req.send(post_text); 337 } 338 return false; 339} 340 341function tweetPuanVer() { 342 var req = new XMLHttpRequest(); 343 if (req) { 344 req.onreadystatechange = function() { 345 document.getElementById('puan_submit').disabled = true; 346 writit('Puan kaydediliyor...','puan-sonuc'); 347 if (req.readyState == 4) { 348 writit(req.responseText,'puan-sonuc'); 349 } 350 }; 351 req.open('POST', '/tweet_puan_ver.asp'); 352 req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8'); 353 var post_text = 'puan='+document.getElementById('puan').value+'&tweet='+document.getElementById('tweet').value+''; 354 //alert(post_text); 355 req.send(post_text); 356 } 357 return false; 358} 359 360function videoPuanVer() { 361 var req = new XMLHttpRequest(); 362 if (req) { 363 req.onreadystatechange = function() { 364 document.getElementById('puan_submit').disabled = true; 365 writit('Puan kaydediliyor...','puan-sonuc'); 366 if (req.readyState == 4) { 367 writit(req.responseText,'puan-sonuc'); 368 } 369 }; 370 req.open('POST', '/video_puan_ver.asp'); 371 req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8'); 372 var post_text = 'puan='+document.getElementById('puan').value+'&videoID='+document.getElementById('videoID').value+''; 373 //alert(post_text); 374 req.send(post_text); 375 } 376 return false; 377} 378 379function oyunPuanVer() { 380 var req = new XMLHttpRequest(); 381 if (req) { 382 req.onreadystatechange = function() { 383 document.getElementById('puan_submit').disabled = true; 384 writit('Puan kaydediliyor...','puan-sonuc'); 385 if (req.readyState == 4) { 386 writit(req.responseText,'puan-sonuc'); 387 } 388 }; 389 req.open('POST', '/oyun_puan_ver.asp'); 390 req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8'); 391 var post_text = 'puan='+document.getElementById('puan').value+'&oyunID='+document.getElementById('oyunID').value+''; 392 //alert(post_text); 393 req.send(post_text); 394 } 395 return false; 396} 397 398function firmaPuanVer() { 399 var req = new XMLHttpRequest(); 400 if (req) { 401 req.onreadystatechange = function() { 402 document.getElementById('puan_submit').disabled = true; 403 writit('Puan kaydediliyor...','puan-sonuc'); 404 if (req.readyState == 4) { 405 writit(req.responseText,'puan-sonuc'); 406 } 407 }; 408 req.open('POST', '/firma_puan_ver.asp'); 409 req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8'); 410 var post_text = 'puan='+document.getElementById('puan').value+'&firmaID='+document.getElementById('firmaID').value+''; 411 //alert(post_text); 412 req.send(post_text); 413 } 414 return false; 415} 416 417function anketoyla() { 418 var req = new XMLHttpRequest(); 419 var anketID = document.getElementById('AnketID').value; 420 var txtCaptcha = document.getElementById('txtCaptcha').value; 421 if (req) { 422 req.onreadystatechange = function() { 423 writit('Oyunuz kaydediliyor...','loading'); 424 if (req.readyState == 4) { 425 writit(req.responseText,'anket-sonuc'); 426 } 427 }; 428 req.open('POST', '/anket-ajax.asp'); 429 req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=ISO-8859-9'); 430 var post_text = ''; 431 var colRadio = document.getElementsByName('anket_secenek'); 432 for (var i=0; i < colRadio.length; i++) { 433 if (colRadio[i].checked) { 434 post_text += 'secenek='+colRadio[i].value+'&'; } 435 } 436 post_text += 'anket='+anketID+'&txtCaptcha='+txtCaptcha+''; 437 req.send(post_text); 438 } 439 return false; 440} 441 442function kodOlustur() { 443 var req = new XMLHttpRequest(); 444 if (req) { 445 req.onreadystatechange = function() { 446 writit('Kaynak Kod Oluþturuluyor...','form_result_msg'); 447 writit('Önizleme Oluþturuluyor...','onizleme'); 448 if (req.readyState == 4) { 449 writit('<textarea name="sonuc" class="input" rows="5" cols="10" style="width:300px">'+req.responseText+'</textarea>','form_result_msg'); 450 writit(req.responseText,'onizleme'); 451 } 452 }; 453 req.open('POST', '/kod_olustur.asp'); 454 req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8'); 455 var post_text = 'siralama='+document.getElementById('siralama').value+'&sayi='+document.getElementById('sayi').value+'&artalan='+document.getElementById('artalan').value+'&yazirenk='+document.getElementById('yazirenk').value+'&yaziboyut='+document.getElementById('yaziboyut').value+'&kalinlik='+document.getElementById('kalinlik').value+'&cizgirenk='+document.getElementById('cizgirenk').value+'&kategori='+document.getElementById('kategori').value+''; 456 req.send(post_text); 457 } 458 return false; 459} 460 461function manset(catID,divID) { 462 463 for (i=1;i<=10;i++) { 464 document.getElementById('manset-resim-'+catID+'-'+i+'').style.display = 'none'; 465 document.getElementById('manset-ozet-'+catID+'-'+i+'').style.display = 'none'; 466 document.getElementById('manset-baslik-'+catID+'-'+i+'').style.display = 'none'; 467 } 468 469 document.getElementById('manset-baslik-'+catID+'-'+divID+'').style.display = 'block'; 470 document.getElementById('manset-resim-'+catID+'-'+divID+'').style.display = 'block'; 471 document.getElementById('manset-ozet-'+catID+'-'+divID+'').style.display = 'block'; 472} 473 474function altmanset(catID,divID) { 475 476 for (i=1;i<=5;i++) { 477 document.getElementById('manset-resim-'+catID+'-'+i+'').style.display = 'none'; 478 document.getElementById('manset-ozet-'+catID+'-'+i+'').style.display = 'none'; 479 document.getElementById('manset-baslik-'+catID+'-'+i+'').style.display = 'none'; 480 } 481 482 document.getElementById('manset-baslik-'+catID+'-'+divID+'').style.display = 'block'; 483 document.getElementById('manset-resim-'+catID+'-'+divID+'').style.display = 'block'; 484 document.getElementById('manset-ozet-'+catID+'-'+divID+'').style.display = 'block'; 485}
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.