A new, object-oriented, better vesion of μForum
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

61 lines
1.2 KiB

  1. var ajax;
  2. function init() {
  3. initAjax();
  4. }
  5. function initAjax() {
  6. try
  7. {
  8. ajax = new XMLHttpRequest();
  9. }
  10. catch(e) // IE <= 6
  11. {
  12. var XmlHttpVersions = [
  13. 'MSXML2.XMLHTTP.6.0',
  14. 'MSXML2.XMLHTTP.5.0',
  15. 'MSXML2.XMLHTTP.4.0',
  16. 'MSXML2.XMLHTTP.3.0',
  17. 'MSXML2.XMLHTTP',
  18. 'Microsoft.XMLHTTP'
  19. ];
  20. for (var i=0; i < XmlHttpVersions.length && null === ajax; i++)
  21. {
  22. try
  23. {
  24. ajax = new ActiveXObject(XmlHttpVersions[i]);
  25. } catch (e) {}
  26. }
  27. if (null === ajax)
  28. {
  29. throw new Error('AJAX Error');
  30. }
  31. }
  32. return true;
  33. }
  34. function response() {
  35. if (ajax.readyState != 4 || ajax.status != 200)
  36. return;
  37. if (ajax.responseText == 'true')
  38. {
  39. document.getElementById('nick-inuse').style.display = 'inline';
  40. document.getElementById('nick-free').style.display = 'none';
  41. }
  42. else
  43. {
  44. document.getElementById('nick-inuse').style.display = 'none';
  45. document.getElementById('nick-free').style.display = 'inline';
  46. }
  47. }
  48. function checkNick() {
  49. if (ajax == null)
  50. init();
  51. if (document.getElementById('nick').value == '') return 0;
  52. ajax.onreadystatechange = response;
  53. ajax.open('GET', 'index.php?mode=checknick&nick=' + document.getElementById('nick').value);
  54. ajax.send(null);
  55. }