mirror of
https://github.com/BorysLevytskyi/BitwiseCmd.git
synced 2025-12-21 04:02:47 +01:00
Introduced core.
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
(function (should, Container, AppShell) {
|
||||
(function (core) {
|
||||
|
||||
var di = new Container();
|
||||
var app = new AppShell(di);
|
||||
var di = new core.Container();
|
||||
var app = new core.AppShell(di);
|
||||
|
||||
app.debugMode = false;
|
||||
|
||||
@@ -13,4 +13,4 @@
|
||||
|
||||
window.app = app;
|
||||
|
||||
})(window.should, window.Container, window.AppShell);
|
||||
})(window.core);
|
||||
@@ -1,4 +1,5 @@
|
||||
(function(app, should){
|
||||
app.compose(function() {
|
||||
var should = app.get('should')
|
||||
app.set('calc', {
|
||||
|
||||
numberOfBits: function (num) {
|
||||
@@ -18,4 +19,4 @@
|
||||
}
|
||||
});
|
||||
|
||||
})(window.app, window.should);
|
||||
});
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
(function() {
|
||||
app.compose(function(){
|
||||
var twoOperandsRegex = /^(\d+)\s*(<<|>>|\||\&|\^)\s*(\d+)$/;
|
||||
var numbersList = /^((\d*)+\s?)+$/;
|
||||
|
||||
@@ -48,4 +48,4 @@
|
||||
|
||||
return new app.models.BitwiseNumbers(numbers);
|
||||
}
|
||||
})(window.app);
|
||||
});
|
||||
@@ -1,7 +1,7 @@
|
||||
(function(should, app){
|
||||
|
||||
app.compose(function() {
|
||||
|
||||
var should = app.get('should');
|
||||
app.set("formatter", {
|
||||
toBinaryString: function(num, totalLength) {
|
||||
|
||||
|
||||
@@ -56,8 +56,7 @@ app.compose(function() {
|
||||
app.controller('resultViewCtrl', function() {
|
||||
var html = app.get('html');
|
||||
|
||||
var resultViewController = {
|
||||
$html: null,
|
||||
return {
|
||||
clear: function (){
|
||||
this.viewElement.innerHTML = '';
|
||||
},
|
||||
@@ -76,9 +75,6 @@ app.compose(function() {
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
return resultViewController;
|
||||
});
|
||||
|
||||
app.controller('configPanelCtrl', {
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
(function(app, HtmlBuilder){
|
||||
(function(app, core){
|
||||
|
||||
app.set('html', HtmlBuilder);
|
||||
app.set('is', is);
|
||||
app.set('html', core.HtmlBuilder);
|
||||
app.set('is', core.is);
|
||||
app.set('should', core.should)
|
||||
/*
|
||||
var template = {
|
||||
compile: function (template) {
|
||||
@@ -38,4 +39,4 @@
|
||||
return str.replace(/(\r|\n)+/g, '').replace("'", "\\\'");
|
||||
}
|
||||
*/
|
||||
})(window.app, window.HtmlBuilder, window.is);
|
||||
})(window.app, window.core);
|
||||
@@ -1,4 +1,7 @@
|
||||
(function(app){
|
||||
(function(app, core){
|
||||
|
||||
var should = core.should;
|
||||
|
||||
function Command(name) {
|
||||
this.name = name;
|
||||
this.executionHandlers = [];
|
||||
@@ -49,4 +52,5 @@
|
||||
};
|
||||
|
||||
window.commandr = commandr;
|
||||
})(window.app);
|
||||
|
||||
})(window.app, window.core);
|
||||
@@ -1,22 +1,20 @@
|
||||
(function(app, should, Container) {
|
||||
(function(app, core) {
|
||||
|
||||
var controllerDi = app.di; // TODO: Compbine
|
||||
var should = core.should;
|
||||
|
||||
app.controller = function(name, instOrFactory) {
|
||||
|
||||
should.beString(name, "name");
|
||||
|
||||
if(instOrFactory == null) {
|
||||
return controllerDi.resolve(name);
|
||||
return this.get(name);
|
||||
}
|
||||
|
||||
var reg = new Container.Registration(instOrFactory);
|
||||
var reg = new core.Container.Registration(instOrFactory);
|
||||
|
||||
reg.onFirstTimeResolve = function (inst) {
|
||||
addControllerMixin(inst);
|
||||
};
|
||||
|
||||
controllerDi.register(name, reg);
|
||||
this.set(name, reg);
|
||||
};
|
||||
|
||||
app.run(function(){
|
||||
@@ -78,4 +76,4 @@
|
||||
}
|
||||
}
|
||||
|
||||
})(window.app, window.should, window.Container);
|
||||
})(window.app, window.core);
|
||||
|
||||
@@ -32,5 +32,5 @@
|
||||
functions.forEach(function(o){ o(); });
|
||||
}
|
||||
|
||||
window.AppShell = AppShell;
|
||||
window.core.AppShell = AppShell;
|
||||
})();
|
||||
@@ -50,5 +50,5 @@
|
||||
});
|
||||
}
|
||||
|
||||
window.bindr = bindr;
|
||||
window.core.bindr = bindr;
|
||||
})();
|
||||
1
core/core.js
Normal file
1
core/core.js
Normal file
@@ -0,0 +1 @@
|
||||
window.core = {};
|
||||
11
core/di.js
11
core/di.js
@@ -1,6 +1,9 @@
|
||||
// Problems: no check for the circular references
|
||||
|
||||
(function(is){
|
||||
(function(core){
|
||||
|
||||
var is = core.is;
|
||||
|
||||
function Container(store) {
|
||||
this.store = {};
|
||||
this.resolutionStack = [];
|
||||
@@ -20,7 +23,7 @@
|
||||
this.store[name] = reg;
|
||||
}
|
||||
|
||||
console.log(name + ' component registered');
|
||||
console.log('[' + name + '] component registered');
|
||||
return reg;
|
||||
};
|
||||
|
||||
@@ -87,5 +90,5 @@
|
||||
return false;
|
||||
}
|
||||
|
||||
window.Container = Container;
|
||||
})(window.is);
|
||||
core.Container = Container;
|
||||
})(window.core);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
(function(){
|
||||
(function(core){
|
||||
|
||||
var HtmlBuilder = {};
|
||||
var should = core.should;
|
||||
|
||||
HtmlBuilder.element = function(template, model) {
|
||||
var el = document.createElement('div');
|
||||
@@ -55,6 +56,6 @@
|
||||
.replace(/'/g, "'");
|
||||
};
|
||||
|
||||
window.HtmlBuilder = HtmlBuilder;
|
||||
core.HtmlBuilder = HtmlBuilder;
|
||||
|
||||
})();
|
||||
})(window.core);
|
||||
@@ -1,5 +1,5 @@
|
||||
(function(){
|
||||
window.is = {
|
||||
window.core.is = {
|
||||
plainObject: function(obj) {
|
||||
return typeof obj == "object" && obj instanceof Object;
|
||||
},
|
||||
|
||||
@@ -47,5 +47,5 @@
|
||||
});
|
||||
};
|
||||
|
||||
window.observable = observable;
|
||||
window.core.observable = observable;
|
||||
});
|
||||
@@ -1,5 +1,5 @@
|
||||
(function(){
|
||||
window.should = {
|
||||
window.core.should = {
|
||||
beNumber: function (num, name) {
|
||||
this.check(typeof num == "number" && !isNaN(num), num + " is not a number");
|
||||
this.check(isFinite(num), num + "is an infinite number")
|
||||
|
||||
@@ -5,11 +5,12 @@
|
||||
|
||||
<title></title>
|
||||
|
||||
<script type="text/javascript" src="core/core.js"></script>
|
||||
<script type="text/javascript" src="core/is.js"></script>
|
||||
<script type="text/javascript" src="core/should.js"></script>
|
||||
<script type="text/javascript" src="core/di.js"></script>
|
||||
<script type="text/javascript" src="core/appShell.js"></script>
|
||||
<script type="text/javascript" src="components/htmlBuilder.js"></script>
|
||||
<script type="text/javascript" src="core/htmlBuilder.js"></script>
|
||||
|
||||
<script type="text/javascript" src="app/app.js"></script>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user