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.

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