bug fix with cloud-view

master
Steve L. Nyemba 7 years ago
parent 289930762c
commit 8e62b8db6e

@ -14,7 +14,7 @@ jx.cloudview.init = function(host,protocol){
jx.cloudview.host = host
jx.cloudview.protocol = protocol
}
jx.cloudview.oauth.init = function (id, key,callback) {
jx.cloudview.oauth.init = function (id, key,callback,err) {
var url = ":protocol://:host/cloud-view/" +id+"/get"
url = url.replace(/:protocol/,jx.cloudview.protocol).replace(/:host/,jx.cloudview.host)
var httpclient = HttpClient.instance()
@ -29,17 +29,19 @@ jx.cloudview.oauth.init = function (id, key,callback) {
jx.cloudview.handler = null
jx.cloudview.popup = window.open(url, 'oauth', 'width=405, height=900')
jx.cloudview.oauth.listen(key,callback)
jx.cloudview.oauth.listen(key,callback,err)
})
}
/**
* @param key
*/
jx.cloudview.oauth.listen = function (key,callback) {
jx.cloudview.oauth.listen = function (key,callback,err) {
if (jx.cloudview.handler != null) {
clearInterval(jx.cloudview.handler)
}
jx.cloudview.handler = setInterval(function () {
try {
@ -58,14 +60,26 @@ jx.cloudview.oauth.listen = function (key,callback) {
var info = JSON.parse(x.responseText)
callback(info)
// jx.dom.set.value('name', info.user.uii)
})
}
//
// Until the control is returned an exception will be generated
// So the popup.close will never be executed ...
jx.cloudview.popup.close()
} catch (error) {
// console.log(error)
//
// If the window was closed chances are the user closed the window without loging in
if(jx.cloudview.popup.closed){
clearInterval(jx.cloudview.handler)
if (err != null){
err()
}
}
console.log([jx.cloudview.popup.closed,error])
}
},1500)
}

Loading…
Cancel
Save