diff --git a/bacon.toml b/bacon.toml index 58c08ada..4714b40c 100644 --- a/bacon.toml +++ b/bacon.toml @@ -2,12 +2,51 @@ # # Complete help on configuration: https://dystroy.org/bacon/config/ -default_job = "eslint-server" +default_job = "biome-libs" -[jobs.eslint-server] +[jobs.biome-libs] +env.RAYON_NUM_THREADS = "1" # for reproducible order +command = [ + "npx", "@biomejs/biome", "lint", + "--colors", "force", + "./libs", + "--skip", "complexity/useArrowFunction", + "--skip", "style/useTemplate", +] +need_stdout = true +analyzer = "biome" +watch = ["libs"] + +[jobs.biome-client] +env.RAYON_NUM_THREADS = "1" # for reproducible order +command = [ + "npx", "@biomejs/biome", "lint", + "--colors", "force", + "./src", + "--skip", "complexity/useArrowFunction", + "--skip", "style/useTemplate", + "--skip", "style/noArguments", + "--skip", "style/useConst", + "--skip", "suspicious/noRedundantUseStrict", + "--skip", "style/useSingleVarDeclarator", + "--skip", "complexity/noForEach", + "--skip", "style/noParameterAssign", + "--skip", "complexity/useLiteralKeys", + "--skip", "suspicious/noAssignInExpressions", # TODO clean +] +need_stdout = true +analyzer = "biome" +watch = [ + "libs", + "biome.json", +] + + +[jobs.eslint-libs] command = ["npx", "eslint", "--color", "libs/*"] need_stdout = true analyzer = "eslint" watch = ["libs"] [keybindings] +c = "job:biome-client" diff --git a/biome.json b/biome.json new file mode 100644 index 00000000..a20e1221 --- /dev/null +++ b/biome.json @@ -0,0 +1,8 @@ +{ + "files": { + "ignore": [ + "jquery-*.js", + "prettify/*" + ] + } +} diff --git a/graphics/M-14.svg b/graphics/M-14.svg new file mode 100644 index 00000000..5d1fccb1 --- /dev/null +++ b/graphics/M-14.svg @@ -0,0 +1,103 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + diff --git a/graphics/M-simple.svg b/graphics/M-simple.svg new file mode 100644 index 00000000..d1ae1402 --- /dev/null +++ b/graphics/M-simple.svg @@ -0,0 +1,97 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + diff --git a/graphics/Miaou-white.svg b/graphics/Miaou-white.svg new file mode 100644 index 00000000..c4ee358d --- /dev/null +++ b/graphics/Miaou-white.svg @@ -0,0 +1,139 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + diff --git a/main.js b/main.js index bc9dd0c6..fb29353c 100644 --- a/main.js +++ b/main.js @@ -1,5 +1,5 @@ -var config, - server = require('./libs/server.js'); +const server = require('./libs/server.js'); +let config; console.log("Miaou running on "+process.title+" "+process.version); diff --git a/package.json b/package.json index dfb0deb4..824e5d3b 100644 --- a/package.json +++ b/package.json @@ -46,6 +46,7 @@ "start": "sh start.sh" }, "devDependencies": { + "@biomejs/biome": "1.9.4", "@eslint/js": "^9.14.0", "eslint": "^9.14.0", "globals": "^15.12.0" diff --git a/src/main-js/miaou.gui.js b/src/main-js/miaou.gui.js index fb5bfc4c..caf43843 100644 --- a/src/main-js/miaou.gui.js +++ b/src/main-js/miaou.gui.js @@ -31,7 +31,7 @@ miaou(function(gui, chat, ed, hist, locals, md, mh, ms, notif, horn, prof, usr, gui.scrollToBottom = function($m){ _scrollToBottom(); - if ($m && $m.find) { // FIXME : cleaner API + if ($m?.find) { // FIXME : cleaner API $m.find('img').imgOn('load', _scrollToBottom); } } @@ -123,7 +123,7 @@ miaou(function(gui, chat, ed, hist, locals, md, mh, ms, notif, horn, prof, usr, vote = $e.attr('vote-level'), o = { mid:message.id}; if (message.vote) o.remove = message.vote; - if (message.vote!=vote) o.add = vote; + if (message.vote!==vote) o.add = vote; md.applyVote(o); ws.emit('vote', o); notif.userAct(message.id); @@ -235,9 +235,16 @@ miaou(function(gui, chat, ed, hist, locals, md, mh, ms, notif, horn, prof, usr, .on('click', '.opener', md.opener) .on('click', '.closer', md.closer); - if (usr.checkAuth('admin')) $('#room-edit').click(function(){ location = 'room?id='+locals.room.id }); - else $('#room-edit').hide(); - $('#auths').click(function(){ location = 'auths?id='+locals.room.id }); + if (usr.checkAuth('admin')) { + $('#room-edit').click(function(){ + document.location = 'room?id='+locals.room.id; + }); + } else { + $('#room-edit').hide(); + } + $('#auths').click(function(){ + document.location = 'auths?id='+locals.room.id; + }); $('#showPreview').click(function(){ $(this).hide(); diff --git a/src/main-js/miaou.hist.js b/src/main-js/miaou.hist.js index fb7e47ed..c728a1d5 100644 --- a/src/main-js/miaou.hist.js +++ b/src/main-js/miaou.hist.js @@ -3,7 +3,7 @@ miaou(function(hist, gui, locals, md, time, ws){ if (!locals.features) return; // it just tests whether we're in a chat/search page - var visible = false, + let visible = false, currentSearch, currentResult, delayTimer, @@ -11,7 +11,7 @@ miaou(function(hist, gui, locals, md, time, ws){ function isCurrentSearch(s){ if (!currentSearch) return false; - for (var field of fields) { + for (let field of fields) { if (currentSearch[field] !== s[field]) return false; } return true; @@ -20,7 +20,7 @@ miaou(function(hist, gui, locals, md, time, ws){ function isSearchEmpty(s){ s = s || currentSearch; if (!s) return true; - for (var field of fields) { + for (let field of fields) { if (s[field]) return false; } return true; @@ -28,17 +28,17 @@ miaou(function(hist, gui, locals, md, time, ws){ // arg : +1 or -1 function moveSelect(d){ - var i, $s = $('#search-results .message.selected'); + let i, $s = $('#search-results .message.selected'); if ($s.length) { i = $s.removeClass('selected').index() + d; } else { if (d<0) return; i = 0; } - var $selected = $('#search-results .message').eq(i).addClass('selected'); + let $selected = $('#search-results .message').eq(i).addClass('selected'); if ($selected.length) { md.focusMessage(+$selected.attr('mid')); - var mtop = $selected.offset().top, + let mtop = $selected.offset().top, $scroller = $('#right'), stop = $scroller.offset().top, sst = $scroller.scrollTop(); if (mtop5000 || maxn==0) return console.log('invalid data', res); + if (n<0 || n>5000 || maxn===0) return console.log('invalid data', res); maxtn = transform(maxn); $('#hist')[n>30?'removeClass':'addClass']('zoomed'); - var sum = 0; + let sum = 0; function day(d, n, sn){ - var date = new Date(d*24*60*60*1000), + let date = new Date(d*24*60*60*1000), month = time.MMM[date.getMonth()]+' '+date.getFullYear(); - if (month != lastMonth) { + if (month !== lastMonth) { $month = $('
').addClass('month').append( $('
').addClass('label').text(month) ).appendTo($hist); lastMonth = month; } - var $bar = $('
').addClass('bar').css('width', transform(n)*80/maxtn + '%'); - var $day = $('
').addClass('day').append($bar) + let $bar = $('
').addClass('bar').css('width', transform(n)*80/maxtn + '%'); + let $day = $('
').addClass('day').append($bar) .attr('d', d).attr('n', n).attr("sum", Math.floor(sum)) .appendTo($month); if (sn) { @@ -156,35 +156,35 @@ miaou(function(hist, gui, locals, md, time, ws){ hist.showPage = function(){ if (!visible) return; - var sh = gui.$messageScroller.height(); - var $messages = $('#messages .message').filter(function(){ - var y = $(this).offset().top; + let sh = gui.$messageScroller.height(); + let $messages = $('#messages .message').filter(function(){ + let y = $(this).offset().top; return y0; }); if (!$messages.length) return; - var fd = Math.floor($messages.first().dat('message').created / (24*60*60)), + let fd = Math.floor($messages.first().dat('message').created / (24*60*60)), ld = Math.floor($messages.last().dat('message').created / (24*60*60)); $('#hist .day').each(function(){ - var $this = $(this), d = +$(this).attr('d'); + let $this = $(this), d = +$(this).attr('d'); $this[fd<=d && d<=ld ? 'addClass' : 'removeClass']('vis'); }); } $('#hist').on('click', '.day', function(){ - var $this = $(this), + let $this = $(this), sn = +$this.attr('sn'), d = +$this.attr('d'); ws.emit("get_after_time", { search: sn ? currentSearch : null, minCreated: d*24*60*60 }); - if (currentResult && currentResult.count) { - var page = Math.floor((currentResult.count-$this.attr("sum"))/currentSearch.pageSize); + if (currentResult?.count) { + let page = Math.floor((currentResult.count-$this.attr("sum"))/currentSearch.pageSize); currentSearch.page = page; hist.search(currentSearch); } }).on('mouseenter', '.day', function(){ - var sn = +$(this).attr('sn'), + let sn = +$(this).attr('sn'), n = +$(this).attr('n'), d = +$(this).attr('d'), h = time.formatDateDDMMM(new Date(d*24*60*60*1000)); @@ -198,7 +198,7 @@ miaou(function(hist, gui, locals, md, time, ws){ function startSearch(){ clearTimeout(delayTimer); - var options = buildSearchOptions(); + let options = buildSearchOptions(); if (isCurrentSearch(options)) return; if (isSearchEmpty(options)) { currentSearch = options; @@ -215,7 +215,7 @@ miaou(function(hist, gui, locals, md, time, ws){ // read the inputs to build the search object function buildSearchOptions(){ - var options = {pattern: $('#search-input').val().trim()}; + let options = {pattern: $('#search-input').val().trim()}; if ($("#search-starred").prop("checked")) { if ($("#search-starred-by-me").prop("checked")) { options.starrer = locals.me.id; @@ -252,7 +252,7 @@ miaou(function(hist, gui, locals, md, time, ws){ if (e.which===27 && typeof window.righttab === "function") { // esc window.righttab("notablemessagespage"); // defined in page-js/pad.js $('#input').focus(); - } else if (e.which==38) { // up arrow + } else if (e.which===38) { // up arrow moveSelect(-1); } else if (e.which==40) { //down arrow moveSelect(1); @@ -274,7 +274,7 @@ miaou(function(hist, gui, locals, md, time, ws){ }); if (!gui.mobile) { - var lines = []; + let lines = []; lines.push( 'Variations of words are found too, not just the exact occurence.', 'If you type several words, all messages with one of those words will be found.', diff --git a/src/main-js/miaou.horn.js b/src/main-js/miaou.horn.js index 7c6d1585..dc34e179 100644 --- a/src/main-js/miaou.horn.js +++ b/src/main-js/miaou.horn.js @@ -5,7 +5,7 @@ miaou(function(horn, gui, locals, md, prefs){ let sounds = { standard: 'ping-standard.wav' }; - var audio; + let audio; horn.init = function(){ if (gui.mobile) { @@ -38,7 +38,7 @@ miaou(function(horn, gui, locals, md, prefs){ volume = +volume; if (!(volume>=0 && volume<=1)) volume = +prefs.get("volume"); if (!audio) { - var sound = prefs.get("sound") || sounds.standard; + let sound = prefs.get("sound") || sounds.standard; audio = new Audio('static/'+sound); } if (volume) { @@ -49,20 +49,19 @@ miaou(function(horn, gui, locals, md, prefs){ horn.show = function(mid, room, authorname, content){ mid = mid||0; - var title = typeof room === "string" ? room : (room || locals.room).name; - if (mid==localStorage.lastnotif) { + let title = typeof room === "string" ? room : (room || locals.room).name; + if (mid===localStorage.lastnotif) { console.log("avoiding duplicate notif mid=", mid); // yes, also for no id messages return; - } else { - localStorage.lastnotif = mid; } + localStorage.lastnotif = mid; if (authorname) title = authorname + ' in ' + title; - var dsk = {}; + let dsk = {}; dsk.icon = 'static/M-64.png'; if (content && prefs.get("connot")==="yes") { dsk.body = content.replace(/^@\w[\w\-]{2,}#\d+/, ''); } - var n = new Notification(title, dsk); + let n = new Notification(title, dsk); setTimeout(function(){ n.close() }, 15000); n.onclick = function(){ window.focus(); n.close(); }; horn.honk(); diff --git a/src/main-js/miaou.links.js b/src/main-js/miaou.links.js index 0b092be6..470af043 100644 --- a/src/main-js/miaou.links.js +++ b/src/main-js/miaou.links.js @@ -1,9 +1,9 @@ miaou(function(links, gui, locals, md, roomFinder, skin, usr){ - var linkwzin; + let linkwzin; function internalLinkWzin(mid){ - var $dest = $('#messages .message[mid='+mid+']'); + let $dest = $('#messages .message[mid='+mid+']'); if (!$dest.length) return; linkwzin = wzin($dest, $(this), {zIndex:5, fill:skin.wzincolors.link, scrollable:'#message-scroller'}) } @@ -73,10 +73,10 @@ miaou(function(links, gui, locals, md, roomFinder, skin, usr){ } else { // it's an url for another room or for a message in another room $link.click(function(e){ - if (gui.currentDownKey==17) { // ctrl + if (gui.currentDownKey===17) { // ctrl return; } - location = this.href; + document.location = this.href; return false; }) .addClass('message-bubbler').attr('roomId', roomId).attr('mid', mid); diff --git a/src/main-js/miaou.md.bubble.js b/src/main-js/miaou.md.bubble.js index 994d2735..a1dba902 100644 --- a/src/main-js/miaou.md.bubble.js +++ b/src/main-js/miaou.md.bubble.js @@ -45,7 +45,7 @@ miaou(function(md, chat, gui, locals, roomFinder, skin, time, usr, ws){ if (+roomId) { $room = $("
").appendTo($content); $.get("json/room?id="+roomId, function(data){ - var room = data.room; + let room = data.room; if (!room) { $r.text("Unknown Room:" + roomId); return; diff --git a/src/main-js/miaou.md.interact.js b/src/main-js/miaou.md.interact.js index 40fcbe3e..3b8ffa3b 100644 --- a/src/main-js/miaou.md.interact.js +++ b/src/main-js/miaou.md.interact.js @@ -10,7 +10,7 @@ miaou(function(md, chat, gui, hist, links, locals, ms, notif, time, usr, ws, wz) // add and remove are in [ up, down, star, pin ] (optional) md.applyVote = function(o){ $('.message[mid='+o.mid+']').each(function(){ - var $md = $(this), + let $md = $(this), m = $md.dat('message'); if (o.add) m[o.add] = (m[o.add]||0)+1; if (o.remove) m[o.remove] = (m[o.remove]||0)-1; @@ -28,10 +28,10 @@ miaou(function(md, chat, gui, hist, links, locals, ms, notif, time, usr, ws, wz) } md.opendIfClosed = function($message){ - var $opener = $message.find(".opener"); + let $opener = $message.find(".opener"); if (!$opener.length) return; $opener.removeClass('opener').addClass('closer'); - var wab = gui.isAtBottom(); + let wab = gui.isAtBottom(); $message.find('.content').removeClass('closed'); notif.userAct($message.dat('message').id); if (wab) gui.scrollToBottom(); @@ -42,7 +42,7 @@ miaou(function(md, chat, gui, hist, links, locals, ms, notif, time, usr, ws, wz) return false; } md.closer = function(e){ - var wab = gui.isAtBottom(), + let wab = gui.isAtBottom(), $md = $(this).removeClass('closer').addClass('opener').closest('.message'); $md.find('.content').addClass('closed'); notif.userAct($md.dat('message').id); @@ -55,11 +55,11 @@ miaou(function(md, chat, gui, hist, links, locals, ms, notif, time, usr, ws, wz) // returns the html needed to fill the message menu (the thing at the top right visible on hover) // Message status is assumed to be up to date function getMessageMenuHtml(message){ - var infos = []; + let infos = []; if (message.old && !message.editable) infos.push('too old to edit'); infos.push(time.formatRelativeTime(message.created)); - var h = infos.map(function(txt){ return ''+txt+'' }).join(' - ') + ' '; - h += `` + let h = infos.map(function(txt){ return ''+txt+'' }).join(' - ') + ' '; + h += "" + '' // fontello icon-code + ' '; if (message.id) { @@ -73,7 +73,7 @@ miaou(function(md, chat, gui, hist, links, locals, ms, notif, time, usr, ws, wz) + '' // fontello icon-window + ' '; } - var possibleVotes = []; + let possibleVotes = []; if (usr.checkAuth('admin')) possibleVotes.push(chat.voteLevels[0]); // pin if (message.author!==locals.me.id || usr.checkAuth('admin')) { possibleVotes.push(chat.voteLevels[1]); // star @@ -85,17 +85,17 @@ miaou(function(md, chat, gui, hist, links, locals, ms, notif, time, usr, ws, wz) '" vote-level='+l.key+' title="'+l.key+'">'+l.icon+'' }) .join(''); - if (message.pin>(message.vote=="pin") && usr.checkAuth('admin')) { + if (message.pin>(message.vote==="pin") && usr.checkAuth('admin')) { h += ' - unpin'; } } return h; } - var $hoveredMessage; + let $hoveredMessage; md.showMessageHoverInfos = function(){ md.hideMessageHoverInfos(); - var $message = $(this), + let $message = $(this), message = $message.dat('message'), $decs = $message.find('.decorations'); $hoveredMessage = $message; @@ -132,8 +132,8 @@ miaou(function(md, chat, gui, hist, links, locals, ms, notif, time, usr, ws, wz) // mainly a workaround for some mouseleave events I can't catch md.hideNotHoveredMessageInfos = function(e){ if ($hoveredMessage) { - var off = $hoveredMessage.offset(); - var x = e.pageX-off.left, y = e.pageY-off.top; + let off = $hoveredMessage.offset(); + let x = e.pageX-off.left, y = e.pageY-off.top; if (x<0 || x>$hoveredMessage.outerWidth() || y<0 || y>$hoveredMessage.outerHeight()) { md.hideMessageHoverInfos(); } @@ -142,13 +142,13 @@ miaou(function(md, chat, gui, hist, links, locals, ms, notif, time, usr, ws, wz) // argument : messageId or $messageDiv md.goToMessageDiv = function(arg){ - var $messages = gui.$messageScroller, + let $messages = gui.$messageScroller, mstop = $messages.offset().top, $message = typeof arg === "number" || typeof arg === "string" ? $('.message[mid='+arg+']', $messages) : arg; if (!$message.length) return; $message.addClass('goingto'); setTimeout(function(){ - var mtop = $message.offset().top; + let mtop = $message.offset().top; if (mtopmstop+$messages.height()) { $messages.animate({scrollTop: mtop-mstop+$messages.scrollTop()-25}, 400); } @@ -161,7 +161,7 @@ miaou(function(md, chat, gui, hist, links, locals, ms, notif, time, usr, ws, wz) // and then scroll to it and flashes it md.focusMessage = function(messageId){ if (!messageId) return; - var $messages = $('#messages .message'), + let $messages = $('#messages .message'), i, l = $messages.length, beforeId = 0, diff --git a/src/main-js/miaou.md.js b/src/main-js/miaou.md.js index 5f203394..6fccb228 100644 --- a/src/main-js/miaou.md.js +++ b/src/main-js/miaou.md.js @@ -3,7 +3,7 @@ miaou(function(md, chat, gui, hist, locals, prefs, skin, time, usr){ - var renderers = [], unrenderers = []; + let renderers = [], unrenderers = []; // registers a function which will be called when a message needs rendering // Unless a renderer returns true, the other renderers will be called. @@ -31,21 +31,21 @@ miaou(function(md, chat, gui, hist, locals, prefs, skin, time, usr){ //if (oldMessage && message.content===oldMessage.content && $content.text().length) { // return; // mainly to avoid removing boxed content //} - for (var i=0; i').addClass('content'); - var $md = $('
').addClass('message').dat('message', m).append($content).append( + let $content = $('
').addClass('content'); + let $md = $('
').addClass('message').dat('message', m).append($content).append( $('
').addClass('nminfo') .html(md.votesAbstract(m) + ' ' + time.formatTime(m.created) + ' by ' + m.authorname) ); @@ -114,7 +114,7 @@ miaou(function(md, chat, gui, hist, locals, prefs, skin, time, usr){ // if the message is present among notable ones, we replace the div // with the new version md.updateNotableMessage = function(m){ - var $container = $('#notable-messages'), + let $container = $('#notable-messages'), $repl = $container.children('.message[mid='+m.id+']'); if ($repl.length) md.addSideMessageDiv(m, $container, $repl); } @@ -123,18 +123,18 @@ miaou(function(md, chat, gui, hist, locals, prefs, skin, time, usr){ // ids : sorted ids of notable messages // m : optional message which is entering the list md.updateNotableMessages = function(upd){ - var $container = $('#notable-messages'), + let $container = $('#notable-messages'), mmap = {}; $container.find('.message').each(function(){ - var m = $(this).dat('message'); + let m = $(this).dat('message'); mmap[m.id] = m; }); if (upd.m) mmap[upd.m.id] = upd.m; $container.empty(); upd.ids.forEach(function(id){ - var m = mmap[id]; + let m = mmap[id]; if (!m) return console.log("No message in notables for id ", id); - var $md = md.addSideMessageDiv(m, $container); + let $md = md.addSideMessageDiv(m, $container); chat.trigger("notable", m, $md); }); } @@ -160,7 +160,7 @@ miaou(function(md, chat, gui, hist, locals, prefs, skin, time, usr){ // builds a notification message with a close button. The fill callback // is passed the container and a close function md.notificationMessage = function(fill){ - var notification = {closelisteners:[]}, + let notification = {closelisteners:[]}, wab = gui.isAtBottom(), $md = notification.$md = $('
').addClass('notification'); $md.appendTo('#notifications').dat('notification', notification); @@ -187,8 +187,8 @@ miaou(function(md, chat, gui, hist, locals, prefs, skin, time, usr){ // checks immediately and potentially after image loading that // the message div isn't greater than authorized md.resize = function($md, wasAtBottom){ - var $content = $md.find('.content'); - var resize = function(){ + let $content = $md.find('.content'); + let resize = function(){ $content.removeClass("closed"); $md.removeClass('has-opener'); $md.find('.opener,.closer').remove(); @@ -205,13 +205,13 @@ miaou(function(md, chat, gui, hist, locals, prefs, skin, time, usr){ // resizes all messages. This must be called each time a container of // .message elements change width. md.resizeAll = function(){ - var todo = [], + let todo = [], wasAtBottom = gui.isAtBottom(), $messages = $('.message'); $messages.find('.closed').removeClass('closed'); $messages.find('.opener').remove(); $messages.each(function(){ - var $md = $(this), + let $md = $(this), $content = $md.find('.content'), h = $content.height(); if (h>158) todo.push({$md:$md, $content:$content}); @@ -228,7 +228,7 @@ miaou(function(md, chat, gui, hist, locals, prefs, skin, time, usr){ md.updateLoaders = function(){ $('.olderLoader,.newerLoader').remove(); - var i, + let i, idmap = {}, $messages = $('#messages .message'), messages = [], @@ -330,7 +330,7 @@ miaou(function(md, chat, gui, hist, locals, prefs, skin, time, usr){ // builds a new .user-messages div for the passed user) function usermessagesdiv(user){ - var $usermessages = $('
').addClass('user-messages').dat('user', user), + let $usermessages = $('
').addClass('user-messages').dat('user', user), $user = $('
').addClass('user').appendTo($usermessages), avsrc = usr.avatarsrc(user); $user.css('color', skin.stringToColour(user.name)).append($('').text(user.name)); @@ -348,7 +348,7 @@ miaou(function(md, chat, gui, hist, locals, prefs, skin, time, usr){ // inserts or updates a message in the main #messages div md.addMessage = function(message, shouldStickToBottom){ - var messages = md.getMessages(), + let messages = md.getMessages(), oldMessage, insertionIndex = messages.length - 1, // -1 : insert at begining, i>=0 : insert after i //~ wasAtBottom = gui.isAtBottom(), @@ -360,7 +360,7 @@ miaou(function(md, chat, gui, hist, locals, prefs, skin, time, usr){ if (message.bot) user.bot = true; if (message.id) { $md.attr('mid', message.id); - for (var i=messages.length; i--;) { + for (let i=messages.length; i--;) { if (messages[i].id===message.id) { oldMessage = messages[insertionIndex = i]; break; @@ -375,7 +375,9 @@ miaou(function(md, chat, gui, hist, locals, prefs, skin, time, usr){ insertionIndex = -1; // the following line because of the possible special case of a // pin vote being removed by somebody's else - if (message.vote && !message[message.vote]) delete message.vote; // fixme ??? + if (message.vote && !message[message.vote]) { + message.vote = undefined; + } } else { while ( insertionIndex && ( messages[insertionIndex].id>message.id @@ -390,7 +392,7 @@ miaou(function(md, chat, gui, hist, locals, prefs, skin, time, usr){ if (message.content) { // Updates the link (as reply) to upwards messages // To make things simpler, we consider only one link upwards - var matches = message.content.match(/^\s*@\w[\w\-]{2,}#(\d+)/); + let matches = message.content.match(/^\s*@\w[\w\-]{2,}#(\d+)/); if (matches) message.repliesTo = +matches[1]; } usr.insert(user, message.changed||message.created); @@ -398,7 +400,7 @@ miaou(function(md, chat, gui, hist, locals, prefs, skin, time, usr){ $md.addClass('me'); $('.error').remove(); } - var $previousmessageset, + let $previousmessageset, $nextmessageset, noEndOfBatch = !message.prev && !message.next; if (~insertionIndex) { @@ -445,19 +447,19 @@ miaou(function(md, chat, gui, hist, locals, prefs, skin, time, usr){ } } if (message.content && message.changed) { - var $pen = $('
') // fontello icon-pencil + let $pen = $('
') // fontello icon-pencil .addClass('decoration pen').appendTo($decorations); if (message.previous) $pen.addClass('clickable').attr('title', 'Click for message history'); } if (!message.id) { if (message.private) { - var desc = "this private message was sent to no one else and will disappear when you refresh the page"; + let desc = "this private message was sent to no one else and will disappear when you refresh the page"; $('
') // fontello icon-snow .appendTo($decorations) .addClass('decoration snap') .attr('title', "Private : "+desc); } else { - var desc = "only sent to people currently in the room, and will disappear if you refresh the page"; + let desc = "only sent to people currently in the room, and will disappear if you refresh the page"; $('
') // fontello icon-snow .appendTo($decorations) .addClass('decoration snap') @@ -469,19 +471,19 @@ miaou(function(md, chat, gui, hist, locals, prefs, skin, time, usr){ $mc.appendTo($md); md.render($mc, message, oldMessage); if (!gui.mobile && prefs.get("datdpl")!=="hover") { - var $mdate = $('
').addClass('mdate').text(time.formatTime(message.created)).appendTo($md); + let $mdate = $('
').addClass('mdate').text(time.formatTime(message.created)).appendTo($md); if (prefs.get("datdpl")!=="always") $mdate.hide(); } return $md; } md.showMessageFlowDisruptions = function(){ - var $messages = $('#messages .message'), + let $messages = $('#messages .message'), lastMessage, $lastMessage; $messages.find('.before-disrupt').removeClass('before-disrupt'); $messages.find('.after-disrupt').removeClass('after-disrupt'); - for (var i=0; i<$messages.length; i++) { - var $message = $messages.eq(i), + for (let i=0; i<$messages.length; i++) { + let $message = $messages.eq(i), message = $message.dat('message'); if (lastMessage && message.created-lastMessage.created > miaou.chat.DISRUPTION_THRESHOLD) { $lastMessage.addClass('before-disrupt'); @@ -497,7 +499,7 @@ miaou(function(md, chat, gui, hist, locals, prefs, skin, time, usr){ // replaces one line of a message md.box = function(args){ - var $from = $('
'), + let $from = $('
'), $m = $('.message[mid='+args.mid+']'), wab = gui.isAtBottom(); md.render($from, {content: args.from}); @@ -516,20 +518,20 @@ miaou(function(md, chat, gui, hist, locals, prefs, skin, time, usr){ // cleaning of #messages .messages when there are too many of them md.startAutoCleaner = function(){ - var nbMessagesThreshold = +prefs.get("mclean"); + let nbMessagesThreshold = +prefs.get("mclean"); if (nbMessagesThreshold>50) { setInterval(function(){ if (!gui.isAtBottom()) return; - var userMessages = Array.from(document.querySelectorAll("#messages .user-messages")); - var nbMessages = 0, + let userMessages = Array.from(document.querySelectorAll("#messages .user-messages")); + let nbMessages = 0, remove = false; - for (var i=userMessages.length; i--;) { - var um = userMessages[i]; + for (let i=userMessages.length; i--;) { + let um = userMessages[i]; if (remove) { um.remove(); continue; } - for (var j=um.children.length; j--;) { + for (let j=um.children.length; j--;) { if (um.children[j].classList.contains("message")) { nbMessages++; } @@ -539,8 +541,8 @@ miaou(function(md, chat, gui, hist, locals, prefs, skin, time, usr){ remove = true; // but we must restore the "prev" property of the message if (!um.previousSibling) return; // we're at the end anyway - var previousMessageElement = um.previousSibling.lastChild; - var previousMessage = $(previousMessageElement).dat("message"); + let previousMessageElement = um.previousSibling.lastChild; + let previousMessage = $(previousMessageElement).dat("message"); if (previousMessage) { // null if there was a loader there (no restoring needed) $(um).find(".message").first().dat("message").prev = previousMessage.id; } diff --git a/src/main-js/miaou.md.rights.js b/src/main-js/miaou.md.rights.js index 9f682e35..916a0dce 100644 --- a/src/main-js/miaou.md.rights.js +++ b/src/main-js/miaou.md.rights.js @@ -11,7 +11,7 @@ miaou(function(md, gui, locals, notif, usr, watch, ws){ ar.user = {id:ar.player, name:ar.name}; } md.notificationMessage(function($c, close){ - var h = ""+ar.user.name+""; + let h = ""+ar.user.name+""; if (!ar.answered) { h += " requests access to the room."; } else if (ar.outcome) { @@ -19,14 +19,14 @@ miaou(function(md, gui, locals, notif, usr, watch, ws){ } else { h += " has been denied entry by "+ar.answerer.name+"."; } - var $p = $('
').html(h); + let $p = $('
').html(h); $c.append($p).dat('user', ar.user); $('