A copyright violation detector running on Wikimedia Cloud Services https://tools.wmflabs.org/copyvios/
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.
 
 
 
 
 

91 lines
2.5 KiB

  1. function copyvio_toggle_details(details) {
  2. link = document.getElementById("cv-result-detail-link");
  3. details = document.getElementById("cv-result-detail");
  4. if (link.innerHTML == "Show details:") {
  5. details.style.display = "block";
  6. link.innerHTML = "Hide details:";
  7. set_cookie("CopyviosShowDetails", "True", 1095);
  8. } else {
  9. details.style.display = "none";
  10. link.innerHTML = "Show details:";
  11. if (get_cookie("CopyviosShowDetails")) {
  12. delete_cookie("CopyviosShowDetails");
  13. }
  14. }
  15. }
  16. function update_screen_size() {
  17. var cache = cache_cookie();
  18. var data = {
  19. "width": window.screen.availWidth,
  20. "height": window.screen.availHeight
  21. }
  22. if (!cache || cache["width"] != data["width"] || cache["height"] != data["height"]) {
  23. set_cookie("CopyviosScreenCache", JSON.stringify(data), 1095);
  24. }
  25. }
  26. function cache_cookie() {
  27. var cookie = get_cookie("CopyviosScreenCache");
  28. if (cookie) {
  29. try {
  30. data = JSON.parse(cookie);
  31. var width = data.width;
  32. var height = data.height;
  33. if (width && height) {
  34. return {"width": width, "height": height};
  35. }
  36. }
  37. catch (SyntaxError) {}
  38. }
  39. return false;
  40. }
  41. // Cookie code partially based on http://www.quirksmode.org/js/cookies.html
  42. function get_cookie(name) {
  43. var nameEQ = name + "=";
  44. var ca = document.cookie.split(";");
  45. for (var i = 0; i < ca.length; i++) {
  46. var c = ca[i];
  47. while (c.charAt(0) == " ") {
  48. c = c.substring(1, c.length);
  49. }
  50. if (c.indexOf(nameEQ) == 0) {
  51. var value = window.atob(c.substring(nameEQ.length, c.length));
  52. if (value.indexOf("--cpv2") == 0) {
  53. return value.substring("--cpv2".length, value.length);
  54. }
  55. }
  56. }
  57. return null;
  58. }
  59. function set_cookie_with_date(name, value, date) {
  60. value = window.btoa("--cpv2" + value);
  61. var path = window.location.pathname.split("/", 2)[1];
  62. if (date) {
  63. var expires = "; expires=" + date.toUTCString();
  64. }
  65. else {
  66. var expires = "";
  67. }
  68. document.cookie = name + "=" + value + expires + "; path=/" + path;
  69. }
  70. function set_cookie(name, value, days) {
  71. if (days) {
  72. var date = new Date();
  73. date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
  74. set_cookie_with_date(name, value, date);
  75. }
  76. else {
  77. set_cookie_with_date(name, value);
  78. }
  79. }
  80. function delete_cookie(name) {
  81. set_cookie(name, "", -1);
  82. }