Skip to content

Commit 0b85919

Browse files
committed
working on the documentation
1 parent 228fb48 commit 0b85919

File tree

6 files changed

+200
-179
lines changed

6 files changed

+200
-179
lines changed

.prettierrc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
{
2-
"useTabs": true
2+
"useTabs": true,
3+
"tabWidth": 4
34
}

OpenScript.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,10 @@ var OpenScript = {
125125
*/
126126
constructor() {}
127127

128+
/**
129+
* Initializes the router for
130+
* Single Page Applications.
131+
*/
128132
init() {
129133
this.reset = OpenScript.State.state(false);
130134

@@ -4284,11 +4288,6 @@ const {
42844288
*/
42854289
each,
42864290

4287-
/**
4288-
* The router class
4289-
*/
4290-
Router,
4291-
42924291
/**
42934292
* The router object
42944293
*/
@@ -4345,3 +4344,8 @@ const {
43454344
} = new OpenScript.Initializer();
43464345

43474346
const OJS = OpenScript;
4347+
4348+
/**
4349+
* The Router Object
4350+
*/
4351+
const router = route;

example/components/App.js

Lines changed: 127 additions & 127 deletions
Original file line numberDiff line numberDiff line change
@@ -1,138 +1,138 @@
11
function Table(data, ...args) {
2-
return h._(
3-
h.table(
4-
{ class: "table" },
5-
h.tbody(each(data, (value) => h.Row(value))),
6-
...args
7-
),
8-
);
2+
return h._(
3+
h.table(
4+
{ class: "table" },
5+
h.tbody(each(data, (value) => h.Row(value))),
6+
...args
7+
)
8+
);
99
}
1010

1111
function Row(columns, ...args) {
12-
return h.$(
13-
h.tr(
14-
each(columns, (value) => h.Column(value)),
15-
...args
16-
)
17-
);
12+
return h.$(
13+
h.tr(
14+
each(columns, (value) => h.Column(value)),
15+
...args
16+
)
17+
);
1818
}
1919

20-
21-
2220
function Column(data, ...args) {
23-
return h._(h.td(data, ...args));
21+
return h._(h.td(data, ...args));
2422
}
2523

2624
class App extends OpenScript.Component {
27-
async mount() {
28-
await super.mount();
29-
req("MainNav");
30-
req("Blog.List");
31-
req("Counter");
32-
req("Chart");
33-
}
34-
35-
render(...args) {
36-
return h.div(
37-
h.MainNav(),
38-
39-
h.div(
40-
{ class: "container py-3" },
41-
42-
h.header(
43-
{
44-
class: "mb-3",
45-
},
46-
47-
h.h1("The Blog List Header"),
48-
h.hr()
49-
),
50-
51-
h.div(
52-
{
53-
class: "card mb-3",
54-
},
55-
h.div({ class: "card-header" }, "Uses Anonymous Component"),
56-
h.div(
57-
{ class: "card-body " },
58-
59-
h.p(
60-
{
61-
class: "card-text",
62-
},
63-
64-
`I will not change: (`,
65-
66-
h.b(Math.floor(Math.random() * 1000)),
67-
68-
`) because I am not re-rendered`,
69-
70-
h.br(),
71-
72-
`I will change: (`,
73-
h.b(v(context("blogCxt").counter)),
74-
`) because I am re-rendered when the number changes. `,
75-
h.b(`Actually, only the number is re-rendered, not this text.`)
76-
)
77-
)
78-
),
79-
80-
h.BlogCounter(context("blogCxt").counter, {
81-
class: "p-1",
82-
}),
83-
84-
h.Chart({
85-
class: "mb-3",
86-
}),
87-
88-
h.BlogList(
89-
context("blogCxt").blogs,
90-
context("blogCxt").counter,
91-
"I am a blog List. I re-render when counter changes"
92-
),
93-
94-
h.BlogList(
95-
context("blogCxt").blogs,
96-
{ value: 0 },
97-
"I am the same blog list. I do not re-render when counter changes because I do not listen its changes."
98-
),
99-
100-
h.Table([
101-
[1, 2, 3],
102-
[4, 5, 6],
103-
[7, 8, 9],
104-
])
105-
),
106-
107-
...args
108-
);
109-
}
110-
111-
$$namespace = {
112-
hello: () => {
113-
console.log("namespace:hello called");
114-
this.instanceMethod();
115-
},
116-
117-
hi: () => {
118-
console.log("namespace:hi called");
119-
this.instanceMethod();
120-
},
121-
122-
$$sns: {
123-
hello: () => {
124-
console.log("namespace:sns:hello called");
125-
this.instanceMethod();
126-
},
127-
128-
hi: () => {
129-
console.log("namespace:sns:hi called");
130-
this.instanceMethod();
131-
},
132-
},
133-
};
134-
135-
instanceMethod() {
136-
console.log(`Instance Method Accessed`);
137-
}
25+
async mount() {
26+
await super.mount();
27+
req("MainNav");
28+
req("Blog.List");
29+
req("Counter");
30+
req("Chart");
31+
}
32+
33+
render(...args) {
34+
return h.div(
35+
h.MainNav(),
36+
37+
h.div(
38+
{ class: "container py-3" },
39+
40+
h.header(
41+
{
42+
class: "mb-3",
43+
},
44+
45+
h.h1("The Blog List Header"),
46+
h.hr()
47+
),
48+
49+
h.div(
50+
{
51+
class: "card mb-3",
52+
},
53+
h.div({ class: "card-header" }, "Uses Anonymous Component"),
54+
h.div(
55+
{ class: "card-body " },
56+
57+
h.p(
58+
{
59+
class: "card-text",
60+
},
61+
62+
`I will not change: (`,
63+
64+
h.b(Math.floor(Math.random() * 1000)),
65+
66+
`) because I am not re-rendered`,
67+
68+
h.br(),
69+
70+
`I will change: (`,
71+
h.b(v(context("blogCxt").counter)),
72+
`) because I am re-rendered when the number changes. `,
73+
h.b(
74+
`Actually, only the number is re-rendered, not this text.`
75+
)
76+
)
77+
)
78+
),
79+
80+
h.BlogCounter(context("blogCxt").counter, {
81+
class: "p-1",
82+
}),
83+
84+
h.Chart({
85+
class: "mb-3",
86+
}),
87+
88+
h.BlogList(
89+
context("blogCxt").blogs,
90+
context("blogCxt").counter,
91+
"I am a blog List. I re-render when counter changes"
92+
),
93+
94+
h.BlogList(
95+
context("blogCxt").blogs,
96+
{ value: 0 },
97+
"I am the same blog list. I do not re-render when counter changes because I do not listen its changes."
98+
),
99+
100+
h.Table([
101+
[1, 2, 3],
102+
[4, 5, 6],
103+
[7, 8, 9],
104+
])
105+
),
106+
107+
...args
108+
);
109+
}
110+
111+
$$namespace = {
112+
hello: () => {
113+
console.log("namespace:hello called");
114+
this.instanceMethod();
115+
},
116+
117+
hi: () => {
118+
console.log("namespace:hi called");
119+
this.instanceMethod();
120+
},
121+
122+
$$sns: {
123+
hello: () => {
124+
console.log("namespace:sns:hello called");
125+
this.instanceMethod();
126+
},
127+
128+
hi: () => {
129+
console.log("namespace:sns:hi called");
130+
this.instanceMethod();
131+
},
132+
},
133+
};
134+
135+
instanceMethod() {
136+
console.log(`Instance Method Accessed`);
137+
}
138138
}

0 commit comments

Comments
 (0)