mirror of
https://github.com/BorysLevytskyi/BitwiseCmd.git
synced 2026-01-16 17:02:38 +01:00
60 lines
1.6 KiB
JavaScript
60 lines
1.6 KiB
JavaScript
app.run(function() {
|
|
"use strict";
|
|
|
|
var cmd = app.get('cmd');
|
|
var cmdConfig = app.get('cmdConfig');
|
|
var rootView = app.get('rootView');
|
|
var shell = app.get('shell');
|
|
|
|
cmd.commands({
|
|
'help': function() {
|
|
var helpResult = document.querySelector('.result .helpResultTpl');
|
|
if(helpResult != null) {
|
|
moveResultUp(helpResult);
|
|
return;
|
|
}
|
|
return new app.models.ViewResult('helpResultTpl');
|
|
},
|
|
'clear': function() {
|
|
cmd.clear();
|
|
},
|
|
'em': function() {
|
|
cmdConfig.emphasizeBytes = !cmdConfig.emphasizeBytes;
|
|
},
|
|
'dark': function() {
|
|
shell.setDarkTheme();
|
|
},
|
|
light: function () {
|
|
shell.setLightTheme();
|
|
},
|
|
about: function() {
|
|
var aboutResult = document.querySelector('.result .aboutTpl');
|
|
if(aboutResult != null) {
|
|
moveResultUp(aboutResult);
|
|
return;
|
|
}
|
|
return new app.models.ViewResult('aboutTpl');
|
|
}
|
|
});
|
|
|
|
// TODO: Make as function
|
|
cmd.command({
|
|
canHandle: function(input) { return app.get('expression').canParse(input); },
|
|
handle: function(input) {
|
|
return app.get('expression').parse(input);
|
|
}
|
|
});
|
|
|
|
function moveResultUp(helpResult) {
|
|
var container = helpResult.parentNode.parentNode;
|
|
if(container.parentNode.firstChild != container) {
|
|
|
|
var out = container.parentNode;
|
|
out.removeChild(container);
|
|
out.insertBefore(container, out.firstChild);
|
|
}
|
|
|
|
}
|
|
|
|
});
|