From 423733ab0d391f23f12ca81efe6fbab410819e40 Mon Sep 17 00:00:00 2001 From: Jules Laplace Date: Thu, 26 Apr 2018 19:35:28 +0200 Subject: more subtle --- css/sally.css | 1 + js/upload.js | 1 + js/user.js | 6 +++--- js/util.js | 17 +++++++++++++++++ 4 files changed, 22 insertions(+), 3 deletions(-) diff --git a/css/sally.css b/css/sally.css index 4c4a576..7d37f34 100644 --- a/css/sally.css +++ b/css/sally.css @@ -214,6 +214,7 @@ textarea { font-size:12pt; width: 37vw; height: 300px; background: #333; color: border: 1px solid #0f0; color: #0f0; width: 100%; + max-width: 360px; } #upload_button.uploading { background: transparent; diff --git a/js/upload.js b/js/upload.js index c50f285..d60ae54 100644 --- a/js/upload.js +++ b/js/upload.js @@ -29,6 +29,7 @@ var upload = (function(){ el.style.display = "block" el.value = data.url el.focus() + setCaretToPos(el, 0) button.innerHTML = "upload" button.className = "" uploading = false diff --git a/js/user.js b/js/user.js index e6ff6a1..79d8b32 100644 --- a/js/user.js +++ b/js/user.js @@ -13,10 +13,10 @@ var user = (function(){ user.load = function(){ user.username = user.getCookie() if (! user.username) { - user.username = 'rando' + randint(9876876) + user.username = '_' + randint(9876876) user.setCookie(user.username) } - if (!user.username.match(/^rando/)) { + if (!user.username.match(/^_/)) { el.value = user.username } } @@ -54,7 +54,7 @@ var user = (function(){ }) } user.setCookie = function(username){ - if (!user.username.match(/^rando/)) { + if (!user.username.match(/^_/)) { console.log("setting to " + username) } document.cookie = "imname="+username+";path=/;domain=.asdf.us;max-age=1086400" diff --git a/js/util.js b/js/util.js index f2fd129..ca97630 100644 --- a/js/util.js +++ b/js/util.js @@ -174,6 +174,23 @@ function defaults (dest, src) { return dest } +function setSelectionRange(input, selectionStart, selectionEnd) { + if (input.setSelectionRange) { + input.focus(); + input.setSelectionRange(selectionStart, selectionEnd); + } + else if (input.createTextRange) { + var range = input.createTextRange(); + range.collapse(true); + range.moveEnd('character', selectionEnd); + range.moveStart('character', selectionStart); + range.select(); + } +} +function setCaretToPos(input, pos) { + setSelectionRange(input, pos, pos); +} + // Naive useragent detection pattern var is_iphone = (navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i)) var is_ipad = (navigator.userAgent.match(/iPad/i)) -- cgit v1.2.3-70-g09d2