index.js 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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 style="position: relative;">';
  19. html +=
  20. "<div class='' style='position: absolute;background-color: darkred;color: white;padding: 0 6px;right: 0;'>" + gLocal.gui.ongoing + "</div>";
  21. html += "</div>";
  22. html += "<div class='card' style='padding:10px;'>";
  23. gLocal.gui.ongoing + "</div>";
  24. html += "<div style='font-weight:700'>";
  25. html +=
  26. "<a href='../article/?collect=" +
  27. iterator.id +
  28. "'>" +
  29. iterator.title +
  30. "</a>";
  31. html += "</div>";
  32. if(iterator.subtitle){
  33. html += "<div style=''>" + iterator.subtitle + "</div>";
  34. }
  35. html += "<div style=''>" + iterator.username.nickname + "</div>";
  36. if(iterator.summary){
  37. html += "<div style=''>" + iterator.summary + "</div>";
  38. }
  39. if( iterator.tag){
  40. html +="<div style='overflow-wrap: anywhere;'>" + iterator.tag + "</div>";
  41. }
  42. const article_limit = 4;
  43. let article_count = 0;
  44. let article_list = JSON.parse(iterator.article_list);
  45. for (const article of article_list) {
  46. html += "<div>";
  47. html +=
  48. "<a href='../article/?id=" +
  49. article.article +
  50. "' target='_blank'>" +
  51. article.title +
  52. "</a>";
  53. html += "</div>";
  54. article_count++;
  55. if (article_count > article_limit) {
  56. break;
  57. }
  58. }
  59. html += "</div>";
  60. html += "</div>";
  61. }
  62. $("#article_new").html(html);
  63. }
  64. );
  65. }
  66. function index_load_term_new() {
  67. $.get("../term/new.php", function (data, status) {
  68. let xDiv = document.getElementById("pali_pedia");
  69. if (xDiv) {
  70. xDiv.innerHTML = data;
  71. }
  72. });
  73. }
  74. function index_load_course_new() {
  75. $.get("../course/list_new.php", function (data, status) {
  76. let xDiv = document.getElementById("course_list_new");
  77. if (xDiv) {
  78. xDiv.innerHTML = data;
  79. }
  80. });
  81. }