profile.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. var localTime = new Date();
  2. function autoDetectTimeOffset(currentTime)
  3. {
  4. if (typeof(currentTime) != 'string')
  5. var serverTime = currentTime;
  6. else
  7. var serverTime = new Date(currentTime);
  8. // Something wrong?
  9. if (!localTime.getTime() || !serverTime.getTime())
  10. return 0;
  11. // Get the difference between the two, set it up so that the sign will tell us who is ahead of who.
  12. var diff = Math.round((localTime.getTime() - serverTime.getTime())/3600000);
  13. // Make sure we are limiting this to one day's difference.
  14. diff %= 24;
  15. return diff;
  16. }
  17. // Prevent Chrome from auto completing fields when viewing/editing other members profiles
  18. function disableAutoComplete()
  19. {
  20. if (is_chrome && document.addEventListener)
  21. document.addEventListener("DOMContentLoaded", disableAutoCompleteNow, false);
  22. }
  23. // Once DOMContentLoaded is triggered, call the function
  24. function disableAutoCompleteNow()
  25. {
  26. for (var i = 0, n = document.forms.length; i < n; i++)
  27. {
  28. var die = document.forms[i].elements;
  29. for (var j = 0, m = die.length; j < m; j++)
  30. // Only bother with text/password fields?
  31. if (die[j].type == "text" || die[j].type == "password")
  32. die[j].setAttribute("autocomplete", "off");
  33. }
  34. }