forked from mozilla/openwebapps
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.html
More file actions
467 lines (406 loc) · 12 KB
/
Copy pathapp.html
File metadata and controls
467 lines (406 loc) · 12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=8"/>
<title>App Detail: {{ app.name }}</title>
<link rel="stylesheet" type="text/css" href="/static/jquery.jgrowl.css" />
<link rel="stylesheet" type="text/css" href="/static/demostore.css" />
<script src="/static/jquery-1.4.2.min.js"></script>
<script src="/static/jquery.jgrowl_minimized.js"></script>
<script src="https://myapps.mozillalabs.com/jsapi/include.js"></script>
<script>
var gAppManifest = {{ app.manifest }};
var gAlreadyPurchased = {{ "true" if (app.price == 0 or alreadyPurchased) else "false" }};
var gAlreadyInstalled = false;
$(document).ready(function () {
window.setTimeout(function() {
$("#install_floater").show();
}, 500);
navigator.apps.getInstalledBy(function(installed) {
if (installed)
{
for (var i=0;i<installed.length;i++)
{
if (installed[i].manifest.base_url == gAppManifest.base_url)
{
gAlreadyInstalled = true;
$("#install_button").hide();
// Multi-user error condition craziness...
if (gAlreadyPurchased) {
{% if app.price > 0 %}
$("#already_installed_text").text("You purchased and installed this application on " + new Date(installed[i].installTime).toLocaleDateString() + ".")
$("#already_installed").show();
{% else %}
$("#already_installed_text").text("You installed this application on " + new Date(installed[i].installTime).toLocaleDateString() + ".")
$("#already_installed").show();
{% end %}
} else {
$("#already_installed_text").append("You've installed this application in this browser, but the current user hasn't purchased it.<br><br>Please check your account signin.<br><br>")
$("#already_installed_text").append($("<button>").text("Buy It Again").click(function() {doPurchase();}));
$("#already_installed").show();
$("#uninstall_hackery").hide();
}
}
}
}
if (!gAlreadyInstalled && gAlreadyPurchased)
{
$("#install_button").text("INSTALL");
$("#install_kicker").text("You've already purchased this app. Click to install it in this browser.").show();
}
});
{% if app.price > 0 %}
function doPurchase() {
// submit Ajax to serve confirming purchase authorization...
jQuery.post("/api/buy", {appid:{{appID}}}, function(data, textStatus) {
// TODO also provide an error handler; failures will fail silently right now
// and on success, install manifest:
navigator.apps.install({manifest: gAppManifest, authorization_url: "{{ authorizationURL }}", callback: function (arg) {
$("#install_button").text('Installed!');
$.jGrowl(gAppManifest.name + ' installed.<br><br><a href="http://myapps.mozillalabs.com" target="_myapps">View App Dashboard</a>', {sticky:true});
}});
$("#dimmer").fadeOut(300);
$("#login_purchase").fadeOut(300);
})
}
{% if not alreadyPurchased %}
$("#purchase_button").live('click', function() {doPurchase()});
$("#install_button").live('click', function() {
$("#dimmer").fadeIn(300);
$("#login_purchase").fadeIn(300);
});
$("#cancel_button").live('click', function() {
$("#dimmer").fadeOut(300);
$("#login_purchase").fadeOut(300);
});
{% if mode == "b" %}
$("#dimmer").show();
$("#login_purchase").show();
{% end %}
{% else %}
$("#install_button").live('click', function() {
navigator.apps.install({manifest: gAppManifest, authorization_url: "{{ authorizationURL }}", callback: function (arg) {
$("#install_button").text('Installed!');
$.jGrowl(gAppManifest.name + ' installed.<br><br><a href="http://myapps.mozillalabs.com" target="_myapps">View App Dashboard</a>', {sticky:true});
}});
});
{% end %}
{% else %}
$("#install_button").live('click', function() {
navigator.apps.install({manifest: gAppManifest, callback: function (arg) {
$("#install_button").text('Installed!');
$.jGrowl(gAppManifest.name + ' installed.<br><br><a href="http://myapps.mozillalabs.com" target="_myapps">View App Dashboard</a>', {sticky:true});
}});
});
{% end %}
});
</script>
<style>
.button
{
}
.app_nav {
margin-right:24px;
text-align:right;
font:bold 12pt "MuesoSans", "trebuchet ms",sans-serif;
}
.app_page {
-moz-border-radius:8px;
-webkit-border-radius:8px;
border-radius:8px;
border:1px solid #707090;
margin:16px;
padding:8px;
white-space:nowrap;
position:relative;
height:400px;
background:white;
}
.app_page .left_column
{
float:left;
display:inline-block;
width:140px;
height:400px;
}
.app_page .left_column .icon
{
padding-left:12px;
}
.app_page .left_column .price
{
font:bold 10pt Helvetica, Arial;
padding:4px 4px 4px 4px;
text-align:center;
margin:12px 0px 0px 12px;
-moz-border-radius:12px;
-webkit-border-radius:12px;
border-radius:16px;
background-color:#ddd;
background-image:-moz-linear-gradient(top, #fff, #ddd);
border:1px solid #888
}
.app_page .left_column .fineprint
{
padding-top:32px;
padding-left:8px;
font:8pt Helvetica,arial;
color:#666;
line-height:140%;
}
.app_page .left_column .fineprint a
{
color:#666;
text-decoration:none
}
.app_page .right_column
{
margin-left:64px;
width:700px;
white-space:normal;
margin-right:auto;
display:inline-block;
vertical-align:top;
height:400px;
}
.app_page .right_column .name
{
font:bold 14pt Helvetica,arial;
width:600px;
}
.app_page .right_column .desc
{
margin-top:16px;
white-space:normal;
font:10pt Helvetica, arial;
}
.install_floater {
float:right;
margin-right:24px;
margin-bottom:25px;
}
.greenbutton {
-moz-border-radius:0.5em 0.5em 0.5em 0.5em;
-webkit-border-radius:0.5em 0.5em 0.5em 0.5em;
-moz-box-shadow:0 -3px 0 rgba(0, 0, 0, 0.1) inset, 0 -3px 12px rgba(240, 240, 240, 0.3) inset, 0 20px 40px rgba(240, 240, 240, 0.3) inset, 0 2px 0 rgba(200, 200, 200, 0.3);
box-shadow:0 -3px 0 rgba(0, 0, 0, 0.1) inset, 0 -3px 12px rgba(240, 240, 240, 0.3) inset, 0 20px 40px rgba(240, 240, 240, 0.3) inset, 0 2px 0 rgba(200, 200, 200, 0.3);
-webkit-box-shadow:0 -3px 0 rgba(0, 0, 0, 0.1) inset, 0 -3px 12px rgba(240, 240, 240, 0.3) inset, 0 20px 40px rgba(240, 240, 240, 0.3) inset, 0 2px 0 rgba(200, 200, 200, 0.3);
background-color:#6bc246;
background-image:-moz-linear-gradient(center top , #6BC246 0%, #5CA33E 100%);
background-image:-webkit-gradient(
linear,
left top,
left bottom,
color-stop(0, rgb(5,202,51)),
color-stop(1, rgb(6,188,36)));
height:24px;
width:120px;
font:bold 14pt Helvetica, arial;
color:white;
margin-top:12px;
cursor:pointer;
padding:18px 10px 12px 10px;
text-align:center;
}
.greenbutton > a {
color:white;
text-decoration:none
}
#install_kicker {
font:bold 9pt Helvetica, Arial;
width:200px;
display:none;
}
#already_installed {
-moz-border-radius:0.5em 0.5em 0.5em 0.5em;
-webkit-border-radius:0.5em 0.5em 0.5em 0.5em;
-moz-box-shadow:0 -3px 0 rgba(0, 0, 0, 0.1) inset, 0 -3px 12px rgba(240, 240, 240, 0.3) inset, 0 20px 40px rgba(240, 240, 240, 0.3) inset, 0 2px 0 rgba(200, 200, 200, 0.3);
box-shadow:0 -3px 0 rgba(0, 0, 0, 0.1) inset, 0 -3px 12px rgba(240, 240, 240, 0.3) inset, 0 20px 40px rgba(240, 240, 240, 0.3) inset, 0 2px 0 rgba(200, 200, 200, 0.3);
background-color:#f0f0f0;
color:#606060;
margin-top:12px;
padding:18px 10px 12px 10px;
width:180px;
min-height:24px;
font:12pt Helvetica;
text-align:center;
border:1px solid #888;
display:none;
}
#uninstall_hackery {
font:9pt Helvetica, Arial;
}
#uninstall_hackery a {
color:#707090;
}
#dimmer {
background:#000;
opacity:0.66;
filter:alpha(opacity=66);
position:fixed;
top:0;
left:0;
width:100%;
height:100%;
z-index:998;
display:none
}
#login_purchase
{
display:none ;
position:absolute;
left:150px;
top:150px;
border:3px solid black;
-moz-border-radius:0.5em;
border-radius:0.5em;
webkit-border-radius:0.5em;
width:500px;
background-color:white;
height:400px;
z-index:999;
}
#login
{
padding:8px 8px 0px 8px;
font:10pt Helvetica, Arial;
}
#login .head
{
font:14pt Helvetica, Arial;
color:#8080D0;
margin-bottom:8px;
}
#login .small
{
font:10pt Helvetica, Arial;
}
#login .verysmall
{
display:inline-block;
font:italic 8pt Helvetica, Arial;
}
#login .verysmall a
{
text-decoration:none;
color:#8080d0;
}
#purchase
{
padding:48px 8px 0px 8px;
font:10pt Helvetica, Arial;
}
#purchase .head
{
font:14pt Helvetica, Arial;
color:#8080D0;
margin-bottom:8px;
}
#login_purchase .controls
{
position:absolute;
left:270px;
top:350px;
}
#login_purchase .controls button
{
font-size:12pt;
width:100px;
}
</style>
</head>
<body>
<div id="banner">
<div id="branding">
<a href="/"><img border="0" style="vertical-align:-2px;padding-right:4px" src="/static/home.png">
AppMonkey: Demonstration Web App Store</a>
</div>
<div id="status">
{% if account %}
Signed in as {{ account.displayName }} - [ <a href="/logout?return_to=/app/{{appID}}">Sign Out</a> ]
{% else %}
<a href="/login">Sign in</a>
{% end if %}
</div>
</div>
<div id="demo_splash">
<div class="banner">Demonstration Web App Store</div>
<div class="footer">AppMonkey is a demonstration by Mozilla Labs of how an application store can work with Installable Web Apps.<br><br>
To learn about Installable Web Apps, <a href="http://apps.mozillalabs.com">visit our site.</a></div>
</div>
<div class="app_nav">
<a href="/">Return to directory page</a>
</div>
<div class="app_page">
<div class="left_column">
<div class="icon">
<img width="128" height="128" src="{{ app.icon96URL }}">
</div>
<div class="price">
{% if app.price == 0 %}
Free
{% else %}
${{int(app.price/100)}}.{{ "%02d" % (app.price % 100) }}{% if alreadyPurchased %} - PAID{%end%}
{% end %}
</div>
<div class="fineprint">
Published: Sep. 22, 2010<br/>
Developer: <a href="#">DeveloperName</a><br/>
<br/>
Browser Compatibility: <br/>
Firefox 4.0, IE 9,
Chrome 5, Safari 4, Opera 10<br>
<br>
Mobile Compatibility: <br/>
Mobile Safari 3.0, Android 2.0
</div>
</div>
<div class="right_column">
<div class="install_floater" id="install_floater" style="display:none" >
<div id="install_button" class="greenbutton">{% if app.price == 0 %}INSTALL{%else%}BUY{%end%}</div>
<div id="install_kicker"></div>
<div id="already_installed">
<div id="already_installed_text"></div>
{% if app.price > 0 %} <div id="uninstall_hackery">For demo purposes, you can <a href="/unregister/{{appID}}">unregister for an app</a> if you like.</div> {% end %}
</div>
</div>
<div class="name">{{ app.name }}</div>
<div class="desc">{{ app.description.replace("\n", "<br>") }}</div>
</div>
</div>
<div id="dimmer"></div>
<div id="login_purchase">
<div id="login">
{% if account %}
<div class="head">Confirm Account</div>
You are signed in as {{ account.displayName }}.
<div class="verysmall">(<a href="/logout?return_to=/app/{{appID}}%3fm=b">Not you?</a>)</div>
{% else %}
<div class="head">Sign In Required</div>
Before you can purchase an application, we need you to <b>sign in</b>.<br>
Your application purchase will be linked with your account.<br><br>
<div class="small">
For demo purposes, we're supporting a few OpenID/OAuth providers;<br>
click one of these icons to log in using an account there.<br>
</div>
<a href="/account/addid/google?return_to=/app/{{appID}}%3fm=b"><img border="0" src="/static/googleOpenID.png"></a>
<a href="/account/addid/yahoo?return_to=/app/{{appID}}%3fm=b"><img border="0" src="/static/yahooOpenID.png"></a>
<a href="/account/addid/twitter?return_to=/app/{{appID}}%3fm=b"><img border="0" src="/static/twitterOpenID.png"></a><br>
<br>
<div class="small">
A real store would use more robust authentication.</div>
{% end if %}
</div>
{% if account %}
<div id="purchase">
<div class="head">Confirm Purchase</div>
Here, we verify the users intent to purchase, and confirm the payment mechanism.<br><br>
If necessary, we send the user off to PayPal or a similar provider to set up a payment authorization.
</div>
{% end %}
<div class="controls">
<button id="cancel_button">Cancel</button>
<button id="purchase_button" {% if not account %}disabled="true"{%end%}>Buy</button>
</div>
</div>
</body>
</html>