Skip to content

Commit 0ef508c

Browse files
LoosmanLoosman
authored andcommitted
Radical change in code. Idea changed and made more generic.
- make HTML element interactive or trigger AJAX call - Ajax responds with JSON or XML package that contains set of actions - Manipulate the dom based on the received actions This is the basic idea. It should save some time for the developer and make it easy to make interactive pages that that are connected to a back-end. Todo: - Create server side library for creating packages - Use history api to store ajax history - test post and file upload
1 parent 9e75850 commit 0ef508c

File tree

10 files changed

+393
-693
lines changed

10 files changed

+393
-693
lines changed

MicroBoatWebapp.js

Lines changed: 304 additions & 681 deletions
Large diffs are not rendered by default.

exampleWithAllParameters.json

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
"load":{
3+
"query":".target",
4+
"html":"<h1>Hello world</h1>",
5+
"method":"load",
6+
"animation":"fade"
7+
},
8+
"redirect":{
9+
"location":"/this/page",
10+
"timeout": 300
11+
},
12+
"refresh":500,
13+
"navigate":{
14+
"location":"/this/page",
15+
"timeout": 300
16+
},
17+
"action":{
18+
"action":"/ajax/count",
19+
"formquery":".myform"
20+
},
21+
"script":"alert('hello world')",
22+
"empty":".emptyme",
23+
"delete":".removeme",
24+
"change":{
25+
"query":"#button",
26+
"attributes":{
27+
"value":"ajax done"
28+
},
29+
"class":{
30+
"remove":"busy",
31+
"add":"finish"
32+
}
33+
}
34+
}

exampleWithMinimalParameters.json

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"load":{
3+
"query":".target",
4+
"html":"<h1>Hello world</h1>"
5+
},
6+
"redirect":"/this/page",
7+
"refresh":0,
8+
"navigate":"/this/page",
9+
"action":"/ajax/count",
10+
"script":"alert('hello world')",
11+
"empty":".emptyme",
12+
"delete":".removeme",
13+
"change":{
14+
"query":"#button",
15+
"attributes":{
16+
"class":"done"
17+
}
18+
}
19+
}

index.html

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>MicroBoatWebapp 0.1.0</title>
5+
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
6+
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
7+
<script type="text/javascript" src="MicroBoatWebapp.js"></script>
8+
</head>
9+
<body>
10+
<h1>hello</h1>
11+
<action action="test.json"></action>
12+
<div class="target"></div>
13+
<button action="test2.json">test</button>
14+
</body>
15+
</html>

index.php renamed to oldindex.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
</script>
2121
</head>
2222
<body>
23-
<action action="start" param="test" ></action>
23+
<h1>hello</h1>
24+
<div class="target"></div>
2425
</body>
2526
</html>

test.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
<h1>Test</h1>
2+
<p>This is a test.</p>

test.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"load":{
3+
"query":".target",
4+
"html":"<i><b>Hello world</b></i>"
5+
}
6+
}

test.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<ajax>
2+
<load query=".target">
3+
<i>This is loaded with the xml package</i>
4+
</load>
5+
</ajax>

test2.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"load":{
3+
"query":".target",
4+
"html":"<p>you pressed the button</p><button action=\"test.json\">test action after dom manipulation</button>"
5+
}
6+
}

todo.txt

Lines changed: 0 additions & 11 deletions
This file was deleted.

0 commit comments

Comments
 (0)