ESRMeter taken from http://members.shaw.ca/swstuff/esrmeter.html (find website on internet archive). Offered here with permission.
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.

41 lines
1.3 KiB

5 years ago
  1. // Wayback Machine hacks
  2. var __wbhack = new function(){
  3. var prefix;
  4. var orig_document = {
  5. createElementNS: document.createElementNS
  6. };
  7. this.init = function(_prefix) {
  8. this.checkCookiesNumber();
  9. prefix = _prefix;
  10. document.createElementNS = function(ns,name) {
  11. if (ns.indexOf(prefix)==0) {
  12. ns = ns.substring(prefix.length).replace(/\/?[0-9]+\//, '');
  13. }
  14. return orig_document.createElementNS.call(this, ns, name);
  15. };
  16. };
  17. this.createCookie = function(name,value,days) {
  18. if (days) {
  19. var date = new Date();
  20. date.setTime(date.getTime()+(days*24*60*60*1000));
  21. var expires = "; expires="+date.toGMTString();
  22. }
  23. else var expires = "";
  24. document.cookie = name+"="+value+expires+"; path=/";
  25. };
  26. this.eraseCookie = function(name) {
  27. this.createCookie(name, "", -1);
  28. };
  29. this.checkCookiesNumber = function() {
  30. var cookies = document.cookie.split(";");
  31. if(cookies.length > 40) {
  32. for(var i=0; i<cookies.length; i++) {
  33. var name = cookies[i].split("=")[0].trim();
  34. this.eraseCookie(name);
  35. }
  36. }
  37. };
  38. // save JSON object for our use - some target pages redefine JSON with their
  39. // own version that may not be compatible with (now) standard JSON.
  40. this.JSON = JSON;
  41. };