Project

General

Profile

การสร้าง Aimagin Connect components » component.js

ตัวอย่าง package - Natthaphon Choomphon-anomakhun (คิว), 07 Oct 2019 11:42

 
1
ID = "_my_package";
2
PACKAGE = {
3
    "_my_package":{
4
        "name":"My package", "text":"My package", "children":["_folder_1", "_folder_2"],
5
        "object":{
6
            "function_1":function(e){
7
                console.log("aaa");
8
                alert();
9
            },
10
            "function_2":function(e){
11
    
12
            },
13
            "function_3":function(e){
14
    
15
            },
16
            "setProperty":function(e) {
17
            },
18
            "getProperty":function(e) {
19
            },
20
            "setCallback2":function(e) {
21
                $('#'+e.id).on("click", e.value);
22
            },
23
            "myOpen":function(e) {
24
                h1 = document.createElement("h1");
25
                h1.innerHTML = "TEST";
26
                e.container.appendChild(h1);
27
            }
28
        }        
29
    },
30
    "_folder_1":{
31
        "name":"Folder-1", "text":"Folder 1", "children":["_component_1_1", "_component_1_2"]
32
    },
33
    "_folder_2":{
34
        "name":"Folder-2", "text":"Folder 2", "children":["_component_2_1", "_component_2_2"]
35
    },
36
    "_component_1_1":{
37
        "name":"Component 1.1", "text":"Component 1.1", "children":true,
38
        "parameter":[
39
            {
40
                "name":"property-group-1", "text":"property-group-1", "children":[
41
                    {
42
                        "name":"property-1-1", "text":"property-1-1", "input":{"type":"0", "value":""}, "setParameter":"setProperty", "getParameter":"getProperty"
43
                    },
44
                    {
45
                        "name":"property-1-2", "text":"property-1-2", "input":{"type":"custom", "value":{}, "open":"myOpen", "save":function(e){
46
                            return {};
47
                        }}, 
48
                        "setParameter":"setProperty", "getParameter":"getProperty"
49
                    },
50
                    {
51
                        "name":"property-1-3", "text":"property-1-3", "input":{"type":"3", "value":""}, "setParameter":function(e){}, "getParameter":"getProperty"
52
                    },                    
53
                ]
54
            },            
55
            {
56
                "name":"property-2", "text":"property-2", "input":{"type":"1", "option":[{value:"option-0", text:"option-0"}, {value:"option-1", text:"option-1"}], value:"option-0"},
57
                "setParameter":function(e) {
58

    
59
                },
60
                "getParameter":function(e) {
61

    
62
                }
63
            },
64
            {
65
                "name":"property-3", "text":"property-3", "input":{"type":"2", "option":[{value:"option-0", text:"option-0"}, {value:"option-1", text:"option-1"}], value:["option-0", "option-1"]},
66
                "setParameter":function(e) {
67

    
68
                },
69
                "getParameter":function(e) {
70

    
71
                }
72
            }
73
        ],
74
        "callback":[
75
            {"name":"callback-group-1", "text":"callback-group-1", "children":[
76
                {"name":"callback-1-1", "text":"callback-1-1", "setCallback":function(e) {}},
77
                {"name":"callback-1-2", "text":"callback-1-2", "setCallback":function(e) {}}                
78
            ]},
79
            {"name":"callback-2", "text":"callback-1", "setCallback":"setCallback2"}
80
        ],
81
        "write_head_init":function(e) {
82
            return "<script></script>";
83
        },
84
        "write_body_start":function(e) {
85
            return "<form><input class='form-control' value='Oh no'><button id='"+e.id+"' class='btn btn-primary btn-lg'>Oh Yes</button>";
86
        },
87
        "write_body_end":function(e) {
88
            return "</form>";
89
        },
90
        "write_body_init":function(e) {
91
            return "<script></script>";
92
        },
93
        "add_body_script":function(e) {
94
        }
95
    },
96
    "_component_1_2":{
97
        "name":"Component 1.2", "text":"Component 1.2", "children":true,
98
        "parameter":[
99
            {
100
                "name":"property-1", "text":"property-1", "input":{"type":"0", "value":""}, "setParameter":"setProperty", "getParameter":"getProperty"
101
            },
102
            {
103
                "name":"property-2", "text":"property-2", "input":{"type":"1", "option":[{value:"option-0", text:"option-0"}, {value:"option-1", text:"option-1"}], value:"option-0"},
104
                "setParameter":function(e) {
105

    
106
                },
107
                "getParameter":function(e) {
108

    
109
                }
110
            }
111
        ],
112
        "callback":[
113
            {"name":"callback-1", "text":"callback-1", "setCallback":function(e) {}, "getCallback":function(e) {}}
114
        ],
115
        "write_head_init":function(e) {
116
            return "<script></script>";
117
        },
118
        "write_body_start":function(e) {
119
            return "<tag>";
120
        },
121
        "write_body_end":function(e) {
122
            return "</tag>";
123
        },
124
        "write_body_init":function(e) {
125
            return "<script></script>";
126
        },
127
        "add_body_script":function(e) {
128
        }        
129
    },
130
    "_component_2_1":{
131
        "name":"Component 2.1", "text":"Component 2.1", "children":false,
132
        "parameter":[
133
            {
134
                "name":"property-1", "text":"property-1", "input":{"type":"0", "value":""}, "setParameter":"setProperty", "getParameter":"getProperty"
135
            },
136
            {
137
                "name":"property-2", "text":"property-2", "input":{"type":"1", "option":[{value:"option-0", text:"option-0"}, {value:"option-1", text:"option-1"}], value:"option-0"},
138
                "setParameter":function(e) {
139

    
140
                },
141
                "getParameter":function(e) {
142

    
143
                }
144
            }
145
        ],
146
        "callback":[
147
            {"name":"callback-1", "text":"callback-1", "setCallback":function(e) {}, "getCallback":function(e) {}}
148
        ],
149
        "write_head_init":function(e) {
150
            return "<script></script>";
151
        },
152
        "write_body_start":function(e) {
153
            return "<tag>";
154
        },
155
        "write_body_end":function(e) {
156
            return "</tag>";
157
        },
158
        "write_body_init":function(e) {
159
            return "<script></script>";
160
        },
161
        "add_body_script":function(e) {
162
        }        
163
    },
164
    "_component_2_2":{
165
        "name":"Component 2.2", "text":"Component 2.2", "children":false,
166
        "parameter":[
167
            {
168
                "name":"property-1", "text":"property-1", "input":{"type":"0", "value":""}, "setParameter":"setProperty", "getParameter":"getProperty"
169
            },
170
            {
171
                "name":"property-2", "text":"property-2", "input":{"type":"1", "option":[{value:"option-0", text:"option-0"}, {value:"option-1", text:"option-1"}], value:"option-0"},
172
                "setParameter":function(e) {
173

    
174
                },
175
                "getParameter":function(e) {
176

    
177
                }
178
            }
179
        ],
180
        "callback":[
181
            {"name":"callback-1", "text":"callback-1", "setCallback":function(e) {}, "getCallback":function(e) {}}
182
        ],
183
        "write_head_init":function(e) {
184
            return "<script></script>";
185
        },
186
        "write_body_start":function(e) {
187
            return "<tag>";
188
        },
189
        "write_body_end":function(e) {
190
            return "</tag>";
191
        },
192
        "write_body_init":function(e) {
193
            return "<script></script>";
194
        },
195
        "add_body_script":function(e) {
196
        }        
197
    }                        
198
};
(1-1/4)