mirror of
https://codeberg.org/vlw/monkeydo.git
synced 2025-09-13 15:53:40 +02:00
Renamed "worker" to "do"
Renaming the "worker" folder to "do" so we can add more workers without having to cram them all in one folder.
This commit is contained in:
parent
c275186126
commit
17224b0a86
3 changed files with 19 additions and 3 deletions
|
@ -1,4 +1,4 @@
|
|||
import { default as MonkeyWorker } from "./worker/MonkeyManager.mjs";
|
||||
import { default as MonkeyWorker } from "./do/MonkeyManager.mjs";
|
||||
|
||||
export default class Monkeydo extends MonkeyWorker {
|
||||
constructor(methods = {},manifest = false) {
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
// Task scheduler and iterator of Monkeydo manifests
|
||||
// Dedicated worker which executes tasks from a Monkeydo manifest
|
||||
|
||||
class Monkey {
|
||||
constructor(manifest) {
|
||||
const self = this;
|
||||
this.data = manifest.body;
|
||||
this.dataLength = this.data.length - 1;
|
||||
|
||||
|
@ -9,6 +10,19 @@ class Monkey {
|
|||
playing: 0,
|
||||
stacking: 0, // Subsequent calls to play() will build a queue (jQuery-style)
|
||||
loop: 0, // Loop n times; <0 = infinite
|
||||
_forwards: 1, // Playback direction
|
||||
set forwards(forwards = true) {
|
||||
if(forwards == this._forwards) {
|
||||
return false;
|
||||
}
|
||||
// Toggle playback direction
|
||||
console.log(this);
|
||||
self.data = self.data.reverse();
|
||||
this._forwards = 1 - this._forwards;
|
||||
},
|
||||
get forwards() {
|
||||
return this._forwards;
|
||||
}
|
||||
}
|
||||
|
||||
this.i = 0; // Manifest iterator index
|
||||
|
@ -37,7 +51,7 @@ class Monkey {
|
|||
play() {
|
||||
// Stack playback as loops if flag is set
|
||||
if(this.flags.playing) {
|
||||
if(this.flags.stacking) {
|
||||
if(this.flags.stacking && this.flags.loop >= 0) {
|
||||
this.flags.loop++;
|
||||
}
|
||||
return;
|
|
@ -13,6 +13,8 @@ export default class MonkeyManager {
|
|||
// Spawn a dedicated worker for scheduling events from manifest
|
||||
this.worker = new Worker(location + "Monkey.js");
|
||||
this.worker.addEventListener("message",message => this.message(message));
|
||||
|
||||
this.reversed = false;
|
||||
}
|
||||
|
||||
// Get a status flag from the worker
|
Loading…
Add table
Reference in a new issue