diff --git a/public/js/chat.js b/public/js/chat.js index 6544e2f0..9d0f386b 100644 --- a/public/js/chat.js +++ b/public/js/chat.js @@ -170,6 +170,9 @@ document.addEventListener('DOMContentLoaded', () => { const editorRow = document.querySelector('.row.editor'); let isResizing = false; + if(!localStorage.getItem('leftColPct')) localStorage.setItem('leftColPct', '70%') + if(!localStorage.getItem('rightColPct')) localStorage.setItem('rightColPct', '30%') + handle.addEventListener('mousedown', function(e) { e.preventDefault(); isResizing = true; @@ -197,6 +200,8 @@ document.addEventListener('DOMContentLoaded', () => { // Apply the new widths leftCol.style.width = `${leftColPercentage}%`; rightCol.style.width = `${rightColPercentage}%`; + localStorage.setItem('leftColPct', leftCol.style.width) + localStorage.setItem('rightColPct', rightCol.style.width) startX = e.pageX; } @@ -209,4 +214,74 @@ document.addEventListener('DOMContentLoaded', () => { window.addEventListener('mousemove', handleMouseMove); window.addEventListener('mouseup', handleMouseUp); }); + + function toggleChat() { + const leftCol = document.querySelector('.left-col'); + const rightCol = document.querySelector('.right-col'); + let chatContainer = document.getElementsByClassName('chat-container')[0]; + + var chatEnabled = localStorage.getItem('chatEnabled'); + if (chatEnabled === 'true') { + leftCol.style.width = localStorage.getItem('leftColPct') || '70%'; + rightCol.style.width = localStorage.getItem('rightColPct') || '30%'; + chatContainer.style.display = ''; + } else { + rightCol.style.width = '0%'; + leftCol.style.width = '100%'; + chatContainer.style.display = 'none'; + } + } + + document.getElementById('chatButton').addEventListener('click', function(e) { + e.preventDefault() + var chatEnabled = localStorage.getItem('chatEnabled'); + if(chatEnabled === 'true' || chatEnabled === null) { + localStorage.setItem('chatEnabled', 'false'); + } else { + localStorage.setItem('chatEnabled', 'true'); + } + + toggleChat() + }); + + toggleChat() + + if(localStorage.getItem('chatEnabled') !== 'false') { + leftCol.style.width = localStorage.getItem('leftColPct'); + rightCol.style.width = localStorage.getItem('rightColPct'); + rightCol.style.display = ''; + } + + leftCol.style.display = ''; + +/* + + localStorage.removeItem("leftColPct"); + localStorage.removeItem("rightColPct"); + localStorage.removeItem("chatEnabled"); + + function toggleChat() { + const leftCol = document.querySelector('.left-col'); + const rightCol = document.querySelector('.right-col'); + let chatContainer = document.getElementsByClassName('chat-container')[0] + + if(localStorage) + + if(rightCol.style.width == '0%') { + rightCol.style.width = '30%'; + leftCol.style.width = '70%'; + chatContainer.style.display = '' + } else { + rightCol.style.width = '0%'; + leftCol.style.width = '100%'; + chatContainer.style.display = 'none' + } + } + + chatButton.addEventListener('click', function(e) { + e.preventDefault() + toggleChat() + }); +*/ + }); \ No newline at end of file diff --git a/sass/_project-sass/_project-Main.scss b/sass/_project-sass/_project-Main.scss index e8994455..746564c1 100644 --- a/sass/_project-sass/_project-Main.scss +++ b/sass/_project-sass/_project-Main.scss @@ -2148,6 +2148,32 @@ a.tag:hover { .row.editor { display: flex; height: calc(100vh - 105px); + /* Width and background of the scrollbar */ + ::-webkit-scrollbar { + width: 6px; + background-color: #F5F5F5; + } + + /* Background of the scrollbar track */ + ::-webkit-scrollbar-track { + background-color: #1d1f21; + } + + /* Style of the scrollbar thumb (the part you drag) */ + ::-webkit-scrollbar-thumb { + background-color: #CCC; + border-radius: 6px; + } + + /* Style of the scrollbar thumb when hovering */ + ::-webkit-scrollbar-thumb:hover { + background-color: #B5B5B5; + } + + /* Style of the scrollbar corner */ + ::-webkit-scrollbar-corner { + background-color: #F5F5F5; + } } .header-Outro.with-columns.press .col { padding: 25px 40px 15px 40px; @@ -2268,34 +2294,6 @@ pre, code { color: #FFFFFF; } - -/* Width and background of the scrollbar */ -::-webkit-scrollbar { - width: 6px; - background-color: #F5F5F5; -} - -/* Background of the scrollbar track */ -::-webkit-scrollbar-track { - background-color: #1d1f21; -} - -/* Style of the scrollbar thumb (the part you drag) */ -::-webkit-scrollbar-thumb { - background-color: #CCC; - border-radius: 6px; -} - -/* Style of the scrollbar thumb when hovering */ -::-webkit-scrollbar-thumb:hover { - background-color: #B5B5B5; -} - -/* Style of the scrollbar corner */ -::-webkit-scrollbar-corner { - background-color: #F5F5F5; -} - .left-col { padding: 1rem; overflow-y: scroll; diff --git a/views/site_files/text_editor.erb b/views/site_files/text_editor.erb index 90c66585..55c66a40 100644 --- a/views/site_files/text_editor.erb +++ b/views/site_files/text_editor.erb @@ -90,7 +90,7 @@ Save View - '> Share Penelope + '> Share Chat