|
1 |
| -var appinfos = [ |
2 |
| - { |
3 |
| - id: "com.example.foobar", |
4 |
| - title: "Example Name", |
5 |
| - appDescription: "App Description", |
6 |
| - vendor: "Example Vendor", |
7 |
| - version: "v0.01", |
8 |
| - icon: "http://placekitten.com/64/64" |
9 |
| - }, |
10 |
| - { |
11 |
| - id: "com.example.blah", |
12 |
| - title: "Blah Blah", |
13 |
| - appDescription: "App Description", |
14 |
| - vendor: "Example Vendor", |
15 |
| - version: "v0.01", |
16 |
| - icon: "http://placekitten.com/64/64" |
17 |
| - }, |
18 |
| - { |
19 |
| - id: "com.example.abc", |
20 |
| - title: "Foo Bar", |
21 |
| - appDescription: "App Description", |
22 |
| - vendor: "Example Vendor", |
23 |
| - version: "v0.01", |
24 |
| - icon: "http://placekitten.com/64/64" |
25 |
| - }, |
26 |
| - { |
27 |
| - id: "com.example.def", |
28 |
| - title: "Foo Bar", |
29 |
| - appDescription: "App Description", |
30 |
| - vendor: "Example Vendor", |
31 |
| - version: "v0.01", |
32 |
| - icon: "http://placekitten.com/64/64" |
33 |
| - }, |
34 |
| - { |
35 |
| - id: "com.example.123", |
36 |
| - title: "Foo Bar", |
37 |
| - appDescription: "App Description", |
38 |
| - vendor: "Example Vendor", |
39 |
| - version: "v0.01", |
40 |
| - icon: "http://placekitten.com/64/64" |
41 |
| - }, |
42 |
| - { |
43 |
| - id: "com.example.456", |
44 |
| - title: "Foo Bar", |
45 |
| - appDescription: "App Description", |
46 |
| - vendor: "Example Vendor", |
47 |
| - version: "v0.01", |
48 |
| - icon: "http://placekitten.com/64/64" |
49 |
| - }, |
50 |
| - { |
51 |
| - id: "com.example.789", |
52 |
| - title: "Foo Bar", |
53 |
| - appDescription: "App Description", |
54 |
| - vendor: "Example Vendor", |
55 |
| - version: "v0.01", |
56 |
| - icon: "http://placekitten.com/64/64" |
57 |
| - }, |
58 |
| - { |
59 |
| - id: "com.example.zed", |
60 |
| - title: "Foo Bar", |
61 |
| - appDescription: "App Description", |
62 |
| - vendor: "Example Vendor", |
63 |
| - version: "v0.01", |
64 |
| - icon: "http://placekitten.com/64/64" |
65 |
| - }, |
66 |
| - { |
67 |
| - id: "com.example.bbbb", |
68 |
| - title: "Foo Bar", |
69 |
| - appDescription: "App Description", |
70 |
| - vendor: "Example Vendor", |
71 |
| - version: "v0.01", |
72 |
| - icon: "http://placekitten.com/64/64" |
73 |
| - } |
74 |
| -]; |
75 |
| - |
76 |
| -function getRandomInt(max) { |
77 |
| - return Math.floor(Math.random() * Math.floor(max)); |
78 |
| -} |
79 |
| - |
80 |
| -function randFloat(a, b) { |
81 |
| - return a + (Math.random()*(b-a)); |
82 |
| -} |
83 |
| - |
84 |
| -function do_app_modal(appinfo) { |
85 |
| - window.location.hash = "#appinfo-" + appinfo.id; |
86 |
| - render_appinfo_modal_dom(appinfo); |
87 |
| -} |
88 |
| - |
89 |
| -function close_app_modal() { |
90 |
| - var modal_container = document.getElementsByClassName("app-modal")[0]; |
91 |
| - modal_container.innerHTML = ""; |
92 |
| - modal_container.style.display = "none"; |
93 |
| -} |
94 |
| - |
95 |
| -function render_appinfo_modal_dom(appinfo) { |
96 |
| - var modal_container = document.getElementsByClassName("app-modal")[0]; |
97 |
| - modal_container.innerHTML = ""; |
98 |
| - |
99 |
| - modal_container.addEventListener("click", function(e) { |
100 |
| - if (e.target == modal_container) { |
101 |
| - close_app_modal(); |
102 |
| - } |
103 |
| - }); |
104 |
| - |
105 |
| - var modal_div = document.createElement("div"); |
106 |
| - modal_container.appendChild(modal_div); |
107 |
| - |
108 |
| - var modal_header = document.createElement("div"); |
109 |
| - modal_header.classList.add("app-modal-header"); |
110 |
| - modal_div.appendChild(modal_header); |
111 |
| - |
112 |
| - var app_img = document.createElement("img"); |
113 |
| - app_img.src = appinfo.icon; |
114 |
| - modal_header.appendChild(app_img); |
115 |
| - |
116 |
| - var app_butt = document.createElement("button"); |
117 |
| - app_butt.addEventListener("click", function() { |
118 |
| - alert("TODO: install app :P"); |
119 |
| - logmsg("Error logging test: installed " + appinfo.id); |
120 |
| - close_app_modal(); // TODO |
121 |
| - }); |
122 |
| - app_butt.innerText = "Install"; |
123 |
| - modal_header.appendChild(app_butt); |
124 |
| - |
125 |
| - var app_title = document.createElement("h2"); |
126 |
| - app_title.innerText = appinfo.title; |
127 |
| - modal_header.appendChild(app_title) |
128 |
| - |
129 |
| - var app_author = document.createElement("p"); |
130 |
| - app_author.innerHTML = "<strong>Developer:</strong>" |
131 |
| - app_author.insertAdjacentText("beforeend", appinfo.vendor); |
132 |
| - modal_header.appendChild(app_author); |
133 |
| - |
134 |
| - var app_version = document.createElement("p"); |
135 |
| - app_version.innerHTML = "<strong>Version:</strong>" |
136 |
| - app_version.insertAdjacentText("beforeend", appinfo.version); |
137 |
| - modal_header.appendChild(app_version); |
138 |
| - |
139 |
| - var desctitle = document.createElement("h3"); |
140 |
| - desctitle.innerText = "Description:"; |
141 |
| - modal_div.appendChild(desctitle); |
142 |
| - |
143 |
| - var desc = document.createElement("p"); |
144 |
| - desc.innerText = appinfo.appDescription; |
145 |
| - modal_div.appendChild(desc); |
146 |
| - |
147 |
| - modal_container.style.display = "block"; |
148 |
| - console.log("foo"); |
149 |
| -} |
150 |
| - |
151 |
| -function render_appinfo_dom(appinfo) |
152 |
| -{ |
153 |
| - var card = document.createElement("li"); |
154 |
| - var cardbutt = document.createElement("button"); |
155 |
| - |
156 |
| - cardbutt.addEventListener("click", function(e) { |
157 |
| - do_app_modal(appinfo); |
158 |
| - }); |
159 |
| - |
160 |
| - var cardimg = document.createElement("img"); |
161 |
| - cardimg.src = appinfo.icon; |
162 |
| - cardbutt.appendChild(cardimg); |
163 |
| - |
164 |
| - var cardtitle = document.createElement("h3"); |
165 |
| - cardtitle.innerText = appinfo.title; |
166 |
| - |
167 |
| - var cardauthor = document.createElement("span"); |
168 |
| - cardauthor.innerHTML = " — "; |
169 |
| - cardauthor.innerText += appinfo.vendor; |
170 |
| - cardtitle.appendChild(cardauthor); |
171 |
| - |
172 |
| - cardbutt.appendChild(cardtitle); |
173 |
| - |
174 |
| - var carddesc = document.createElement("p"); |
175 |
| - carddesc.innerText = appinfo.appDescription; |
176 |
| - cardbutt.appendChild(carddesc); |
177 |
| - |
178 |
| - card.appendChild(cardbutt) |
179 |
| - return card; |
180 |
| -} |
181 |
| - |
182 |
| -function render_applist() |
183 |
| -{ |
184 |
| - var applist = document.getElementsByClassName("applist")[0].children[0]; |
185 |
| - var query = document.getElementsByClassName("searchbox")[0].value.toLowerCase();; |
186 |
| - applist.innerHTML = ""; |
187 |
| - |
188 |
| - appinfos.forEach(function(appinfo){ |
189 |
| - if (appinfo.title.toLowerCase().includes(query) || appinfo.appDescription.toLowerCase().includes(query)) { |
190 |
| - applist.appendChild(render_appinfo_dom(appinfo)); |
191 |
| - } |
192 |
| - }); |
193 |
| -} |
194 |
| - |
195 |
| - |
196 |
| -window.onload = function() |
197 |
| -{ |
198 |
| - console.log("loaded"); |
199 |
| - |
200 |
| - var bubbles = document.getElementsByClassName("bubbles")[0]; |
201 |
| - for (var i=0; i<100; i++) { |
202 |
| - var bubble = document.createElement("div"); |
203 |
| - var scale = randFloat(0.4,1); |
204 |
| - bubble.classList.add("bubble"); |
205 |
| - bubble.style.left = getRandomInt(1280) + "px"; |
206 |
| - bubble.style.animation = "bubbleup "+(randFloat(3,6)/scale)+"s cubic-bezier(.53,.14,.91,.44) infinite, bubblewobble "+randFloat(2,3)+"s ease-in-out infinite"; |
207 |
| - bubble.style["animation-delay"] = randFloat(0,3)+"s"; |
208 |
| - bubble.style.transform = "scale("+scale+")"; |
209 |
| - bubbles.appendChild(bubble); |
210 |
| - } |
211 |
| - |
212 |
| - var searchBox = document.getElementsByClassName("searchbox")[0]; |
213 |
| - |
214 |
| - searchBox.addEventListener("input", function(e) { |
215 |
| - console.log(e.target.value); |
216 |
| - render_applist(); |
217 |
| - }); |
218 |
| - |
219 |
| - render_applist(); |
220 |
| -} |
221 |
| - |
222 |
| -function logmsg(str) { |
223 |
| - document.getElementById("log-window").innerText += str + "\n"; |
224 |
| -} |
225 |
| - |
226 |
| -window.onerror = function myErrorHandler(errorMsg, url, lineNumber) { |
227 |
| - logmsg("[!] JS Error on line " + lineNumber + ": " + errorMsg); |
228 |
| - return false; |
229 |
| -} |
230 |
| - |
231 |
| -window.onhashchange = function() { |
232 |
| - if (window.location.hash == "") { |
233 |
| - close_app_modal(); |
234 |
| - } |
235 |
| -} |
| 1 | +/** |
| 2 | + Instantiate your enyo/Application kind in this file. Note, application |
| 3 | + rendering should be deferred until the DOM is ready by wrapping it in a |
| 4 | + call to ready(). |
| 5 | +*/ |
| 6 | + |
| 7 | +var |
| 8 | + ready = require('enyo/ready'), |
| 9 | + App = require('./App'); |
| 10 | + |
| 11 | +ready(function () { |
| 12 | + new App(); |
| 13 | +}); |
0 commit comments