Skip to content

Commit

Permalink
Merge pull request #164 from finger563/feature/simulator-alert-bad-ev…
Browse files Browse the repository at this point in the history
…ent-name

feat(simulator): Update simulator to alert if the event name is bad
  • Loading branch information
finger563 authored May 23, 2024
2 parents 2f1e706 + 9696108 commit d7e9c15
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/visualizers/widgets/HFSMViz/Simulator/Simulator.js
Original file line number Diff line number Diff line change
Expand Up @@ -1046,6 +1046,16 @@ define(['js/util',
var eventNames = self.getEventNames().sort();
eventNames.map(function (eventName) {
if (eventName && eventName.trim()) {
// warn if the event name is not valid (matches
// /^[a-zA-Z_][a-zA-Z0-9_]+$/gi regex)
if (!eventName.match(/^[a-zA-Z_][a-zA-Z0-9_]+$/gi)) {
alert('WARNING:\n'+
'Event name "'+eventName+'" is not a valid C++ identifier!\n'+
'Please use only alphanumeric characters and underscores!\n'+
'Simulator may not be able to handle this event and the event button (left panel) may not work!'
);
}

var buttonHtml = mustache.render(eventTempl, { eventName: eventName });
self._eventButtons.append( buttonHtml );
var eventButton = $(self._eventButtons).find('#'+eventName).first();
Expand Down

0 comments on commit d7e9c15

Please sign in to comment.