Added docks.
This commit is contained in:
		
							parent
							
								
									9e89e27c66
								
							
						
					
					
						commit
						af399e3b72
					
				| @ -345,13 +345,18 @@ class Socket extends EventHandler { | |||||||
| 
 | 
 | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| class App extends EventHandler { | class NotificationAudio { | ||||||
|     rooms = [] |     constructor(timeout){ | ||||||
|     rest = rest |         if(!timeout) | ||||||
|     ws = null |             timeout = 500 | ||||||
|     rpc = null |         this.schedule = new Schedule(timeout) | ||||||
|  |     } | ||||||
|     sounds = ["/audio/soundfx.d_beep3.mp3"] |     sounds = ["/audio/soundfx.d_beep3.mp3"] | ||||||
|     playSound(soundIndex) { |     play(soundIndex) { | ||||||
|  |         this.schedule.delay(() => { | ||||||
|  |              | ||||||
|  |          | ||||||
|  | 
 | ||||||
|         if (!soundIndex) |         if (!soundIndex) | ||||||
|             soundIndex = 0 |             soundIndex = 0 | ||||||
| 
 | 
 | ||||||
| @ -364,17 +369,30 @@ class App extends EventHandler { | |||||||
|             .catch((error) => { |             .catch((error) => { | ||||||
|                 console.error("Notification failed:", error); |                 console.error("Notification failed:", error); | ||||||
|             }); |             }); | ||||||
|  |         }) | ||||||
|     } |     } | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | class App extends EventHandler { | ||||||
|  |     rooms = [] | ||||||
|  |     rest = rest | ||||||
|  |     ws = null | ||||||
|  |     rpc = null | ||||||
|  |     audio = null  | ||||||
|     constructor() { |     constructor() { | ||||||
|         super() |         super() | ||||||
|         this.rooms.push(new Room("General")) |         this.rooms.push(new Room("General")) | ||||||
|         this.ws = new Socket() |         this.ws = new Socket() | ||||||
|         this.rpc = this.ws.client |         this.rpc = this.ws.client | ||||||
|         const me = this |         const me = this | ||||||
|  |         this.audio = new NotificationAudio(500) | ||||||
|         this.ws.addEventListener("channel-message", (data) => { |         this.ws.addEventListener("channel-message", (data) => { | ||||||
|             me.emit(data.channel_uid, data) |             me.emit(data.channel_uid, data) | ||||||
|         }) |         }) | ||||||
|     } |     } | ||||||
|  |     playSound(index){ | ||||||
|  |         this.audio.play(index) | ||||||
|  |     } | ||||||
|     async benchMark(times, message) { |     async benchMark(times, message) { | ||||||
|         if (!times) |         if (!times) | ||||||
|             times = 100 |             times = 100 | ||||||
|  | |||||||
| @ -55,7 +55,7 @@ class MessageListElement extends HTMLElement { | |||||||
|         const text = document.createElement("div") |         const text = document.createElement("div") | ||||||
|         text.classList.add("text") |         text.classList.add("text") | ||||||
|         if(message.html) |         if(message.html) | ||||||
|             text.innerHTML = this.linkifyText(message.html) |             text.innerHTML = message.html | ||||||
|         const time = document.createElement("div") |         const time = document.createElement("div") | ||||||
|         time.classList.add("time") |         time.classList.add("time") | ||||||
|         time.textContent = message.created_at |         time.textContent = message.created_at | ||||||
|  | |||||||
| @ -17,8 +17,8 @@ class Schedule { | |||||||
|         this.interval = null  |         this.interval = null  | ||||||
|     } |     } | ||||||
|     cancelDelay() { |     cancelDelay() { | ||||||
|         clearTimeout(this.interval) |         clearTimeout(this.timeOut) | ||||||
|         this.interval = null |         this.timeOut = null | ||||||
|     } |     } | ||||||
|     repeat(func){ |     repeat(func){ | ||||||
|         if(this.interval){ |         if(this.interval){ | ||||||
| @ -35,9 +35,10 @@ class Schedule { | |||||||
|         } |         } | ||||||
|         const me = this  |         const me = this  | ||||||
|         this.timeOut = setTimeout(()=>{ |         this.timeOut = setTimeout(()=>{ | ||||||
|  |             func(me.timeOutCount) | ||||||
|             clearTimeout(me.timeOut) |             clearTimeout(me.timeOut) | ||||||
|             me.timeOut = null |             me.timeOut = null | ||||||
|             func(me.timeOutCount) |              | ||||||
|             me.cancelDelay() |             me.cancelDelay() | ||||||
|             me.timeOutCount = 0 |             me.timeOutCount = 0 | ||||||
|         }, this.msDelay) |         }, this.msDelay) | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user