add checkbox in popup and handle case in popup.js

This commit is contained in:
manto89 2023-06-19 00:02:19 +02:00
parent b731a051f1
commit 82c1b21d64
2 changed files with 9 additions and 0 deletions

View File

@ -27,6 +27,10 @@
<div id="save-link-with-note-wrapper">
<textarea id="save-link-with-note-textarea" rows="5"></textarea>
<div>
<input type="checkbox" id="keep-title-checkbox" name="keep-title-checkbox" value="Bike">
<label for="keep-title-checkbox">Keep page title as note title</label><br>
</div>
<div style="display: flex;">
<button type="submit" class="button wide" id="save-button">Save</button>

View File

@ -35,6 +35,7 @@ $saveTabsButton.on("click", () => sendMessage({name: 'save-tabs'}));
const $saveLinkWithNoteWrapper = $("#save-link-with-note-wrapper");
const $textNote = $("#save-link-with-note-textarea");
const $keepTitle = $("#keep-title-checkbox");
$textNote.on('keypress', function (event) {
if ((event.which === 10 || event.which === 13) && event.ctrlKey) {
@ -66,6 +67,10 @@ async function saveLinkWithNote() {
title = '';
content = '';
}
else if ($keepTitle[0].checked){
title = '';
content = textNoteVal;
}
else {
const match = /^(.*?)([.?!]\s|\n)/.exec(textNoteVal);