summaryrefslogtreecommitdiffstats
path: root/sca-cpp/trunk/hosting/server/htdocs/login/index.html
blob: efc3feaeaa537ab8c3c95adc2068db8456287e0f (plain)
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
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
<!DOCTYPE html>
<!--
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 * 
 *   http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.    
-->
<html>
<head>
<!-- Firebug inspector -->
<!--
<script type="text/javascript" src="https://getfirebug.com/releases/lite/1.3/firebug-lite.js"></script>
-->
<!-- Weinre inspector -->
<!--
<script src="http://www.example.com:9998/target/target-script-min.js#anonymous"></script>
-->
<title>Sign in</title>
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0"/> 
<!--
<meta name="apple-mobile-web-app-capable" content="yes"/>
<meta name="apple-mobile-web-app-status-bar-style" content="black"/>
-->
<link rel="apple-touch-icon-precomposed" href="/public/touchicon.png"/>
<base href="/login/"/>
<script type="text/javascript">
try {

(function loginhead() {

window.appcache = {};

/**
 * Get and cache a resource.
 */
appcache.get = function(uri, mode) {
    var h = uri.indexOf('#');
    var u = h == -1? uri : uri.substring(0, h);

    // Get resource from local storage first
    var ls = window.lstorage || localStorage;
    if (mode != 'remote') {
        var item = null;
        try { item = ls.getItem('ui.r.' + u); } catch(e) {}
        if (item != null && item != '')
            return item;
        if (mode == 'local')
            return null;
    }

    // Get resource from network
    //if (window.debug) debug('appcache.get', u);
    var http = new XMLHttpRequest();
    http.open("GET", mode == 'remote'? (u + '?t=' + new Date().getTime() + '&r=' + Math.random()) : u, false);
    http.setRequestHeader("Accept", "*/*");
    http.send(null);
    if (http.status == 200) {
        var xl = http.getResponseHeader("X-Login");
        if (xl != null && xl != '') {
            if (window.debug) debug('http error', u, 'X-Login');
            return null;
        }
        var ct = http.getResponseHeader("Content-Type");
        if (http.responseText == '' || ct == null || ct == '') {
            if (window.debug) debug('http error', u, 'No-Content');
            return null;
        }
        try { ls.setItem('ui.r.' + u, http.responseText); } catch(e) {}
        return http.responseText;
    }
    if (window.debug) debug('http error', u, http.status, http.statusText);
    return null;
};

appcache.remove = function(uri) {
    var h = uri.indexOf('#');
    var u = h == -1? uri : uri.substring(0, h);
    var ls = window.lstorage || localStorage;
    try { ls.removeItem(u); } catch(e) {}
    return true;
};

})();

/**
 * Load Javascript and CSS.
 */
(function loginboot() {

window.eval.call(window, 'try {\n' + appcache.get('/all-min.js') + '\n' + appcache.get('/public/config-min.js') + '\n} catch(e) { console.log(e.stack); throw e; }\n');
ui.includeCSS(appcache.get('/ui-min.css'));

// Disable cache for testing
//lstorage.enabled = false;

})();

} catch(e) {
    if (window.debug) debug(e.stack);
    throw e;
}
</script>
</head>
<body class="delayed">

<div id="menucontainer" class="tbarmenu">
<div id="menu"></div>
</div>

<div id="viewheadcontainer" class="viewhead">
<div id="viewhead">
<span class="cmenu">Sign in</span>
</div>
</div>

<div id="working" class="working" style="display: none;"></div>

<div id="viewcontainer">
<div id="view">
<div id="viewcontent" class="viewcontent" style="margin-left: auto; margin-right: auto; text-align: center;">

<br/>
<form id="formSignin" name="formSignin" method="POST" action="/login/dologin" style="width: 100%;">
<table style="width: 100%;">
<tr><td><span id="loginprompt" style="font-size: 16px;"></span></tr></td>
<tr><td><input type="text" class="flatentry" name="httpd_username" value="" placeholder="Username or email"/></td></tr>
<tr><td><input type="password" class="flatentry" name="httpd_password" value="" placeholder="Password"/></td></tr>
<tr><td><input type="submit" class="bluebutton" style="font-size: 16px; line-height: 16px; padding: 6px; height: 32px" value="Sign in"/></td></tr>
</table>
<input type="hidden" name="httpd_location" value="/"/>
</form>
<br/>

<form name="facebookOAuth2Form" style="width: 100%;">
<table style="width: 100%;">
<tr><td><span style="font-size: 16px;">Sign in with your <span style="font-weight: bold;">Facebook</span> account</span></td></tr>
<tr><td><input type="button" id="facebookOAuth2Signin" value="Sign in" class="bluebutton" style="font-size: 16px; line-height: 16px; padding: 6px; height: 32px"/></td></tr>
</table>
</form>
<br/>

<form name="googleOAuth2Form" style="width: 100%;">
<table style="width: 100%;">
<tr><td><span style="font-size: 16px;">Sign in with your <span style="font-weight: bold;" >Google</span> account</span></td></tr>
<tr><td><input type="button" id="googleOAuth2Signin" value="Sign in" class="bluebutton" style="font-size: 16px; line-height: 16px; padding: 6px; height: 32px"/></td></tr>
</table>
</form>
<br/>

<form name="oauth2Signin" action="/oauth2/authorize/" method="GET">
<input type="hidden" name="oauth2_authorize" value=""/>
<input type="hidden" name="oauth2_access_token" value=""/>
<input type="hidden" name="oauth2_client_id" value=""/>
<input type="hidden" name="oauth2_info" value=""/>
<input type="hidden" name="oauth2_display" value=""/>
<input type="hidden" name="oauth2_scope" value=""/>
<input type="hidden" name="openauth_referrer" value=""/>
</form>

</div>
</div>
</div>

<div id="viewfootcontainer" class="viewfoot">
<div id="viewfoot"></div>
<div id="status"></div>
</div>

<div id="installer" class="installer"></div>

<script type="text/javascript">
try {

(function loginbody() {

/**
 * Setup page layout.
 */
(function layout() {
    $('viewcontainer').className = ui.isMobile()? 'viewcontainer3dm' : 'viewcontainer3d';
    $('view').className = ui.isMobile()? 'viewloaded3dm' : 'viewloaded3d';
    $('loginprompt').innerHTML = config.loginprompt();
    document.title = config.windowtitle() + ' - Sign in';
    $('viewhead').innerHTML = '<span class="bcmenu">' + config.pagetitle() + '</span>' +
        '<span class="rmenu"><input type="button" id="signUp" class="redbutton" style="font-size: 16px; line-height: 16px; padding: 6px; height: 32px" title="' + config.signuptitle() + '" value="Sign up"/></span>';
    if (!ui.isMobile())
        $('viewcontent').className = 'viewcontent flatscrollbars';
    $('status').className = ui.isMobile()? 'status3dm' : 'status3d';
})();

/**
 * Setup menu bar.
 */
(function showmenu() {
    $('menu').innerHTML = ui.menubar(mklist(ui.menu('menuhome', 'Home', '/', '_self', false)), mklist());
    $('viewfoot').innerHTML = config.viewfoot();
})();

/**
 * Initialize status message area.
 */
(function initstatus() {
    if (isNil($('status')))
        return;
    $('status').style.display = 'none';
    
    function divtransitionend(e) {
        e.target.style.display = 'none';
        e.target.className = ui.isMobile()? 'status3dm' : 'status3d';
        e.target.error = false;
    }
    $('status').addEventListener('webkitTransitionEnd', divtransitionend, false);
    $('status').addEventListener('transitionend', divtransitionend, false);
})();

/**
 * Show a status message.
 */
window.showstatus = function(s, c) {
    //debug('show status', s);
    if (isNil($('status')) || $('status').error)
        return s;
    $('status').innerHTML = '<span class="' + (c? c : 'okstatus') + '">' + s + '</span>';
    $('status').className = ui.isMobile()? 'status3dm' : 'status3d';
    $('status').style.display = 'block';
    $('status').error = c == 'errorstatus';
    if ($('status').delay)
        ui.cancelDelay($('status').delay);
    $('status').delay = ui.delay(function hidestatus() {
        $('status').className = ui.isMobile()? 'statusout3dm' : 'statusout3d';
        $('status').error = false;
    }, 3000);
    return s;
};

/**
 * Show an error message.
 */
window.errorstatus = function(s) {
    //debug('error', s);
    return showstatus(s, 'errorstatus');
};

/**
 * Show working status.
 */
window.workingstatus = function(w, c) {
    //debug('show working', w);
    if (isNil($('working')))
        return w;
    if (!ui.isMobile())
        $('working').style.top = ui.pixpos(Math.round(window.clientHeight / 2));
    $('working').style.display = w? 'block' : 'none';
    return w;
};

/**
 * Show the online/offline status.
 */
window.onlinestatus = function() {
    return navigator.onLine? (ui.isMobile()? showstatus('Online') : showstatus('Online')) : errorstatus('Offline');
};

/**
 * Parse the query parameters.
 */
function qparams() {
    var qp = new Array();
    var qs = window.location.search.substring(1).split('&');
    for (var i = 0; i < qs.length; i++) {
        var e = qs[i].indexOf('=');
        if (e > 0)
            qp[qs[i].substring(0, e)] = unescape(qs[i].substring(e + 1));
    }
    return qp;
}

/**
 * Show login status.
 */
function loginstatus() {
    var a = qparams()['openauth_attempt'];
    if (typeof(a) != 'undefined' && a == '1')
        errorstatus('Incorrect email or password, please try again');
}

/**
 * Return the referrer URL.
 */
function openauthreferrer() {
    var r = qparams()['openauth_referrer'];
    if (typeof(r) == 'undefined' || domainname(r) != domainname(window.location.hostname))
        return '/';
    var q = r.indexOf('?');
    if (q > 0)
        return r.substring(0, q);
    return r;
}

/**
 * Signin with OAuth 2.0.
 */
function submitoauth2signin(w) {
    parms = w();
    lstorage.removeItem('/r/Editor/accounts');
    lstorage.removeItem('/r/Editor/dashboards');
    document.oauth2Signin.oauth2_authorize.value = parms[0];
    document.oauth2Signin.oauth2_access_token.value = parms[1];
    document.oauth2Signin.oauth2_client_id.value = parms[2];
    document.oauth2Signin.oauth2_info.value = parms[3];
    document.oauth2Signin.oauth2_scope.value = parms[4];
    document.oauth2Signin.oauth2_display.value = parms[5];
    document.oauth2Signin.openauth_referrer.value = openauthreferrer();
    document.oauth2Signin.action = '/oauth2/authorize/';
    document.oauth2Signin.submit();
}

function withfacebook() {
    var parms = ['https://graph.facebook.com/oauth/authorize', 'https://graph.facebook.com/oauth/access_token', 'facebook.com', 'https://graph.facebook.com/me', 'email', ui.isMobile()? 'touch' : 'page'];
    return parms;
}

function withgoogle() {
    var parms = ['https://accounts.google.com/o/oauth2/auth', 'https://accounts.google.com/o/oauth2/token', 'google.com', 'https://www.googleapis.com/oauth2/v1/userinfo', 'https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/userinfo.profile', ''];
    return parms;
}

$('facebookOAuth2Signin').onclick = function() {
    return submitoauth2signin(withfacebook);
};

$('googleOAuth2Signin').onclick = function() {
    return submitoauth2signin(withgoogle);
};

/**
 * Signin with a username and password.
 */
$('formSignin').onsubmit = function submitformsignin() {
    document.formSignin.httpd_location.value = '/';
    document.formSignin.submit();
};

/**
 * Signup.
 */
$('signUp').onclick = function submitsignup() {
    ui.navigate('/public/notyet/', '_self');
};

/**
 * Handle orientation change.
 */
document.body.onorientationchange = function(e) {
    //debug('onorientationchange');
    return ui.onorientationchange(e);
};

/**
 * Populate cache with app resources.
 */
var appresources = [
    ['/all-min.js'],
    ['/ui-min.css'],
    ['/public/config-min.js']
];

/**
 * Install the application cache.
 */
(function installappcache() {
    if (ui.isMobile()) {
        // On mobile devices, trigger usage of an application cache manifest
        window.onappcachechecking = function(e) {
            //debug('appcache checking', e);
            workingstatus(true);
            showstatus('Checking');
        };
        window.onappcacheerror = function(e) {
            //debug('appcache error', e);
            onlinestatus();
            workingstatus(false);
        };
        window.onappcachenoupdate = function(e) {
            //debug('appcache noupdate', e);
            onlinestatus();
            workingstatus(false);
        };
        window.onappcachedownloading = function(e) {
            //debug('appcache downloading', e);
            workingstatus(true);
            showstatus('Updating');
        };
        window.onappcacheprogress = function(e) {
            //debug('appcache progress', e);
            workingstatus(true);
            showstatus('Updating');
        };
        window.onappcacheupdateready = function(e) {
            //debug('appcache updateready', e);
            try {
                applicationCache.swapCache();
            } catch(e) {}
            onlinestatus();
            workingstatus(false);
            //debug('appcache swapped', e);

            // Update offline resources in local storage and reload the page
            map(function(res) {
                showstatus('Updating');
                appcache.remove(res[0]);
                appcache.get(res[0], 'remote');
            }, append(appresources, config.appresources()));
            window.location.reload();
        };
        window.onappcachecached = function(e) {
            //debug('appcache cached', e);
            onlinestatus();
            workingstatus(false);

            // Install offline resources in local storage
            map(function(res) {
                showstatus('Updating');
                appcache.remove(res[0]);
                appcache.get(res[0], 'remote');
            }, append(appresources, config.appresources()));
        };

        window.onloadappcache = function() {
            //debug('appcache iframe loaded');
        };

        ui.delay(function() {
            $('installer').innerHTML = '<iframe src="/public/cache/" class="installer"></iframe>';
        });

    } else {
        // On non-mobile devices, check for cache-manifest changes ourselves.
        workingstatus(true);
        showstatus('Checking');
        var lcmf = appcache.get('/public/cache/cache-manifest.cmf', 'local');
        var rcmf = appcache.get('/public/cache/cache-manifest.cmf', 'remote');
        if (lcmf == rcmf) {
            onlinestatus();
            workingstatus(false);
            return true;
        }

        //debug('cache-manifest changed, reloading');
        ui.delay(function() {
            workingstatus(true);
            showstatus('Updating');
            ui.delay(function() {
                workingstatus(true);
                showstatus('Updating');
                map(function(res) {
                    appcache.remove(res[0]);
                    appcache.get(res[0], 'remote');
                }, append(appresources, config.appresources()));
                if (!isNil(lcmf)) {
                    //debug('reloading');
                    window.location.reload();
                }
                onlinestatus();
                workingstatus(false);
            });
        });
    }
})();

/**
 * Handle network offline/online events.
 */
window.addEventListener('offline', function(e) {
    //debug('going offline');
    showstatus('Offline');
}, false);
window.addEventListener('online', function(e) {
    //debug('going online');
    showstatus('Online');
}, false);

/**
 * Initialize the document.
 */
window.onload = function() {
    //debug('onload');
    ui.onload();

    // Show the login status
    loginstatus();
    return true;
};

})();

} catch(e) {
    debug(e.stack);
    throw e;
}
</script>

</body>
</html>