An unfinished system to manage all your paper documentation in an easy way.
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

autodoc.js 2.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /* AutoDoc Javascript */
  2. var conf = {
  3. default_hash: "home",
  4. openapi: "/v1",
  5. pageinit: {
  6. home: "page_load_home()"
  7. }
  8. };
  9. $(document).ready(function () {
  10. change_page();
  11. });
  12. $(window).bind("hashchange", function () {
  13. change_page();
  14. });
  15. function change_page() {
  16. var hash = document.location.hash.substr(1) || conf.default_hash;
  17. if (!$("#autodoc_tab_" + hash).length) {
  18. hash = conf.default_hash;
  19. }
  20. /* change menu highlights and content visibility */
  21. $("#autodoc_navbar")
  22. .find("a")
  23. .each(function (id, obj) {
  24. var curhash = $(obj)
  25. .attr("href")
  26. .substr(1);
  27. if (curhash == hash) {
  28. console.log("add " + curhash);
  29. $(obj)
  30. .parent()
  31. .addClass("active");
  32. $("#autodoc_tab_" + curhash).removeClass("d-none");
  33. } else {
  34. console.log("remove " + curhash);
  35. $(obj)
  36. .parent()
  37. .removeClass("active");
  38. $("#autodoc_tab_" + curhash).addClass("d-none");
  39. }
  40. });
  41. if (conf.pageinit[hash]) {
  42. eval(conf.pageinit[hash]);
  43. }
  44. }
  45. function page_load_home() {
  46. document_load(0);
  47. }
  48. function document_load(page) {
  49. if (!page) {
  50. page = 0;
  51. }
  52. var tmpl = $("#autodoc_template_home");
  53. var row = $(tmpl)
  54. .find(".autodoc_template_home_row")
  55. .clone();
  56. $.getJSON(
  57. conf.openapi + "/documents?pageSize=3&pageIndex=" + page,
  58. null,
  59. function (data, textStatus, jqXHR) {
  60. $.each(data, function (id, doc) {
  61. var col = $(tmpl)
  62. .find(".autodoc_template_home_col")
  63. .clone();
  64. $(col).find(".autodoc_template_home_img").attr('src', conf.openapi + '/documents/' + doc.id + '/image');
  65. $(col)
  66. .find(".autodoc_template_home_owner")
  67. .html(doc.owner);
  68. $(col)
  69. .find(".autodoc_template_home_created")
  70. .html(doc.created);
  71. $.each(doc.tags, function (id, tag) {
  72. $(col)
  73. .find(".autodoc_template_home_tag")
  74. .after(
  75. $(col)
  76. .find(".autodoc_template_home_tag")
  77. .clone()
  78. .html(tag)
  79. );
  80. });
  81. $(row).append(col);
  82. });
  83. $('#autodoc_home_body').append(row);
  84. }
  85. );
  86. }