diff --git a/js/scripts.js b/js/scripts.js
index d872d56..48fc5c5 100644
--- a/js/scripts.js
+++ b/js/scripts.js
@@ -5,166 +5,45 @@
'use strict';
const __PATTERNS = [
- /* Dotted, 0.1s, 0.1s */
{
- name: 'Dotted Weak',
- type: 'Simple',
- icon: '😌',
- pattern: [
+ "name": "Constant Weak",
+ "type": "Simple",
+ "icon": "😏",
+ "pattern": [
{
- startDelay: 100,
- duration: 100,
- weakMagnitude: 1.0,
- strongMagnitude: 0.0,
- },
- ],
+ "startDelay": 0,
+ "duration": 1000,
+ "weakMagnitude": 1.0,
+ "strongMagnitude": 0.0
+ }
+ ]
},
{
- name: 'Dotted Strong',
- type: 'Simple',
- icon: '😉',
- pattern: [
+ "name": "Constant Strong",
+ "type": "Simple",
+ "icon": "🤩",
+ "pattern": [
{
- startDelay: 100,
- duration: 100,
- weakMagnitude: 0.0,
- strongMagnitude: 1.0,
- },
- ],
+ "startDelay": 0,
+ "duration": 1000,
+ "weakMagnitude": 0.0,
+ "strongMagnitude": 1.0
+ }
+ ]
},
{
- name: 'Dotted Max',
- type: 'Simple',
- icon: '🙃',
- pattern: [
+ "name": "Constant Max",
+ "type": "Simple",
+ "icon": "😍",
+ "pattern": [
{
- startDelay: 100,
- duration: 100,
- weakMagnitude: 1.0,
- strongMagnitude: 1.0,
- },
- ],
- },
- /* Short Dashed, 0.1s, 0.25s */
- {
- name: 'Short Dashed Weak',
- type: 'Simple',
- icon: '🙂',
- pattern: [
- {
- startDelay: 100,
- duration: 250,
- weakMagnitude: 1.0,
- strongMagnitude: 0.0,
- },
- ],
- },
- {
- name: 'Short Dashed Strong',
- type: 'Simple',
- icon: '😇',
- pattern: [
- {
- startDelay: 100,
- duration: 250,
- weakMagnitude: 0.0,
- strongMagnitude: 1.0,
- },
- ],
- },
- {
- name: 'Short Dashed Max',
- type: 'Simple',
- icon: '😊',
- pattern: [
- {
- startDelay: 100,
- duration: 250,
- weakMagnitude: 1.0,
- strongMagnitude: 1.0,
- },
- ],
- },
- /* Long Dashed, 0.1s, 0.5s */
- {
- name: 'Long Dashed Weak',
- type: 'Simple',
- icon: '😋',
- pattern: [
- {
- startDelay: 100,
- duration: 500,
- weakMagnitude: 1.0,
- strongMagnitude: 0.0,
- },
- ],
- },
- {
- name: 'Long Dashed Strong',
- type: 'Simple',
- icon: '😜',
- pattern: [
- {
- startDelay: 100,
- duration: 500,
- weakMagnitude: 0.0,
- strongMagnitude: 1.0,
- },
- ],
- },
- {
- name: 'Long Dashed Max',
- type: 'Simple',
- icon: '🤪',
- pattern: [
- {
- startDelay: 100,
- duration: 500,
- weakMagnitude: 1.0,
- strongMagnitude: 1.0,
- },
- ],
- },
- /* Constant, 0s, 1s */
- {
- name: 'Constant Weak',
- type: 'Simple',
- icon: '😏',
- pattern: [
- {
- startDelay: 0,
- duration: 1000,
- weakMagnitude: 1.0,
- strongMagnitude: 0.0,
- },
- ],
- },
- {
- name: 'Constant Strong',
- type: 'Simple',
- icon: '🤩',
- pattern: [
- {
- startDelay: 0,
- duration: 1000,
- weakMagnitude: 0.0,
- strongMagnitude: 1.0,
- },
- ],
- },
- {
- name: 'Constant Max',
- type: 'Simple',
- icon: '😍',
- pattern: [
- {
- startDelay: 0,
- duration: 1000,
- weakMagnitude: 1.0,
- strongMagnitude: 1.0,
- },
- ],
- },
+ "startDelay": 0,
+ "duration": 1000,
+ "weakMagnitude": 1.0,
+ "strongMagnitude": 1.0
+ }
+ ]
+ }
];
class Gamepad {
@@ -289,9 +168,6 @@ class VibrationMaster {
};
init = () => {
this.#DOMs();
- this.patterns = __PATTERNS;
- this.print(this.patterns);
-
this.load();
if (!this.checkGamepadSupport()) {
@@ -360,9 +236,19 @@ class VibrationMaster {
};
};
- load = () => {
- const response = fetch('./json/patterns.json');
- console.log(response);
+ load = async () => {
+ const url = './json/patterns.json';
+
+ const response = await fetch(url);
+
+ if (response.ok) {
+ let json = await response.json();
+ this.pattern = json;
+ this.print(this.pattern);
+ } else {
+ this.pattern = __PATTERNS;
+ this.print(this.pattern);
+ };
};
print = (patterns) => {
this.$PATTERN_LIST.innerHTML = '';
From 99031063828fab9352966cda2be16afed8363fc2 Mon Sep 17 00:00:00 2001
From: Eugene Serb <46799701+eugene-serb@users.noreply.github.com>
Date: Sat, 18 Jun 2022 23:11:09 +0300
Subject: [PATCH 08/46] Added singleton library, deleted patterns in
constructors
---
feedback.html | 2 +-
js/scripts.js | 275 +++++++++++++++++++++++++++++++++++++-------------
2 files changed, 204 insertions(+), 73 deletions(-)
diff --git a/feedback.html b/feedback.html
index c0e7b9d..a191413 100644
--- a/feedback.html
+++ b/feedback.html
@@ -98,7 +98,7 @@
-
Hi, friend! I am the author and developer of Wavelovers app and I want to thank you for using this app. If you have any ideas or wishes, you can write to me.
+
Hi! I am the author and developer of Wavelovers app and I want to thank you for using this app. If you have any ideas or wishes, you can write to me.
Follow me on Twitter:
@eugene_serb
diff --git a/js/scripts.js b/js/scripts.js
index 48fc5c5..57cc9c9 100644
--- a/js/scripts.js
+++ b/js/scripts.js
@@ -4,53 +4,184 @@
'use strict';
-const __PATTERNS = [
- {
- "name": "Constant Weak",
- "type": "Simple",
- "icon": "😏",
- "pattern": [
+class Library {
+ constructor() {
+ if (typeof Library.instance === 'object') {
+ return Library.instance;
+ };
+ this.init();
+ Library.instance = this;
+ return this;
+ };
+ init = () => {
+ this.patterns = this.getBase();
+ };
+ getBase = () => {
+ return [
{
- "startDelay": 0,
- "duration": 1000,
- "weakMagnitude": 1.0,
- "strongMagnitude": 0.0
- }
- ]
- },
- {
- "name": "Constant Strong",
- "type": "Simple",
- "icon": "🤩",
- "pattern": [
+ "name": "Dotted Weak",
+ "type": "Simple",
+ "icon": "😌",
+ "pattern": [
+ {
+ "startDelay": 100,
+ "duration": 100,
+ "weakMagnitude": 1.0,
+ "strongMagnitude": 0.0
+ }
+ ]
+ },
{
- "startDelay": 0,
- "duration": 1000,
- "weakMagnitude": 0.0,
- "strongMagnitude": 1.0
- }
- ]
- },
- {
- "name": "Constant Max",
- "type": "Simple",
- "icon": "😍",
- "pattern": [
+ "name": "Dotted Strong",
+ "type": "Simple",
+ "icon": "😉",
+ "pattern": [
+ {
+ "startDelay": 100,
+ "duration": 100,
+ "weakMagnitude": 0.0,
+ "strongMagnitude": 1.0
+ }
+ ]
+ },
{
- "startDelay": 0,
- "duration": 1000,
- "weakMagnitude": 1.0,
- "strongMagnitude": 1.0
+ "name": "Dotted Max",
+ "type": "Simple",
+ "icon": "🙃",
+ "pattern": [
+ {
+ "startDelay": 100,
+ "duration": 100,
+ "weakMagnitude": 1.0,
+ "strongMagnitude": 1.0
+ }
+ ]
+ },
+ {
+ "name": "Short Dashed Weak",
+ "type": "Simple",
+ "icon": "🙂",
+ "pattern": [
+ {
+ "startDelay": 100,
+ "duration": 250,
+ "weakMagnitude": 1.0,
+ "strongMagnitude": 0.0
+ }
+ ]
+ },
+ {
+ "name": "Short Dashed Strong",
+ "type": "Simple",
+ "icon": "😇",
+ "pattern": [
+ {
+ "startDelay": 100,
+ "duration": 250,
+ "weakMagnitude": 0.0,
+ "strongMagnitude": 1.0
+ }
+ ]
+ },
+ {
+ "name": "Short Dashed Max",
+ "type": "Simple",
+ "icon": "😊",
+ "pattern": [
+ {
+ "startDelay": 100,
+ "duration": 250,
+ "weakMagnitude": 1.0,
+ "strongMagnitude": 1.0
+ }
+ ]
+ },
+ {
+ "name": "Long Dashed Weak",
+ "type": "Simple",
+ "icon": "😋",
+ "pattern": [
+ {
+ "startDelay": 100,
+ "duration": 500,
+ "weakMagnitude": 1.0,
+ "strongMagnitude": 0.0
+ }
+ ]
+ },
+ {
+ "name": "Long Dashed Strong",
+ "type": "Simple",
+ "icon": "😜",
+ "pattern": [
+ {
+ "startDelay": 100,
+ "duration": 500,
+ "weakMagnitude": 0.0,
+ "strongMagnitude": 1.0
+ }
+ ]
+ },
+ {
+ "name": "Long Dashed Max",
+ "type": "Simple",
+ "icon": "🤪",
+ "pattern": [
+ {
+ "startDelay": 100,
+ "duration": 500,
+ "weakMagnitude": 1.0,
+ "strongMagnitude": 1.0
+ }
+ ]
+ },
+ {
+ "name": "Constant Weak",
+ "type": "Simple",
+ "icon": "😏",
+ "pattern": [
+ {
+ "startDelay": 0,
+ "duration": 1000,
+ "weakMagnitude": 1.0,
+ "strongMagnitude": 0.0
+ }
+ ]
+ },
+ {
+ "name": "Constant Strong",
+ "type": "Simple",
+ "icon": "🤩",
+ "pattern": [
+ {
+ "startDelay": 0,
+ "duration": 1000,
+ "weakMagnitude": 0.0,
+ "strongMagnitude": 1.0
+ }
+ ]
+ },
+ {
+ "name": "Constant Max",
+ "type": "Simple",
+ "icon": "😍",
+ "pattern": [
+ {
+ "startDelay": 0,
+ "duration": 1000,
+ "weakMagnitude": 1.0,
+ "strongMagnitude": 1.0
+ }
+ ]
}
- ]
- }
-];
+ ];
+ };
+};
class Gamepad {
- constructor(gamepad, $container, library) {
+ constructor(gamepad, $container) {
this.unit = gamepad;
this.$container = $container;
- this.library = library;
this.init();
};
@@ -60,16 +191,13 @@ class Gamepad {
this.isSelected = false;
this.isVibrating = false;
this.isLocked = false;
+
+ this.library = new Library;
+
this.cooldown = 0;
this.index = 0;
- this.pattern = [
- {
- startDelay: 0,
- duration: 1000,
- weakMagnitude: 1.0,
- strongMagnitude: 1.0,
- }
- ];
+ this.pattern = this.library.patterns[this.index].pattern;
+
this.generateBox();
};
@@ -111,7 +239,7 @@ class Gamepad {
};
vibrate = async () => {
this.isVibrating = true;
- this.pattern = this.library[this.index].pattern;
+ this.pattern = this.library.patterns[this.index].pattern;
while (this.isVibrating) {
for (let i = 0; i < this.pattern.length; i++) {
@@ -130,22 +258,22 @@ class Gamepad {
previous = () => {
if (Date.now() >= this.cooldown) {
if (this.index === 0) {
- this.index = this.library.length - 1;
+ this.index = this.library.patterns.length - 1;
} else {
this.index--;
};
- this.pattern = this.library[this.index].pattern;
+ this.pattern = this.library.patterns[this.index].pattern;
this.cooldown = Date.now() + 500;
};
};
next = () => {
if (Date.now() >= this.cooldown) {
- if (this.index === this.library.length - 1) {
+ if (this.index === this.library.patterns.length - 1) {
this.index = 0;
} else {
this.index++;
};
- this.pattern = this.library[this.index].pattern;
+ this.pattern = this.library.patterns[this.index].pattern;
this.cooldown = Date.now() + 500;
};
};
@@ -158,7 +286,7 @@ class Gamepad {
change = (index) => {
this.index = index;
- this.pattern = this.library[this.index].pattern;
+ this.pattern = this.library.patterns[this.index].pattern;
};
};
@@ -168,7 +296,9 @@ class VibrationMaster {
};
init = () => {
this.#DOMs();
- this.load();
+
+ this.library = new Library();
+ this.print(this.library.patterns);
if (!this.checkGamepadSupport()) {
console.log(`This browser does not support of gamepads.`);
@@ -237,17 +367,18 @@ class VibrationMaster {
};
load = async () => {
- const url = './json/patterns.json';
-
- const response = await fetch(url);
-
- if (response.ok) {
- let json = await response.json();
- this.pattern = json;
- this.print(this.pattern);
- } else {
- this.pattern = __PATTERNS;
- this.print(this.pattern);
+ const url = 'https://eugene-serb.github.io/wavelovers/json/patterns.json';
+ try {
+ const response = await fetch(url);
+ if (response.ok) {
+ let json = await response.json();
+ this.library.patterns = json;
+ this.print(this.library.patterns);
+ } else {
+ console.log('Connect to the Internet for download more patterns...');
+ };
+ } catch (error) {
+ console.log('[error]', error);
};
};
print = (patterns) => {
@@ -277,7 +408,7 @@ class VibrationMaster {
if (this.gamepads.length > 0) {
this.gamepads.forEach(gamepad => {
if (gamepad.canVibrate === true) {
- this.unselect();
+ this.unselect(this.library.patterns);
if (gamepad.index === index &&
gamepad.isVibrating === true) {
gamepad.reset();
@@ -285,7 +416,7 @@ class VibrationMaster {
gamepad.reset()
gamepad.change(index);
gamepad.vibrate();
- this.select(index);
+ this.select(this.library.patterns, index);
};
};
});
@@ -295,13 +426,13 @@ class VibrationMaster {
};
};
- unselect = () => {
- this.patterns.forEach(pattern => {
+ unselect = (patterns) => {
+ patterns.forEach(pattern => {
pattern['container'].classList.remove('pattern-item__selected');
});
};
- select = (index) => {
- this.patterns[index]['container'].classList.add('pattern-item__selected');
+ select = (patterns, index) => {
+ patterns[index]['container'].classList.add('pattern-item__selected');
};
checkGamepadSupport = () => {
@@ -320,7 +451,7 @@ class VibrationMaster {
if (this.gamepads.length > 1) {
return;
} else {
- this.gamepads.push(new Gamepad(event.gamepad, this.$DEVICE_LIST, this.patterns));
+ this.gamepads.push(new Gamepad(event.gamepad, this.$DEVICE_LIST));
};
});
window.addEventListener('gamepaddisconnected', (event) => {
From 072e0e20a776d62adb9d1343888efa9451d78c8d Mon Sep 17 00:00:00 2001
From: Eugene Serb <46799701+eugene-serb@users.noreply.github.com>
Date: Sun, 19 Jun 2022 11:47:45 +0300
Subject: [PATCH 09/46] Updated feedback.html. Made feedback and donate posts
separated, fix link with new CSS class .link_hash that break all to new lines
---
css/styles.css | 4 ++++
feedback.html | 5 +++--
2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/css/styles.css b/css/styles.css
index 8de64e2..0e517d3 100644
--- a/css/styles.css
+++ b/css/styles.css
@@ -506,3 +506,7 @@ table, th, td {
color: var(--color-white);
}
+.link_hash {
+ word-break: break-all;
+}
+
diff --git a/feedback.html b/feedback.html
index a191413..074197e 100644
--- a/feedback.html
+++ b/feedback.html
@@ -102,12 +102,13 @@
Follow me on Twitter:
@eugene_serb
-
+
+
From 6a1c657c8f9a6722feb839fa04716d3b1da0906d Mon Sep 17 00:00:00 2001
From: Eugene Serb <46799701+eugene-serb@users.noreply.github.com>
Date: Sun, 19 Jun 2022 11:50:32 +0300
Subject: [PATCH 10/46] Updated web manifest
---
site.webmanifest | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/site.webmanifest b/site.webmanifest
index 899dac7..7418fbd 100644
--- a/site.webmanifest
+++ b/site.webmanifest
@@ -1,6 +1,6 @@
{
- "name": "",
- "short_name": "",
+ "name": "Wavelovers",
+ "short_name": "Wavelovers",
"icons": [
{
"src": "https://eugene-serb.github.io/wavelovers/img/android-chrome-192x192.png",
@@ -13,8 +13,8 @@
"type": "image/png"
}
],
- "theme_color": "#ffffff",
- "background_color": "#ffffff",
+ "theme_color": "#EFCFE3",
+ "background_color": "#EFCFE3",
"display": "standalone"
}
From 8b33325c4a8c1790ec4b7a4463265f33622f1305 Mon Sep 17 00:00:00 2001
From: Eugene Serb <46799701+eugene-serb@users.noreply.github.com>
Date: Mon, 20 Jun 2022 16:28:39 +0300
Subject: [PATCH 11/46] Create CNAME
---
CNAME | 1 +
1 file changed, 1 insertion(+)
create mode 100644 CNAME
diff --git a/CNAME b/CNAME
new file mode 100644
index 0000000..db815ff
--- /dev/null
+++ b/CNAME
@@ -0,0 +1 @@
+wavelovers.ru
\ No newline at end of file
From b42d2fc9c6a6a07b608b6ecaa85f9e98ae2d0d46 Mon Sep 17 00:00:00 2001
From: Eugene Serb <46799701+eugene-serb@users.noreply.github.com>
Date: Mon, 20 Jun 2022 16:46:50 +0300
Subject: [PATCH 12/46] Added sitemaps, changed urls, feedback changed about
---
feedback.html => about.html | 74 ++++++++++---------------------------
index.html | 66 ++++++++-------------------------
sitemap-internal.xml | 16 ++++++++
sitemap.xml | 8 ++++
4 files changed, 59 insertions(+), 105 deletions(-)
rename feedback.html => about.html (50%)
create mode 100644 sitemap-internal.xml
create mode 100644 sitemap.xml
diff --git a/feedback.html b/about.html
similarity index 50%
rename from feedback.html
rename to about.html
index 074197e..434c724 100644
--- a/feedback.html
+++ b/about.html
@@ -1,7 +1,7 @@
-
Wavelovers – Feedback
+
Wavelovers – About
@@ -9,67 +9,35 @@
-
-
-
-
-
-
-
+
+
+
+
+
+
+
-
+
-
+
-
-
-
+
+
+
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+