perf: updated lib, typing issues (#195)

Fixes deduplication of stuff
and fixes the deprecated warnings by changing the methods to use the new one.

Signed-off-by: Darren <git@darrennathanael.com>
This commit is contained in:
Darren 2022-04-03 00:38:37 -05:00 committed by GitHub
parent 8dfbb2e352
commit a9e843367a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 5 deletions

View File

@ -3,7 +3,7 @@
// -----------------------------------------------------------------------------
// Add data-platform to the body tag to show platform related shortcuts
// -----------------------------------------------------------------------------
const isMac = navigator.platform.indexOf('Mac') !== -1;
const isMac = navigator.userAgentData.platform.includes('Mac') !== -1;
document.body.dataset.platform = isMac ? 'mac' : 'win';
// -----------------------------------------------------------------------------
@ -108,7 +108,8 @@ if (clipboardLink && clipboardField) {
clipboardLink.onclick = function(e) {
e.preventDefault();
clipboardField.select();
document.execCommand('Copy');
// because execCommand is deprecated.
navigator.clipboard.writeText(clipboardField.value);
};
}
@ -123,7 +124,8 @@ if (snippetClipboardLink && snippetClipboardField) {
snippetClipboardLink.onclick = function(e) {
e.preventDefault();
snippetClipboardField.select();
document.execCommand('Copy');
// because execCommand is deprecated.
navigator.clipboard.writeText(snippetClipboardField.value);
snippetClipboardConfirm.style.maxHeight = '80px';
window.scrollTo(0, 0);
};

View File

@ -51,10 +51,11 @@
.form-lexer { grid-area: a;}
.form-expire { grid-area: b; }
.form-rtl { grid-area: c; white-space: nowrap; }
.form-action { grid-area: d; }
// .form-action { grid-area: d; }
.form-textarea { grid-area: e; }
.form-action {
grid-area: d;
.btn {
width: auto;
padding: 6px 20px;

View File

@ -19,7 +19,8 @@ def get_expire_values(expires):
expires = None
else:
expire_type = Snippet.EXPIRE_TIME
expires = expires and expires or config.EXPIRE_DEFAULT
# Correct one of the identical sub-expressions on both sides of operator "and".
expires = expires or config.EXPIRE_DEFAULT
expires = datetime.datetime.now() + datetime.timedelta(seconds=int(expires))
return expires, expire_type