An unfinished system to manage all your paper documentation in an easy way.
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. /* AutoDoc Javascript */
  2. var conf = {
  3. default_hash: "home",
  4. openapi: "/v1",
  5. pageinit: {
  6. home: "page_load_home()"
  7. },
  8. home: {
  9. width: 4
  10. }
  11. };
  12. $(document).ready(function() {
  13. change_page();
  14. });
  15. $(window).bind("hashchange", function() {
  16. change_page();
  17. });
  18. function change_page() {
  19. var hash = document.location.hash.substr(1) || conf.default_hash;
  20. if (!$("#autodoc_tab_" + hash).length) {
  21. hash = conf.default_hash;
  22. }
  23. /* change menu highlights and content visibility */
  24. $("#autodoc_navbar")
  25. .find("a")
  26. .each(function(id, obj) {
  27. var curhash = $(obj)
  28. .attr("href")
  29. .substr(1);
  30. if (curhash == hash) {
  31. $(obj)
  32. .parent()
  33. .addClass("active");
  34. $("#autodoc_tab_" + curhash).removeClass("d-none");
  35. } else {
  36. $(obj)
  37. .parent()
  38. .removeClass("active");
  39. $("#autodoc_tab_" + curhash).addClass("d-none");
  40. }
  41. });
  42. if (conf.pageinit[hash]) {
  43. eval(conf.pageinit[hash]);
  44. }
  45. }
  46. function isvisible(obj) {
  47. var top_of_element = $(obj).offset().top;
  48. var bottom_of_element = $(obj).offset().top + $(obj).outerHeight();
  49. var bottom_of_screen = $(window).scrollTop() + $(window).innerHeight();
  50. var top_of_screen = $(window).scrollTop();
  51. console.log("screen: " + top_of_screen + " " + bottom_of_screen);
  52. console.log("elem: " + top_of_element + " " + bottom_of_element);
  53. if (bottom_of_screen > top_of_element && top_of_screen < bottom_of_element) {
  54. return true;
  55. }
  56. return false;
  57. }
  58. function page_load_home() {
  59. document_load(0);
  60. }
  61. function document_load(page) {
  62. if (!page || page == 0) {
  63. $('#autodoc_home_body').html('');
  64. page = 0;
  65. }
  66. var tmpl = $("#autodoc_template_home");
  67. var row = $(tmpl)
  68. .find(".autodoc_template_home_row")
  69. .clone();
  70. $.getJSON(
  71. conf.openapi +
  72. "/documents?pageSize=" +
  73. conf.home.width +
  74. "&pageIndex=" +
  75. page,
  76. null,
  77. function(data, textStatus, jqXHR) {
  78. $.each(data, function(id, doc) {
  79. var col = $(tmpl)
  80. .find(".autodoc_template_home_col")
  81. .clone();
  82. $(col)
  83. .find(".autodoc_template_home_img")
  84. .attr(
  85. "src",
  86. conf.openapi +
  87. "/documents/" +
  88. doc.id +
  89. "/image?maxWidth=" +
  90. Math.floor(1000 / conf.home.width)
  91. );
  92. $(col)
  93. .find(".autodoc_template_home_owner")
  94. .html(doc.owner);
  95. $(col)
  96. .find(".autodoc_template_home_created")
  97. .html(doc.created);
  98. $.each(doc.tags, function(id, tag) {
  99. $(col)
  100. .find(".autodoc_template_home_tag")
  101. .after(
  102. $(col)
  103. .find(".autodoc_template_home_tag")
  104. .clone()
  105. .html(tag)
  106. );
  107. });
  108. $(row).append(col);
  109. });
  110. $("#autodoc_home_body").append(row);
  111. }
  112. );
  113. // continue to load until out of browser.
  114. if (isvisible($(".autodoc_template_home_col").last())) {
  115. document_load(page + 1);
  116. }
  117. }