Browse Source

Renamed params. Hopefuly logic is ok. Compiler now uses params

dev/git-series/gccdum
Rubén Rincón 6 years ago
parent
commit
a7b0c71832
  1. 17
      static/alert.js
  2. 16
      static/compiler.js
  3. 7
      static/editor.js

17
static/alert.js

@ -56,14 +56,22 @@ define(function (require) {
modal.modal();
};
// We append elements so in a near future we can stack sucesive notifications
/* Options parameter:
* group: What group this notification is from. Sets data-group's value. Default: none
* noCollapse: If set to true, other notifications with the same group will not be removed before sending this. (Note that this only has any effect if group is set). Default: false
* alertClass: Space separated classes to give to the notification div element. Default: none
* noAutoDissmis: If set to true, the notification will not fade out nor be removed automatically. Default: false (This element will be dissmised)
* dissmisTime: If allowed by noAutoDissmis, controls how long the notification will be visible before being automatically removed. Default: 5000ms
*/
Alert.prototype.notify = function (body, options) {
var modal = $('#notifications');
if (!modal) return;
var newElement = $('<div class="alert notification" tabindex="-1" role="dialog"><button type="button" class="close" data-dismiss="alert">&times;</button><span id="msg">' + body + '</span></div>');
if (options) {
if (options.group) {
modal.find('[data-group="' + options.group + '"]').remove();
if (options.noCollapse) {
modal.find('[data-group="' + options.group + '"]').remove();
}
newElement.attr('data-group', options.group);
}
if (options.alertClass) {
@ -71,12 +79,13 @@ define(function (require) {
}
}
modal.append(newElement);
if (!options || !options.neverDismiss) {
if (!options || !options.noAutoDissmis) {
// Dissmis this after dissmisTime
setTimeout(function () {
newElement.fadeOut('slow', function() {
newElement.remove();
});
}, options && options.hideTime ? options.hideTime : 5000);
}, options && options.dissmisTime ? options.dissmisTime : 5000);
}
};

16
static/compiler.js

@ -130,18 +130,24 @@ define(function (require) {
var pos = ed.getPosition();
var word = ed.getModel().getWordAtPosition(pos);
if (!word || !word.word) return;
var token = word.word.toUpperCase();
var asmHelp = asmDocs[token];
var opcode = word.word.toUpperCase();
var asmHelp = asmDocs[opcode];
if (asmHelp) {
new Alert().alert(token + " help", asmHelp.html +
new Alert().alert(opcode + " help", asmHelp.html +
'<br><br>For more information, visit <a href="http://www.felixcloutier.com/x86/' + asmHelp.url +'" target="_blank" rel="noopener noreferrer">the ' +
token + ' documentation <img src="assets/external_link.png" width="16px" height="16px" alt="Opens in a new window"/></a>.',
opcode + ' documentation <img src="assets/external_link.png" width="16px" height="16px" alt="Opens in a new window"/></a>.',
function() {
ed.focus();
ed.setPosition(pos);
});
} else {
new Alert().notify('This token was not found in the documentation.', 3000, 'notification-error');
new Alert().notify('This opcode was not found in the documentation.',{
"group": "noopcodeindocs",
"noCollapse": false,
"alertClass": "notification-error",
"noAutoDissmis": false,
"dissmisTime": 3000
});
}
}
});

7
static/editor.js

@ -109,10 +109,11 @@ define(function (require) {
compileOnChange: !this.settings.compileOnChange
});
new Alert().notify('Compile on code change has been toggled ' + (this.settings.compileOnChange ? 'ON' : 'OFF'), {
"hideTime": 3000,
"alertClass": this.settings.compileOnChange ? "notification-on" : "notification-off",
"group": "togglecompile",
"neverDismiss": false
"noCollapse": false,
"alertClass": this.settings.compileOnChange ? "notification-on" : "notification-off",
"noAutoDissmis": false,
"dissmisTime": 3000
});
}, this)
});

Loading…
Cancel
Save