A copyright violation detector running on Wikimedia Cloud Services https://tools.wmflabs.org/copyvios/
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

script.js 5.9 KiB

9 år sedan
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. function update_screen_size() {
  2. var cache = cache_cookie();
  3. var data = {
  4. "width": window.screen.availWidth,
  5. "height": window.screen.availHeight
  6. }
  7. if (!cache || cache["width"] != data["width"] || cache["height"] != data["height"]) {
  8. set_cookie("CopyviosScreenCache", JSON.stringify(data), 1095);
  9. }
  10. }
  11. function cache_cookie() {
  12. var cookie = get_cookie("CopyviosScreenCache");
  13. if (cookie) {
  14. try {
  15. data = JSON.parse(cookie);
  16. var width = data.width;
  17. var height = data.height;
  18. if (width && height) {
  19. return {"width": width, "height": height};
  20. }
  21. }
  22. catch (SyntaxError) {}
  23. }
  24. return false;
  25. }
  26. // Cookie code partially based on http://www.quirksmode.org/js/cookies.html
  27. function get_cookie(name) {
  28. var nameEQ = name + "=";
  29. var ca = document.cookie.split(";");
  30. for (var i = 0; i < ca.length; i++) {
  31. var c = ca[i];
  32. while (c.charAt(0) == " ") {
  33. c = c.substring(1, c.length);
  34. }
  35. if (c.indexOf(nameEQ) == 0) {
  36. var value = window.atob(c.substring(nameEQ.length, c.length));
  37. if (value.indexOf("--cpv2") == 0) {
  38. return value.substring("--cpv2".length, value.length);
  39. }
  40. }
  41. }
  42. return null;
  43. }
  44. function set_cookie_with_date(name, value, date) {
  45. value = window.btoa("--cpv2" + value);
  46. var path = window.location.pathname.split("/", 2)[1];
  47. if (date) {
  48. var expires = "; expires=" + date.toUTCString();
  49. }
  50. else {
  51. var expires = "";
  52. }
  53. document.cookie = name + "=" + value + expires + "; path=/" + path;
  54. }
  55. function set_cookie(name, value, days) {
  56. if (days) {
  57. var date = new Date();
  58. date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
  59. set_cookie_with_date(name, value, date);
  60. }
  61. else {
  62. set_cookie_with_date(name, value);
  63. }
  64. }
  65. function delete_cookie(name) {
  66. set_cookie(name, "", -1);
  67. }
  68. function toggle_notice() {
  69. var details = $("#notice-collapse-box"),
  70. trigger = $("#notice-collapse-trigger");
  71. if (details.is(":hidden")) {
  72. details.show();
  73. trigger.text("[hide]");
  74. }
  75. else {
  76. details.hide();
  77. trigger.text("[show]");
  78. }
  79. }
  80. function install_notice() {
  81. var details = $("#notice-collapse-box"),
  82. trigger = $("#notice-collapse-trigger");
  83. if (details.length >= 0 && trigger.length >= 0) {
  84. trigger.replaceWith($("<a/>", {
  85. id: "notice-collapse-trigger",
  86. href: "#",
  87. text: "[show]",
  88. click: function() {
  89. toggle_notice();
  90. return false;
  91. }
  92. }));
  93. details.hide();
  94. }
  95. }
  96. $(document).ready(function() {
  97. $("#action-search").change(function() {
  98. $(".cv-search").prop("disabled", false);
  99. $(".cv-compare").prop("disabled", true);
  100. $(".cv-search-oo-ui").addClass("oo-ui-widget-enabled").removeClass("oo-ui-widget-disabled");
  101. $(".cv-compare-oo-ui").addClass("oo-ui-widget-disabled").removeClass("oo-ui-widget-enabled");
  102. });
  103. $("#action-compare").change(function() {
  104. $(".cv-search").prop("disabled", true);
  105. $(".cv-compare").prop("disabled", false);
  106. $(".cv-search-oo-ui").addClass("oo-ui-widget-disabled").removeClass("oo-ui-widget-enabled");
  107. $(".cv-compare-oo-ui").addClass("oo-ui-widget-enabled").removeClass("oo-ui-widget-disabled");
  108. });
  109. if ($("#action-search" ).is(":checked")) $("#action-search" ).change();
  110. if ($("#action-compare").is(":checked")) $("#action-compare").change();
  111. $("#cv-form").submit(function() {
  112. if ($("#action-search").is(":checked")) {
  113. var hidden = [
  114. ["engine", "use_engine"], ["links", "use_links"],
  115. ["turnitin", "turnitin"]];
  116. $.each(hidden, function(i, val) {
  117. if ($("#cv-cb-" + val[0]).is(":checked"))
  118. $("#cv-form input[type='hidden'][name='" + val[1] + "']")
  119. .prop("disabled", true);
  120. });
  121. }
  122. $("#cv-form button[type='submit']")
  123. .prop("disabled", true)
  124. .css("cursor", "progress")
  125. .parent()
  126. .addClass("oo-ui-widget-disabled")
  127. .removeClass("oo-ui-widget-enabled");
  128. });
  129. if ($("#cv-additional").length >= 0) {
  130. $("#cv-additional").css("display", "block");
  131. $(".source-default-hidden").css("display", "none");
  132. $("#show-additional-sources").click(function() {
  133. $(".source-default-hidden").css("display", "");
  134. $("#cv-additional").css("display", "none");
  135. return false;
  136. });
  137. }
  138. if ($(".login-link").length >= 0) {
  139. $(".login-link").click(function(e) {
  140. e.preventDefault();
  141. var $loginForm = $("<form>")
  142. .attr("action", "/login")
  143. .attr("method", "POST");
  144. // Tell `/login` where to go after logging in
  145. $loginForm.append(
  146. $("<input>")
  147. .attr("type", "hidden")
  148. .attr("name", "next")
  149. .attr("value", window.location.pathname + window.location.search)
  150. )
  151. $("body").after($loginForm);
  152. $loginForm.trigger("submit");
  153. $loginForm.remove();
  154. return false;
  155. });
  156. }
  157. if ($(".logout-link").length >= 0) {
  158. $(".logout-link").click(function(e) {
  159. e.preventDefault();
  160. if (!confirm("Are you sure you want to log out?")) {
  161. return;
  162. }
  163. var $logoutForm = $("<form>")
  164. .attr("action", "/logout")
  165. .attr("method", "POST");
  166. $("body").after($logoutForm);
  167. $logoutForm.trigger("submit");
  168. $logoutForm.remove();
  169. return false;
  170. });
  171. }
  172. install_notice();
  173. });