binhend 1.1.0 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/example_api/routes/test/bb.js +1 -1
- package/example_api/routes/test/index.js +1 -1
- package/example_api/routes/test/some.js +1 -1
- package/example_api/routes/test.js +5 -1
- package/example_api/routes/testa.js +1 -1
- package/example_webcomp/components/common/InputText.js +11 -1
- package/example_webcomp/components/common/Link.js +1 -1
- package/example_webcomp/components/common/Link2.js +1 -1
- package/example_webcomp/components/index.js +9 -1
- package/example_webcomp/components/layouts/AppMainLayout.js +1 -1
- package/example_webcomp/components/layouts/AppToDos.js +7 -5
- package/example_webcomp/{public/common → components/layouts}/Link.js +5 -6
- package/example_webcomp/components/layouts/PageContent.js +1 -1
- package/example_webcomp/components/layouts/PageHeader.js +2 -2
- package/example_webcomp/components/layouts/ToDoItem.js +3 -2
- package/example_webcomp/components/styles/temp.css +4 -1
- package/package.json +1 -1
- package/src/binh.js +20 -207
- package/src/binh.server.app.js +70 -0
- package/src/binh.server.config.js +79 -0
- package/src/binh.web.builder.js +72 -0
- package/src/code.js +70 -15
- package/src/component.js +1 -1
- package/src/cryptography.js +6 -1
- package/example_webcomp/public/AnUserInterface.js +0 -0
- package/example_webcomp/public/common/InputText.js +0 -17
- package/example_webcomp/public/common/Link2.js +0 -13
- package/example_webcomp/public/index.html +0 -18
- package/example_webcomp/public/index.js +0 -6
- package/example_webcomp/public/layouts/AppMainLayout.js +0 -96
- package/example_webcomp/public/layouts/AppToDos.js +0 -100
- package/example_webcomp/public/layouts/PageContent.js +0 -29
- package/example_webcomp/public/layouts/PageHeader.js +0 -52
- package/example_webcomp/public/layouts/ToDoItem.js +0 -30
- package/example_webcomp/public/services/AnyService.js +0 -8
- package/example_webcomp/public/services/ServiceToDos.js +0 -46
- package/example_webcomp/public/styles/ToDoItemStyle.js +0 -44
- package/example_webcomp/public/styles/ToDoItemStyle2.js +0 -9
- package/example_webcomp/public/styles/temp.css +0 -4
- package/example_webcomp/public/styles/todo.css +0 -31
- package/example_webcomp/public/styles/todo.css.js +0 -9
- package/testa.js +0 -28
package/src/code.js
CHANGED
|
@@ -1,20 +1,76 @@
|
|
|
1
1
|
|
|
2
2
|
const { parse } = require('path');
|
|
3
3
|
|
|
4
|
-
function dependencies(component, root) {
|
|
5
|
-
var
|
|
4
|
+
function dependencies(component, root, metadata) {
|
|
5
|
+
var global = metadata || {}, local = {}, variables = {}, code = '';
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
var url = filepath.replace(root, '').replace(/\\/g, '/');
|
|
7
|
+
var children = component.module.children;
|
|
9
8
|
|
|
10
|
-
|
|
9
|
+
children.forEach(function(child) {
|
|
10
|
+
child = child.exports;
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
if (child.constructor !== component.constructor) return;
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
var filename = child.filename;
|
|
15
|
+
var url = filename.replace(root, '').replace(/\\/g, '/');
|
|
16
|
+
var name = component.vars[filename] || parse(filename).name.replace(/-/g, '').replace(/\W.*/, '');
|
|
17
|
+
|
|
18
|
+
local[filename] = {
|
|
19
|
+
name, url,
|
|
20
|
+
type: child.type,
|
|
21
|
+
component: child
|
|
22
|
+
};
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
Object.keys(local).forEach(function(filename) {
|
|
26
|
+
var declaration = '',
|
|
27
|
+
current = local[filename],
|
|
28
|
+
existed = global[filename];
|
|
29
|
+
|
|
30
|
+
var { type, name, url, component } = current;
|
|
31
|
+
|
|
32
|
+
if (existed) {
|
|
33
|
+
var sameVariableName = (name === existed.name);
|
|
34
|
+
if (sameVariableName) return;
|
|
35
|
+
|
|
36
|
+
declaration += `${name} = Binh.${type}('${url}');\r\n`;
|
|
37
|
+
variables[name] = true;
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
declaration += `${name} = Binh.${type}('${url}', ${component.toString()});\r\n`;
|
|
41
|
+
global[filename] = local[filename];
|
|
42
|
+
variables[name] = true;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
code += IIF([
|
|
46
|
+
declaration,
|
|
47
|
+
dependencies(component, root, Object.assign({}, global, local))
|
|
48
|
+
]);
|
|
49
|
+
|
|
50
|
+
code += '\r\n\r\n';
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
var vars = Object.keys(variables);
|
|
54
|
+
|
|
55
|
+
if (vars.length) {
|
|
56
|
+
code += `var ${vars.join(', ')};\r\n`;
|
|
15
57
|
}
|
|
16
58
|
|
|
17
|
-
code
|
|
59
|
+
return code;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function bundle(component, root) {
|
|
63
|
+
var code = '';
|
|
64
|
+
|
|
65
|
+
if (component.filename.indexOf('AppToDos.js') > -1) {
|
|
66
|
+
console.log('debug');
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
code += dependencies(component, root);
|
|
70
|
+
|
|
71
|
+
code += '\r\n';
|
|
72
|
+
|
|
73
|
+
code += `Binh.${component.type}(${component.toString()});\r\n`;
|
|
18
74
|
|
|
19
75
|
return code;
|
|
20
76
|
}
|
|
@@ -40,7 +96,7 @@ function prequire(component, codes) {
|
|
|
40
96
|
var code = '', links = distinctValues(component, 'links');
|
|
41
97
|
|
|
42
98
|
if (links.length) {
|
|
43
|
-
code = `Binh.
|
|
99
|
+
code = `Binh.prequire(['${links.join("','")}'], function() {\r\n\r\n${codes.join('\r\n')}\r\n});`;
|
|
44
100
|
}
|
|
45
101
|
else {
|
|
46
102
|
code = IIF(codes);
|
|
@@ -54,12 +110,11 @@ function IIF(codes) {
|
|
|
54
110
|
}
|
|
55
111
|
|
|
56
112
|
function distinctValues(component, key) {
|
|
57
|
-
var arrays = [component[key]]
|
|
58
|
-
dependencies = component.dependencies;
|
|
113
|
+
var arrays = [component[key]];
|
|
59
114
|
|
|
60
|
-
|
|
61
|
-
arrays.push(
|
|
62
|
-
}
|
|
115
|
+
component.module.children.forEach(function(child) {
|
|
116
|
+
arrays.push(child.exports[key]);
|
|
117
|
+
});
|
|
63
118
|
|
|
64
119
|
return uniquefy(arrays);
|
|
65
120
|
}
|
|
@@ -81,7 +136,7 @@ function uniquefy(arrays) {
|
|
|
81
136
|
}
|
|
82
137
|
|
|
83
138
|
module.exports = {
|
|
84
|
-
|
|
139
|
+
bundle,
|
|
85
140
|
htmltags,
|
|
86
141
|
prequire,
|
|
87
142
|
IIF
|
package/src/component.js
CHANGED
|
@@ -81,7 +81,7 @@ function ensureDirectoryExistence(filepath) {
|
|
|
81
81
|
|
|
82
82
|
function joinCodes(component, root) {
|
|
83
83
|
var fullcode = CodeFormat.prequire(component, [
|
|
84
|
-
CodeFormat.
|
|
84
|
+
CodeFormat.bundle(component, root),
|
|
85
85
|
CodeFormat.htmltags(component)
|
|
86
86
|
]);
|
|
87
87
|
|
package/src/cryptography.js
CHANGED
|
@@ -4,6 +4,10 @@ const algorithm = 'aes-256-cbc';
|
|
|
4
4
|
const lenght_iv = 16;
|
|
5
5
|
const lenght_key = 32;
|
|
6
6
|
|
|
7
|
+
function randomUUID(disableEntropyCache = true) {
|
|
8
|
+
crypto.randomUUID({ disableEntropyCache });
|
|
9
|
+
}
|
|
10
|
+
|
|
7
11
|
function generateSecurityKey() {
|
|
8
12
|
return crypto.randomBytes(lenght_key).toString('hex');
|
|
9
13
|
}
|
|
@@ -45,5 +49,6 @@ function hash(text, encoding = 'hex', length = 256) {
|
|
|
45
49
|
module.exports = {
|
|
46
50
|
encrypt, decrypt, hash,
|
|
47
51
|
generateSecurityKey,
|
|
48
|
-
generateInitialVector
|
|
52
|
+
generateInitialVector,
|
|
53
|
+
randomUUID
|
|
49
54
|
};
|
|
File without changes
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
!function(){
|
|
2
|
-
|
|
3
|
-
Binh.ui(function main() {
|
|
4
|
-
var inputbox = input({ type: 'text', placeholder: 'Enter to-do item' });
|
|
5
|
-
|
|
6
|
-
inputbox.on('keypress', function (event) {
|
|
7
|
-
if (event.key === "Enter") {
|
|
8
|
-
inputbox.does('submit', inputbox.element.value);
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
return inputbox;
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
var input = Binh.el('input');
|
|
16
|
-
|
|
17
|
-
}();
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
<head>
|
|
4
|
-
<title>Binh Demo</title>
|
|
5
|
-
<meta charset="utf-8">
|
|
6
|
-
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
7
|
-
<!-- <link rel="stylesheet" href="/lib/bootstrap.3.4.1.min.css"> -->
|
|
8
|
-
<!-- <link rel="stylesheet" href="style.css"> -->
|
|
9
|
-
<!-- <script src="/lib/jquery.3.5.1.min.js"></script>
|
|
10
|
-
<script src="/lib/bootstrap.3.4.1.min.js"></script> -->
|
|
11
|
-
|
|
12
|
-
<script src="http://localhost:1300/dev/binh.min.js"></script>
|
|
13
|
-
<!-- <script src="https://binhjs.pages.dev/dist/binh.min.js"></script> -->
|
|
14
|
-
<!-- <script src="https://cdn.jsdelivr.net/gh/penciless/binhjs/dist/binh.min.js"></script> -->
|
|
15
|
-
<script src="/index.js"></script>
|
|
16
|
-
</head>
|
|
17
|
-
<body></body>
|
|
18
|
-
</html>
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
Binh.requires(['https://code.jquery.com/jquery-3.7.0.min.js'], function() {
|
|
2
|
-
|
|
3
|
-
var PageHeader = Binh.ui('/layouts/PageHeader.js', function PageHeader() {
|
|
4
|
-
var Link = this.ui('/common/Link2.js');
|
|
5
|
-
|
|
6
|
-
var PageHeader = div({ id: 'page-header' });
|
|
7
|
-
|
|
8
|
-
PageHeader(
|
|
9
|
-
div({ class: 'container' })(
|
|
10
|
-
div({ class: 'row' })(
|
|
11
|
-
nav({ class: 'navbar navbar-default' })(
|
|
12
|
-
div({ class: 'container-fluid' })([
|
|
13
|
-
div({ class: 'navbar-header' })(
|
|
14
|
-
a({ class: 'navbar-brand', href: '#' })(
|
|
15
|
-
'Website Name'
|
|
16
|
-
)
|
|
17
|
-
),
|
|
18
|
-
ul({ class: 'nav navbar-nav' })(
|
|
19
|
-
li({ class: 'active' })(
|
|
20
|
-
Link('Home', '/')
|
|
21
|
-
),
|
|
22
|
-
li(
|
|
23
|
-
Link('Abc', '/abc')
|
|
24
|
-
),
|
|
25
|
-
li(
|
|
26
|
-
Link('Haha', '/haha')
|
|
27
|
-
),
|
|
28
|
-
li(
|
|
29
|
-
a('Page 3')
|
|
30
|
-
)
|
|
31
|
-
)
|
|
32
|
-
])
|
|
33
|
-
)
|
|
34
|
-
)
|
|
35
|
-
),
|
|
36
|
-
function (thisEl) {
|
|
37
|
-
setTimeout(function() {
|
|
38
|
-
console.log('>>> Page Header:', thisEl);
|
|
39
|
-
}, 1000);
|
|
40
|
-
}
|
|
41
|
-
);
|
|
42
|
-
|
|
43
|
-
return PageHeader;
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
var PageContent = Binh.ui('/layouts/PageContent.js', function PageContent() {
|
|
47
|
-
var { Router } = Binh;
|
|
48
|
-
|
|
49
|
-
var PageContent = div({ id: 'page-content' });
|
|
50
|
-
|
|
51
|
-
PageContent(
|
|
52
|
-
new Router({
|
|
53
|
-
'': div('default work!'),
|
|
54
|
-
'/abc': div('abc work!'),
|
|
55
|
-
'/haha': trans('haha work!')
|
|
56
|
-
})
|
|
57
|
-
)
|
|
58
|
-
(
|
|
59
|
-
function (thisEl) {
|
|
60
|
-
setTimeout(function() {
|
|
61
|
-
console.log('>>> Page Content:', thisEl);
|
|
62
|
-
}, 1000);
|
|
63
|
-
}
|
|
64
|
-
);
|
|
65
|
-
|
|
66
|
-
return PageContent;
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
var AnyService = Binh.service('/services/AnyService.js', function AnyService() {
|
|
70
|
-
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
Binh.ui(function AppMainLayout() {
|
|
74
|
-
var MainLayout = div({ id: 'app-main-layout' });
|
|
75
|
-
|
|
76
|
-
MainLayout(
|
|
77
|
-
PageHeader,
|
|
78
|
-
PageContent,
|
|
79
|
-
function (thisEl) {
|
|
80
|
-
setTimeout(function() {
|
|
81
|
-
console.log('>>> App Main Layout:', thisEl);
|
|
82
|
-
}, 1000);
|
|
83
|
-
}
|
|
84
|
-
);
|
|
85
|
-
|
|
86
|
-
return MainLayout;
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
var div = Binh.el('div'),
|
|
90
|
-
nav = Binh.el('nav'),
|
|
91
|
-
ul = Binh.el('ul'),
|
|
92
|
-
li = Binh.el('li'),
|
|
93
|
-
a = Binh.el('a'),
|
|
94
|
-
trans = Binh.el('trans');
|
|
95
|
-
|
|
96
|
-
});
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
!function(){
|
|
2
|
-
|
|
3
|
-
var InputText = Binh.ui('/common/InputText.js', function main() {
|
|
4
|
-
var inputbox = input({ type: 'text', placeholder: 'Enter to-do item' });
|
|
5
|
-
|
|
6
|
-
inputbox.on('keypress', function (event) {
|
|
7
|
-
if (event.key === "Enter") {
|
|
8
|
-
inputbox.does('submit', inputbox.element.value);
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
return inputbox;
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
var ServiceToDos = Binh.service('/services/ServiceToDos.js', function(define, state, http) {
|
|
16
|
-
var todos = state.as('todos');
|
|
17
|
-
|
|
18
|
-
todos.schema(function(resolve) {
|
|
19
|
-
new http(api('get'))
|
|
20
|
-
.get(function(response) {
|
|
21
|
-
resolve(parseResponse(response));
|
|
22
|
-
});
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
function handleResponse(response) {
|
|
26
|
-
todos.set(parseResponse(response));
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
function parseResponse(response) {
|
|
30
|
-
var todoitems = [];
|
|
31
|
-
|
|
32
|
-
Object.keys(response).forEach(function(key) {
|
|
33
|
-
var each = response[key];
|
|
34
|
-
todoitems.push({ id: key, text: each.text });
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
return todoitems;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
define('add', function(value) {
|
|
41
|
-
new http(api('add'))
|
|
42
|
-
.body({ text: value })
|
|
43
|
-
.post(handleResponse);
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
define('remove', function(id) {
|
|
47
|
-
new http(api('remove'))
|
|
48
|
-
.body({ id: id })
|
|
49
|
-
.post(handleResponse);
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
function api(relative_url) {
|
|
53
|
-
return 'https://todolist-of-binh.fly.dev/todos/' + relative_url;
|
|
54
|
-
}
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
Binh.ui(function main() {
|
|
58
|
-
var PageHeader = this.ui('/layouts/PageHeader.js');
|
|
59
|
-
var ToDoItem = this.ui('/layouts/ToDoItem.js');
|
|
60
|
-
// var addTodoItem = ServiceToDos.does('add');
|
|
61
|
-
// var addTodoItem = ServiceToDos.debounce('add', 1500); // trailing only
|
|
62
|
-
var addTodoItem = ServiceToDos.debounce('add', 1500, true); // both leading & trailing
|
|
63
|
-
// var addTodoItem = ServiceToDos.debounce('add', 1500, true, true); // leading only
|
|
64
|
-
// var addTodoItem = ServiceToDos.throttle('add', 1500);
|
|
65
|
-
// var addTodoItem = ServiceToDos.once('add', 1500);
|
|
66
|
-
|
|
67
|
-
var inputbox = InputText().when('submit', addTodoItem);
|
|
68
|
-
|
|
69
|
-
var todolist = div({ class: 'todo-items' });
|
|
70
|
-
|
|
71
|
-
todolist.subscribe('todos', function(data) {
|
|
72
|
-
todolist.empty();
|
|
73
|
-
data.forEach(function(datum) {
|
|
74
|
-
todolist(
|
|
75
|
-
ToDoItem(datum).when('remove', ServiceToDos.instant('remove'))
|
|
76
|
-
);
|
|
77
|
-
});
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
var maindiv = div({ class: 'container' });
|
|
81
|
-
var left_section = div({ id: 'left-section' })('left section')(PageHeader);
|
|
82
|
-
var right_section = div({ id: 'right-section' })('right section');
|
|
83
|
-
|
|
84
|
-
maindiv(
|
|
85
|
-
left_section,
|
|
86
|
-
right_section(
|
|
87
|
-
div('To-Do List'),
|
|
88
|
-
inputbox,
|
|
89
|
-
todolist
|
|
90
|
-
)
|
|
91
|
-
);
|
|
92
|
-
|
|
93
|
-
return maindiv;
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
var div = Binh.el('div'),
|
|
97
|
-
span = Binh.el('span'),
|
|
98
|
-
input = Binh.el('input');
|
|
99
|
-
|
|
100
|
-
}();
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
!function(){
|
|
2
|
-
|
|
3
|
-
Binh.ui(function PageContent() {
|
|
4
|
-
var { Router } = Binh;
|
|
5
|
-
|
|
6
|
-
var PageContent = div({ id: 'page-content' });
|
|
7
|
-
|
|
8
|
-
PageContent(
|
|
9
|
-
new Router({
|
|
10
|
-
'': div('default work!'),
|
|
11
|
-
'/abc': div('abc work!'),
|
|
12
|
-
'/haha': trans('haha work!')
|
|
13
|
-
})
|
|
14
|
-
)
|
|
15
|
-
(
|
|
16
|
-
function (thisEl) {
|
|
17
|
-
setTimeout(function() {
|
|
18
|
-
console.log('>>> Page Content:', thisEl);
|
|
19
|
-
}, 1000);
|
|
20
|
-
}
|
|
21
|
-
);
|
|
22
|
-
|
|
23
|
-
return PageContent;
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
var div = Binh.el('div'),
|
|
27
|
-
trans = Binh.el('trans');
|
|
28
|
-
|
|
29
|
-
}();
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
!function(){
|
|
2
|
-
|
|
3
|
-
Binh.ui(function PageHeader() {
|
|
4
|
-
var Link = this.ui('/common/Link2.js');
|
|
5
|
-
|
|
6
|
-
var PageHeader = div({ id: 'page-header' });
|
|
7
|
-
|
|
8
|
-
PageHeader(
|
|
9
|
-
div({ class: 'container' })(
|
|
10
|
-
div({ class: 'row' })(
|
|
11
|
-
nav({ class: 'navbar navbar-default' })(
|
|
12
|
-
div({ class: 'container-fluid' })([
|
|
13
|
-
div({ class: 'navbar-header' })(
|
|
14
|
-
a({ class: 'navbar-brand', href: '#' })(
|
|
15
|
-
'Website Name'
|
|
16
|
-
)
|
|
17
|
-
),
|
|
18
|
-
ul({ class: 'nav navbar-nav' })(
|
|
19
|
-
li({ class: 'active' })(
|
|
20
|
-
Link('Home', '/')
|
|
21
|
-
),
|
|
22
|
-
li(
|
|
23
|
-
Link('Abc', '/abc')
|
|
24
|
-
),
|
|
25
|
-
li(
|
|
26
|
-
Link('Haha', '/haha')
|
|
27
|
-
),
|
|
28
|
-
li(
|
|
29
|
-
a('Page 3')
|
|
30
|
-
)
|
|
31
|
-
)
|
|
32
|
-
])
|
|
33
|
-
)
|
|
34
|
-
)
|
|
35
|
-
),
|
|
36
|
-
function (thisEl) {
|
|
37
|
-
setTimeout(function() {
|
|
38
|
-
console.log('>>> Page Header:', thisEl);
|
|
39
|
-
}, 1000);
|
|
40
|
-
}
|
|
41
|
-
);
|
|
42
|
-
|
|
43
|
-
return PageHeader;
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
var div = Binh.el('div'),
|
|
47
|
-
nav = Binh.el('nav'),
|
|
48
|
-
ul = Binh.el('ul'),
|
|
49
|
-
li = Binh.el('li'),
|
|
50
|
-
a = Binh.el('a');
|
|
51
|
-
|
|
52
|
-
}();
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
!function(){
|
|
2
|
-
|
|
3
|
-
var ToDoItemStyle2 = Binh.style('/styles/ToDoItemStyle2.js', function anonymous(
|
|
4
|
-
) {
|
|
5
|
-
return "@charset \"utf-8\"; @import url(\"/styles/temp.css\"); /* .btn-remove { color: blue; margin-left: '15px'; } */ @media (min-width: 800px) { .btn-remove { color: red; margin-left: '15px'; } } @keyframes slidein { from { transform: translateX(0%); } to { transform: translateX(100%); } } @page { size: 8.5in 9in; margin-top: 4in; }";
|
|
6
|
-
});
|
|
7
|
-
|
|
8
|
-
Binh.ui(function main(props) {
|
|
9
|
-
// var ToDoItemStyle = this.style('/styles/todo.css');
|
|
10
|
-
|
|
11
|
-
var todoitem = div({ style: 'margin: 3px;' });
|
|
12
|
-
|
|
13
|
-
var remove_button = span({ class: 'btn-remove' })('X');
|
|
14
|
-
|
|
15
|
-
remove_button.on('click', function() {
|
|
16
|
-
todoitem.does('remove', props.id);
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
todoitem(span(props.text), span('-------'), remove_button);
|
|
20
|
-
|
|
21
|
-
// return todoitem.style(ToDoItemStyle);
|
|
22
|
-
// return todoitem.style('styles/todo.css');
|
|
23
|
-
return todoitem.style(ToDoItemStyle2);
|
|
24
|
-
// return todoitem.style(todo);
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
var div = Binh.el('div'),
|
|
28
|
-
span = Binh.el('span');
|
|
29
|
-
|
|
30
|
-
}();
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
!function(){
|
|
2
|
-
|
|
3
|
-
Binh.service(function(define, state, http) {
|
|
4
|
-
var todos = state.as('todos');
|
|
5
|
-
|
|
6
|
-
todos.schema(function(resolve) {
|
|
7
|
-
new http(api('get'))
|
|
8
|
-
.get(function(response) {
|
|
9
|
-
resolve(parseResponse(response));
|
|
10
|
-
});
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
function handleResponse(response) {
|
|
14
|
-
todos.set(parseResponse(response));
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
function parseResponse(response) {
|
|
18
|
-
var todoitems = [];
|
|
19
|
-
|
|
20
|
-
Object.keys(response).forEach(function(key) {
|
|
21
|
-
var each = response[key];
|
|
22
|
-
todoitems.push({ id: key, text: each.text });
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
return todoitems;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
define('add', function(value) {
|
|
29
|
-
new http(api('add'))
|
|
30
|
-
.body({ text: value })
|
|
31
|
-
.post(handleResponse);
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
define('remove', function(id) {
|
|
35
|
-
new http(api('remove'))
|
|
36
|
-
.body({ id: id })
|
|
37
|
-
.post(handleResponse);
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
function api(relative_url) {
|
|
41
|
-
return 'https://todolist-of-binh.fly.dev/todos/' + relative_url;
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}();
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
!function(){
|
|
2
|
-
|
|
3
|
-
Binh.style(function(css) {
|
|
4
|
-
// css('@charset "utf-8";');
|
|
5
|
-
|
|
6
|
-
css(`@import url("styles/temp.css");`);
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
css('.btn-remove', [
|
|
10
|
-
'color: purple;',
|
|
11
|
-
'margin-left: 10px'
|
|
12
|
-
]);
|
|
13
|
-
|
|
14
|
-
css(
|
|
15
|
-
`@media (min-width: 800px) {
|
|
16
|
-
.btn-remove {
|
|
17
|
-
color: red;
|
|
18
|
-
margin-left: '15px';
|
|
19
|
-
}
|
|
20
|
-
}`
|
|
21
|
-
);
|
|
22
|
-
|
|
23
|
-
css(`
|
|
24
|
-
@keyframes slidein {
|
|
25
|
-
from {
|
|
26
|
-
transform: translateX(0%);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
to {
|
|
30
|
-
transform: translateX(100%);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
`);
|
|
34
|
-
|
|
35
|
-
css(`
|
|
36
|
-
@page {
|
|
37
|
-
size: 8.5in 9in;
|
|
38
|
-
margin-top: 4in;
|
|
39
|
-
}
|
|
40
|
-
`);
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}();
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
!function(){
|
|
2
|
-
|
|
3
|
-
Binh.style(function anonymous(
|
|
4
|
-
) {
|
|
5
|
-
return "@charset \"utf-8\"; @import url(\"/styles/temp.css\"); /* .btn-remove { color: blue; margin-left: '15px'; } */ @media (min-width: 800px) { .btn-remove { color: red; margin-left: '15px'; } } @keyframes slidein { from { transform: translateX(0%); } to { transform: translateX(100%); } } @page { size: 8.5in 9in; margin-top: 4in; }";
|
|
6
|
-
});
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}();
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
@charset "utf-8";
|
|
2
|
-
|
|
3
|
-
@import url("/styles/temp.css");
|
|
4
|
-
|
|
5
|
-
/* .btn-remove {
|
|
6
|
-
color: blue;
|
|
7
|
-
margin-left: '15px';
|
|
8
|
-
} */
|
|
9
|
-
|
|
10
|
-
@media (min-width: 800px) {
|
|
11
|
-
|
|
12
|
-
.btn-remove {
|
|
13
|
-
color: red;
|
|
14
|
-
margin-left: '15px';
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
@keyframes slidein {
|
|
19
|
-
from {
|
|
20
|
-
transform: translateX(0%);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
to {
|
|
24
|
-
transform: translateX(100%);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
@page {
|
|
29
|
-
size: 8.5in 9in;
|
|
30
|
-
margin-top: 4in;
|
|
31
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
!function(){
|
|
2
|
-
|
|
3
|
-
Binh.style(function anonymous(
|
|
4
|
-
) {
|
|
5
|
-
return "@charset \"utf-8\"; @import url(\"/styles/temp.css\"); /* .btn-remove { color: blue; margin-left: '15px'; } */ @media (min-width: 800px) { .btn-remove { color: red; margin-left: '15px'; } } @keyframes slidein { from { transform: translateX(0%); } to { transform: translateX(100%); } } @page { size: 8.5in 9in; margin-top: 4in; }";
|
|
6
|
-
});
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}();
|