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