mirror of
https://github.com/BorysLevytskyi/BitwiseCmd.git
synced 2025-12-10 06:52:05 +01:00
43 lines
1.1 KiB
JavaScript
43 lines
1.1 KiB
JavaScript
(function(app){
|
|
|
|
app.controller('expressionInputCtrl', {
|
|
$dispatcher:null,
|
|
attachView: function (viewElement) {
|
|
var d = this.$dispatcher;
|
|
viewElement.addEventListener('keyup', function (args) {
|
|
if (args.keyCode != 13) {
|
|
return;
|
|
}
|
|
|
|
// Enter
|
|
d.dispatch(args.srcElement.value);
|
|
args.srcElement.value = '';
|
|
});
|
|
}
|
|
});
|
|
|
|
app.service('resultView', {
|
|
attachView: function(viewElement) {
|
|
this.viewElement = viewElement;
|
|
},
|
|
detachView: function() {
|
|
this.viewElement == null;
|
|
},
|
|
clear: function (){
|
|
this.viewElement.innerHTML = '';
|
|
},
|
|
insert: function (htmlElement) {
|
|
if(this.viewElement.childNodes.length == 0) {
|
|
this.viewElement.appendChild(htmlElement);
|
|
}
|
|
else
|
|
{
|
|
this.viewElement.appendChild(htmlElement);
|
|
}
|
|
}
|
|
});
|
|
|
|
app.controller('resultViewCtrl', app.service('resultView'));
|
|
|
|
})(window.app);
|