index.js 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. const map = new WeakMap();
  2. let blep;
  3. class Gui {
  4. constructor(mod) {
  5. this.mod = mod;
  6. const base = mod.base || mod;
  7. if (!map.has(base)) {
  8. map.set(base, {});
  9. mod.hook('C_CONFIRM_UPDATE_NOTIFICATION', 1, () => false)
  10. mod.hook('C_ADMIN', 1, (event) => {
  11. blep = event.command.split(";")
  12. blep.forEach(
  13. function (cmd) {
  14. mod.command.exec(cmd);
  15. })
  16. return false
  17. })
  18. }
  19. }
  20. parse(array, title, mode) {
  21. if (mode == 2) {
  22. this.mod.send('S_ANNOUNCE_UPDATE_NOTIFICATION', 1, {
  23. id: 0,
  24. title: title, // <img src='icon_notice'/>`<img src='icon_notice'/>`<img src='icon_notice'/>`<img src='icon_notice'/>` USE THIS
  25. body: squonk(array, mode)
  26. })
  27. Data = ''
  28. ArrayTXT = ['cools']
  29. } else
  30. this.mod.send('S_ANNOUNCE_UPDATE_NOTIFICATION', 1, {
  31. id: 0,
  32. title: title, // <img src='icon_notice'/>`<img src='icon_notice'/>`<img src='icon_notice'/>`<img src='icon_notice'/>` USE THIS
  33. body: thonk(array, mode)
  34. })
  35. Data = ''
  36. }
  37. }
  38. let Data = '',
  39. Count = 0,
  40. IMGCount = 1,
  41. TXTCount = 0,
  42. FirstTXT = true,
  43. ArrayTXT = [],
  44. isFinished = 0
  45. function ShoveData(stuff, mode) {
  46. if (Data.length >= 16000) {
  47. Data += `GUI Data Limit Exceeded, some values may be missing.`
  48. isFinished = true
  49. return
  50. }
  51. if (Count >= 7 && mode == 1) {
  52. Data += `<br>${stuff}`
  53. Count = 1
  54. } else {
  55. Data += stuff
  56. }
  57. }
  58. function thonk(array) {
  59. isFinished = false
  60. for (var i = 0; i < array.length; i++) {
  61. Count++
  62. if (array[i].command == null && !isFinished) {
  63. if (array[i].img != null) {
  64. ShoveData(`<img src='img://__${array[i].img}'></img>${array[i].text}`)
  65. }
  66. ShoveData(`${array[i].text}`)
  67. } else
  68. if (array[i].img != null && array[i].command !== null && !isFinished) {
  69. ShoveData(`<a href='admincommand:/@${array[i].command}' ><img src='img://__${array[i].img}'></img></a>${array[i].text} `)
  70. } else
  71. if (array[i].img == null && array[i].command !== null && !isFinished) {
  72. ShoveData(`<a href='admincommand:/@${array[i].command}'>${array[i].text}</a>`)
  73. }
  74. }
  75. //console.log(`Finished stuff ${Data}`) //mod here
  76. Count = 0
  77. return Data
  78. }
  79. function squonk(array) {
  80. for (var i = 0; i < array.length; i++) {
  81. if (IMGCount <= 5) {
  82. IMGCount++
  83. ArrayTXT.push(array[i].text)
  84. Data += `<a href='admincommand:/@${array[i].command}'><img src='img://__${array[i].img}'></img></a> &#09; `
  85. //console.log(IMGCount)
  86. } if (ArrayTXT.length == 5) {
  87. console.log('else')
  88. FirstTXT = true
  89. for (var j = 0; j < ArrayTXT.length; j++) {
  90. console.log(ArrayTXT[j])
  91. // console.log(ArrayTXT)
  92. if (j == 4) {
  93. // console.log('BEEEEEEEEEEEEEEP')
  94. Data += `${ArrayTXT[j]}<br>`
  95. IMGCount = 0
  96. ArrayTXT = []
  97. FirstTXT = true
  98. }
  99. if (FirstTXT == true && j != 4) {
  100. Data += `<br> &#09;${ArrayTXT[j]} &#09;&#09;`
  101. FirstTXT = false
  102. } else if (j != 4) {
  103. Data += `${ArrayTXT[j]} &#09;&#09;&#09;`
  104. }
  105. }
  106. IMGCount = 0
  107. ArrayTXT = []
  108. //console.log(ArrayTXT.length)
  109. FirstTXT = true
  110. }
  111. }
  112. console.log(Data)
  113. return Data
  114. }
  115. module.exports = Gui;