index.js 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. function index_onload() {
  2. index_load_term_new();
  3. index_load_collect_new();
  4. index_load_course_new();
  5. }
  6. function index_load_collect_new() {
  7. $.get(
  8. "../collect/list.php",
  9. {
  10. begin: 0,
  11. page: 4,
  12. },
  13. function (data, status) {
  14. let arrCollectList = JSON.parse(data);
  15. let html = "";
  16. for (const iterator of arrCollectList.data) {
  17. html += "<div style='width:25%;padding:0.5em;'>";
  18. html += "<div class='card' style='padding:10px;'>";
  19. html +=
  20. "<div class='' style='position: absolute;background-color: #862002;margin-top: -10px;margin-left: 12em;color: white;padding: 0 3px;display: inline-block;'>" +
  21. "done</div>";
  22. html += "<div style='font-weight:700'>";
  23. html +=
  24. "<a href='../article/?collect=" +
  25. iterator.id +
  26. "'>" +
  27. iterator.title +
  28. "</a>";
  29. html += "</div>";
  30. html += "<div style=''>" + iterator.subtitle + "</div>";
  31. html += "<div style=''>" + iterator.username.nickname + "</div>";
  32. html += "<div style=''>" + iterator.summary + "</div>";
  33. html +=
  34. "<div style='overflow-wrap: anywhere;'>" + iterator.tag + "</div>";
  35. const article_limit = 4;
  36. let article_count = 0;
  37. let article_list = JSON.parse(iterator.article_list);
  38. for (const article of article_list) {
  39. html += "<div>";
  40. html +=
  41. "<a href='../article/?id=" +
  42. article.article +
  43. "' target='_blank'>" +
  44. article.title +
  45. "</a>";
  46. html += "</div>";
  47. article_count++;
  48. if (article_count > article_limit) {
  49. break;
  50. }
  51. }
  52. html += "</div>";
  53. html += "</div>";
  54. }
  55. $("#article_new").html(html);
  56. }
  57. );
  58. }
  59. function index_load_term_new() {
  60. $.get("../term/new.php", function (data, status) {
  61. let xDiv = document.getElementById("pali_pedia");
  62. if (xDiv) {
  63. xDiv.innerHTML = data;
  64. }
  65. });
  66. }
  67. function index_load_course_new() {
  68. $.get("../course/list_new.php", function (data, status) {
  69. let xDiv = document.getElementById("course_list_new");
  70. if (xDiv) {
  71. xDiv.innerHTML = data;
  72. }
  73. });
  74. }