Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

range inputs #26

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=0">
<link rel="shortcut icon" href="/favicon.ico">
<link rel="stylesheet" href="/coloris.min.css">
<link rel="stylesheet" href="/petal.css">
<link rel="shortcut icon" href="favicon.ico">
<link rel="stylesheet" href="coloris.min.css">
<link rel="stylesheet" href="petal.css">
<title>Petal</title>
</head>
<body id="main">
Expand All @@ -28,7 +28,7 @@
</div>
<div id="chat">
<div id="backToLatest" class="hidden">Back to latest message</div>
<img id="petal" src="/favicon.ico" draggable="false">
<img id="petal" src="favicon.ico" draggable="false">
<div id="menu" class="hidden">
<div id="menuTabs">
<div id="profileTab" class="menuTab active" data-page="profilePage">Profile</div>
Expand All @@ -40,7 +40,7 @@
<div id="profilePage" class="menuPage active">
<p>Change name / colors</p>
<div id="userProfile" class="msg-group mt-md mb-sm" data-profile-background>
<img id="changeAvatar" class="avatar cursor-inherit" src="/avatars/anon.png" data-profile-avatar>
<img id="changeAvatar" class="avatar cursor-inherit" src="avatars/anon.png" data-profile-avatar>
<div class="col">
<div id="userProfileNameRow">
<div id="userProfileName" class="author" autocomplete="off" autocorrect="off" spellcheck="false" data-profile-name>anon</div>
Expand Down Expand Up @@ -114,16 +114,16 @@
</div>
<div id="profilePopover" class="hidden">
<div id="profilePopoverRow">
<img id="profilePopoverAvatar" src="/avatars/anon.png" data-profile-popover-avatar>
<img id="profilePopoverAvatar" src="avatars/anon.png" data-profile-popover-avatar>
<div id="profilePopoverName" data-profile-popover-name>anon</div>
</div>
<div id="profilePopoverBio" data-profile-popover-bio></div>
</div>
<ul id="messageContextMenu" class="hidden bad" data-id="">
<li class="bad">Delete message</li>
</ul>
<script src="/purify.min.js"></script>
<script src="/coloris.min.js"></script>
<script src="/petal.js"></script>
<script src="purify.min.js"></script>
<script src="coloris.min.js"></script>
<script src="petal.js"></script>
</body>
</html>
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{ "dependencies": { "dompurify": "^3.0.11", "jsdom": "^24.0.0" } }
{"dependencies":{"dompurify":"^3.0.11","jsdom":"^24.0.0","tough-cookie":"^4.1.4"}}
2 changes: 1 addition & 1 deletion petal.css
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ button:focus-visible, button:hover {
outline: none;
}

input {
input:not([type="range"]) {
background-color: var(--lighten);
border: 1px solid var(--lightener);
color: #ffffff;
Expand Down
19 changes: 16 additions & 3 deletions petal.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ premiumCurrencyEmoji = '&#x1F338;',
premiumCurrencyName = 'Blossom',
maxMessageLength = 500,
maxBioLength = 500,
maxBioLines = 5,
sanitize = s => DOMPurify.sanitize(s, sanitizeConfig),
validName = s => s.length > 0 && !/[^0-9a-z]/i.test(s),
validHexColor = s => s.length === 7 && /#[0-9a-f]{6}/i.test(s),
Expand Down Expand Up @@ -639,9 +640,14 @@ const payloadHandlers = {
profilePopover.style.backgroundColor = payload.bgColor
profilePopoverBio.innerHTML = processText(payload.bio) || '<div class="no-bio"></div>'
profilePopover.classList.remove('hidden')

if (Number(profilePopover.style.top.replace('px', '')) > (window.innerHeight/2)){

profilePopover.style.top = (Number(profilePopover.style.top.replace('px', '')) -profilePopover.offsetHeight) + 'px'}
profilePopover.style.left = Math.min(window.innerWidth - profilePopover.offsetWidth, Number(profilePopover.style.left.replace('px', ''))) + 'px'
profilePopover.style.top = Math.min(window.innerHeight - profilePopover.offsetHeight, Number(profilePopover.style.top.replace('px', ''))) + 'px'

profilePopoverOpen = true

},
'bio-auth-required': payload => {
menuDataElements.bioInfo.innerText = 'Change name before writing bio'
Expand Down Expand Up @@ -842,6 +848,7 @@ const events = {
if (reconnectInterval !== -1) {
server = connect(data.server)
}

}, 1000)
}
} else {
Expand Down Expand Up @@ -1581,15 +1588,21 @@ menuDataElements.bio.addEventListener('input', event => saveBio.classList.remove

saveBio.addEventListener('click', event => {
saveBio.classList.add('hidden')
if (menuDataElements.bio.value.length <= maxBioLength) {
if (menuDataElements.bio.value.length <= maxBioLength && menuDataElements.bio.value.split(/\r\n|\r|\n/).length<maxBioLines ) {
send({
type: 'bio',
bio: sanitize(menuDataElements.bio.value)
})
} else {
}else if(menuDataElements.bio.value.length > maxBioLength) {
menuDataElements.bioInfo.innerText = `Bio cannot be longer than ${maxBioLength} characters`
menuDataElements.bioInfo.classList.remove('hidden')
}
else if(menuDataElements.bio.value.split(/\r\n|\r|\n/).length>maxBioLines){

menuDataElements.bioInfo.innerText= `Bio cannot be longer than ${maxBioLines} lines vertically`
menuDataElements.bioInfo.classList.remove('hidden')

}
})

let passwordCheckTimeout = null
Expand Down