MCPcopy
hub / github.com/socketio/socket.io / addMessageElement

Function addMessageElement

examples/chat/public/main.js:117–141  ·  view source on GitHub ↗
(el, options)

Source from the content-addressed store, hash-verified

115 // options.prepend - If the element should prepend
116 // all other messages (default = false)
117 const addMessageElement = (el, options) => {
118 const $el = $(el);
119 // Setup default options
120 if (!options) {
121 options = {};
122 }
123 if (typeof options.fade === 'undefined') {
124 options.fade = true;
125 }
126 if (typeof options.prepend === 'undefined') {
127 options.prepend = false;
128 }
129
130 // Apply options
131 if (options.fade) {
132 $el.hide().fadeIn(FADE_TIME);
133 }
134 if (options.prepend) {
135 $messages.prepend($el);
136 } else {
137 $messages.append($el);
138 }
139
140 $messages[0].scrollTop = $messages[0].scrollHeight;
141 }
142
143 // Prevents input from having injected markup
144 const cleanInput = (input) => {

Callers 2

logFunction · 0.70
addChatMessageFunction · 0.70

Calls 1

$Function · 0.50

Tested by

no test coverage detected