Updated, cleaned

This commit is contained in:
Eugene Serb 2022-06-21 17:47:39 +03:00
parent 607567788a
commit e90622e8a3
3 changed files with 12 additions and 236 deletions

View File

@ -96,7 +96,7 @@
<div class="wavelovers"> <div class="wavelovers">
<div class="content-item"> <div class="content-item">
<h2 class="content-item__header">Buy Pro</h2> <h2 class="content-item__header">Buy Pro</h2>
<p>Pre order of the PRO version just for $5.</p> <p>Pre order of the PRO version just for $5. Dates of the Release will be announced later.</p>
<br /> <br />
<span>Write me: </span> <span>Write me: </span>
<a href="mailto:eugene.serb@gmail.com" target="_blank">eugene.serb@gmail.com</a> <a href="mailto:eugene.serb@gmail.com" target="_blank">eugene.serb@gmail.com</a>
@ -117,7 +117,7 @@
<td>+</td> <td>+</td>
</tr> </tr>
<tr> <tr>
<td>Gamepad buttons</td> <td>Control with a Gamepad</td>
<td>-</td> <td>-</td>
<td>+</td> <td>+</td>
</tr> </tr>
@ -126,6 +126,16 @@
<td>-</td> <td>-</td>
<td>+</td> <td>+</td>
</tr> </tr>
<tr>
<td>Additional patterns</td>
<td>-</td>
<td>+</td>
</tr>
<tr>
<td>Full control over gamepads</td>
<td>-</td>
<td>+</td>
</tr>
</tbody> </tbody>
<tfoot> <tfoot>
<tr> <tr>

View File

@ -188,13 +188,10 @@ class Gamepad {
init = () => { init = () => {
this.id = Date.now(); this.id = Date.now();
this.canVibrate = (this.unit.vibrationActuator) ? true : false; this.canVibrate = (this.unit.vibrationActuator) ? true : false;
this.isSelected = false;
this.isVibrating = false; this.isVibrating = false;
this.isLocked = false;
this.library = new Library; this.library = new Library;
this.cooldown = 0;
this.index = 0; this.index = 0;
this.pattern = this.library.patterns[this.index].pattern; this.pattern = this.library.patterns[this.index].pattern;
@ -255,35 +252,6 @@ class Gamepad {
sleep = (ms) => { sleep = (ms) => {
return new Promise(resolve => setTimeout(resolve, ms)); return new Promise(resolve => setTimeout(resolve, ms));
}; };
previous = () => {
if (Date.now() >= this.cooldown) {
if (this.index === 0) {
this.index = this.library.patterns.length - 1;
} else {
this.index--;
};
this.pattern = this.library.patterns[this.index].pattern;
this.cooldown = Date.now() + 500;
};
};
next = () => {
if (Date.now() >= this.cooldown) {
if (this.index === this.library.patterns.length - 1) {
this.index = 0;
} else {
this.index++;
};
this.pattern = this.library.patterns[this.index].pattern;
this.cooldown = Date.now() + 500;
};
};
lock = () => {
if (Date.now() >= this.cooldown) {
this.isLocked = !this.isLocked;
this.cooldown = Date.now() + 500;
};
};
change = (index) => { change = (index) => {
this.index = index; this.index = index;
this.pattern = this.library.patterns[this.index].pattern; this.pattern = this.library.patterns[this.index].pattern;
@ -337,50 +305,7 @@ class Wavelovers {
}); });
}; };
}; };
eventHandler = () => {
if (this.gamepads.length > 0) {
this.gamepads.forEach(gamepad => {
if (gamepad.canVibrate === true) {
if (gamepad.unit.buttons[2].pressed === true &&
gamepad.unit.buttons[3].pressed === true) {
gamepad.lock();
};
if (gamepad.isLocked === false) {
if (gamepad.unit.buttons[0].pressed === true) {
if (gamepad.isVibrating === false) {
gamepad.vibrate();
};
};
if (gamepad.unit.buttons[1].pressed === true) {
gamepad.reset();
};
if (gamepad.unit.buttons[4].pressed === true) {
gamepad.previous();
};
if (gamepad.unit.buttons[5].pressed === true) {
gamepad.next();
};
};
};
});
};
};
load = async () => {
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) => { print = (patterns) => {
this.$PATTERN_LIST.innerHTML = ''; this.$PATTERN_LIST.innerHTML = '';
patterns.forEach((pattern, index) => { patterns.forEach((pattern, index) => {

View File

@ -1,159 +0,0 @@
[
{
"name": "Dotted Weak",
"type": "Simple",
"icon": "😌",
"pattern": [
{
"startDelay": 100,
"duration": 100,
"weakMagnitude": 1.0,
"strongMagnitude": 0.0
}
]
},
{
"name": "Dotted Strong",
"type": "Simple",
"icon": "😉",
"pattern": [
{
"startDelay": 100,
"duration": 100,
"weakMagnitude": 0.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
}
]
}
]