1+ <!DOCTYPE html>
2+ < html >
3+ < head >
4+
5+ < title > basic.js Code Editor</ title >
6+
7+ < meta charset ="UTF-8 ">
8+ < meta name ="viewport " content ="width=device-width, initial-scale=1.0, user-scalable=no ">
9+
10+ <!-- LIBRARY FILES -->
11+ < script src ="library/src-noconflict/ace.js " type ="text/javascript " charset ="utf-8 "> </ script >
12+ < link rel ="stylesheet " type ="text/css " href ="library/basic.min.css ">
13+ < script src ="library/basic.min.js " type ="text/javascript " charset ="utf-8 "> </ script >
14+ < script src ="js/basic-editor.js " type ="text/javascript " charset ="utf-8 "> </ script >
15+
16+ < style >
17+
18+ body {
19+ overflow : hidden;
20+ }
21+
22+ .editor {
23+
24+ position : absolute;
25+ margin : 0px ;
26+ border-radius : 6px ;
27+ font-size : 11px ;
28+
29+ }
30+
31+ </ style >
32+
33+ < script >
34+
35+ var start = function ( ) {
36+
37+ basicEditor . create ( document . getElementById ( "code-example" ) . innerHTML ) ;
38+
39+ }
40+
41+ </ script >
42+
43+ </ head >
44+ < body >
45+
46+ < div id ="code-example " style ="display:none ">
47+ var plantDataList = [
48+ { id: "1", name: "Broccoli", description: "Vegetable", filePath: "images/broccoli.png" },
49+ { id: "2", name: "Strawberry", description: "Fruit", filePath: "images/strawberry.png" },
50+ { id: "3", name: "Carrot", description: "Vegetable", filePath: "images/carrot.png" },
51+ ]
52+
53+ var plantList = [];
54+
55+ var boxItems
56+
57+ var start = function() {
58+
59+ page.color = "whitesmoke"
60+
61+ // BOX: Fruit items container box.
62+ boxItems = createBox(40, 40, 300, 230)
63+ that.color = "white"
64+ that.round = 13
65+ that.scrollY = 1
66+ that.center()
67+
68+ for(var i = 0; i < plantDataList .length; i++) {
69+
70+ // PLANTITEM: Every item.
71+ createPlantItem(plantDataList[i].name, plantDataList[i].description, plantDataList[i].filePath)
72+ boxItems.add(that)
73+
74+ plantList.push(that)
75+
76+ }
77+
78+ page.onResize(pageResized)
79+
80+ }
81+
82+ var pageResized = function() {
83+
84+ boxItems.center()
85+
86+ }
87+
88+ var createPlantItem = function(titleText, descriptionText, iconFullPath) {
89+
90+ var ITEM_WIDTH = 300
91+
92+ // BOX: Object container box
93+ var box = createBox(0, 0, ITEM_WIDTH, 94)
94+ that.color = "transparent"
95+ // Disable coordinate system.
96+ that.element.style.position = "relative"
97+
98+ // BOX: Item background box
99+ box.boxBackground = createBox(4, 2, ITEM_WIDTH - 8, 90)
100+ box.add(that)
101+ that.color = "rgba(0, 0, 0, 0.01)"
102+ that.round = 13
103+ that.border = 1
104+ that.borderColor = "rgba(0, 0, 0, 0.04)"
105+ that.setMotion("background-color 0.3s")
106+
107+ // IMAGE: Item icon image
108+ box.imgLogo = createImage(30, 12, 70, 70)
109+ box.add(that)
110+ that.load(iconFullPath)
111+ that.round = 4
112+ that.color = "transparent"
113+ that.border = 0
114+
115+ // LABEL: Item title text
116+ box.lblTitle = createLabel(120, 25, 280, "auto")
117+ box.add(that)
118+ that.text = titleText
119+
120+ // LABEL: Item description text
121+ box.lblDesc = createLabel(120, 49, 280, "auto")
122+ box.add(that)
123+ that.text = descriptionText
124+ that.textColor = "gray"
125+ that.fontSize = 14
126+
127+ makeBasicObject(box)
128+ return box
129+
130+ }
131+ </ div >
132+
133+ </ body >
134+ </ html>
0 commit comments