simplyview 2.0.3 → 2.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/dist/simply.everything.js +26 -21
- package/js/simply.include.js +5 -15
- package/js/simply.viewmodel.js +20 -5
- package/package.json +7 -2
- package/docs/examples.md +0 -82
- package/docs/readme.md +0 -33
- package/docs/simply.action.md +0 -42
- package/docs/simply.activate.md +0 -27
- package/docs/simply.api.md +0 -188
- package/docs/simply.app.md +0 -27
- package/docs/simply.collect.md +0 -64
- package/docs/simply.command.md +0 -110
- package/docs/simply.include.md +0 -61
- package/docs/simply.keyboard.md +0 -60
- package/docs/simply.path.md +0 -3
- package/docs/simply.route.md +0 -133
- package/docs/simply.view.md +0 -53
- package/docs/simply.viewmodel.md +0 -3
- package/examples/commands.html +0 -70
- package/examples/counter.html +0 -52
- package/examples/examples.css +0 -3
- package/examples/github.html +0 -39
- package/examples/include/fifth.js +0 -1
- package/examples/include/first.js +0 -1
- package/examples/include/include.html +0 -4
- package/examples/include/include2.html +0 -1
- package/examples/include/index.html +0 -18
- package/examples/include/scripts.html +0 -16
- package/examples/include/third.js +0 -3
- package/examples/todo.html +0 -48
- package/examples/viewmodel.html +0 -359
- package/make +0 -18
- package/test/simply.route.test.js +0 -102
package/docs/simply.command.md
DELETED
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
# simply.command
|
|
2
|
-
|
|
3
|
-
simply.command provides a way to tie behaviour (javascript code) to HTML
|
|
4
|
-
elements:
|
|
5
|
-
```html
|
|
6
|
-
<button data-simply-command="doSomething">does something</button>
|
|
7
|
-
```
|
|
8
|
-
|
|
9
|
-
Commands can be set on any HTML element, but the behaviour differs based on
|
|
10
|
-
the element type:
|
|
11
|
-
|
|
12
|
-
- BUTTON, A:
|
|
13
|
-
Command triggers on click. Value is copied from the data-simply-value attribute.
|
|
14
|
-
- INPUT, TEXTAREA, SELECT:
|
|
15
|
-
Command triggers on change. Value is copied from the input value.
|
|
16
|
-
- FORM:
|
|
17
|
-
Command triggers on submit. Value is the set of form values.
|
|
18
|
-
- All others:
|
|
19
|
-
Command triggers on click. Value is copied from the data-simply-value
|
|
20
|
-
attribute. Only runs if no other command handlers match.
|
|
21
|
-
|
|
22
|
-
If a command is triggered, the default event handler is cancelled. So links
|
|
23
|
-
aren't followed, forms aren't submitted, etc.
|
|
24
|
-
|
|
25
|
-
Initialize the commands like this:
|
|
26
|
-
|
|
27
|
-
```javascript
|
|
28
|
-
var commands = simply.command(myApp, {
|
|
29
|
-
myCommand: function(el, value) {
|
|
30
|
-
doSomething(value);
|
|
31
|
-
}
|
|
32
|
-
});
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
For basic applications, commands are sufficient. But once your application
|
|
36
|
-
gets more complex it pays to limit the code in commands to just the parts that
|
|
37
|
-
tie into the HTML structure of your application. So searching the DOM,
|
|
38
|
-
getting attribute values, etc.
|
|
39
|
-
|
|
40
|
-
Once that is done, you should call an internal function that doesn't know
|
|
41
|
-
anything about the exact HTML structure. [simply.action](simply.action.md)
|
|
42
|
-
is purpose build to be used in that way. The Todo example shows how you can use this.
|
|
43
|
-
|
|
44
|
-
## commands.action
|
|
45
|
-
|
|
46
|
-
Each command function runs with the commands object returned from
|
|
47
|
-
simply.command as its scope. The action method is a useful shortcut to app.actions:
|
|
48
|
-
|
|
49
|
-
```javascript
|
|
50
|
-
var myApp = simply.app({
|
|
51
|
-
commands: {
|
|
52
|
-
addTodo: function(form, values) {
|
|
53
|
-
form.elements.todo.value = '';
|
|
54
|
-
this.action.call('addTodo', values.todo);
|
|
55
|
-
}
|
|
56
|
-
},
|
|
57
|
-
|
|
58
|
-
actions: {
|
|
59
|
-
addTodo: function(todo) {
|
|
60
|
-
this.app.view.todos.push(todo);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
});
|
|
64
|
-
```
|
|
65
|
-
|
|
66
|
-
The same thing can also be accomplished like this:
|
|
67
|
-
```javascript
|
|
68
|
-
this.app.actions.addTodo(values.todo);
|
|
69
|
-
```
|
|
70
|
-
|
|
71
|
-
## commands.call
|
|
72
|
-
|
|
73
|
-
Allows you to call a command directly:
|
|
74
|
-
```javascript
|
|
75
|
-
myApp.commands.call('addTodo', el, value);
|
|
76
|
-
```
|
|
77
|
-
|
|
78
|
-
## commands.appendHandler
|
|
79
|
-
|
|
80
|
-
Adds a command handler on top of the existing ones, so it gets matched first.
|
|
81
|
-
|
|
82
|
-
```javascript
|
|
83
|
-
myApp.commands.appendHandler({
|
|
84
|
-
match: 'input[type="radio"]',
|
|
85
|
-
|
|
86
|
-
check: function(el, evt) {
|
|
87
|
-
return (evt.type=='change');
|
|
88
|
-
},
|
|
89
|
-
|
|
90
|
-
get: function(el) {
|
|
91
|
-
return el.dataset.simplyValue || el.value;
|
|
92
|
-
}
|
|
93
|
-
});
|
|
94
|
-
```
|
|
95
|
-
|
|
96
|
-
Handler properties:
|
|
97
|
-
|
|
98
|
-
- match:
|
|
99
|
-
A CSS selector that checks if an element is handled by this command handler.
|
|
100
|
-
- check:
|
|
101
|
-
A function that checks if the command should be run in this event.
|
|
102
|
-
- get:
|
|
103
|
-
A function that returns the value for this command.
|
|
104
|
-
|
|
105
|
-
## commands.prependHandler
|
|
106
|
-
|
|
107
|
-
Adds a command handler, just like appendHandler. But it adds it first in the
|
|
108
|
-
list, so it will be matched last. This way you can add handlers with a more
|
|
109
|
-
generic CSS selector and append more specific handlers.
|
|
110
|
-
|
package/docs/simply.include.md
DELETED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
# simply.include
|
|
2
|
-
|
|
3
|
-
simply.include is a component that allows you to include external HTML - with
|
|
4
|
-
CSS and javascript - in the current HTML document. You will need to make sure
|
|
5
|
-
you don't overwrite global variables, the javascript and css get applied to
|
|
6
|
-
the whole document.
|
|
7
|
-
|
|
8
|
-
This component makes it easy to create microfrontends for microservices,
|
|
9
|
-
without forcing you to use a specific framework or technology.
|
|
10
|
-
|
|
11
|
-
Start by including the simply.include script, or simply.everything.js:
|
|
12
|
-
|
|
13
|
-
```html
|
|
14
|
-
<script src="js/simply.everything.js"></script>
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
-
Then add a simply-include link at the exact spot where you want to include a
|
|
18
|
-
widget or application or just a piece of HTML:
|
|
19
|
-
|
|
20
|
-
```html
|
|
21
|
-
<link rel="simply-include" href="/simplyview/widgets/my-widget/index.html"></link>
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
Your widget may contain any HTML, CSS and javascript you like, except it
|
|
25
|
-
shouldn't contain a HEAD. So a widget might look like this:
|
|
26
|
-
|
|
27
|
-
```html
|
|
28
|
-
<script src="/simplyview/js/simply.everything.js"></script>
|
|
29
|
-
<link rel="simply-include-once" href="/simplyview/common/head.html">
|
|
30
|
-
<link rel="simply-include-once" href="/simplyview/common/menu.html">
|
|
31
|
-
<link rel="stylesheet" href="/simplyview/widgets/my-widget/style.css">
|
|
32
|
-
<div class="my-widget">
|
|
33
|
-
....
|
|
34
|
-
</div>
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
The widget includes some common HTML, but only if it wasn't included before.
|
|
38
|
-
Assuming your pages all include the common head and menu, the widget will skip
|
|
39
|
-
this if the widget is included in a page. However you can also call the widget
|
|
40
|
-
as a normal page. In that case the common head and menu will be included and
|
|
41
|
-
the widget will decorate itself with the default styling and menu.
|
|
42
|
-
|
|
43
|
-
simply.include will automatically detect `<link rel="simply-include(-once)">`
|
|
44
|
-
links in the DOM, no matter when and how they appear, and replace them with
|
|
45
|
-
the HTML fetched from the linked href.
|
|
46
|
-
|
|
47
|
-
## Security
|
|
48
|
-
|
|
49
|
-
simply.include is meant to include HTML with CSS and javascript into an
|
|
50
|
-
existing document. So you must take care that whatever you include is what you
|
|
51
|
-
meant to include. If you allow user input, you must make sure that it doesn't
|
|
52
|
-
have `<link rel="simply-include(-once)">` tags. Or that if they do, they won't
|
|
53
|
-
get executed.
|
|
54
|
-
|
|
55
|
-
As a baseline, always clean user input of any offending tags, or even better:
|
|
56
|
-
clean it of all HTML. If that can't be done, make sure you use a whitelist of
|
|
57
|
-
acceptable tags.
|
|
58
|
-
|
|
59
|
-
Finally as a catchall, use Content-Security-Policy headers to only allow script
|
|
60
|
-
execution of whitelisted URL's. Don't allow inline scripts or you will still
|
|
61
|
-
be open to Cross Site Scripting attacks (XSS).
|
package/docs/simply.keyboard.md
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
# simply.keyboard
|
|
2
|
-
|
|
3
|
-
simply.keyboard is a simple library to add keyboard support to your application:
|
|
4
|
-
|
|
5
|
-
```javascript
|
|
6
|
-
let myKeys = {
|
|
7
|
-
default: {
|
|
8
|
-
ArrowDown: (e) => {
|
|
9
|
-
// handle arrow down
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
simply.keyboard(myApp, myKeys);
|
|
14
|
-
```
|
|
15
|
-
|
|
16
|
-
But generally you won't use this directly, but through simply.app:
|
|
17
|
-
|
|
18
|
-
```javascript
|
|
19
|
-
var myApp = simply.app({
|
|
20
|
-
keyboard: {
|
|
21
|
-
default: {
|
|
22
|
-
ArrowDown: (e) => {
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
});
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
You can add multiple keyboard definitions:
|
|
31
|
-
|
|
32
|
-
```javascript
|
|
33
|
-
var counterApp = simply.app({
|
|
34
|
-
keyboard: {
|
|
35
|
-
default: {
|
|
36
|
-
ArrowDown: (e) => {
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
-
},
|
|
40
|
-
alternate: {
|
|
41
|
-
ArrowDown: (e) => {
|
|
42
|
-
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
});
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
The default keyboard is 'default', but you can switch the keyboard by setting this attribute:
|
|
50
|
-
|
|
51
|
-
```html
|
|
52
|
-
<div data-simply-keyboard="alternate">
|
|
53
|
-
<input type="text" name="example">
|
|
54
|
-
</div>
|
|
55
|
-
```
|
|
56
|
-
|
|
57
|
-
Whenever a keyboard `keydown` is fired, simply.keyboard will look for the closest parent with a `data-simply-keyboard` attribute. If found, it will use that keyboard definition. If not found, it will use `default`.
|
|
58
|
-
|
|
59
|
-
The `keydown` event is only handled if the activeElement (the element that has focus) is inside the application container. See `simply.app` for more on that.
|
|
60
|
-
|
package/docs/simply.path.md
DELETED
package/docs/simply.route.md
DELETED
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
# simply.route
|
|
2
|
-
|
|
3
|
-
simply.route is a simple url routing component. It will listen to URL changes
|
|
4
|
-
and match them against the routes you provide. If a match is found, it will
|
|
5
|
-
call the matching function and update the address bar without reloading.
|
|
6
|
-
|
|
7
|
-
simply.route will run the first matching route handler it finds, in the order
|
|
8
|
-
in which they were registered.
|
|
9
|
-
|
|
10
|
-
Each route is a function with a single argument: `params`. Each variable you
|
|
11
|
-
define in the route, like `:section`, is translated into a property of the
|
|
12
|
-
params object, e.g. `params.section`. If you add a `:*` at the end of the route
|
|
13
|
-
it will be translated to `params.remainder`.
|
|
14
|
-
|
|
15
|
-
simply.route also supports events that trigger either before route matching,
|
|
16
|
-
before route calling or after a route is called.
|
|
17
|
-
|
|
18
|
-
If you need more complex behaviour, you should replace simply.route with a
|
|
19
|
-
different library. simply.route is explicitly meant to be a simple library
|
|
20
|
-
that is sufficient for 90% of javascript applications.
|
|
21
|
-
|
|
22
|
-
## simply.route.load
|
|
23
|
-
|
|
24
|
-
```javascript
|
|
25
|
-
simply.route.load({
|
|
26
|
-
|
|
27
|
-
'/:section/:*': function(params) {
|
|
28
|
-
loadSection(params.section, params.remainder);
|
|
29
|
-
},
|
|
30
|
-
|
|
31
|
-
'/': function() {
|
|
32
|
-
loadHome();
|
|
33
|
-
}
|
|
34
|
-
});
|
|
35
|
-
```
|
|
36
|
-
|
|
37
|
-
## simply.route.match
|
|
38
|
-
|
|
39
|
-
```javascript
|
|
40
|
-
simply.route.match(path);
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
This allows you to trigger a route. You can also provide extra parameters
|
|
44
|
-
for the route handler:
|
|
45
|
-
|
|
46
|
-
```javascript
|
|
47
|
-
simply.route.match(path, { foo: 'bar' });
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
## simply.route.goto
|
|
51
|
-
|
|
52
|
-
Updates the browsers address bar and matches the path.
|
|
53
|
-
|
|
54
|
-
```javascript
|
|
55
|
-
simply.route.goto(path);
|
|
56
|
-
```
|
|
57
|
-
|
|
58
|
-
## simply.route.has
|
|
59
|
-
|
|
60
|
-
Returns true if the route is registered.
|
|
61
|
-
|
|
62
|
-
```javascript
|
|
63
|
-
if (simply.route.has(path)) { ... }
|
|
64
|
-
```
|
|
65
|
-
|
|
66
|
-
## simply.route.init
|
|
67
|
-
|
|
68
|
-
Allows you to set the root pathname for routing. The root pathname is prepended
|
|
69
|
-
on every route you define. So if your application lives in the '/hnpwa/'
|
|
70
|
-
directory in the document root of you website, init simply.route like this:
|
|
71
|
-
|
|
72
|
-
```javascript
|
|
73
|
-
simply.route.init({
|
|
74
|
-
root: '/hnpwa/'
|
|
75
|
-
});
|
|
76
|
-
````
|
|
77
|
-
|
|
78
|
-
## simply.route.addListener
|
|
79
|
-
|
|
80
|
-
In the normal route handling, once a matching route is found, simply.route calls
|
|
81
|
-
it and stops. But sometimes you may want to trigger some code for multiple routes.
|
|
82
|
-
With route listeners you can do just that. You can setup a function that will be
|
|
83
|
-
called either before a route is found (`match`), before it is called (`call`) or after
|
|
84
|
-
it is called (`finish`).
|
|
85
|
-
|
|
86
|
-
In each of these steps you may change the default behaviour of simply.route by altering
|
|
87
|
-
parameters passed to your listener function and returning them.
|
|
88
|
-
|
|
89
|
-
### match
|
|
90
|
-
|
|
91
|
-
This allows you to add complex behaviour to the route matching step, so you can for
|
|
92
|
-
example match multiple different URL's to a single route. The single parameter is the
|
|
93
|
-
path to match on:
|
|
94
|
-
|
|
95
|
-
```
|
|
96
|
-
simply.route.addListener('match', '/protected/', function(params) {
|
|
97
|
-
// assume user is a variable in scope
|
|
98
|
-
if (!user || !user.isLoggedIn ) {
|
|
99
|
-
return {
|
|
100
|
-
path: '/login/'
|
|
101
|
-
};
|
|
102
|
-
}
|
|
103
|
-
});
|
|
104
|
-
```
|
|
105
|
-
|
|
106
|
-
### call
|
|
107
|
-
|
|
108
|
-
This allows you to change parameters before the actual route function is called.
|
|
109
|
-
|
|
110
|
-
```
|
|
111
|
-
simply.route.addListener('call', '/foo/', function(params) {
|
|
112
|
-
params.foo = 'bar';
|
|
113
|
-
return params;
|
|
114
|
-
});
|
|
115
|
-
```
|
|
116
|
-
|
|
117
|
-
### finish
|
|
118
|
-
|
|
119
|
-
This allows you to do stuff after a route is called. You can also change the result
|
|
120
|
-
of the route, though that is usually not a good idea.
|
|
121
|
-
|
|
122
|
-
## simply.route.removeListener
|
|
123
|
-
|
|
124
|
-
This allows you to remove a route listener. You need to exactly match the fase of the
|
|
125
|
-
listener (`match`, `call` or `finish`), the route and the function:
|
|
126
|
-
|
|
127
|
-
```javascript
|
|
128
|
-
simply.route.removeListener('call', '/foo/', fooListener);
|
|
129
|
-
```
|
|
130
|
-
|
|
131
|
-
## simply.route.clear
|
|
132
|
-
|
|
133
|
-
Removes all routes and listeners globally.
|
package/docs/simply.view.md
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
# simply.view
|
|
2
|
-
|
|
3
|
-
simply.view provides a simple interface to use the databinding from
|
|
4
|
-
[SimplyEdit](https://simplyedit.io/) in a web application:
|
|
5
|
-
|
|
6
|
-
```javascript
|
|
7
|
-
var myView = {
|
|
8
|
-
foo: 'bar'
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
simply.view(myApp, myView);
|
|
12
|
-
```
|
|
13
|
-
|
|
14
|
-
But generally you won't use this directly, but through simply.app:
|
|
15
|
-
|
|
16
|
-
```javascript
|
|
17
|
-
var counterApp = simply.app({
|
|
18
|
-
view: {
|
|
19
|
-
counter: 1
|
|
20
|
-
}
|
|
21
|
-
});
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
Any data-simply-field you define in your apps HTML is automatically bound to the corresponding entry in the view.
|
|
25
|
-
|
|
26
|
-
## Example
|
|
27
|
-
|
|
28
|
-
A simple example - an app that can count up and down:
|
|
29
|
-
|
|
30
|
-
```html
|
|
31
|
-
<div id="counter">
|
|
32
|
-
<input type="text" data-simply-field="counter">
|
|
33
|
-
<button data-simply-command="add1">+</button>
|
|
34
|
-
<button data-simply-command="sub1">-</button>
|
|
35
|
-
</div>
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
```javascript
|
|
39
|
-
var counterApp = simply.app({
|
|
40
|
-
|
|
41
|
-
container: document.getElementById('counter'),
|
|
42
|
-
|
|
43
|
-
commands: {
|
|
44
|
-
add1: function() { this.app.view.counter++; },
|
|
45
|
-
sub1: function() { this.app.view.counter--; }
|
|
46
|
-
},
|
|
47
|
-
|
|
48
|
-
view: {
|
|
49
|
-
counter: 0
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
};
|
|
53
|
-
```
|
package/docs/simply.viewmodel.md
DELETED
package/examples/commands.html
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
<!doctype html>
|
|
3
|
-
<body>
|
|
4
|
-
|
|
5
|
-
<label>testSubmit:</label>
|
|
6
|
-
<form data-simply-command="testSubmit">
|
|
7
|
-
<div>
|
|
8
|
-
<label>
|
|
9
|
-
testChange:
|
|
10
|
-
<input type="text" name="a" data-simply-command="testChange">
|
|
11
|
-
</label>
|
|
12
|
-
</div>
|
|
13
|
-
<div>
|
|
14
|
-
<label>
|
|
15
|
-
testChange:
|
|
16
|
-
<select name="b" data-simply-command="testChange">
|
|
17
|
-
<option>foo</option>
|
|
18
|
-
<option>bar</option>
|
|
19
|
-
</select>
|
|
20
|
-
</label>
|
|
21
|
-
</div>
|
|
22
|
-
<div>
|
|
23
|
-
<label>
|
|
24
|
-
testChange:
|
|
25
|
-
<textarea name="c" data-simply-command="testChange"></textarea>
|
|
26
|
-
</label>
|
|
27
|
-
</div>
|
|
28
|
-
<div>
|
|
29
|
-
<label>
|
|
30
|
-
testInput:
|
|
31
|
-
<input type="text" name="d" data-simply-command="testInput" data-simply-immediate="true">
|
|
32
|
-
</label>
|
|
33
|
-
</div>
|
|
34
|
-
<button type="submit">Submit</button>
|
|
35
|
-
</form>
|
|
36
|
-
<div><a href="foo" data-simply-command="testClick">testClick A</a></div>
|
|
37
|
-
<div><button data-simply-command="testClick" data-simply-value="bar">testClick Button</button></div>
|
|
38
|
-
|
|
39
|
-
<pre data-simply-field="out"></pre>
|
|
40
|
-
|
|
41
|
-
<script src="../dist/simply.everything.js"></script>
|
|
42
|
-
|
|
43
|
-
<script>
|
|
44
|
-
var test = simply.app({
|
|
45
|
-
view: {
|
|
46
|
-
out: 'start'
|
|
47
|
-
}
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
test.commands.testChange = function(el, value) {
|
|
51
|
-
test.view.out = el.name+': '+value;
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
test.commands.testSubmit = function(form, values) {
|
|
55
|
-
var out = [];
|
|
56
|
-
for (var key of Object.keys(values)) {
|
|
57
|
-
out.push(key+': '+values[key]);
|
|
58
|
-
}
|
|
59
|
-
test.view.out = out.join('\n');
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
test.commands.testInput = function(el, value) {
|
|
63
|
-
test.view.out = el.name + ': '+value;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
test.commands.testClick = function(el, value) {
|
|
67
|
-
test.view.out = el.tagName + ': '+value;
|
|
68
|
-
}
|
|
69
|
-
</script>
|
|
70
|
-
</body>
|
package/examples/counter.html
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
<h1>Examples</h1>
|
|
2
|
-
<h2>Counter</h2>
|
|
3
|
-
<link rel="stylesheet" href="examples.css">
|
|
4
|
-
|
|
5
|
-
<div id="counterApp">
|
|
6
|
-
<input type="text" data-simply-field="counter">
|
|
7
|
-
<button data-simply-command="add1">+</button>
|
|
8
|
-
<button data-simply-command="sub1">-</button>
|
|
9
|
-
<div>Counter is now: <span data-simply-field="counter"></span></div>
|
|
10
|
-
</div>
|
|
11
|
-
|
|
12
|
-
<div id="counterApp2">
|
|
13
|
-
<input type="text" data-simply-field="counter">
|
|
14
|
-
<button data-simply-command="add1">+</button>
|
|
15
|
-
<button data-simply-command="sub1">-</button>
|
|
16
|
-
<div>Counter is now: <span data-simply-field="counter"></span></div>
|
|
17
|
-
</div>
|
|
18
|
-
|
|
19
|
-
<script src="//cdn.simplyedit.io/1/simply-edit.js"></script>
|
|
20
|
-
<script src="../dist/simply.everything.js"></script>
|
|
21
|
-
<script>
|
|
22
|
-
var counterApp = simply.app({
|
|
23
|
-
container: document.getElementById('counterApp'),
|
|
24
|
-
commands: {
|
|
25
|
-
add1: function() {
|
|
26
|
-
counterApp.view.counter++;
|
|
27
|
-
},
|
|
28
|
-
sub1: function() {
|
|
29
|
-
counterApp.view.counter--;
|
|
30
|
-
}
|
|
31
|
-
},
|
|
32
|
-
view: {
|
|
33
|
-
counter: 1
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
var counterApp2 = simply.app({
|
|
38
|
-
container: document.getElementById('counterApp2'),
|
|
39
|
-
commands: {
|
|
40
|
-
add1: function() {
|
|
41
|
-
counterApp2.view.counter++;
|
|
42
|
-
},
|
|
43
|
-
sub1: function() {
|
|
44
|
-
counterApp2.view.counter--;
|
|
45
|
-
}
|
|
46
|
-
},
|
|
47
|
-
view: {
|
|
48
|
-
counter: 2
|
|
49
|
-
}
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
</script>
|
package/examples/examples.css
DELETED
package/examples/github.html
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
<!doctype html>
|
|
2
|
-
<meta charset="utf-8">
|
|
3
|
-
<pre id="output"></pre>
|
|
4
|
-
<script src="../dist/simply.everything.js"></script>
|
|
5
|
-
<script src="../js/simply.api.js"></script>
|
|
6
|
-
<script>
|
|
7
|
-
var githubApi = simply.api.proxy({
|
|
8
|
-
baseURL: 'https://api.github.com',
|
|
9
|
-
headers: {
|
|
10
|
-
'Accept': 'application/vnd.github.v3+json',
|
|
11
|
-
'User-Agent': 'poef'
|
|
12
|
-
},
|
|
13
|
-
handlers: {
|
|
14
|
-
fetch: function(verb, params, options) {
|
|
15
|
-
console.log(verb, params, options);
|
|
16
|
-
return simply.api.fetch(verb, params, options)
|
|
17
|
-
.then(function(response) {
|
|
18
|
-
console.log(response,[...response.headers.entries()].map((h) => h[0]+': '+h[1]));
|
|
19
|
-
return response;
|
|
20
|
-
});
|
|
21
|
-
},
|
|
22
|
-
result: function(result, options) {
|
|
23
|
-
return simply.api.getResult(result, options)
|
|
24
|
-
.then(function(result) {
|
|
25
|
-
console.log(result);
|
|
26
|
-
return result;
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
githubApi.users.poef().then(function(user) {
|
|
33
|
-
document.getElementById('output').innerText = JSON.stringify(user,
|
|
34
|
-
null, 4);
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
githubApi.test = 'test';
|
|
38
|
-
console.log(githubApi.test);
|
|
39
|
-
</script>
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
console.log('fifth');
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
console.log('first');
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
<h2>Sub includes work as well</h2>
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
<!doctype html>
|
|
2
|
-
<html>
|
|
3
|
-
<head>
|
|
4
|
-
<script src="../../dist/simply.everything.js"></script>
|
|
5
|
-
</head>
|
|
6
|
-
<body>
|
|
7
|
-
<link rel="simply-include" href="include.html">
|
|
8
|
-
<textarea class="autosize" data-simply-activate="autosize">index</textarea>
|
|
9
|
-
<link rel="simply-include" href="scripts.html">
|
|
10
|
-
<p>Done.</p>
|
|
11
|
-
<script>
|
|
12
|
-
simply.activate.addListener('autosize', function() {
|
|
13
|
-
this.value="activated";
|
|
14
|
-
console.log('activate', this)
|
|
15
|
-
});
|
|
16
|
-
</script>
|
|
17
|
-
</body>
|
|
18
|
-
</html>
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
<script src="first.js"></script>
|
|
2
|
-
<script>
|
|
3
|
-
console.log('second');
|
|
4
|
-
</script>
|
|
5
|
-
<script src="third.js"></script>
|
|
6
|
-
<script>
|
|
7
|
-
console.log('after third');
|
|
8
|
-
</script>
|
|
9
|
-
<script>
|
|
10
|
-
console.log('fourth');
|
|
11
|
-
</script>
|
|
12
|
-
<script src="fifth.js"></script>
|
|
13
|
-
<script src="//cdn.simplyedit.io/1/simply-edit.js"></script>
|
|
14
|
-
<script>
|
|
15
|
-
console.log(editor);
|
|
16
|
-
</script>
|