index.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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(cmd => mod.command.exec(cmd))
  13. return false
  14. })
  15. }
  16. }
  17. parse(array, title, mode) {
  18. if (mode == 2) {
  19. this.mod.send('S_ANNOUNCE_UPDATE_NOTIFICATION', 1, {
  20. id: 0,
  21. title: title, // <img src='icon_notice'/>`<img src='icon_notice'/>`<img src='icon_notice'/>`<img src='icon_notice'/>`
  22. body: squonk(array, mode)
  23. })
  24. Data = ''
  25. ArrayTXT = ['cools']
  26. } else
  27. this.mod.send('S_ANNOUNCE_UPDATE_NOTIFICATION', 1, {
  28. id: 0,
  29. title: title, // <img src='icon_notice'/>`<img src='icon_notice'/>`<img src='icon_notice'/>`<img src='icon_notice'/>`
  30. body: thonk(array, mode)
  31. })
  32. Data = ''
  33. }
  34. }
  35. let Data = '',
  36. Count = 0,
  37. IMGCount = 1,
  38. FirstTXT = true,
  39. ArrayTXT = [],
  40. isFinished = 0
  41. function ShoveData(stuff, mode) {
  42. if (Data.length >= 16000) {
  43. Data += `GUI Data Limit Exceeded, some values may be missing.`
  44. isFinished = true
  45. return
  46. }
  47. if (Count >= 7 && mode == 1) {
  48. Data += `<br>${stuff}`
  49. Count = 1
  50. } else Data += stuff
  51. }
  52. function thonk(array) {
  53. isFinished = false
  54. for (var i = 0; i < array.length; i++) {
  55. Count++
  56. if (array[i].command == null && !isFinished) {
  57. if (array[i].img != null) ShoveData(`<img src='img://__${array[i].img}'></img>${array[i].text}`);
  58. ShoveData(`${array[i].text}`)
  59. } else if (array[i].img != null && array[i].command !== null && !isFinished) {
  60. ShoveData(`<a href='admincommand:/@${array[i].command}' ><img src='img://__${array[i].img}'></img></a>${array[i].text} `)
  61. } else if (array[i].img == null && array[i].command !== null && !isFinished) ShoveData(`<a href='admincommand:/@${array[i].command}'>${array[i].text}</a>`)
  62. }
  63. Count = 0
  64. return Data
  65. }
  66. function squonk(array) {
  67. for (var i = 0; i < array.length; i++) {
  68. if (IMGCount <= 5) {
  69. IMGCount++
  70. ArrayTXT.push(array[i].text)
  71. Data += `<a href='admincommand:/@${array[i].command}'><img src='img://__${array[i].img}'></img></a> &#09; `
  72. } if (ArrayTXT.length == 5) {
  73. console.log('else')
  74. FirstTXT = true
  75. for (var j = 0; j < ArrayTXT.length; j++) {
  76. console.log(ArrayTXT[j])
  77. if (j == 4) {
  78. Data += `${ArrayTXT[j]}<br>`
  79. IMGCount = 0
  80. ArrayTXT = []
  81. FirstTXT = true
  82. }
  83. if (FirstTXT == true && j != 4) {
  84. Data += `<br> &#09;${ArrayTXT[j]} &#09;&#09;`
  85. FirstTXT = false
  86. } else if (j != 4) {
  87. Data += `${ArrayTXT[j]} &#09;&#09;&#09;`
  88. }
  89. }
  90. IMGCount = 0
  91. ArrayTXT = []
  92. FirstTXT = true
  93. }
  94. }
  95. console.log(Data)
  96. return Data
  97. }
  98. module.exports = Gui;