From 65d281066d910a72a12407f089d6d09c1aa83422 Mon Sep 17 00:00:00 2001 From: mudasir-murtaza Date: Thu, 17 Oct 2024 11:22:26 +0500 Subject: [PATCH 1/4] Added keyboard shortcuts for adding tasks and submitting edits (fixes issue #18) --- script.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/script.js b/script.js index 55ea114..123569f 100644 --- a/script.js +++ b/script.js @@ -332,6 +332,20 @@ document.addEventListener('DOMContentLoaded', () => { const inputNameElement = document.querySelector('.js-name-input'); inputNameElement.focus(); + // Add event listener for "Enter" key to trigger add or edit + document.querySelector('.js-name-input').addEventListener('keydown', (e) => { + if (e.key === 'Enter') { + if (isEditing) { + // If in edit mode, call addTodo to update the task + addTodo(); + } else { + // If not in edit mode, call addTodo to add a new task + addTodo(); + } + } + }); + + // Hide edit cancel action button on page load const cancelEditBtn = document.querySelector('.js-cancel-button'); cancelEditBtn.style.display = 'none'; From 73c128e5c4df756eee02e7b4c4da2aa829e4032a Mon Sep 17 00:00:00 2001 From: Mudasir Murtaza <109586296+mudasirmurtaza@users.noreply.github.com> Date: Thu, 17 Oct 2024 11:35:31 +0500 Subject: [PATCH 2/4] Create lint-and-format.yml Signed-off-by: Mudasir Murtaza <109586296+mudasirmurtaza@users.noreply.github.com> --- .github/workflows/lint-and-format.yml | 28 +++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 .github/workflows/lint-and-format.yml diff --git a/.github/workflows/lint-and-format.yml b/.github/workflows/lint-and-format.yml new file mode 100644 index 0000000..ae49937 --- /dev/null +++ b/.github/workflows/lint-and-format.yml @@ -0,0 +1,28 @@ +name: Lint and Format + +on: + pull_request: + branches: + - main + +jobs: + format: + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Setup Node.js + uses: actions/setup-node@v2 + with: + node-version: '16' # You can specify the version you need + + - name: Install dependencies + run: npm install --save-dev prettier + + - name: Check formatting + run: npx prettier --check . + + - name: Format code + run: npx prettier --write . From 1697e56e7832fa263374dc88a5c1fd20b2e91193 Mon Sep 17 00:00:00 2001 From: Mudasir Murtaza <109586296+mudasirmurtaza@users.noreply.github.com> Date: Thu, 17 Oct 2024 11:37:44 +0500 Subject: [PATCH 3/4] Update format.yml Signed-off-by: Mudasir Murtaza <109586296+mudasirmurtaza@users.noreply.github.com> --- .github/workflows/format.yml | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml index 8437d2a..33bb137 100644 --- a/.github/workflows/format.yml +++ b/.github/workflows/format.yml @@ -1,9 +1,6 @@ -name: Format +name: Lint and Format on: - push: - branches: - - main pull_request: branches: - main @@ -14,16 +11,18 @@ jobs: steps: - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v2 - - name: Set up Node.js - uses: actions/setup-node@v3 + - name: Setup Node.js + uses: actions/setup-node@v2 with: - node-version: '20' + node-version: '20' - name: Install dependencies - run: npm install + run: npm install --save-dev prettier + + - name: Check formatting + run: npx prettier --check . - - name: Run Prettier to check formatting - run: npm run prettier -- --check - continue-on-error: false + - name: Format code + run: npx prettier --write . From 50ffb7ae23ab4b975a5e6fc4722d058ddf9e9578 Mon Sep 17 00:00:00 2001 From: Mudasir Murtaza <109586296+mudasirmurtaza@users.noreply.github.com> Date: Thu, 17 Oct 2024 11:46:23 +0500 Subject: [PATCH 4/4] Update format.yml Signed-off-by: Mudasir Murtaza <109586296+mudasirmurtaza@users.noreply.github.com> --- .github/workflows/format.yml | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/.github/workflows/format.yml b/.github/workflows/format.yml index 33bb137..2ec4d52 100644 --- a/.github/workflows/format.yml +++ b/.github/workflows/format.yml @@ -1,28 +1,26 @@ -name: Lint and Format +name: Format on: + push: + branches: + - main pull_request: branches: - main - -jobs: - format: - runs-on: ubuntu-latest +@@ -14,16 +11,18 @@ jobs: steps: - name: Checkout code - uses: actions/checkout@v2 + uses: actions/checkout@v3 - - name: Setup Node.js - uses: actions/setup-node@v2 + - name: Set up Node.js + uses: actions/setup-node@v3 with: - node-version: '20' + node-version: '20' - name: Install dependencies - run: npm install --save-dev prettier - - - name: Check formatting - run: npx prettier --check . + run: npm install - - name: Format code - run: npx prettier --write . + - name: Run Prettier to check formatting + run: npm run prettier -- --check + continue-on-error: false