WebSocketClient = { init: function () { serverUrl = $('#serverUrl'); connectionStatus =…
- User
WebSocketClient = { init: function () { serverUrl = ('#serverUrl'); connectionStatus = ('#connectionStatus'); sendMessage = ('#sendMessage'); historyList = ('#history');
connectButton = $('#connectButton'); disconnectButton = $('#disconnectButton'); sendButton = $('#sendButton'); loadHistory(); $('#clearHistory').click(function (e) { clearHistory(); }); connectButton.click(function (e) { close(); open(); }); disconnectButton.click(function (e) { close(); }); sendButton.click(function (e) { var msg = $('#sendMessage').val(); addMessage(msg, 'SENT'); ws.send(msg); saveHistory(msg); }); $('#clearMessage').click(function (e) { clearLog(); }); historyList.delegate('.removeHistory', 'click', function (e) { var link = $(this).parent().find('a'); removeHistory({ 'url': link.attr('href'), 'msg': link.attr('data-msg') }); localStorage.setItem('history', JSON.stringify(historyItems)); }); historyList.delegate('.historyUrl', 'click', function (e) { window.haha1 = this; serverUrl.val(this.href); sendMessage.val(this.dataset.msg); e.preventDefault(); }); serverUrl.keydown(function (e) { if (e.which === 13) { connectButton.click(); } }); var isCtrl; sendMessage.keyup(function (e) { if (e.which === 17) { isCtrl = false; } }).keydown(function (e) { if (e.which === 17) { isCtrl = true; } if (e.which === 13 && isCtrl === true) { sendButton.click(); return false; } }); }};
Update this to use modern JS and classes, and replace jquery withr egular js
- Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.