|
4 | 4 | <meta charset="utf-8"> |
5 | 5 | <meta http-equiv="Content-type" content="text/html;charset=utf-8"> |
6 | 6 | <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" /> |
7 | | - <script type="text/javascript"> |
8 | | - var parent, pageUrl |
9 | | - window.addEventListener('load', function () { init() }); |
10 | 7 |
|
11 | | - function init () { |
12 | | - parent = window.parent |
13 | | -// console.log('Frame parent: ', parent) |
14 | | - pageUrl = parent.window.location.href |
15 | | -// console.log('Parent url: ', pageUrl) |
16 | | -// console.log('Parent origin: ', parent.window.location.origin) |
17 | | -// console.log('iFrame origin: ', window.location.origin) |
18 | | -// var pageOrigin = opener.location.origin; |
19 | | -// opener.postMessage(pageUrl, pageOrigin); |
20 | | - initEvents() |
21 | | - } |
22 | | - function initButton(id, action) { |
23 | | - document.getElementById(id).addEventListener('click', action) |
24 | | - } |
25 | | - function initEvents () { |
26 | | - initButton('local_provider', |
27 | | - function () { selectProvider('https://ldnode.local:8443') }) |
28 | | - initButton('db_provider', |
29 | | - function () { selectProvider('https://databox2.com') }) |
30 | | - } |
31 | | - function selectProvider (providerUri) { |
32 | | - console.log('Provider selected: ', providerUri) |
33 | | - var message = { |
34 | | - event_type: 'providerSelected', |
35 | | - value: providerUri |
36 | | - } |
37 | | - parent.postMessage(message, parent.window.location.origin) |
38 | | - } |
39 | | - function setField (id, value) { |
40 | | - var field = document.getElementById(id) |
41 | | - if (field) { |
42 | | - field.innerHTML = value |
43 | | - } |
44 | | - } |
45 | | - function hide (id) { |
46 | | - document.getElementById(id).className = 'hidden' |
47 | | - } |
48 | | - function show (id) { |
49 | | - var div = document.getElementById(id) |
50 | | - div.className = div.className.replace('hidden', '') |
51 | | - } |
52 | | - </script> |
53 | 8 | </head> |
54 | 9 | <body> |
55 | 10 | <div class="container"> |
56 | 11 | <div class="row"> |
57 | | - <div class="col-sm-2"><strong>Provider:</strong></div> |
58 | | - <div class="col-sm-2"> |
59 | | - <button type="button" class="btn btn-xs btn-primary" id="db_provider"> |
60 | | - databox2.com |
61 | | - </button> |
| 12 | + <div class="col-xs-12 text-center" style="margin-top: 3em;"> |
| 13 | + Login with: |
62 | 14 | </div> |
63 | | - <div class="col-sm-2"> |
64 | | - <button type="button" class="btn btn-xs btn-default" id="local_provider"> |
65 | | - localhost |
| 15 | + </div> |
| 16 | + <div class="row"> |
| 17 | + <div class="col-xs-12 text-center" style="padding-top: 2em;"> |
| 18 | + <button type="button" class="btn btn-md btn-primary" id="dbProvider"> |
| 19 | + databox2.com |
66 | 20 | </button> |
67 | 21 | </div> |
68 | | - <div class="col-sm-6"> |
69 | | - or custom: |
70 | | - <input type="text" id="custom_provider" value="" placeholder="databox.me" /> |
| 22 | + </div> |
| 23 | + <div class="row"> |
| 24 | + <div class="col-xs-12 text-center" style="padding-top: 2em;"> |
| 25 | + or custom:<br /> |
| 26 | + <input type="text" id="customProviderUri" value="https://" placeholder="databox.me" /> |
| 27 | + <button type="button" class="btn btn-md" id="customProvider">Go</button> |
71 | 28 | </div> |
72 | 29 | </div> |
73 | 30 | </div> |
| 31 | +<script type="text/javascript"> |
| 32 | + window.addEventListener('load', function () { init() }); |
| 33 | + |
| 34 | + function init () { |
| 35 | + initEvents() |
| 36 | + } |
| 37 | + function initButton(id, action) { |
| 38 | + document.getElementById(id).addEventListener('click', action) |
| 39 | + } |
| 40 | + function initEvents () { |
| 41 | + initButton('dbProvider', |
| 42 | + function () { selectProvider('https://databox2.com') }) |
| 43 | + initButton('customProvider', |
| 44 | + function () { |
| 45 | + var defaultValue = 'https://' |
| 46 | + var customUri = document.getElementById('customProviderUri') |
| 47 | + if (customUri && customUri.value !== defaultValue) { |
| 48 | + selectProvider(customUri.value) |
| 49 | + } |
| 50 | + }) |
| 51 | + } |
| 52 | + function selectProvider (providerUri) { |
| 53 | + console.log('Provider selected: ', providerUri) |
| 54 | + var message = { |
| 55 | + event_type: 'providerSelected', |
| 56 | + value: providerUri |
| 57 | + } |
| 58 | + opener.postMessage(message, opener.window.location.origin) |
| 59 | + } |
| 60 | +</script> |
74 | 61 | </body> |
75 | 62 | </html> |
0 commit comments