main.js 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. console.log("JS Loaded")
  2. const url = "127.0.0.1:3000"
  3. var inputForm = document.getElementById("mainUpdateTopicList")
  4. inputForm.addEventListener("submit", (e)=>{
  5. //prevent auto submission
  6. e.preventDefault()
  7. const formdata = new FormData(inputForm)
  8. fetch(url,{
  9. method:"updateMainTopicList",
  10. body:formdata,
  11. })
  12. .then(
  13. response => response.text()
  14. ).then(
  15. (data) => {document.getElementById("mainTopicList").innerHTML=data}
  16. ).catch(
  17. error => console.error(error)
  18. )
  19. })
  20. var inputForm = document.getElementById("mainUpdateInterests")
  21. inputForm.addEventListener("submit", (e)=>{
  22. //prevent auto submission
  23. e.preventDefault()
  24. const formdata = new FormData(inputForm)
  25. fetch(url,{
  26. method:"updateMainInterests",
  27. body:formdata,
  28. })
  29. .then(
  30. response => response.text()
  31. ).catch(
  32. error => console.error(error)
  33. )
  34. })
  35. var inputForm = document.getElementById("archiveUpdateTopicList")
  36. inputForm.addEventListener("submit", (e)=>{
  37. //prevent auto submission
  38. e.preventDefault()
  39. const formdata = new FormData(inputForm)
  40. fetch(url,{
  41. method:"updateArchiveTopicList",
  42. body:formdata,
  43. })
  44. .then(
  45. (data) => {document.getElementById("archiveUpdateTopicList").innerHTML=data}
  46. ).catch(
  47. error => console.error(error)
  48. )
  49. })
  50. var inputForm = document.getElementById("archiveUpdateInterests")
  51. inputForm.addEventListener("submit", (e)=>{
  52. //prevent auto submission
  53. e.preventDefault()
  54. const formdata = new FormData(inputForm)
  55. fetch(url,{
  56. method:"updateArchiveInterests",
  57. body:formdata,
  58. })
  59. .then(
  60. response => response.text()
  61. ).catch(
  62. error => console.error(error)
  63. )
  64. })
  65. var inputForm = document.getElementById("archiveUpdateTopicList")
  66. inputForm.addEventListener("submit", (e)=>{
  67. //prevent auto submission
  68. e.preventDefault()
  69. const formdata = new FormData(inputForm)
  70. fetch(url,{
  71. method:"updateArchiveTopicList",
  72. body:formdata,
  73. })
  74. .then(
  75. (data) => {document.getElementById("displayArchiveTweets").innerHTML=data}
  76. ).catch(
  77. error => console.error(error)
  78. )
  79. })
  80. var inputForm = document.getElementById("mainTweets")
  81. inputForm.addEventListener("submit", (e)=>{
  82. //prevent auto submission
  83. e.preventDefault()
  84. const formdata = new FormData(inputForm)
  85. fetch(url,{
  86. method:"getTweets",
  87. body:formdata,
  88. }).then(
  89. (data) => {document.getElementById("displayMainTweets").innerHTML=data}
  90. ).catch(
  91. error => console.error(error)
  92. )
  93. })
  94. var inputForm = document.getElementById("inputTweet")
  95. inputForm.addEventListener("submit", (e)=>{
  96. //prevent auto submission
  97. e.preventDefault()
  98. const formdata = new FormData(inputForm)
  99. fetch(url,{
  100. method:"POST",
  101. body:formdata,
  102. }).then(
  103. response => response.text()
  104. ).catch(
  105. error => console.error(error)
  106. )
  107. })