Skip to content

Commit 6b98fba

Browse files
author
maurinElectroTextile
committed
Updated alert()
1 parent 396aee0 commit 6b98fba

6 files changed

Lines changed: 49 additions & 39 deletions

File tree

docs/index.html

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ <h5 id="NAME" class="card-subtitle"></h5>
139139
<div class="sensor d-flex justify-content-center">
140140
<div id="canvas-3D"></div>
141141
</div>
142-
</div>
142+
</div>
143143

144144
</section>
145145

@@ -148,15 +148,17 @@ <h5 id="NAME" class="card-subtitle"></h5>
148148
<div class="card-body card shadow">
149149
<div id="summary_action" class="alert alert-warning text-center">DISCONNECTED</div>
150150
<div id="e256_params"></div>
151+
151152
<div id="set_button_params" class="param collapse">
152153
<button id="btnSet" class="btn w-100 btn-warning" type="button">SET PARAMS</button>
153154
</div>
155+
154156
<div id="midi_term" class="card-body h-100 collapse"></div>
155-
<div id="live_alert_placeholder"></div>
156-
</div>
157+
<div id="live_alert_placeholder" style="z-index: 10;"></div>
157158

159+
</div>
160+
158161
</section>
159-
160162
</div>
161163

162164
<script type="text/javascript" src="./js/e256_config.js"></script>

docs/js/e256_mappings/switch.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ function switch_factory() {
99
const DEFAULT_SWITCH_WIDTH = canvas_width / SCALE_X;
1010
const DEFAULT_SWITCH_HEIGHT = canvas_height / SCALE_X;
1111
//const DEFAULT_SWITCH_MIN_SIZE = 50;
12-
const DEFAULT_SWITCH_TOUCHS = 3;
12+
const DEFAULT_SWITCH_TOUCHS = 1;
1313
const DEFAULT_SWITCH_MODE_Z = NOTE_ON;
1414
const DEFAULT_SWITCH_BUTTON_PADDING = 8;
1515

@@ -146,11 +146,11 @@ function switch_factory() {
146146
}
147147

148148
_touch_ellipse.onMouseEnter = function () {
149-
this.style.fillColor = "orange";
149+
//this.style.fillColor = "orange";
150150
}
151151

152152
_touch_ellipse.onMouseLeave = function () {
153-
this.style.fillColor = "pink";
153+
//this.style.fillColor = "pink";
154154
}
155155

156156
_touch_ellipse.onMouseDown = function () {
@@ -160,6 +160,7 @@ function switch_factory() {
160160
current_touch = _touch_group;
161161
break;
162162
case THROUGH_MODE:
163+
this.style.fillColor = "orange";
163164
switch (_switch.data.mode_z) {
164165
case NOTE_ON:
165166
_touch_group.msg.note.midi.status = (_touch_group.msg.note.midi.status | NOTE_ON);
@@ -191,6 +192,7 @@ function switch_factory() {
191192
// N/A
192193
break;
193194
case THROUGH_MODE:
195+
this.style.fillColor = "pink";
194196
switch (_switch.data.mode_z) { // BUG_FIX: this.data.mode_z -> _switch.data.mode_z
195197
case NOTE_ON:
196198
_touch_group.msg.note.midi.status = (_touch_group.msg.note.midi.status & NOTE_OFF);

docs/js/e256_menu.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ $(".e256_setMode").click(
4040
send_midi_msg(new program_change(MIDI_MODES_CHANNEL, e256_current_mode));
4141
console.log("REQUEST: " + MODE_CODES[e256_current_mode]);
4242
} else {
43-
alert_msg("ETEXTILE-SYNTHESIZER IS NOT CONNECTED!", "danger", 1500, null);
43+
alert_msg("not_connected", "ETEXTILE-SYNTHESIZER IS NOT CONNECTED!", "danger");
4444
}
4545
}
4646
);
@@ -59,7 +59,7 @@ $("#uploadConfig").click(
5959
send_midi_msg(new program_change(MIDI_MODES_CHANNEL, ALLOCATE_MODE));
6060
console.log("REQUEST: ALLOCATE_MODE");
6161
} else {
62-
alert_msg("ETEXTILE-SYNTHESIZER IS NOT CONNECTED!", "danger", 1500, null);
62+
alert_msg("not_connected", "ETEXTILE-SYNTHESIZER IS NOT CONNECTED!", "danger");
6363
}
6464
}
6565
);
@@ -80,7 +80,7 @@ $("#fetchConfig").click(
8080
send_midi_msg(new program_change(MIDI_MODES_CHANNEL, LOAD_MODE));
8181
console.log("REQUEST: LOAD_MODE");
8282
} else {
83-
alert_msg("ETEXTILE-SYNTHESIZER IS NOT CONNECTED!", "danger", 1500, null);
83+
alert_msg("not_connected", "ETEXTILE-SYNTHESIZER IS NOT CONNECTED!", "danger");
8484
}
8585
}
8686
);

docs/js/e256_menu_params.js

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -403,17 +403,17 @@ function circular_buffer(max_length) {
403403

404404
circular_buffer.prototype = Object.create(Array.prototype);
405405

406-
circular_buffer.prototype.push = function (midiMsg) {
406+
circular_buffer.prototype.push = function (midi_msg) {
407407

408-
Array.prototype.push.call(this, midiMsg);
408+
Array.prototype.push.call(this, midi_msg);
409409

410410
let div_midi_msg = document.createElement("div");
411411

412412
div_midi_msg.setAttribute("id", "midi_msg_" + this._msg_count);
413413

414-
let status = midi_msg_status_unpack(midiMsg.status);
414+
let status = midi_msg_status_unpack(midi_msg.status);
415415

416-
div_midi_msg.textContent = MIDI_TYPES[status.type] + " : [ " + status.channel + ", " + midiMsg.data1 + ", " + midiMsg.data2 + " ]";
416+
div_midi_msg.textContent = MIDI_TYPES[status.type] + " : [ " + status.channel + ", " + midi_msg.data1 + ", " + midi_msg.data2 + " ]";
417417

418418
switch (e256_current_mode) {
419419
case THROUGH_MODE:
@@ -436,23 +436,28 @@ circular_buffer.prototype.push = function (midiMsg) {
436436

437437
var midi_term = new circular_buffer(25);
438438

439+
439440
//////////////// Alert
440-
function alert_msg(message, type, timeout, identifier) {
441+
function alert_msg(identifier, message, type) {
442+
443+
const is_existing_alert_node = document.querySelector("#" + identifier);
444+
445+
if (is_existing_alert_node === null) {
446+
447+
const div_alert = document.createElement('div');
441448

442-
const div_alert = document.createElement('div');
443-
div_alert.setAttribute("id", "alert_msg_" + identifier);
444-
div_alert.className = "alert alert-" + type;
445-
div_alert.setAttribute("role", "alert");
446-
div_alert.textContent = message;
449+
div_alert.setAttribute("id", identifier);
450+
div_alert.className = "alert alert-" + type;
451+
div_alert.setAttribute("role", "alert");
452+
div_alert.textContent = message;
447453

448-
$("#live_alert_placeholder").append(div_alert);
454+
$("#live_alert_placeholder").append(div_alert);
449455

450-
if (timeout) {
451456
setTimeout(
452457
function () {
453-
const _alert_msg = bootstrap.Alert.getOrCreateInstance("#alert_msg_" + identifier);
454-
_alert_msg.close();
455-
}, timeout);
458+
const alert_timeout =bootstrap.Alert.getOrCreateInstance("#" + identifier);
459+
alert_timeout.close();
460+
}, 2000);
456461
}
457462

458463
};

docs/js/e256_midi_io.js

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ async function MIDIsetup() {
185185
navigator.requestMIDIAccess({ sysex: true }).then(onMIDISuccess);
186186
}
187187
if (permissionStatus.state === "prompt") {
188-
alert_msg("This browser does not support MIDI!", "danger", 2000, null);
188+
alert_msg("no_midi_support", "This browser does not support MIDI!", "danger");
189189
}
190190
});
191191
};
@@ -401,7 +401,7 @@ function onMIDIMessage(midiMsg) {
401401
draw_controlers_from_config(fetch_config_file);
402402
}
403403
else {
404-
alert_msg("NO CONFIG FILE LOADED IN THE E256 FLASH MEMORY!", "danger", 2000, null);
404+
alert_msg("no_config_file", "NO CONFIG FILE LOADED IN THE E256 FLASH MEMORY!", "danger");
405405
}
406406
send_midi_msg(new program_change(MIDI_MODES_CHANNEL, EDIT_MODE));
407407
console.log("REQUEST: EDIT_MODE");
@@ -429,15 +429,13 @@ function onMIDIMessage(midiMsg) {
429429
break;
430430

431431
case CONFIG_APPLY_DONE:
432-
alert_msg("PRESS THE ETEXTILE-SYNTHESIZER LEFT PUSH BUTTON TO SAVE THE CONFIG IN THE FLASH MEMORY!", "warning", false, "save"); // FIXME!
432+
alert_msg("config_apply", "PRESS THE ETEXTILE-SYNTHESIZER LEFT PUSH BUTTON TO SAVE THE CONFIG IN THE FLASH MEMORY!", "warning");
433433
send_midi_msg(new program_change(MIDI_MODES_CHANNEL, EDIT_MODE));
434434
console.log("REQUEST: EDIT_MODE");
435435
break;
436436

437437
case WRITE_MODE_DONE:
438-
const alert = bootstrap.Alert.getOrCreateInstance('#alert_msg_save')
439-
if (alert) alert.close();
440-
alert_msg("NOW THE ETEXTILE-SYNTHESIZER CAN BE USED IN STANDALONE MODE!", "success", 3000);
438+
alert_msg("config_saved", "NOW THE ETEXTILE-SYNTHESIZER CAN BE USED IN STANDALONE MODE!", "success");
441439
break;
442440

443441
default:
@@ -473,7 +471,7 @@ function onMIDIMessage(midiMsg) {
473471
break;
474472
default:
475473
//console.log("NOT_HANDLED_SISEX: " + MODE_CODES[e256_current_mode]);
476-
alert_msg("NOT_HANDLED_SISEX: " + MODE_CODES[e256_current_mode], "danger", 2000);
474+
alert_msg("wrong_sysex", "NOT_HANDLED_SYSEX: " + MODE_CODES[e256_current_mode], "danger");
477475
break;
478476
}
479477
break;
@@ -485,6 +483,7 @@ function onMIDIMessage(midiMsg) {
485483
};
486484

487485
function send_midi_msg(midiMsg) {
486+
488487
if (midi_device_connected) {
489488
if (midiMsg.data2 === null) {
490489
MIDI_output.send([midiMsg.status, midiMsg.data1]);
@@ -494,7 +493,7 @@ function send_midi_msg(midiMsg) {
494493
midi_term.push(midiMsg);
495494
}
496495
else {
497-
alert_msg("ETEXTILE-SYNTHESIZER IS NOT CONNECTED!", "danger", 1500);
496+
alert_msg("not_connected", "ETEXTILE-SYNTHESIZER IS NOT CONNECTED!", "danger");
498497
}
499498
};
500499

@@ -538,14 +537,16 @@ function e256_alocate_memory() {
538537
};
539538
*/
540539

541-
$(document).ready(function () {
542-
$("#loading_canvas").collapse("show");
543-
MIDIsetup();
544-
});
540+
$(document).ready(
541+
function () {
542+
$("#loading_canvas").collapse("show");
543+
MIDIsetup();
544+
}
545+
);
545546

546547
function string_to_bytes(str) {
547548
let bytes = [];
548-
for (let i = 0, n = str.length; i < n; i++) {
549+
for (let i = 0; i < str.length; i++) {
549550
let char = str.charCodeAt(i);
550551
bytes.push(char);
551552
}

docs/js/e256_paper_script.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ paperTool.onMouseDown = function (mouseEvent) {
7373
}
7474
}
7575
else {
76-
alert_msg("SELECT A MAPPING!", "danger", 2000, null);
76+
alert_msg("select_mapping", "SELECT A MAPPING!", "danger");
7777
}
7878
}
7979
else { // If cliking on item

0 commit comments

Comments
 (0)