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.

пре 12 година
пре 12 година
пре 12 година
пре 12 година
пре 12 година
пре 12 година
пре 12 година
пре 12 година
пре 12 година
пре 12 година
пре 12 година
пре 12 година
пре 12 година
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. function potd_set_background() {
  2. var cookie = get_cookie("EarwigBackgroundCache");
  3. if (cookie) {
  4. try {
  5. data = JSON.parse(cookie);
  6. var filename = data.filename;
  7. var url = data.url;
  8. var descurl = data.descurl;
  9. var imgwidth = data.imgwidth;
  10. var imgheight = data.imgheight;
  11. if (filename && url && descurl && imgwidth && imgheight) {
  12. set_background(filename, url, descurl, imgwidth, imgheight);
  13. return;
  14. }
  15. }
  16. catch (SyntaxError) {}
  17. }
  18. var d = new Date();
  19. var callback = "earwigpotd1";
  20. var date = (d.getUTCFullYear()) + "-" + zero_pad(d.getUTCMonth() + 1, 2) + "-" + zero_pad(d.getUTCDate(), 2);
  21. var base = "//commons.wikimedia.org/w/api.php?action=query&prop=revisions&rvprop=content&format=json&titles=Template:Potd/";
  22. var url = base + date + "&callback=" + callback;
  23. var script = document.createElement("script");
  24. var head = document.getElementsByTagName("head")[0];
  25. window[callback] = function(data) {
  26. head.removeChild(script);
  27. parse_file_name(data);
  28. };
  29. script.src = url;
  30. head.appendChild(script);
  31. }
  32. function parse_file_name(data) {
  33. var content = "";
  34. var res = data["query"]["pages"];
  35. for (pageid in res) {
  36. content = res[pageid]["revisions"][0]["*"];
  37. }
  38. var filename = /\{\{Potd filename\|(1=)?(.*?)\|.*?\}\}/.exec(content)[2];
  39. var callback = "earwigpotd2";
  40. var base = "//commons.wikimedia.org/w/api.php?action=query&prop=imageinfo&iiprop=url|size&format=json&titles=File:";
  41. var url = base + escape(filename) + "&callback=" + callback;
  42. var script = document.createElement("script");
  43. var head = document.getElementsByTagName("head")[0];
  44. window[callback] = function(data) {
  45. head.removeChild(script);
  46. parse_file_url(data, escape(filename.replace(/ /g, "_")));
  47. };
  48. script.src = url;
  49. head.appendChild(script);
  50. }
  51. function parse_file_url(data, filename) {
  52. var url = "";
  53. var descurl = "";
  54. var imgwidth = 1024;
  55. var imgheight = 768;
  56. var res = data["query"]["pages"];
  57. for (pageid in res) {
  58. r = res[pageid]["imageinfo"][0];
  59. url = r["url"];
  60. descurl = r["descriptionurl"];
  61. imgwidth = r["width"];
  62. imgheight = r["height"];
  63. }
  64. set_background(filename, url, descurl, imgwidth, imgheight);
  65. var data = {"filename": filename, "url": url, "descurl": descurl, "imgwidth": imgwidth, "imgheight": imgheight};
  66. var expires = new Date();
  67. expires.setUTCMilliseconds(0);
  68. expires.setUTCSeconds(0);
  69. expires.setUTCMinutes(0);
  70. expires.setUTCHours(0);
  71. expires.setUTCDate(expires.getUTCDate() + 1);
  72. set_cookie_with_date("EarwigBackgroundCache", JSON.stringify(data), expires);
  73. }
  74. function set_background(filename, url, descurl, imgwidth, imgheight) {
  75. var s = get_window_size();
  76. var winwidth = s[0];
  77. var winheight = s[1];
  78. var width = winwidth;
  79. if (imgwidth/imgheight > winwidth/winheight) {
  80. width = Math.round((imgwidth/imgheight) * winheight);
  81. }
  82. if (width >= imgwidth) {
  83. document.body.style.backgroundImage = "url('" + url + "')";
  84. if (width > imgwidth) {
  85. document.body.style.setProperty("background-size", "cover");
  86. }
  87. } else {
  88. url = url.replace(/\/commons\//, "/commons/thumb/") + "/" + width + "px-" + filename;
  89. document.body.style.backgroundImage = "url('" + url + "')";
  90. }
  91. document.getElementById("bg_image_link").href = descurl;
  92. }
  93. function zero_pad(value, length) {
  94. value = String(value);
  95. length = length || 2;
  96. while (value.length < length) {
  97. value = "0" + value;
  98. }
  99. return value;
  100. }
  101. function get_window_size() {
  102. // See http://www.javascripter.net/faq/browserw.htm
  103. var width = 1024,
  104. height = 768;
  105. if (document.body && document.body.offsetWidth && document.body.offsetHeight) {
  106. width = document.body.offsetWidth;
  107. height = document.body.offsetHeight;
  108. }
  109. if (document.compatMode=="CSS1Compat" && document.documentElement && document.documentElement.offsetWidth && document.documentElement.offsetHeight) {
  110. width = document.documentElement.offsetWidth;
  111. height = document.documentElement.offsetHeight;
  112. }
  113. if (window.innerWidth && window.innerHeight) {
  114. width = window.innerWidth;
  115. height = window.innerHeight;
  116. }
  117. return [width, height];
  118. }