-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
29 lines (24 loc) · 1.18 KB
/
main.js
File metadata and controls
29 lines (24 loc) · 1.18 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
function openUrl (url, title) {
title = title || 'auth'
var w = 500, h = 600
var screenLeft = window.screenLeft !== undefined ? window.screenLeft : screen.left
var screenTop = window.screenTop !== undefined ? window.screenTop : screen.top
var width = window.innerWidth ? window.innerWidth : document.documentElement.clientWidth ? document.documentElement.clientWidth : screen.width
var height = window.innerHeight ? window.innerHeight : document.documentElement.clientHeight ? document.documentElement.clientHeight : screen.height
var left = ((width / 2) - (w / 2)) + screenLeft
var top = ((height / 2) - (h / 2)) + screenTop
var newWindow = window.open(url, title, 'toolbar=no,location=no,status=yes,resizable=yes,scrollbars=yes, width=' + w + ', height=' + h + ', top=' + top + ', left=' + left)
if (window.focus) {
newWindow.focus()
}
}
window.addEventListener('message', function (event) {
if (typeof event.data === 'string' && ~event.data.indexOf('FlespiToken')) {
var div = document.createElement('div');
div.innerHTML = event.data;
document.querySelector('#tokens').appendChild(div);
}
})
function login () {
openUrl('https://flespi.io/login/#providers')
}