| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107 |
- const map = new WeakMap();
- let blep;
- class Gui {
- constructor(mod) {
- this.mod = mod;
- const base = mod.base || mod;
- if (!map.has(base)) {
- map.set(base, {});
- mod.hook('C_CONFIRM_UPDATE_NOTIFICATION', 1, () => false)
- mod.hook('C_ADMIN', 1, (event) => {
- blep = event.command.split(";")
- blep.forEach(cmd => mod.command.exec(cmd))
- return false
- })
- }
- }
- parse(array, title, mode) {
- if (mode == 2) {
- this.mod.send('S_ANNOUNCE_UPDATE_NOTIFICATION', 1, {
- id: 0,
- title: title, // <img src='icon_notice'/>`<img src='icon_notice'/>`<img src='icon_notice'/>`<img src='icon_notice'/>`
- body: squonk(array, mode)
- })
- Data = ''
- ArrayTXT = ['cools']
- } else
- this.mod.send('S_ANNOUNCE_UPDATE_NOTIFICATION', 1, {
- id: 0,
- title: title, // <img src='icon_notice'/>`<img src='icon_notice'/>`<img src='icon_notice'/>`<img src='icon_notice'/>`
- body: thonk(array, mode)
- })
- Data = ''
- }
- }
- let Data = '',
- Count = 0,
- IMGCount = 1,
- FirstTXT = true,
- ArrayTXT = [],
- isFinished = 0
- function ShoveData(stuff, mode) {
- if (Data.length >= 16000) {
- Data += `GUI Data Limit Exceeded, some values may be missing.`
- isFinished = true
- return
- }
- if (Count >= 7 && mode == 1) {
- Data += `<br>${stuff}`
- Count = 1
- } else Data += stuff
- }
- function thonk(array) {
- isFinished = false
- for (var i = 0; i < array.length; i++) {
- Count++
- if (array[i].command == null && !isFinished) {
- if (array[i].img != null) ShoveData(`<img src='img://__${array[i].img}'></img>${array[i].text}`);
- ShoveData(`${array[i].text}`)
- } else if (array[i].img != null && array[i].command !== null && !isFinished) {
- ShoveData(`<a href='admincommand:/@${array[i].command}' ><img src='img://__${array[i].img}'></img></a>${array[i].text} `)
- } else if (array[i].img == null && array[i].command !== null && !isFinished) ShoveData(`<a href='admincommand:/@${array[i].command}'>${array[i].text}</a>`)
- }
- Count = 0
- return Data
- }
- function squonk(array) {
- for (var i = 0; i < array.length; i++) {
- if (IMGCount <= 5) {
- IMGCount++
- ArrayTXT.push(array[i].text)
- Data += `<a href='admincommand:/@${array[i].command}'><img src='img://__${array[i].img}'></img></a> 	 `
- } if (ArrayTXT.length == 5) {
- console.log('else')
- FirstTXT = true
- for (var j = 0; j < ArrayTXT.length; j++) {
- console.log(ArrayTXT[j])
- if (j == 4) {
- Data += `${ArrayTXT[j]}<br>`
- IMGCount = 0
- ArrayTXT = []
- FirstTXT = true
- }
- if (FirstTXT == true && j != 4) {
- Data += `<br> 	${ArrayTXT[j]} 		`
- FirstTXT = false
- } else if (j != 4) {
- Data += `${ArrayTXT[j]} 			`
- }
- }
- IMGCount = 0
- ArrayTXT = []
- FirstTXT = true
- }
- }
- console.log(Data)
- return Data
- }
- module.exports = Gui;
|