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.host = host
jx.cloudview.protocol = protocol 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" var url = ":protocol://:host/cloud-view/" +id+"/get"
url = url.replace(/:protocol/,jx.cloudview.protocol).replace(/:host/,jx.cloudview.host) url = url.replace(/:protocol/,jx.cloudview.protocol).replace(/:host/,jx.cloudview.host)
var httpclient = HttpClient.instance() var httpclient = HttpClient.instance()
@ -29,17 +29,19 @@ jx.cloudview.oauth.init = function (id, key,callback) {
jx.cloudview.handler = null jx.cloudview.handler = null
jx.cloudview.popup = window.open(url, 'oauth', 'width=405, height=900') 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 * @param key
*/ */
jx.cloudview.oauth.listen = function (key,callback) { jx.cloudview.oauth.listen = function (key,callback,err) {
if (jx.cloudview.handler != null) { if (jx.cloudview.handler != null) {
clearInterval(jx.cloudview.handler) clearInterval(jx.cloudview.handler)
} }
jx.cloudview.handler = setInterval(function () { jx.cloudview.handler = setInterval(function () {
try { try {
@ -58,14 +60,26 @@ jx.cloudview.oauth.listen = function (key,callback) {
var info = JSON.parse(x.responseText) var info = JSON.parse(x.responseText)
callback(info) callback(info)
// jx.dom.set.value('name', info.user.uii) // 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() jx.cloudview.popup.close()
} catch (error) { } 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) },1500)
} }

Loading…
Cancel
Save