From 9cc11a806c8a3f58a9c4213ed4ada27dac9a3e7e Mon Sep 17 00:00:00 2001
From: paihu
Date: Sat, 11 Jan 2020 22:19:47 +0900
Subject: [PATCH 1/5] =?UTF-8?q?feat:=20#77=20=E3=83=88=E3=82=A5=E3=83=BC?=
=?UTF-8?q?=E3=83=88=E3=81=AE=E4=B8=A6=E3=81=B3=E9=A0=86=E3=82=92=E3=83=95?=
=?UTF-8?q?=E3=83=AA=E3=83=83=E3=83=97=E3=81=99=E3=82=8B=E3=83=9C=E3=82=BF?=
=?UTF-8?q?=E3=83=B3=E3=82=92=E8=BF=BD=E5=8A=A0?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
index.html | 1 +
js/index.js | 19 +++++++++++++++++++
2 files changed, 20 insertions(+)
diff --git a/index.html b/index.html
index 4f33edc..f1e0897 100644
--- a/index.html
+++ b/index.html
@@ -47,6 +47,7 @@
+
diff --git a/js/index.js b/js/index.js
index 0ec808a..2b14d77 100644
--- a/js/index.js
+++ b/js/index.js
@@ -84,6 +84,22 @@ function addCard() {
impl.genPermalink();
}
+function flipCards() {
+ const cards = $("cards");
+ if (!cards) return;
+ let card_nodes = [];
+ while (cards.hasChildNodes()) {
+ card_nodes.push(cards.firstChild);
+ cards.removeChild(cards.firstChild);
+ }
+ if (card_nodes.length == 0) return;
+ while (card_nodes.length > 0) {
+ cards.appendChild(card_nodes.pop());
+ }
+ impl.card_list.reverse();
+ impl.genPermalink();
+}
+
function copyPermalink() {
if (isEmptyPermalink()) {
alertUsageNoPermalink();
@@ -125,4 +141,7 @@ impl.ready(() => {
$("copylink").addEventListener("click", () => {
copyPermalink();
});
+ $("flip").addEventListener("click", () => {
+ flipCards();
+ });
});
From 50fc377499ea61c5821ea8bbd15db484bffdbf59 Mon Sep 17 00:00:00 2001
From: paihu
Date: Sat, 11 Jan 2020 23:32:40 +0900
Subject: [PATCH 2/5] =?UTF-8?q?fix:=E3=83=86=E3=82=AD=E3=82=B9=E3=83=88?=
=?UTF-8?q?=E3=83=8E=E3=83=BC=E3=83=89=E3=81=8C=E3=81=82=E3=82=8A=E3=80=81?=
=?UTF-8?q?flip=E5=BE=8C=E3=82=AB=E3=83=BC=E3=83=89=E9=A0=86=E3=81=8C?=
=?UTF-8?q?=E5=A4=89=E3=81=88=E3=82=89=E3=82=8C=E3=81=AA=E3=81=8F=E3=81=AA?=
=?UTF-8?q?=E3=82=8B=E3=81=AE=E3=82=92=E4=BF=AE=E6=AD=A3?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
js/common.js | 4 ++--
js/index.js | 7 ++++++-
2 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/js/common.js b/js/common.js
index 137a88d..7666a91 100644
--- a/js/common.js
+++ b/js/common.js
@@ -193,10 +193,10 @@ export function handleDrop(e) {
let node_index = -1;
for (let i = 0; i < children.length; i++) {
if (children[i] === src) {
- src_index = i - 1;
+ src_index = i;
}
if (children[i] === node) {
- node_index = i - 1;
+ node_index = i;
}
}
if (src_index < 0) {
diff --git a/js/index.js b/js/index.js
index 2b14d77..3b4401d 100644
--- a/js/index.js
+++ b/js/index.js
@@ -80,6 +80,9 @@ function addCard() {
.reverse()[0]
);
+ if($("cards").hasChildNodes() && $("cards").firstChild.nodeName == "#text") {
+ $("cards").removeChild($("cards").firstChild)
+ }
$("cards").appendChild(clone);
impl.genPermalink();
}
@@ -89,7 +92,9 @@ function flipCards() {
if (!cards) return;
let card_nodes = [];
while (cards.hasChildNodes()) {
- card_nodes.push(cards.firstChild);
+ if(cards.firstChild.nodeName == "#text"){
+ card_nodes.push(cards.firstChild);
+ }
cards.removeChild(cards.firstChild);
}
if (card_nodes.length == 0) return;
From e4a1f3f3548451e8cb9246ab223ac69ebd5a54e4 Mon Sep 17 00:00:00 2001
From: paihu
Date: Sat, 11 Jan 2020 23:39:47 +0900
Subject: [PATCH 3/5] improve: eslint --fix
---
js/index.js | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/js/index.js b/js/index.js
index 3b4401d..64f2783 100644
--- a/js/index.js
+++ b/js/index.js
@@ -80,8 +80,8 @@ function addCard() {
.reverse()[0]
);
- if($("cards").hasChildNodes() && $("cards").firstChild.nodeName == "#text") {
- $("cards").removeChild($("cards").firstChild)
+ if ($("cards").hasChildNodes() && $("cards").firstChild.nodeName == "#text") {
+ $("cards").removeChild($("cards").firstChild);
}
$("cards").appendChild(clone);
impl.genPermalink();
@@ -92,7 +92,7 @@ function flipCards() {
if (!cards) return;
let card_nodes = [];
while (cards.hasChildNodes()) {
- if(cards.firstChild.nodeName == "#text"){
+ if (cards.firstChild.nodeName == "#text") {
card_nodes.push(cards.firstChild);
}
cards.removeChild(cards.firstChild);
From abba4549d438b40a91cba00472dfeb12ae1c3319 Mon Sep 17 00:00:00 2001
From: paihu
Date: Sat, 11 Jan 2020 23:42:11 +0900
Subject: [PATCH 4/5] =?UTF-8?q?fix:=20flip=E3=83=9C=E3=82=BF=E3=83=B3?=
=?UTF-8?q?=E3=81=A7=E5=85=A8toot=E3=81=8C=E6=B6=88=E3=81=88=E3=82=8B?=
=?UTF-8?q?=E3=83=90=E3=82=B0=E3=81=AE=E4=BF=AE=E6=AD=A3?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
js/index.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/js/index.js b/js/index.js
index 64f2783..92b90a6 100644
--- a/js/index.js
+++ b/js/index.js
@@ -92,7 +92,7 @@ function flipCards() {
if (!cards) return;
let card_nodes = [];
while (cards.hasChildNodes()) {
- if (cards.firstChild.nodeName == "#text") {
+ if (cards.firstChild.nodeName !== "#text") {
card_nodes.push(cards.firstChild);
}
cards.removeChild(cards.firstChild);
From 96edc4aea6f30a358deb7d35dad00dcffbe73d5a Mon Sep 17 00:00:00 2001
From: paihu
Date: Sat, 11 Jan 2020 23:44:58 +0900
Subject: [PATCH 5/5] =?UTF-8?q?refactor:=20=E6=AF=94=E8=BC=83=E3=81=AB=20?=
=?UTF-8?q?=3D=3D=20=E3=81=A7=E3=81=AF=E3=81=AA=E3=81=8F=3D=3D=3D=20?=
=?UTF-8?q?=E3=82=92=E4=BD=BF=E3=81=86?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
js/index.js | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/js/index.js b/js/index.js
index 92b90a6..488aabf 100644
--- a/js/index.js
+++ b/js/index.js
@@ -80,7 +80,7 @@ function addCard() {
.reverse()[0]
);
- if ($("cards").hasChildNodes() && $("cards").firstChild.nodeName == "#text") {
+ if ($("cards").hasChildNodes() && $("cards").firstChild.nodeName === "#text") {
$("cards").removeChild($("cards").firstChild);
}
$("cards").appendChild(clone);
@@ -97,7 +97,7 @@ function flipCards() {
}
cards.removeChild(cards.firstChild);
}
- if (card_nodes.length == 0) return;
+ if (card_nodes.length === 0) return;
while (card_nodes.length > 0) {
cards.appendChild(card_nodes.pop());
}